… | |
… | |
62 | return TRUE; |
62 | return TRUE; |
63 | } |
63 | } |
64 | #endif |
64 | #endif |
65 | #endif |
65 | #endif |
66 | |
66 | |
67 | char * fptools_id = "$Id: fptools.c,v 1.13 2020/12/11 20:09:23 root Exp $"; |
67 | char * fptools_id = "$Id: fptools.c,v 1.14 2020/12/11 20:27:00 root Exp $"; |
68 | |
68 | |
69 | /* |
69 | /* |
70 | * some versions of free can't handle a NULL pointer properly |
70 | * some versions of free can't handle a NULL pointer properly |
71 | * (ANSI says, free ignores a NULL pointer, but some machines |
71 | * (ANSI says, free ignores a NULL pointer, but some machines |
72 | * prefer to SIGSEGV on it) |
72 | * prefer to SIGSEGV on it) |
… | |
… | |
120 | /* |
120 | /* |
121 | * duplicate a memory area |
121 | * duplicate a memory area |
122 | */ |
122 | */ |
123 | |
123 | |
124 | void * TOOLEXPORT |
124 | void * TOOLEXPORT |
125 | FP_memdup (void *ptr, int len) |
125 | FP_memdup (const void *ptr, int len) |
126 | { |
126 | { |
127 | void *result; |
127 | void *result; |
128 | |
128 | |
129 | if (ptr == NULL) |
129 | if (ptr == NULL) |
130 | return NULL; |
130 | return NULL; |
… | |
… | |
172 | count--; |
172 | count--; |
173 | } |
173 | } |
174 | return count ? (tolower (*str1) - tolower (*str2)) : 0; |
174 | return count ? (tolower (*str1) - tolower (*str2)) : 0; |
175 | } |
175 | } |
176 | #endif |
176 | #endif |
|
|
177 | |
|
|
178 | int TOOLEXPORT |
|
|
179 | FP_strnicmp_fast (const char *str1, const char *str2, int count) |
|
|
180 | { |
|
|
181 | if (str1==NULL || str2==NULL) |
|
|
182 | return -1; |
|
|
183 | |
|
|
184 | while (*str1 && count) { |
|
|
185 | if ((*str1 ^ *str2) & 0xdf) |
|
|
186 | break; |
|
|
187 | |
|
|
188 | str1++; |
|
|
189 | str2++; |
|
|
190 | count--; |
|
|
191 | } |
|
|
192 | |
|
|
193 | return (*str1 & 0xdf) - (*str2 & 0xdf); |
|
|
194 | } |
177 | |
195 | |
178 | char * TOOLEXPORT |
196 | char * TOOLEXPORT |
179 | FP_strpbrk (char *str, char *accept) |
197 | FP_strpbrk (char *str, char *accept) |
180 | { |
198 | { |
181 | char *ptr; |
199 | char *ptr; |
… | |
… | |
365 | |
383 | |
366 | return 1; |
384 | return 1; |
367 | } |
385 | } |
368 | |
386 | |
369 | char * TOOLEXPORT |
387 | char * TOOLEXPORT |
370 | FP_strrchr (char *string, int tc) |
388 | FP_strrchr (const char *string, int tc) |
371 | { |
389 | { |
372 | char *ptr; |
390 | const char *ptr; |
373 | |
391 | |
374 | if (string == NULL || !*string) |
392 | if (string == NULL || !*string) |
375 | return NULL; |
393 | return NULL; |
376 | |
394 | |
377 | ptr = string + strlen (string) - 1; |
395 | ptr = string + strlen (string) - 1; |
378 | |
396 | |
379 | while (ptr != string && *ptr != tc) |
397 | while (ptr != string && *ptr != tc) |
380 | ptr--; |
398 | ptr--; |
381 | |
399 | |
382 | if (*ptr == tc) |
400 | if (*ptr == tc) |
383 | return ptr; |
401 | return (char *)ptr; |
384 | |
402 | |
385 | return NULL; |
403 | return NULL; |
386 | } |
404 | } |
387 | |
405 | |
388 | /* |
406 | /* |