Mercurial > trustbridge
comparison common/strhelp.c @ 131:9104b1b2e4da
Added string comparison functions.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Mon, 24 Mar 2014 13:32:12 +0100 |
parents | c602d8cfa619 |
children | c719d3fdbc15 |
comparison
equal
deleted
inserted
replaced
122:65941f3d5db8 | 131:9104b1b2e4da |
---|---|
1 | 1 #include <stdbool.h> |
2 #include <stdio.h> | 2 #include <stdio.h> |
3 #include <stdlib.h> | 3 #include <stdlib.h> |
4 #include <string.h> | 4 #include <string.h> |
5 #include <assert.h> | 5 #include <assert.h> |
6 | 6 |
100 free (str_array[i]); | 100 free (str_array[i]); |
101 | 101 |
102 free (str_array); | 102 free (str_array); |
103 } | 103 } |
104 } | 104 } |
105 | |
106 bool | |
107 str_equal (char *s1, char *s2) | |
108 { | |
109 size_t l1 = strlen(s1); | |
110 size_t l2 = strlen(s2); | |
111 if ((l1 == l2) && | |
112 (strncmp(s1, s2, l1) == 0)) | |
113 return true; | |
114 else | |
115 return false; | |
116 } | |
117 | |
118 bool | |
119 str_starts_with (char *s1, char *s2) | |
120 { | |
121 if (strncmp(s1, s2, strlen(s2)) == 0) | |
122 return true; | |
123 else | |
124 return false; | |
125 } |