From d6142085f78cdf59ee63bca5b13c5833bfccca38 Mon Sep 17 00:00:00 2001 From: "Alexander S. Aganichev" Date: Sun, 16 Jun 2002 10:07:36 +0000 Subject: [PATCH] changed to use ctype.h functions --- goldlib/gall/gstrutil.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/goldlib/gall/gstrutil.cpp b/goldlib/gall/gstrutil.cpp index eb60079..cd973b5 100644 --- a/goldlib/gall/gstrutil.cpp +++ b/goldlib/gall/gstrutil.cpp @@ -445,8 +445,8 @@ char* strsrep(char* str, const char* search, const char* replace) { char* strtrim(char* p) { int i; - for(i=strlen(p)-1; (i >= 0) and ('!' > p[i]); i--) {} - p[i+1] = NUL; + for(i = strlen(p) - 1; (i >= 0) and (isspace(p[i]) or iscntrl(p[i])); i--) {} + p[i + 1] = NUL; return p; } @@ -455,8 +455,13 @@ std::string& strtrim(std::string& p) { if(not p.empty()) { std::string::iterator trail = p.end(); - while(trail != p.begin() and *(--trail) < '!') {} - if(*trail > ' ') trail++; + while(trail != p.begin()) { + --trail; + if(not isspace(*trail) and not iscntrl(*trail)) { + ++trail; + break; + } + } p.erase(trail, p.end()); } return p; @@ -472,7 +477,7 @@ char* strltrim(char* str) { char* q; p = q = str; - while(*p and isspace(*p)) + while(*p and (isspace(*p) or iscntrl(*p))) p++; if(p != q) {