mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 15:03:34 +00:00
Building o//third_party/python now takes 5 seconds on my PC This change works towards modifying Python to use runtime dispatching when appropriate. For example, when loading the magnums in the socket module, it's a good idea to check if the magnum is zero, because that means the local system platform doesn't support it.
28 lines
664 B
C
28 lines
664 B
C
/* clang-format off */
|
|
|
|
/* Cross platform case insensitive string compare functions
|
|
*/
|
|
|
|
#include "third_party/python/Include/Python.h"
|
|
|
|
int
|
|
PyOS_mystrnicmp(const char *s1, const char *s2, Py_ssize_t size)
|
|
{
|
|
if (size == 0)
|
|
return 0;
|
|
while ((--size > 0) &&
|
|
(tolower((unsigned)*s1) == tolower((unsigned)*s2))) {
|
|
if (!*s1++ || !*s2++)
|
|
break;
|
|
}
|
|
return tolower((unsigned)*s1) - tolower((unsigned)*s2);
|
|
}
|
|
|
|
int
|
|
PyOS_mystricmp(const char *s1, const char *s2)
|
|
{
|
|
while (*s1 && (tolower((unsigned)*s1++) == tolower((unsigned)*s2++))) {
|
|
;
|
|
}
|
|
return (tolower((unsigned)*s1) - tolower((unsigned)*s2));
|
|
}
|