2006-07-05 15:47:25 -04:00
|
|
|
#include <pbd/whitespace.h>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
void
|
|
|
|
strip_whitespace_edges (string& str)
|
|
|
|
{
|
|
|
|
string::size_type i;
|
|
|
|
string::size_type len;
|
2006-07-27 21:08:57 -04:00
|
|
|
string::size_type s;
|
2006-07-05 15:47:25 -04:00
|
|
|
|
|
|
|
len = str.length();
|
2006-07-27 21:08:57 -04:00
|
|
|
|
|
|
|
/* strip front */
|
2006-07-05 15:47:25 -04:00
|
|
|
|
|
|
|
for (i = 0; i < len; ++i) {
|
|
|
|
if (isgraph (str[i])) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
/* strip back */
|
|
|
|
|
|
|
|
if (len > 1) {
|
|
|
|
|
|
|
|
s = i;
|
|
|
|
i = len - 1;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (isgraph (str[i]) || i == 0) {
|
|
|
|
break;
|
|
|
|
}
|
2006-07-05 15:47:25 -04:00
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
--i;
|
|
|
|
|
|
|
|
} while (true);
|
|
|
|
|
|
|
|
str = str.substr (s, (i - s) + 1);
|
2006-07-05 15:47:25 -04:00
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
} else {
|
|
|
|
str = str.substr (s);
|
|
|
|
}
|
2006-07-05 15:47:25 -04:00
|
|
|
}
|
|
|
|
|