Macro for making comparisons easy. (camel_ustrcasecmp): Use

2001-02-07  Jeffrey Stedfast  <fejj@ximian.com>

	* camel-search-private.c (CAMEL_SEARCH_COMPARE): Macro for making
	comparisons easy.
	(camel_ustrcasecmp): Use CAMEL_SEARCH_COMPARE and check for
	end-of-string before the utf-8 error check.
	(camel_ustrncasecmp): Same.
	(camel_search_header_match): Strip leading spaces before doing
	anything else. Also use vlen and mlen so as to not need to do 500
	strlen()'s.
	(camel_ustrcasecmp): Don't get_utf8() for the 2 strings in the
	comparison part of the loop because of short-circuit expression
	evaluation. (blame JPR if this is the wrong term!)
	(camel_ustrncasecmp): Same.

svn path=/trunk/; revision=8057
This commit is contained in:
Jeffrey Stedfast
2001-02-07 21:27:11 +00:00
committed by Jeffrey Stedfast
parent de975c303a
commit fa272d3dc9
2 changed files with 20 additions and 6 deletions

View File

@ -8,6 +8,10 @@
(camel_search_header_match): Strip leading spaces before doing
anything else. Also use vlen and mlen so as to not need to do 500
strlen()'s.
(camel_ustrcasecmp): Don't get_utf8() for the 2 strings in the
comparison part of the loop because of short-circuit expression
evaluation. (blame JPR if this is the wrong term!)
(camel_ustrncasecmp): Same.
2001-02-06 Jeffrey Stedfast <fejj@ximian.com>

View File

@ -307,13 +307,18 @@ camel_ustrcasecmp (const char *s1, const char *s2)
CAMEL_SEARCH_COMPARE (s1, s2, NULL);
while ((u1 = utf8_get(&s1)) && (u2 = utf8_get(&s2))) {
u1 = unicode_tolower(u1);
u2 = unicode_tolower(u2);
u1 = utf8_get (&s1);
u2 = utf8_get (&s2);
while (u1 && u2) {
u1 = unicode_tolower (u1);
u2 = unicode_tolower (u2);
if (u1 < u2)
return -1;
else if (u1 > u2)
return 1;
u1 = utf8_get (&s1);
u2 = utf8_get (&s2);
}
/* end of one of the strings ? */
@ -332,14 +337,19 @@ camel_ustrncasecmp (const char *s1, const char *s2, size_t len)
CAMEL_SEARCH_COMPARE (s1, s2, NULL);
while (len > 0 && (u1 = utf8_get(&s1)) && (u2 = utf8_get(&s2))) {
u1 = unicode_tolower(u1);
u2 = unicode_tolower(u2);
u1 = utf8_get (&s1);
u2 = utf8_get (&s2);
while (len > 0 && u1 && u2) {
u1 = unicode_tolower (u1);
u2 = unicode_tolower (u2);
if (u1 < u2)
return -1;
else if (u1 > u2)
return 1;
len--;
u1 = utf8_get (&s1);
u2 = utf8_get (&s2);
}
if (len == 0)