ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/uulib/fptools.c
(Generate patch)

Comparing Convert-UUlib/uulib/fptools.c (file contents):
Revision 1.15 by root, Fri Dec 11 21:59:30 2020 UTC vs.
Revision 1.16 by root, Sat Dec 12 00:44:18 2020 UTC

62 return TRUE; 62 return TRUE;
63} 63}
64#endif 64#endif
65#endif 65#endif
66 66
67char * fptools_id = "$Id: fptools.c,v 1.15 2020/12/11 21:59:30 root Exp $"; 67char * 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
161int TOOLEXPORT 161int TOOLEXPORT
162FP_strnicmp (const char *str1, const char *str2, int count) 162FP_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
178int TOOLEXPORT 185int TOOLEXPORT
179FP_strnicmp_fast (const char *str1, const char *str2, int count) 186FP_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
196char * TOOLEXPORT 205char * TOOLEXPORT
197FP_strpbrk (char *str, char *accept) 206FP_strpbrk (char *str, char *accept)
198{ 207{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines