Christian Heimes | 99170a5 | 2007-12-19 02:07:34 +0000 | [diff] [blame] | 1 | /* Cross platform case insenstive 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) && (tolower(*s1) == tolower(*s2))) { |
| 12 | if (!*s1++ || !*s2++) |
| 13 | break; |
| 14 | } |
| 15 | return tolower(*s1) - tolower(*s2); |
| 16 | } |
| 17 | |
| 18 | int |
| 19 | PyOS_mystricmp(const char *s1, const char *s2) |
| 20 | { |
| 21 | while (*s1 && (tolower(*s1++) == tolower(*s2++))) { |
| 22 | ; |
| 23 | } |
| 24 | return (tolower(*s1) - tolower(*s2)); |
| 25 | } |