… | |
… | |
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.15 2020/12/11 21:59:30 root Exp $"; |
67 | char * fptools_id = "$Id: fptools.c,v 1.16 2020/12/12 00:44:18 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) |
… | |
… | |
159 | |
159 | |
160 | #ifndef FP_strnicmp |
160 | #ifndef FP_strnicmp |
161 | int TOOLEXPORT |
161 | int TOOLEXPORT |
162 | FP_strnicmp (const char *str1, const char *str2, int count) |
162 | FP_strnicmp (const char *str1, const char *str2, int count) |
163 | { |
163 | { |
164 | if (str1==NULL || str2==NULL) |
164 | int d; |
|
|
165 | |
|
|
166 | if (!str1 || !str2) |
165 | return -1; |
167 | return -1; |
166 | |
168 | |
167 | while (*str1 && count) { |
169 | while (count--) { |
|
|
170 | if (!*str1) |
|
|
171 | return -1; |
|
|
172 | |
168 | if (tolower(*str1) != tolower(*str2)) |
173 | d = tolower (*str1) - tolower (*str2); |
169 | break; |
174 | if (d) |
|
|
175 | return d; |
|
|
176 | |
170 | str1++; |
177 | str1++; |
171 | str2++; |
178 | str2++; |
172 | count--; |
|
|
173 | } |
179 | } |
174 | return count ? (tolower (*str1) - tolower (*str2)) : 0; |
180 | |
|
|
181 | return 0; |
175 | } |
182 | } |
176 | #endif |
183 | #endif |
177 | |
184 | |
178 | int TOOLEXPORT |
185 | int TOOLEXPORT |
179 | FP_strnicmp_fast (const char *str1, const char *str2, int count) |
186 | FP_strnicmp_fast (const char *str1, const char *str2, int count) |
180 | { |
187 | { |
181 | if (!str1 || !str2) |
188 | if (!str1 || !str2) |
182 | return -1; |
189 | return -1; |
183 | |
190 | |
184 | while (*str1 && count) { |
191 | while (count--) { |
|
|
192 | if (!*str1) |
|
|
193 | return -1; |
|
|
194 | |
185 | if ((*str1 ^ *str2) & 0xdf) |
195 | if ((*str1 ^ *str2) & 0xdf) |
186 | break; |
196 | return (*str1 & 0xdf) - (*str2 & 0xdf); |
187 | |
197 | |
188 | str1++; |
198 | str1++; |
189 | str2++; |
199 | str2++; |
190 | count--; |
|
|
191 | } |
200 | } |
192 | |
201 | |
193 | return (*str1 & 0xdf) - (*str2 & 0xdf); |
202 | return 0; |
194 | } |
203 | } |
195 | |
204 | |
196 | char * TOOLEXPORT |
205 | char * TOOLEXPORT |
197 | FP_strpbrk (char *str, char *accept) |
206 | FP_strpbrk (char *str, char *accept) |
198 | { |
207 | { |