Staging
v0.5.1
https://github.com/python/cpython
Revision 324e1790094708538acf2e7795f9c44e3732aaf7 authored by Serhiy Storchaka on 07 December 2018, 06:02:33 UTC, committed by GitHub on 07 December 2018, 06:02:33 UTC
(cherry picked from commit 42b1d6127bd8595522a78a75166ebb9fba74a6a2)
(cherry picked from commit 7a2cf1e7d3bf300e98c702589d405734f4a8fcf8)
1 parent 107b27e
Raw File
Tip revision: 324e1790094708538acf2e7795f9c44e3732aaf7 authored by Serhiy Storchaka on 07 December 2018, 06:02:33 UTC
[2.7] bpo-33023: Fix NotImplemented to NotImplementedError. (GH-10934). (GH-11001) (GH-11008)
Tip revision: 324e179
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