view Python/pystrcmp.c @ 45661:ff3e9aeaa692 legacy-trunk

Issue#2238: some syntax errors from *args or **kwargs expressions would give bogus error messages, because of untested exceptions:: >>> f(**g(1=2)) XXX undetected error Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'int' object is not iterable instead of the expected SyntaxError: keyword can't be an expression Will backport.
author Amaury Forgeot d'Arc <amauryfa@gmail.com>
date Wed, 05 Mar 2008 01:50:33 +0000
parents 4dc01402d78a
children 0a485593ae1c
line wrap: on
line source

/* 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));
}