Staging
v0.5.1
https://github.com/python/cpython
Revision 30e208d525cd472446feb91b774cf472e7122918 authored by Benjamin Peterson on 22 July 2008, 23:44:37 UTC, committed by Benjamin Peterson on 22 July 2008, 23:44:37 UTC
1 parent d8dd86c
Raw File
Tip revision: 30e208d525cd472446feb91b774cf472e7122918 authored by Benjamin Peterson on 22 July 2008, 23:44:37 UTC
remove unneeded import
Tip revision: 30e208d
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