# HG changeset patch # User Matti Hamalainen # Date 1338515033 -10800 # Node ID b6f6c989deabfcf45d423e10c4b20aca7e7c822a # Parent cbbf502e4a705b83c873dc342d16a4ec333e1848 Add str_trim_right(). diff -r cbbf502e4a70 -r b6f6c989deab util.c --- a/util.c Sun May 27 13:28:51 2012 +0300 +++ b/util.c Fri Jun 01 04:43:53 2012 +0300 @@ -31,6 +31,17 @@ } +char * str_trim_right(char *buf) +{ + size_t pos; + + for (pos = strlen(buf) - 1; pos > 0 && th_isspace(buf[pos]); pos--) + buf[pos] = 0; + + return buf; +} + + int str_compare(const void *s1, const void *s2) { return th_strcasecmp((const char *) s1, (const char *) s2); diff -r cbbf502e4a70 -r b6f6c989deab util.h --- a/util.h Sun May 27 13:28:51 2012 +0300 +++ b/util.h Fri Jun 01 04:43:53 2012 +0300 @@ -83,6 +83,7 @@ BOOL str_get_timestamp(char *str, size_t len, const char *fmt); char * str_trim_left(char *buf); +char * str_trim_right(char *buf); int str_compare(const void *s1, const void *s2); #endif