Staging
v0.8.1
https://github.com/python/cpython
Revision f722c2969aa767d4dd9d9e1d4b1b682c90bde611 authored by Benjamin Peterson on 30 June 2014, 01:57:11 UTC, committed by Benjamin Peterson on 30 June 2014, 01:57:11 UTC
1 parent bb4d352
Raw File
Tip revision: f722c2969aa767d4dd9d9e1d4b1b682c90bde611 authored by Benjamin Peterson on 30 June 2014, 01:57:11 UTC
update pydoc-topics
Tip revision: f722c29
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