Mercurial > hg > nnchat
changeset 498:b6f6c989deab
Add str_trim_right().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 01 Jun 2012 04:43:53 +0300 |
parents | cbbf502e4a70 |
children | 52d7fed83b37 |
files | util.c util.h |
diffstat | 2 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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);