made rtrim() and ltrim() global functions, to reduce code duplication (it seems parallaction/parser.cpp code re-use them too

svn-id: r25564
This commit is contained in:
Gregory Montoir 2007-02-13 21:06:57 +00:00
parent 474d49dc14
commit 1ce912e106
6 changed files with 30 additions and 62 deletions

View file

@ -431,5 +431,21 @@ String operator +(const String &x, const char *y) {
return temp;
}
char *ltrim(char *t) {
while (isspace(*t))
t++;
return t;
}
char *rtrim(char *t) {
int l = strlen(t) - 1;
while (l >= 0 && isspace(t[l]))
t[l--] = 0;
return t;
}
char *trim(char *t) {
return rtrim(ltrim(t));
}
} // End of namespace Common