Staging
v0.5.1
https://github.com/python/cpython
Revision c5a216e0b97712bf19b4a6b7655c6bf22a367edd authored by Inada Naoki on 20 March 2019, 10:01:55 UTC, committed by GitHub on 20 March 2019, 10:01:55 UTC
1 parent 9b4a1b1
Raw File
Tip revision: c5a216e0b97712bf19b4a6b7655c6bf22a367edd authored by Inada Naoki on 20 March 2019, 10:01:55 UTC
bpo-8677: use PY_SSIZE_T_CLEAN in Modules/_gdbmodule.c (GH-12464)
Tip revision: c5a216e
pystrcmp.c
/* Cross platform case insensitive string compare functions
 */

#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));
}
back to top