blob: 0012ef33bc3878e5f2b63298e3fbbd4cf6aba502 [file] [log] [blame]
Christian Heimes99170a52007-12-19 02:07:34 +00001/* Cross platform case insenstive string compare functions
2 */
3
4#include "Python.h"
5
6int
7PyOS_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
18int
19PyOS_mystricmp(const char *s1, const char *s2)
20{
21 while (*s1 && (tolower(*s1++) == tolower(*s2++))) {
22 ;
23 }
24 return (tolower(*s1) - tolower(*s2));
25}