Staging
v0.5.1
Revision 1a274359283d3d1f4f60dd527843f72e0368caf3 authored by Miss Islington (bot) on 24 January 2020, 20:10:52 UTC, committed by GitHub on 24 January 2020, 20:10:52 UTC

Use `from ... import ...` to ensure module is fully loaded before accessing its attributes.
(cherry picked from commit 9017e0bd5e124ae6d2ed94b9e9cacb2e86270980)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 61b3484
Raw File
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