Staging
v0.5.1
https://github.com/python/cpython
Revision dd7cf4564b2fbec981b0b34a84acf0fb46862b88 authored by Ned Deily on 27 September 2018, 00:04:22 UTC, committed by Ned Deily on 27 September 2018, 00:04:22 UTC
2 parent s 4ea64a2 + 2064bcf
Raw File
Tip revision: dd7cf4564b2fbec981b0b34a84acf0fb46862b88 authored by Ned Deily on 27 September 2018, 00:04:22 UTC
Merge tag 'v3.7.1rc1' into 3.7
Tip revision: dd7cf45
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