[Mailer] Fix for #333698

"simon.zheng" <[email protected]>
Newsgroups gmane.comp.gnome.evolution.patches
Message-ID <1141718413.16552.11.camel@fulltime>
Hi,

Bug #333698 - Evolution can't find mails with some localized subject on
Solaris sparc.
http://bugzilla.gnome.org/show_bug.cgi?id=333698

To avoid break the complete utf8 characters, we should traverse strings
by utf8 character order rather than one by one byte. 

Sending patch for review.

Thanks,
-Simon

_______________________________________________
Evolution-patches mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/evolution-patches
333698-header-match.diff (text/x-patch, 2.3 KB)
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/ChangeLog,v
retrieving revision 1.2526
diff -u -p -r1.2526 ChangeLog
--- ChangeLog	21 Feb 2006 12:17:27 -0000	1.2526
+++ ChangeLog	7 Mar 2006 07:12:16 -0000
@@ -1,3 +1,12 @@
+2006-03-07  Simon Zheng  <[email protected]>
+
+	** Fixes bug #333698
+
+	* camel-search-private.c (header_match):
+	(camel_search_header_match):
+	To traverse strings by utf8 char order rather than one by one byte, 
+	use camel_utf8_getc() and other utf8-specific routines instead. 
+
 2006-02-21  Rohini S  <[email protected]>
 
 	** See bug 318697
Index: camel-search-private.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-search-private.c,v
retrieving revision 1.36
diff -u -p -r1.36 camel-search-private.c
--- camel-search-private.c	6 Dec 2005 04:21:54 -0000	1.36
+++ camel-search-private.c	7 Mar 2006 07:12:16 -0000
@@ -368,6 +368,7 @@ header_match(const char *value, const ch
 {
 	const unsigned char *p;
 	int vlen, mlen;
+	guint32 c;
 	
 	if (how == CAMEL_SEARCH_MATCH_SOUNDEX)
 		return header_soundex (value, match);
@@ -380,8 +381,8 @@ header_match(const char *value, const ch
 	/* from dan the man, if we have mixed case, perform a case-sensitive match,
 	   otherwise not */
 	p = (const unsigned char *)match;
-	while (*p) {
-		if (isupper(*p)) {
+	while (c = camel_utf8_getc(&p)) {
+		if (g_unichar_isupper(c)) {
 			switch (how) {
 			case CAMEL_SEARCH_MATCH_EXACT:
 				return strcmp(value, match) == 0;
@@ -396,7 +397,6 @@ header_match(const char *value, const ch
 			}
 			return FALSE;
 		}
-		p++;
 	}
 	
 	switch (how) {
@@ -420,13 +420,15 @@ header_match(const char *value, const ch
 gboolean
 camel_search_header_match (const char *value, const char *match, camel_search_match_t how, camel_search_t type, const char *default_charset)
 {
-	const char *name, *addr;
+	const char *name, *addr, *ptr;
 	int truth = FALSE, i;
 	CamelInternetAddress *cia;
 	char *v, *vdom, *mdom;
+	guint32 c;
 
-	while (*value && isspace (*value))
-		value++;
+	ptr = value;
+	while ((c = camel_utf8_getc((const unsigned char **)&ptr)) && g_unichar_isspace(c))
+		value = ptr;
 	
 	switch(type) {
 	case CAMEL_SEARCH_TYPE_ENCODED:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.