Staging
v0.5.1
https://github.com/python/cpython
Revision 3e96f324dcdbeb78fcd8fa4ffe2cd0c67f3828b2 authored by Steve Dower on 02 March 2015, 16:01:10 UTC, committed by Steve Dower on 02 March 2015, 16:01:10 UTC
1 parent 2f3d440
Raw File
Tip revision: 3e96f324dcdbeb78fcd8fa4ffe2cd0c67f3828b2 authored by Steve Dower on 02 March 2015, 16:01:10 UTC
Issue #23451: Update pyconfig.h for Windows to require Vista headers and remove unnecessary version checks.
Tip revision: 3e96f32
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