diff --git a/libs/pbd/pbd/whitespace.h b/libs/pbd/pbd/whitespace.h index f38c0d5409..064d73451e 100644 --- a/libs/pbd/pbd/whitespace.h +++ b/libs/pbd/pbd/whitespace.h @@ -29,7 +29,7 @@ namespace PBD { // returns the empty string if the entire string is whitespace // so check length after calling. LIBPBD_API extern void strip_whitespace_edges (std::string& str); - + LIBPBD_API extern void remove_extra_whitespace (std::string const & in, std::string out); } // namespace PBD #endif // __pbd_whitespace_h__ diff --git a/libs/pbd/whitespace.cc b/libs/pbd/whitespace.cc index 28be5fc442..631fad837f 100644 --- a/libs/pbd/whitespace.cc +++ b/libs/pbd/whitespace.cc @@ -16,6 +16,8 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include +#include #include "pbd/whitespace.h" @@ -77,4 +79,11 @@ strip_whitespace_edges (string& str) } } +void +remove_extra_whitespace (string const & input, string & output) +{ + std::unique_copy (input.begin(), input.end(), std::back_insert_iterator(output), [](char a,char b){ return isspace(a) && isspace(b);}); +} + + } // namespace PBD