diff util.c @ 498:b6f6c989deab

Add str_trim_right().
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 01 Jun 2012 04:43:53 +0300
parents 73f8df0ecffe
children 291e3caa91a0
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);