Staging
v0.5.1
https://github.com/python/cpython
Revision 53349a005c85931498be3074519e0bf0091b1c93 authored by Raymond Hettinger on 14 February 2008, 14:08:04 UTC, committed by Raymond Hettinger on 14 February 2008, 14:08:04 UTC
1 parent 51b9c24
Raw File
Tip revision: 53349a005c85931498be3074519e0bf0091b1c93 authored by Raymond Hettinger on 14 February 2008, 14:08:04 UTC
Minor doc updates for Py3.0
Tip revision: 53349a0
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