Staging
v0.5.1
https://github.com/python/cpython
Revision ebc8dedd1996db68c889c2cdf2701fd7eadc501f authored by Georg Brandl on 30 March 2008, 07:09:22 UTC, committed by Georg Brandl on 30 March 2008, 07:09:22 UTC
1 parent c52ed59
Raw File
Tip revision: ebc8dedd1996db68c889c2cdf2701fd7eadc501f authored by Georg Brandl on 30 March 2008, 07:09:22 UTC
Convert test_ast to unittest and add a test for r62049.
Tip revision: ebc8ded
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