view Python/pystrcmp.c @ 87686:07425df887b5 3.3

Fixes issue #15798: subprocess.Popen() no longer fails if file descriptor 0, 1 or 2 is closed. The errpipe_write fd will always be >= 3.
author Gregory P. Smith <greg@krypto.org>
date Sun, 01 Dec 2013 17:27:40 -0800
parents fd25030223b0
children
line wrap: on
line source

/* 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));
}