Staging
v0.5.1
Revision e135102ae091f3d756a57ca995e34f0739810ad9 authored by Barry Warsaw on 01 March 2010, 21:49:12 UTC, committed by Barry Warsaw on 01 March 2010, 21:49:12 UTC
........
  r78566 | barry.warsaw | 2010-03-01 16:46:51 -0500 (Mon, 01 Mar 2010) | 4 lines

  Manually copy patch for bug 7250 from the release26-maint branch.  I suck
  because I did this in the wrong order and couldn't smack svnmerge into
  submission.
........
1 parent f670629
Raw File
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