Staging
v0.5.1
https://github.com/python/cpython
Revision d5460096778dcb700f850c16c6ad63531430d433 authored by Senthil Kumaran on 09 April 2014, 15:41:02 UTC, committed by Senthil Kumaran on 09 April 2014, 15:41:02 UTC
1 parent 05bbb8c
Raw File
Tip revision: d5460096778dcb700f850c16c6ad63531430d433 authored by Senthil Kumaran on 09 April 2014, 15:41:02 UTC
issue #21190: Fix the docs README link
Tip revision: d546009
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