comparison 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
comparison
equal deleted inserted replaced
497:cbbf502e4a70 498:b6f6c989deab
25 25
26 26
27 char * str_trim_left(char *buf) 27 char * str_trim_left(char *buf)
28 { 28 {
29 while (*buf != 0 && th_isspace(*buf)) buf++; 29 while (*buf != 0 && th_isspace(*buf)) buf++;
30 return buf;
31 }
32
33
34 char * str_trim_right(char *buf)
35 {
36 size_t pos;
37
38 for (pos = strlen(buf) - 1; pos > 0 && th_isspace(buf[pos]); pos--)
39 buf[pos] = 0;
40
30 return buf; 41 return buf;
31 } 42 }
32 43
33 44
34 int str_compare(const void *s1, const void *s2) 45 int str_compare(const void *s1, const void *s2)