diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 74d66a8d3..f0c8f9e21 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -7,6 +7,10 @@ bill@newbreedsoftware.com http://www.newbreedsoftware.com/tuxpaint/ +2004.November.23 (0.9.15) + * simplify strip_trailing_whitespace, now O(n) + Albert Cahalan + 2004.November.22 (0.9.15) * Enable more compuler warnings, and update code to prevent them. Albert Cahalan diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 53fb9c116..d5656e8e5 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -8249,11 +8249,11 @@ static Mix_Chunk * loadsound(const char * const fname) static void strip_trailing_whitespace( char *buf ) { - while (buf[strlen(buf) - 1] == ' ' || - buf[strlen(buf) - 1] == '\r' || - buf[strlen(buf) - 1] == '\n') + unsigned i = strlen(buf); + while(i--) { - buf[strlen(buf) - 1] = '\0'; + if(!isspace(buf[i])) break; + buf[i] = '\0'; } }