Staging
v0.5.1
https://github.com/python/cpython
Revision b368e4e8ce78f5f5cd2d31c20b4f728ef73d2e92 authored by Ned Deily on 07 September 2017, 03:07:43 UTC, committed by Ned Deily on 07 September 2017, 03:17:09 UTC
1 parent dee54f6
Raw File
Tip revision: b368e4e8ce78f5f5cd2d31c20b4f728ef73d2e92 authored by Ned Deily on 07 September 2017, 03:07:43 UTC
Link to generated changelog, not website.
Tip revision: b368e4e
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