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