Staging
v0.5.1
https://github.com/python/cpython
Revision 0bb8567e1e6cfe1e65ac5113945096bf2d369fa4 authored by Georg Brandl on 23 February 2008, 22:35:33 UTC, committed by Georg Brandl on 23 February 2008, 22:35:33 UTC
Originally written for GHOP by Josip Dzolonga, heavily patched by me.
1 parent c76ea27
Raw File
Tip revision: 0bb8567e1e6cfe1e65ac5113945096bf2d369fa4 authored by Georg Brandl on 23 February 2008, 22:35:33 UTC
In test_heapq and test_bisect, test both the Python and the C implementation.
Tip revision: 0bb8567
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