diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-09-28 07:39:01 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-10-15 11:02:55 +1000 |
commit | 0833de336567cccd1de4d246eed30b7fd5ce0413 (patch) | |
tree | 4a7b08a5ba4dcdc5f81b71d81fdfb82f1b819cea | |
parent | 4a965dd5f0848337d4da4c584381cb1150f77516 (diff) | |
download | jimtcl-0833de336567cccd1de4d246eed30b7fd5ce0413.zip jimtcl-0833de336567cccd1de4d246eed30b7fd5ce0413.tar.gz jimtcl-0833de336567cccd1de4d246eed30b7fd5ce0413.tar.bz2 |
string trimright now always removes nulls
Not Tcl compatible, but makes sense
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | jim.c | 5 | ||||
-rw-r--r-- | jim_tcl.txt | 1 |
2 files changed, 3 insertions, 3 deletions
@@ -2227,15 +2227,14 @@ static const char *trim_left(const char *str, const char *trimchars) return str + strspn(str, trimchars); } +/* Note that trim_right() always trims null characters */ static void trim_right(char *str, const char *trimchars) { char *p = str + strlen(str) - 1; char *end = str - 1; - int c; while (p != end) { - c = *p; - if (strchr(trimchars, c) == 0) { + if (*p && strchr(trimchars, *p) == NULL) { break; } p--; diff --git a/jim_tcl.txt b/jim_tcl.txt index 126e260..eb2cec6 100644 --- a/jim_tcl.txt +++ b/jim_tcl.txt @@ -3561,6 +3561,7 @@ The legal options (which may be abbreviated) are: removed. If *chars* is not specified then white space is removed (spaces, tabs, newlines, and carriage returns). + Null characters are always removed. subst ~~~~~ |