Staging
v0.5.1
https://github.com/python/cpython
Revision 7c4afcb1c4cc04d649db648c663fd50189b72034 authored by Tarek Ziadé on 19 March 2010, 21:56:34 UTC, committed by Tarek Ziadé on 19 March 2010, 21:56:34 UTC
1 parent f723956
Raw File
Tip revision: 7c4afcb1c4cc04d649db648c663fd50189b72034 authored by Tarek Ziadé on 19 March 2010, 21:56:34 UTC
Fixed #2698 - now reads the compiler option when creating the compiler
Tip revision: 7c4afcb
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