texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/main/manipulate_indices.c (get_so


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/manipulate_indices.c (get_sort_key): use upper cased sort string to obtain the sort key for all the collation types.
Date: Tue, 13 Feb 2024 09:19:53 -0500

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 2ed8caa01b * tp/Texinfo/XS/main/manipulate_indices.c (get_sort_key): 
use upper cased sort string to obtain the sort key for all the collation types.
2ed8caa01b is described below

commit 2ed8caa01b612cc67ce4e7ab886f90a4421615a0
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Feb 13 15:19:45 2024 +0100

    * tp/Texinfo/XS/main/manipulate_indices.c (get_sort_key): use upper
    cased sort string to obtain the sort key for all the collation types.
---
 ChangeLog                               |  5 +++++
 tp/Texinfo/XS/main/manipulate_indices.c | 27 +++++++++++----------------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 04eedd9de9..45b3d8638b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-02-13  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/manipulate_indices.c (get_sort_key): use upper
+       cased sort string to obtain the sort key for all the collation types.
+
 2024-02-13  Patrice Dumas  <pertusus@free.fr>
 
        * tp/t/test_utils.pl (test): pass USE_UNICODE_COLLATION option.
diff --git a/tp/Texinfo/XS/main/manipulate_indices.c 
b/tp/Texinfo/XS/main/manipulate_indices.c
index 2b5ef5a86a..e719b9f18f 100644
--- a/tp/Texinfo/XS/main/manipulate_indices.c
+++ b/tp/Texinfo/XS/main/manipulate_indices.c
@@ -271,14 +271,16 @@ static BYTES_STRING *
 get_sort_key (INDEX_COLLATOR *collator, const char *sort_string)
 {
   BYTES_STRING *sort_key;
+  char *uc_sort_string = to_upper_or_lower_multibyte (sort_string, 1);
   switch (collator->type)
     {
       case ctn_no_unicode:
         sort_key = (BYTES_STRING *) malloc (sizeof (BYTES_STRING));
-        sort_key->len = strlen (sort_string);
+        sort_key->len = strlen (uc_sort_string);
         sort_key->bytes = (unsigned char *)
            malloc (sizeof (unsigned char) * sort_key->len);
-        memcpy (sort_key->bytes, (unsigned char *) sort_string, sort_key->len);
+        memcpy (sort_key->bytes, (unsigned char *) uc_sort_string,
+                sort_key->len);
         break;
       #ifdef HAVE_STRXFRM_L
       case ctn_locale_collation:
@@ -286,15 +288,12 @@ get_sort_key (INDEX_COLLATOR *collator, const char 
*sort_string)
           size_t check_len;
           char *char_sort_key;
           sort_key = (BYTES_STRING *) malloc (sizeof (BYTES_STRING));
-          sort_key->len
-            = strxfrm_l (0, sort_string, 0,
-                         collator->locale);
+          sort_key->len = strxfrm_l (0, uc_sort_string, 0, collator->locale);
           char_sort_key = (char *) malloc (sizeof (char) * sort_key->len);
-          check_len
-            = strxfrm_l (char_sort_key, sort_string, sort_key->len,
-                         collator->locale);
+          check_len = strxfrm_l (char_sort_key, uc_sort_string, sort_key->len,
+                                 collator->locale);
           sort_key->bytes = (unsigned char *)
-           malloc (sizeof (unsigned char) * sort_key->len);
+                     malloc (sizeof (unsigned char) * sort_key->len);
           memcpy (sort_key->bytes, (unsigned char *) char_sort_key,
                   sort_key->len);
           free (char_sort_key);
@@ -306,15 +305,11 @@ get_sort_key (INDEX_COLLATOR *collator, const char 
*sort_string)
       case ctn_unicode:
       case ctn_language_collation:
       default: /* !HAVE_STRXFRM_L && ctn_locale_collation */
-        {
-          char *uc_sort_string
-            = to_upper_or_lower_multibyte (sort_string, 1);
-          sort_key = call_collator_getSortKey (collator->sv,
-                                               uc_sort_string);
-          free (uc_sort_string);
-        }
+        sort_key = call_collator_getSortKey (collator->sv,
+                                             uc_sort_string);
         break;
     }
+  free (uc_sort_string);
   return sort_key;
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]