Staging
v0.5.1
https://github.com/python/cpython
Revision 8d1cbfffea7a5dbf7a3c60b066a2c2120ef08cd0 authored by Lysandros Nikolaou on 23 April 2020, 12:22:16 UTC, committed by GitHub on 23 April 2020, 12:22:16 UTC
1 parent 1df5a9e
Raw File
Tip revision: 8d1cbfffea7a5dbf7a3c60b066a2c2120ef08cd0 authored by Lysandros Nikolaou on 23 April 2020, 12:22:16 UTC
bpo-40334: Suppress all output in test_peg_generator (GH-19675)
Tip revision: 8d1cbff
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