MCPcopy Create free account
hub / github.com/MapServer/MapServer / strstrIgnoreCase

Function strstrIgnoreCase

mapmssql2008.c:153–188  ·  view source on GitHub ↗

TODO Take a look at glibc's strcasestr */

Source from the content-addressed store, hash-verified

151
152/* TODO Take a look at glibc's strcasestr */
153static char *strstrIgnoreCase(const char *haystack, const char *needle)
154{
155 char *hay_lower;
156 char *needle_lower;
157 int len_hay,len_need;
158 int t;
159 char *loc;
160 int match = -1;
161
162 len_hay = strlen(haystack);
163 len_need = strlen(needle);
164
165 hay_lower = (char*) msSmallMalloc(len_hay + 1);
166 needle_lower =(char*) msSmallMalloc(len_need + 1);
167
168
169 for(t = 0; t < len_hay; t++) {
170 hay_lower[t] = (char)tolower(haystack[t]);
171 }
172 hay_lower[t] = 0;
173
174 for(t = 0; t < len_need; t++) {
175 needle_lower[t] = (char)tolower(needle[t]);
176 }
177 needle_lower[t] = 0;
178
179 loc = strstr(hay_lower, needle_lower);
180 if(loc) {
181 match = loc - hay_lower;
182 }
183
184 msFree(hay_lower);
185 msFree(needle_lower);
186
187 return (char *) (match < 0 ? NULL : haystack + match);
188}
189
190static int msMSSQL2008LayerParseData(layerObj *layer, char **geom_column_name, char **geom_column_type, char **table_name, char **urid_name, char **user_srid, char **index_name, int debug);
191

Callers 2

prepare_databaseFunction · 0.85

Calls 2

msSmallMallocFunction · 0.85
msFreeFunction · 0.85

Tested by

no test coverage detected