2008-03-23 03:19:57 -03:00
|
|
|
/* Cross platform case insensitive string compare functions
|
2007-12-18 19:22:54 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Python.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
PyOS_mystrnicmp(const char *s1, const char *s2, Py_ssize_t size)
|
|
|
|
{
|
|
|
|
if (size == 0)
|
|
|
|
return 0;
|
2008-03-23 03:19:57 -03:00
|
|
|
while ((--size > 0) &&
|
|
|
|
(tolower((unsigned)*s1) == tolower((unsigned)*s2))) {
|
2007-12-18 19:22:54 -04:00
|
|
|
if (!*s1++ || !*s2++)
|
|
|
|
break;
|
|
|
|
}
|
2008-03-23 03:19:57 -03:00
|
|
|
return tolower((unsigned)*s1) - tolower((unsigned)*s2);
|
2007-12-18 19:22:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
PyOS_mystricmp(const char *s1, const char *s2)
|
|
|
|
{
|
2008-03-23 03:19:57 -03:00
|
|
|
while (*s1 && (tolower((unsigned)*s1++) == tolower((unsigned)*s2++))) {
|
2007-12-18 19:22:54 -04:00
|
|
|
;
|
|
|
|
}
|
2008-03-23 03:19:57 -03:00
|
|
|
return (tolower((unsigned)*s1) - tolower((unsigned)*s2));
|
2007-12-18 19:22:54 -04:00
|
|
|
}
|