2021-08-13 10:20:45 +00:00
|
|
|
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
|
|
|
|
│ vi: set et ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi │
|
|
|
|
╞══════════════════════════════════════════════════════════════════════════════╡
|
|
|
|
│ Python 3 │
|
|
|
|
│ https://docs.python.org/3/license.html │
|
|
|
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
2021-08-12 07:42:14 +00:00
|
|
|
#include "third_party/python/Include/object.h"
|
|
|
|
#include "third_party/python/Include/pyctype.h"
|
2021-08-10 17:26:13 +00:00
|
|
|
|
2021-08-08 04:08:33 +00:00
|
|
|
/* Cross platform case insensitive string compare functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
PyOS_mystrnicmp(const char *s1, const char *s2, Py_ssize_t size)
|
|
|
|
{
|
|
|
|
if (size == 0)
|
|
|
|
return 0;
|
|
|
|
while ((--size > 0) &&
|
2021-08-12 07:42:14 +00:00
|
|
|
(Py_TOLOWER(*s1) == Py_TOLOWER(*s2))) {
|
2021-08-08 04:08:33 +00:00
|
|
|
if (!*s1++ || !*s2++)
|
|
|
|
break;
|
|
|
|
}
|
2021-08-12 07:42:14 +00:00
|
|
|
return Py_TOLOWER(*s1) - Py_TOLOWER(*s2);
|
2021-08-08 04:08:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
PyOS_mystricmp(const char *s1, const char *s2)
|
|
|
|
{
|
2021-08-12 07:42:14 +00:00
|
|
|
while (*s1 && (Py_TOLOWER((unsigned)*s1++) == Py_TOLOWER((unsigned)*s2++))) {
|
2021-08-08 04:08:33 +00:00
|
|
|
}
|
2021-08-12 07:42:14 +00:00
|
|
|
return (Py_TOLOWER((unsigned)*s1) - Py_TOLOWER((unsigned)*s2));
|
2021-08-08 04:08:33 +00:00
|
|
|
}
|