7086280e4af07d52fe66dcd68d011bc27657e8e8 kent Tue Apr 17 12:14:26 2012 -0700 Adding trimLastChar function. diff --git src/lib/common.c src/lib/common.c index 5b9daa6..06a35c6 100644 --- src/lib/common.c +++ src/lib/common.c @@ -1429,30 +1429,38 @@ eLen = strlen(end); offset = sLen - eLen; if (offset < 0) return FALSE; return sameString(string+offset, end); } char lastChar(char *s) /* Return last character in string. */ { if (s == NULL || s[0] == 0) return 0; return s[strlen(s)-1]; } +void trimLastChar(char *s) +/* Erase last character in string. */ +{ +int len = strlen(s); +if (len > 0) + s[len-1] = 0; +} + char *lastNonwhitespaceChar(char *s) // Return pointer to last character in string that is not whitespace. { if (s == NULL || s[0] == 0) return NULL; char *sPos = s + (strlen(s) - 1); for (;sPos >= s;sPos--) { if (!isspace(*sPos)) return sPos; } return NULL; }