Mercurial > trustbridge
comparison common/strhelp.c @ 142:52993db093f4
merged.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Mon, 24 Mar 2014 16:06:50 +0100 |
parents | 5fa4791d6d0e |
children | b026e6d2a161 |
comparison
equal
deleted
inserted
replaced
141:f5fa39347366 | 142:52993db093f4 |
---|---|
1 #include <ctype.h> | |
1 #include <stdbool.h> | 2 #include <stdbool.h> |
2 #include <stdio.h> | 3 #include <stdio.h> |
3 #include <stdlib.h> | 4 #include <stdlib.h> |
4 #include <string.h> | 5 #include <string.h> |
5 #include <assert.h> | 6 #include <assert.h> |
107 str_equal (char *s1, char *s2) | 108 str_equal (char *s1, char *s2) |
108 { | 109 { |
109 size_t l1 = strlen(s1); | 110 size_t l1 = strlen(s1); |
110 size_t l2 = strlen(s2); | 111 size_t l2 = strlen(s2); |
111 if ((l1 == l2) && | 112 if ((l1 == l2) && |
112 (strncmp(s1, s2, l1) == 0)) | 113 (strcmp(s1, s2) == 0)) |
113 return true; | 114 return true; |
114 else | 115 else |
115 return false; | 116 return false; |
116 } | 117 } |
117 | 118 |
121 if (strncmp(s1, s2, strlen(s2)) == 0) | 122 if (strncmp(s1, s2, strlen(s2)) == 0) |
122 return true; | 123 return true; |
123 else | 124 else |
124 return false; | 125 return false; |
125 } | 126 } |
127 | |
128 void | |
129 str_trim (char **s) | |
130 { | |
131 size_t i; | |
132 if (*s != NULL) | |
133 { | |
134 while (isspace(**s)) | |
135 (*s)++; | |
136 i = strlen(*s); | |
137 while (isspace((*s)[--i])) | |
138 (*s)[i] = '\0'; | |
139 } | |
140 } |