symbian-qemu-0.9.1-12/python-2.6.1/Python/pystrcmp.c
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     1 /* Cross platform case insensitive string compare functions
       
     2  */
       
     3 
       
     4 #include "Python.h"
       
     5 
       
     6 int
       
     7 PyOS_mystrnicmp(const char *s1, const char *s2, Py_ssize_t size)
       
     8 {
       
     9 	if (size == 0)
       
    10 		return 0;
       
    11 	while ((--size > 0) &&
       
    12 	       (tolower((unsigned)*s1) == tolower((unsigned)*s2))) {
       
    13 		if (!*s1++ || !*s2++)
       
    14 			break;
       
    15 	}
       
    16 	return tolower((unsigned)*s1) - tolower((unsigned)*s2);
       
    17 }
       
    18 
       
    19 int
       
    20 PyOS_mystricmp(const char *s1, const char *s2)
       
    21 {
       
    22 	while (*s1 && (tolower((unsigned)*s1++) == tolower((unsigned)*s2++))) {
       
    23 		;
       
    24 	}
       
    25 	return (tolower((unsigned)*s1) - tolower((unsigned)*s2));
       
    26 }