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)
|
|
|
|
{
|
2010-05-09 12:15:40 -03:00
|
|
|
if (size == 0)
|
|
|
|
return 0;
|
|
|
|
while ((--size > 0) &&
|
|
|
|
(tolower((unsigned)*s1) == tolower((unsigned)*s2))) {
|
|
|
|
if (!*s1++ || !*s2++)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return tolower((unsigned)*s1) - tolower((unsigned)*s2);
|
2007-12-18 19:22:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
PyOS_mystricmp(const char *s1, const char *s2)
|
|
|
|
{
|
2010-05-09 12:15:40 -03:00
|
|
|
while (*s1 && (tolower((unsigned)*s1++) == tolower((unsigned)*s2++))) {
|
|
|
|
;
|
|
|
|
}
|
|
|
|
return (tolower((unsigned)*s1) - tolower((unsigned)*s2));
|
2007-12-18 19:22:54 -04:00
|
|
|
}
|