/src/Python-3.8.3/Python/pystrcmp.c
Line  | Count  | Source  | 
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  | 0  | { | 
9  | 0  |     if (size == 0)  | 
10  | 0  |         return 0;  | 
11  | 0  |     while ((--size > 0) &&  | 
12  | 0  |            (tolower((unsigned)*s1) == tolower((unsigned)*s2))) { | 
13  | 0  |         if (!*s1++ || !*s2++)  | 
14  | 0  |             break;  | 
15  | 0  |     }  | 
16  | 0  |     return tolower((unsigned)*s1) - tolower((unsigned)*s2);  | 
17  | 0  | }  | 
18  |  |  | 
19  |  | int  | 
20  |  | PyOS_mystricmp(const char *s1, const char *s2)  | 
21  | 0  | { | 
22  | 0  |     while (*s1 && (tolower((unsigned)*s1++) == tolower((unsigned)*s2++))) { | 
23  | 0  |         ;  | 
24  | 0  |     }  | 
25  | 0  |     return (tolower((unsigned)*s1) - tolower((unsigned)*s2));  | 
26  | 0  | }  |