Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 189b6d85c9295e8224313c076fe5f298817cc76d authored by Barry Warsaw on 01 March 2008, 03:15:20 UTC
More copyright year and version number bumps
Tip revision: 189b6d8
pystrcmp.c
/* Cross platform case insenstive 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(*s1) == tolower(*s2))) {
		if (!*s1++ || !*s2++)
			break;
	}
	return tolower(*s1) - tolower(*s2);
}

int
PyOS_mystricmp(const char *s1, const char *s2)
{
	while (*s1 && (tolower(*s1++) == tolower(*s2++))) {
		;
	}
	return (tolower(*s1) - tolower(*s2));
}
back to top