1 /* Cross platform case insensitive string compare functions 2 */ 3 4 #include "Python.h" 5 6 int PyOS_mystrnicmp(const char * s1,const char * s2,Py_ssize_t size)7PyOS_mystrnicmp(const char *s1, const char *s2, Py_ssize_t size) 8 { 9 const unsigned char *p1, *p2; 10 if (size == 0) 11 return 0; 12 p1 = (const unsigned char *)s1; 13 p2 = (const unsigned char *)s2; 14 for (; (--size > 0) && *p1 && *p2 && (tolower(*p1) == tolower(*p2)); 15 p1++, p2++) { 16 ; 17 } 18 return tolower(*p1) - tolower(*p2); 19 } 20 21 int PyOS_mystricmp(const char * s1,const char * s2)22PyOS_mystricmp(const char *s1, const char *s2) 23 { 24 const unsigned char *p1 = (const unsigned char *)s1; 25 const unsigned char *p2 = (const unsigned char *)s2; 26 for (; *p1 && *p2 && (tolower(*p1) == tolower(*p2)); p1++, p2++) { 27 ; 28 } 29 return (tolower(*p1) - tolower(*p2)); 30 } 31