Staging
v0.5.1
https://github.com/python/cpython
Revision 53f9135667226f33e049e327db60fb033afbd77a authored by Serhiy Storchaka on 26 December 2017, 22:38:56 UTC, committed by GitHub on 26 December 2017, 22:38:56 UTC
1 parent 13a6c09
Raw File
Tip revision: 53f9135667226f33e049e327db60fb033afbd77a authored by Serhiy Storchaka on 26 December 2017, 22:38:56 UTC
bpo-32416: Refactor tests for the f_lineno setter and add new tests. (#4991)
Tip revision: 53f9135
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