Re: [evolution-patches] [addressbook] Patch for a bug in "By Company" view (case sensitive grouping)



Hi,

Sending the revised patch with changes done.
It now performs case insensitive, locale sensitive UTF8 string
comparison.

thanks
Devashish Sharma

On Wed, 2005-09-14 at 16:03 +0300, Tor Lillqvist wrote:
> On on, 2005-09-14 at 17:59 +0530, Devashish wrote:
> > Hi,
> > 
> > Changed the compare type for Organization to stringcase. This new type
> > has been defined for performing case insensitive string compares. 
> 
> I guess you didn't notice my recent blogging about strcasecmp() ;-)
> Using strcasecmp() is wrong. It's behaviour is undefined for non-ASCII
> bytes according to the Single UNIX specification. (In glibc, it
> apparently simply ignores non-ASCII bytes. In other implementations, it
> might even give false positives.)
> 
> g_ascii_strcasecmp() would be better (at least one knows for sure what
> it does on all platforms, it ignores non-ASCII like strcasecmp() in
> glibc).
> 
> But ignoring non-ASCII is not very friendly, is it? The strings we are
> comparing presumably are known to be in UTF-8, so what we want is case
> insensitive, normalized, and locale-sensitive UTF-8 comparison. There
> already is code for that in Evolution. One function is
> e_utf8_casefold_collate_len() in addressbook/util/eab-book-util.c .
> There might be other similar functions, I think I have seen several, or
> maybe those were in e-d-s.
> 
> --tml
> 
> 
Index: e-util/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/e-util/ChangeLog,v
retrieving revision 1.554
diff -u -p -r1.554 ChangeLog
--- e-util/ChangeLog	24 Aug 2005 03:05:59 -0000	1.554
+++ e-util/ChangeLog	15 Sep 2005 05:35:55 -0000
@@ -1,3 +1,8 @@
+2005-08-26  Devashish Sharma <sdevashish novell com>
+
+	* e-util.c (g_str_case_compare): added a function for case insensitive
+	and locale sensitive UTF8 string compare.
+
 2005-08-23  Not Zed  <NotZed Ximian com>
 
 	* e-util.c (e_mkdir_hier): cast warning, good ol win32 patches.
Index: e-util/e-util.c
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-util.c,v
retrieving revision 1.65
diff -u -p -r1.65 e-util.c
--- e-util/e-util.c	24 Aug 2005 03:05:59 -0000	1.65
+++ e-util/e-util.c	15 Sep 2005 05:35:55 -0000
@@ -58,6 +58,19 @@ g_str_compare (const void *x, const void
 }
 
 int
+g_str_case_compare (const void *x, const void *y)
+{
+	if (x == NULL || y == NULL) {
+		if (x == y)
+			return 0;
+		else
+			return x ? -1 : 1;
+	}
+	
+	return g_utf8_collate (g_utf8_casefold (x, -1), g_utf8_casefold (y, -1));
+}
+
+int
 g_collate_compare (const void *x, const void *y)
 {
 	if (x == NULL || y == NULL) {
Index: e-util/e-util.h
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-util.h,v
retrieving revision 1.56
diff -u -p -r1.56 e-util.h
--- e-util/e-util.h	17 Jun 2005 15:20:29 -0000	1.56
+++ e-util/e-util.h	15 Sep 2005 05:35:55 -0000
@@ -139,6 +139,8 @@ typedef enum {
 } EFocus;
 int       g_str_compare                                                    (const void        *x,
 									    const void        *y);
+int       g_str_case_compare                                               (const void        *x,
+									    const void        *y);
 int       g_collate_compare                                                (const void        *x,
 									    const void        *y);
 int       g_int_compare                                                    (const void        *x,
Index: widgets/table/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/widgets/table/ChangeLog,v
retrieving revision 1.6
diff -u -p -r1.6 ChangeLog
--- widgets/table/ChangeLog	25 Aug 2005 06:54:58 -0000	1.6
+++ widgets/table/ChangeLog	26 Aug 2005 06:52:50 -0000
@@ -1,3 +1,9 @@
+2005-08-26  Devashish Sharma <sdevashish novell com>
+
+	* e-table-extras.c (ete_init): Added compare type "stringcase" to ETableExtras->
+	compares hash table for case insensitive string compares.The
+	corresponding function g_str_case_compare has been added to e-util.c
+	
 2005-08-24  Li Yuan  <li yuan sun com>
 
 	Fixes #314352.
Index: widgets/table/e-table-extras.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/table/e-table-extras.c,v
retrieving revision 1.19
diff -u -p -r1.19 e-table-extras.c
--- widgets/table/e-table-extras.c	17 Jun 2005 15:20:34 -0000	1.19
+++ widgets/table/e-table-extras.c	26 Aug 2005 06:52:50 -0000
@@ -168,6 +168,7 @@ ete_init (ETableExtras *extras)
 	extras->pixbufs = g_hash_table_new(g_str_hash, g_str_equal);
 
 	e_table_extras_add_compare(extras, "string", g_str_compare);
+	e_table_extras_add_compare(extras, "stringcase", g_str_case_compare);
 	e_table_extras_add_compare(extras, "collate", g_collate_compare);
 	e_table_extras_add_compare(extras, "integer", g_int_compare);
 	e_table_extras_add_compare(extras, "string-integer", e_strint_compare);
Index: addressbook/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1991
diff -u -p -r1.1991 ChangeLog
--- addressbook/ChangeLog	14 Sep 2005 10:27:07 -0000	1.1991
+++ addressbook/ChangeLog	15 Sep 2005 05:40:31 -0000
@@ -1,3 +1,12 @@
+2005-08-26  Devashish Sharma <sdevashish novell com>
+
+	* gui/widgets/e-addressbook-view.etspec: Changed the compare type for
+	Organization to stringcase. This new type has been defined for
+	performing case insensitive locale sensitive UTF8 string compares. It solves 
+	the problem where contacts with organization as Novell and novell were grouped in
+	different groups when grouped by organization. The same can be done
+	for other fields which require case insensitive compares.
+
 2005-09-14  Sushma Rai  <rsushma novell com>
 
 	* gui/contact-list-editor/e-contact-list-editor.etspec: Set selection 
Index: addressbook/gui/widgets/e-addressbook-view.etspec
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-addressbook-view.etspec,v
retrieving revision 1.7
diff -u -p -r1.7 e-addressbook-view.etspec
--- addressbook/gui/widgets/e-addressbook-view.etspec	26 Aug 2005 05:39:36 -0000	1.7
+++ addressbook/gui/widgets/e-addressbook-view.etspec	26 Aug 2005 07:01:44 -0000
@@ -36,7 +36,7 @@
     different and established translation for this in your language. -->	
   <ETableColumn model_col="34" _title="TTYTDD"            expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
 
-  <ETableColumn model_col="35" _title="Organization"      expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
+  <ETableColumn model_col="35" _title="Organization"      expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="stringcase"/>
   <ETableColumn model_col="36" _title="Unit"              expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
   <ETableColumn model_col="37" _title="Office"            expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>
   <ETableColumn model_col="38" _title="Title"             expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]