Staging
v0.5.1
https://github.com/python/cpython
Revision e29ab7e75138e198b51c8bd04afa16d9d2c976a5 authored by Miss Islington (bot) on 07 September 2017, 00:04:14 UTC, committed by R. David Murray on 07 September 2017, 00:04:14 UTC
(cherry picked from commit 8204b903683f9e0f037ccfaa87622716019914d7)
1 parent fd645ec
Raw File
Tip revision: e29ab7e75138e198b51c8bd04afa16d9d2c976a5 authored by Miss Islington (bot) on 07 September 2017, 00:04:14 UTC
[3.6] bpo-30824: Add mimetype for .json (GH-3048) (#3401)
Tip revision: e29ab7e
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