Staging
v0.5.1
https://github.com/python/cpython
Revision 815b41b1cdb98686fc3f9cdf995b6983c12c04b3 authored by Martin v. Löwis on 28 February 2014, 14:27:29 UTC, committed by Martin v. Löwis on 28 February 2014, 14:27:29 UTC
are opened in text mode. Patch by Serhiy Storchaka.
1 parent 9db1ab8
Raw File
Tip revision: 815b41b1cdb98686fc3f9cdf995b6983c12c04b3 authored by Martin v. Löwis on 28 February 2014, 14:27:29 UTC
Issue #20731: Properly position in source code files even if they
Tip revision: 815b41b
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