summarylogtreecommitdiffstats
path: root/compare-in-utf-8.diff
diff options
context:
space:
mode:
Diffstat (limited to 'compare-in-utf-8.diff')
-rw-r--r--compare-in-utf-8.diff115
1 files changed, 115 insertions, 0 deletions
diff --git a/compare-in-utf-8.diff b/compare-in-utf-8.diff
new file mode 100644
index 000000000000..2b65b178460d
--- /dev/null
+++ b/compare-in-utf-8.diff
@@ -0,0 +1,115 @@
+Correctly order the names in the index when they contain UTF-8
+characters. Use libunac for converting the accented characters in
+UTF-8 into plain ASCII.
+
+ -- Rafael Laboissiere <rafael@debian.org> Sat, 21 Feb 2009 19:18:36 +0100
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -22,6 +22,10 @@
+ LIBS="$LIBS $(pkg-config glib-2.0 --libs)"
+ CFLAGS="$CFLAGS $(pkg-config glib-2.0 --cflags)"
+
++# Libunac settings
++LIBS="$LIBS $(pkg-config unac --libs)"
++CFLAGS="$CFLAGS $(pkg-config unac --cflags)"
++
+ # Checks for header files.
+ AC_HEADER_STDC
+
+--- a/src/entry.c
++++ b/src/entry.c
+@@ -25,6 +25,7 @@
+ #include <string.h>
+ #include <vc.h>
+ #include <glib/gunicode.h>
++#include <unac.h>
+
+ #define MENU_PRINT_FORMAT_SIZE 80
+
+@@ -175,15 +176,43 @@
+ entry_node **ena = NULL;
+ entry_node **enb = NULL;
+
++ char* ena_desc = NULL;
++ char* enb_desc = NULL;
++ char* pure_a = NULL;
++ char* pure_b = NULL;
++ int length[1] = {0};
++ int a_alloc = 1;
++ int b_alloc = 1;
++
+ ena = (entry_node **) a;
+ enb = (entry_node **) b;
+
+- ret_val = cmp_given_n ((*ena)->description, (*enb)->description);
++ ena_desc = (*ena)->description;
++ enb_desc = (*enb)->description;
++
++ /* Try to convert the strings from UTF-8 and fall back to the original
++ strings if it fails */
++ if (unac_string ("UTF-8", ena_desc, strlen (ena_desc), &pure_a, length)) {
++ pure_a = ena_desc;
++ a_alloc = 0;
++ }
++
++ if (unac_string ("UTF-8", enb_desc, strlen (enb_desc), &pure_b, length)) {
++ pure_b = enb_desc;
++ b_alloc = 0;
++ }
++
++ ret_val = cmp_given_n (pure_a, pure_b);
+ if (0 == ret_val)
+ {
+- ret_val = strcmp ((*ena)->description, (*enb)->description);
++ ret_val = strcmp (pure_a, pure_b);
+ }
+
++ if (a_alloc)
++ free (pure_a);
++ if (b_alloc)
++ free (pure_b);
++
+ return ret_val;
+ }
+
+@@ -197,10 +226,38 @@
+ entry_node **ena = NULL;
+ entry_node **enb = NULL;
+
++ char* ena_desc = NULL;
++ char* enb_desc = NULL;
++ char* pure_a = NULL;
++ char* pure_b = NULL;
++ int length[1] = {0};
++ int a_alloc = 1;
++ int b_alloc = 1;
++
+ ena = (entry_node **) a;
+ enb = (entry_node **) b;
+
+- ret_val = strcmp ((*ena)->description, (*enb)->description);
++ ena_desc = (*ena)->description;
++ enb_desc = (*enb)->description;
++
++ /* Try to convert the strings from UTF-8 and fall back to the original
++ strings if it fails */
++ if (unac_string ("UTF-8", ena_desc, strlen (ena_desc), &pure_a, length)) {
++ pure_a = ena_desc;
++ a_alloc = 0;
++ }
++
++ if (unac_string ("UTF-8", enb_desc, strlen (enb_desc), &pure_b, length)) {
++ pure_b = enb_desc;
++ b_alloc = 0;
++ }
++
++ ret_val = strcmp (pure_a, pure_b);
++
++ if (a_alloc)
++ free (pure_a);
++ if (b_alloc)
++ free (pure_b);
+
+ return ret_val;
+ }