[goffice] Fixed sorting with accentuated characters. [#631504]



commit bcad4a38ee8b517318eed588e6864ac2c8c15955
Author: Jean Brefort <jean brefort normalesup org>
Date:   Wed Oct 6 22:58:20 2010 +0200

    Fixed sorting with accentuated characters. [#631504]

 ChangeLog                 |   12 ++++++++++++
 NEWS                      |    3 +++
 goffice/utils/go-string.c |   33 +++++++++++++++++++++++++++++----
 goffice/utils/go-string.h |    1 +
 4 files changed, 45 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 91aeb16..8a11ce3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2010-10-06  Jean Brefort  <jean brefort normalesup org>
+
+	reviewed by: <delete if not using a buddy>
+
+	* goffice/app/go-cmd-context-impl.h:
+	* goffice/app/go-cmd-context.c (go_cmd_context_get_response):
+	* goffice/app/go-cmd-context.h:
+	* goffice/app/goffice-app.h:
+	* goffice/utils/go-string.c (go_string_cmp_ignorecase),
+	(go_string_get_casefold), (go_string_get_casefolded_collate):
+	* goffice/utils/go-string.h:
+
 2010-10-03  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* goffice/utils/datetime.c (days_between_GO_BASIS_MSRB_30_360):
diff --git a/NEWS b/NEWS
index 7a51ffa..fdc143d 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ goffice 0.8.12:
 
 Andreas
 	* Fix US 30/360 date calculations. [#631242][#630784]
+	
+Jean:
+	* Fixed sorting with accentuated characters. [#631504]
 
 --------------------------------------------------------------------------
 goffice 0.8.11:
diff --git a/goffice/utils/go-string.c b/goffice/utils/go-string.c
index 16b5ec9..6a8c173 100644
--- a/goffice/utils/go-string.c
+++ b/goffice/utils/go-string.c
@@ -326,8 +326,8 @@ go_string_cmp_ignorecase (gconstpointer gstr_a, gconstpointer gstr_b)
 {
 	return (gstr_a == gstr_b)
 		? 0
-		: strcmp (go_string_get_casefold (gstr_a),
-			  go_string_get_casefold (gstr_b));
+		: strcmp (go_string_get_casefolded_collate (gstr_a),
+			  go_string_get_casefolded_collate (gstr_b));
 }
 
 gboolean
@@ -393,11 +393,36 @@ go_string_get_casefold (GOString const *gstr)
 	if (0 != (gstri->flags & GO_STRING_HAS_COLLATE))
 		offset += GSF_LE_GET_GUINT32(gstri->base.str + offset) + 4 + 1;
 
+	if (0 == (gstri->flags & GO_STRING_HAS_CASEFOLD))
+		go_string_get_casefolded_collate (gstr);
+	return gstri->base.str + offset + 4;
+}
+
+char const *
+go_string_get_casefolded_collate (GOString const *gstr)
+{
+	GOStringImpl *gstri = (GOStringImpl *)gstr;
+	unsigned int offset;
+
+	if (NULL == gstr)
+		return "";
+
+	offset = GO_STRING_LEN (gstri) + 1;
+	if (0 != (gstri->flags & GO_STRING_HAS_COLLATE))
+		offset += GSF_LE_GET_GUINT32(gstri->base.str + offset) + 4 + 1;
+
 	if (0 == (gstri->flags & GO_STRING_HAS_CASEFOLD)) {
+		char *collate;
+		int len;
 		gchar *casefold = g_utf8_casefold (gstri->base.str, GO_STRING_LEN (gstri));
-		gstri->flags |= GO_STRING_HAS_CASEFOLD;
 		go_string_impl_append_extra (gstri, casefold, offset);
-	}
+		len = GSF_LE_GET_GUINT32(gstri->base.str + offset);
+		collate = g_utf8_collate_key (gstri->base.str + offset + 4, len);
+		offset += len + 4 + 1;
+		gstri->flags |= GO_STRING_HAS_CASEFOLD;
+		go_string_impl_append_extra (gstri, collate, offset);
+	} else
+		offset += GSF_LE_GET_GUINT32(gstri->base.str + offset) + 4 + 1;
 	return gstri->base.str + offset + 4;
 }
 
diff --git a/goffice/utils/go-string.h b/goffice/utils/go-string.h
index be1b186..3d1dcd0 100644
--- a/goffice/utils/go-string.h
+++ b/goffice/utils/go-string.h
@@ -53,6 +53,7 @@ guint32		  go_string_get_len	  (GOString const *gstr);
 unsigned int	  go_string_get_ref_count (GOString const *gstr);
 char const	 *go_string_get_collation (GOString const *gstr);
 char const	 *go_string_get_casefold  (GOString const *gstr);
+char const       *go_string_get_casefolded_collate (GOString const *gstr);
 
 PangoAttrList	 *go_string_get_markup	  (GOString const *gstr);
 GOStringPhonetic *go_string_get_phonetic  (GOString const *gstr);



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