texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Wed, 14 Feb 2024 08:22:51 -0500 (EST)

branch: master
commit 638ae96181a047f4aa9863cd3d03f36547f5ae68
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Feb 14 11:43:41 2024 +0100

    * tp/Texinfo/Indices.pm (_setup_sort_sortable_strings_collator)
    (sort_indices_by_index, sort_indices_by_letter),
    tp/Texinfo/XS/main/manipulate_indices.c
    (setup_sort_sortable_strings_collator, sort_indices_by_index)
    (sort_indices_by_letter): require a document argument.  Remove
    merged_index_entries and indices_information arguments, put document
    as first argument.  Update callers.
---
 ChangeLog                               | 10 ++++++++
 tp/Texinfo/Document.pm                  | 20 +++++++---------
 tp/Texinfo/Indices.pm                   | 41 +++++++++++----------------------
 tp/Texinfo/XS/main/IndicesXS.xs         | 12 ----------
 tp/Texinfo/XS/main/document.c           | 18 ++++++---------
 tp/Texinfo/XS/main/manipulate_indices.c | 40 ++++++++------------------------
 tp/Texinfo/XS/main/manipulate_indices.h | 12 ++++------
 tp/t/test_sort.t                        | 16 +++++--------
 tp/t/test_utils.pl                      |  9 ++++----
 9 files changed, 62 insertions(+), 116 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f438217d98..fdaac82d13 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-02-14  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Indices.pm (_setup_sort_sortable_strings_collator)
+       (sort_indices_by_index, sort_indices_by_letter),
+       tp/Texinfo/XS/main/manipulate_indices.c
+       (setup_sort_sortable_strings_collator, sort_indices_by_index)
+       (sort_indices_by_letter): require a document argument.  Remove
+       merged_index_entries and indices_information arguments, put document
+       as first argument.  Update callers.
+
 2024-02-13  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/document.c
diff --git a/tp/Texinfo/Document.pm b/tp/Texinfo/Document.pm
index 9209dc04fe..cb06d04b4b 100644
--- a/tp/Texinfo/Document.pm
+++ b/tp/Texinfo/Document.pm
@@ -251,13 +251,11 @@ sub sorted_indices_by_letter($$$$$)
     if (!$document->{'sorted_indices_by_letter'});
 
   if (!$document->{'sorted_indices_by_letter'}->{$lang_key}) {
+    $document->merged_indices();
     $document->{'sorted_indices_by_letter'}->{$lang_key}
-      = Texinfo::Indices::sort_indices_by_letter($registrar,
-                               $customization_information,
-                        $use_unicode_collation, $locale_lang,
-                          $document->merged_indices(),
-                          $document->indices_information(),
-                          $document);
+      = Texinfo::Indices::sort_indices_by_letter($document,
+                          $registrar, $customization_information,
+                           $use_unicode_collation, $locale_lang);
   }
   return $document->{'sorted_indices_by_letter'}->{$lang_key};
 }
@@ -286,13 +284,11 @@ sub sorted_indices_by_index($$$$$)
     if (!$document->{'sorted_indices_by_index'});
 
   if (!$document->{'sorted_indices_by_index'}->{$lang_key}) {
+    $document->merged_indices();
     $document->{'sorted_indices_by_index'}->{$lang_key}
-      = Texinfo::Indices::sort_indices_by_index($registrar,
-                               $customization_information,
-                        $use_unicode_collation, $locale_lang,
-                          $document->merged_indices(),
-                          $document->indices_information(),
-                          $document);
+      = Texinfo::Indices::sort_indices_by_index($document,
+                       $registrar, $customization_information,
+                        $use_unicode_collation, $locale_lang);
   }
   return $document->{'sorted_indices_by_index'}->{$lang_key};
 }
diff --git a/tp/Texinfo/Indices.pm b/tp/Texinfo/Indices.pm
index 6f266ad804..cf04ebfb41 100644
--- a/tp/Texinfo/Indices.pm
+++ b/tp/Texinfo/Indices.pm
@@ -458,27 +458,18 @@ sub setup_sortable_index_entries($$)
   return $index_sortable_index_entries;
 }
 
-sub _setup_sort_sortable_strings_collator($$$$;$$$)
+sub _setup_sort_sortable_strings_collator($$$$$)
 {
+  my $document = shift;
   my $registrar = shift;
   my $customization_information = shift;
   my $use_unicode_collation = shift;
   my $locale_lang = shift;
-  my $index_entries = shift;
-  my $indices_information = shift;
-  my $document = shift;
 
-  my $indices_sort_strings;
-  if ($document) {
-    # simple wrapper around setup_index_entries_sort_strings that caches the
-    # result
-    $indices_sort_strings = Texinfo::Document::indices_sort_strings($document,
+  # simple wrapper around setup_index_entries_sort_strings that caches the
+  # result
+  my $indices_sort_strings = Texinfo::Document::indices_sort_strings($document,
                                       $registrar, $customization_information);
-  } else {
-    $indices_sort_strings = setup_index_entries_sort_strings($registrar,
-                                   $customization_information, $index_entries,
-                                   $indices_information);
-  }
 
   my $collator = _setup_collator($use_unicode_collation, $locale_lang);
 
@@ -488,21 +479,18 @@ sub _setup_sort_sortable_strings_collator($$$$;$$$)
   return ($index_sortable_index_entries, $collator);
 }
 
-sub sort_indices_by_index($$$$;$$$)
+sub sort_indices_by_index($$$;$$)
 {
+  my $document = shift;
   my $registrar = shift;
   my $customization_information = shift;
   my $use_unicode_collation = shift;
   my $locale_lang = shift;
-  my $index_entries = shift;
-  my $indices_information = shift;
-  my $document = shift;
 
   my ($index_sortable_index_entries, $collator)
-      = _setup_sort_sortable_strings_collator($registrar,
+     = _setup_sort_sortable_strings_collator($document, $registrar,
                        $customization_information, $use_unicode_collation,
-                       $locale_lang, $index_entries, $indices_information,
-                       $document);
+                       $locale_lang);
 
   if (!$index_sortable_index_entries) {
     return undef;
@@ -634,21 +622,18 @@ sub index_entry_first_letter_text_or_command($;$)
   }
 }
 
-sub sort_indices_by_letter($$$$;$$$)
+sub sort_indices_by_letter($$$;$$)
 {
+  my $document = shift;
   my $registrar = shift;
   my $customization_information = shift;
   my $use_unicode_collation = shift;
   my $locale_lang = shift;
-  my $index_entries = shift;
-  my $indices_information = shift;
-  my $document = shift;
 
   my ($index_sortable_index_entries, $collator)
-     = _setup_sort_sortable_strings_collator($registrar,
+     = _setup_sort_sortable_strings_collator($document, $registrar,
                        $customization_information, $use_unicode_collation,
-                       $locale_lang, $index_entries, $indices_information,
-                       $document);
+                       $locale_lang);
 
   if (!$index_sortable_index_entries) {
     return undef;
diff --git a/tp/Texinfo/XS/main/IndicesXS.xs b/tp/Texinfo/XS/main/IndicesXS.xs
index e863ae2ea5..17c117e3bc 100644
--- a/tp/Texinfo/XS/main/IndicesXS.xs
+++ b/tp/Texinfo/XS/main/IndicesXS.xs
@@ -154,15 +154,3 @@ index_entry_element_sort_string (SV 
*customization_info_sv, SV *main_entry_sv, S
     OUTPUT:
          RETVAL
 
-#void
-#sort_indices_by_letter (SV *registrar, SV *customization_information, SV 
*index_entries, SV *indices_information, ...)
-#     PROTOTYPE: $$$$;$
-#     PREINIT:
-#         SV *sorted_index_entries_sv;
-#      PPCODE:
-#         sorted_index_entries_sv = build_sorted_indices_by_letter (
-#
-#         EXTEND(SP, 2);
-#         PUSHs(sv_2mortal(sorted_index_entries_sv));
-#         PUSHs(sv_2mortal(result_sv));
-
diff --git a/tp/Texinfo/XS/main/document.c b/tp/Texinfo/XS/main/document.c
index 6947f2dd00..9c7b1a8f24 100644
--- a/tp/Texinfo/XS/main/document.c
+++ b/tp/Texinfo/XS/main/document.c
@@ -278,13 +278,11 @@ sorted_indices_by_index (ERROR_MESSAGE_LIST 
*error_messages,
 
   if (!collation_sorted_indices->sorted_indices)
     {
-      const MERGED_INDICES *merged_indices
-         = document_merged_indices (document);
+      document_merged_indices (document);
       collation_sorted_indices->sorted_indices
-        = sort_indices_by_index (error_messages, options,
-                                  use_unicode_collation, collation_language,
-                                  collation_locale, merged_indices,
-                                  document->index_names, document);
+        = sort_indices_by_index (document, error_messages, options,
+                                 use_unicode_collation, collation_language,
+                                 collation_locale);
     }
   return collation_sorted_indices->sorted_indices;
 }
@@ -391,13 +389,11 @@ sorted_indices_by_letter (ERROR_MESSAGE_LIST 
*error_messages,
 
   if (!collation_sorted_indices->sorted_indices)
     {
-      const MERGED_INDICES *merged_indices
-         = document_merged_indices (document);
+      document_merged_indices (document);
       collation_sorted_indices->sorted_indices
-        = sort_indices_by_letter (error_messages, options,
+        = sort_indices_by_letter (document, error_messages, options,
                                   use_unicode_collation, collation_language,
-                                  collation_locale, merged_indices,
-                                  document->index_names, document);
+                                  collation_locale);
     }
   return collation_sorted_indices->sorted_indices;
 }
diff --git a/tp/Texinfo/XS/main/manipulate_indices.c 
b/tp/Texinfo/XS/main/manipulate_indices.c
index c487067553..570a90309e 100644
--- a/tp/Texinfo/XS/main/manipulate_indices.c
+++ b/tp/Texinfo/XS/main/manipulate_indices.c
@@ -689,29 +689,18 @@ setup_sortable_index_entries (INDEX_COLLATOR *collator,
 
 
 static INDICES_SORTABLE_ENTRIES *
-setup_sort_sortable_strings_collator (
+setup_sort_sortable_strings_collator (DOCUMENT *document,
                       ERROR_MESSAGE_LIST *error_messages,
                       OPTIONS *options, int use_unicode_collation,
                       const char *collation_language,
                       const char *collation_locale,
-                      const MERGED_INDICES *merged_indices,
-                      INDEX **indices_information, DOCUMENT *document,
                       INDEX_COLLATOR **collator)
 {
   const INDICES_SORT_STRINGS *indices_sort_strings;
   INDICES_SORTABLE_ENTRIES *index_sortable_index_entries;
 
-  if (document)
-    {
-      indices_sort_strings = document_indices_sort_strings (document,
+  indices_sort_strings = document_indices_sort_strings (document,
                                                 error_messages, options, 0);
-    }
-  else
-    {
-      indices_sort_strings = setup_index_entries_sort_strings (error_messages,
-                                                      options, merged_indices,
-                                                      indices_information, 0);
-    }
 
   *collator = setup_collator (use_unicode_collation, collation_language,
                               collation_locale);
@@ -876,23 +865,19 @@ destroy_collator (INDEX_COLLATOR *collator)
 }
 
 INDEX_SORTED_BY_INDEX *
-sort_indices_by_index (ERROR_MESSAGE_LIST *error_messages,
+sort_indices_by_index (DOCUMENT *document, ERROR_MESSAGE_LIST *error_messages,
                        OPTIONS *options, int use_unicode_collation,
                        const char *collation_language,
-                       const char *collation_locale,
-                       const MERGED_INDICES *merged_indices,
-                       INDEX **indices_information, DOCUMENT *document)
+                       const char *collation_locale)
 {
   size_t i;
   int index_nr = 0;
   INDEX_COLLATOR *collator;
 
   INDICES_SORTABLE_ENTRIES *indices_sortable_entries
-    = setup_sort_sortable_strings_collator (error_messages, options,
+    = setup_sort_sortable_strings_collator (document, error_messages, options,
                                     use_unicode_collation, collation_language,
-                                    collation_locale,
-                                    merged_indices, indices_information,
-                                    document, &collator);
+                                    collation_locale, &collator);
 
   if (!indices_sortable_entries || indices_sortable_entries->number <= 0)
     {
@@ -950,14 +935,11 @@ sort_indices_by_index (ERROR_MESSAGE_LIST *error_messages,
 }
 
 
-
 INDEX_SORTED_BY_LETTER *
-sort_indices_by_letter (ERROR_MESSAGE_LIST *error_messages,
+sort_indices_by_letter (DOCUMENT *document, ERROR_MESSAGE_LIST *error_messages,
                         OPTIONS *options, int use_unicode_collation,
                         const char *collation_language,
-                        const char *collation_locale,
-                        const MERGED_INDICES *merged_indices,
-                        INDEX **indices_information, DOCUMENT *document)
+                        const char *collation_locale)
 {
   size_t i;
   int index_nr = 0;
@@ -965,11 +947,9 @@ sort_indices_by_letter (ERROR_MESSAGE_LIST *error_messages,
   INDEX_COLLATOR *collator;
 
   INDICES_SORTABLE_ENTRIES *indices_sortable_entries
-    = setup_sort_sortable_strings_collator (error_messages, options,
+    = setup_sort_sortable_strings_collator (document, error_messages, options,
                                     use_unicode_collation, collation_language,
-                                    collation_locale,
-                                    merged_indices, indices_information,
-                                    document, &collator);
+                                    collation_locale, &collator);
 
   if (!indices_sortable_entries || indices_sortable_entries->number <= 0)
     {
diff --git a/tp/Texinfo/XS/main/manipulate_indices.h 
b/tp/Texinfo/XS/main/manipulate_indices.h
index 4f9934d5a7..90d4694b9d 100644
--- a/tp/Texinfo/XS/main/manipulate_indices.h
+++ b/tp/Texinfo/XS/main/manipulate_indices.h
@@ -60,20 +60,16 @@ INDICES_SORT_STRINGS *setup_index_entries_sort_strings (
                     INDEX **indices_information, int prefer_reference_element);
 
 INDEX_SORTED_BY_INDEX *sort_indices_by_index (
-                       ERROR_MESSAGE_LIST *error_messages,
+                       DOCUMENT *document, ERROR_MESSAGE_LIST *error_messages,
                        OPTIONS *options, int use_unicode_collation,
                        const char *collation_language,
-                       const char *collation_locale,
-                       const MERGED_INDICES *merged_indices,
-                       INDEX **indices_information, DOCUMENT *document);
+                       const char *collation_locale);
 
 INDEX_SORTED_BY_LETTER *sort_indices_by_letter (
-                        ERROR_MESSAGE_LIST *error_messages,
+                        DOCUMENT *document, ERROR_MESSAGE_LIST *error_messages,
                         OPTIONS *options, int use_unicode_collation,
                         const char *collation_language,
-                        const char *collation_locale,
-                        const MERGED_INDICES *merged_indices,
-                        INDEX **indices_information, DOCUMENT *document);
+                        const char *collation_locale);
 
 INDEX_ENTRY_TEXT_OR_COMMAND *index_entry_first_letter_text_or_command
                                                 (INDEX_ENTRY *index_entry);
diff --git a/tp/t/test_sort.t b/tp/t/test_sort.t
index 7bd897c1d0..6b4b575cfe 100644
--- a/tp/t/test_sort.t
+++ b/tp/t/test_sort.t
@@ -50,7 +50,6 @@ my $index_entries = $document->merged_indices();
 my $main_configuration = Texinfo::MainConfig::new({});
 $main_configuration->{'document_descriptor'}
   = $document->document_descriptor();
-#$main_configuration->register_XS_document_main_configuration($document);
 
 my $indices_sort_strings
   = Texinfo::Indices::setup_index_entries_sort_strings($registrar,
@@ -60,9 +59,8 @@ my $index_entries_sort_strings
   = Texinfo::Indices::format_index_entries_sort_strings($indices_sort_strings);
 
 my $sorted_index_entries
-  = Texinfo::Indices::sort_indices_by_index($registrar, $main_configuration,
-                                          undef, undef,
-                                          $index_entries, 
$indices_information);
+  = Texinfo::Indices::sort_indices_by_index($document, $registrar,
+                                            $main_configuration);
 
 my @entries = ();
 foreach my $entry (@{$sorted_index_entries->{'cp'}}) {
@@ -77,9 +75,8 @@ my @entries_ref = ('!', '"', 'aaaaaaaaaaaa', 'e', 'E', 'ẽ', 
'ł');
 cmp_deeply (\@entries, \@entries_ref, 'sorted index entries');
 
 my $sorted_index_entries_by_letter
- = Texinfo::Indices::sort_indices_by_letter($registrar, $main_configuration,
-                                          undef, undef,
-                                       $index_entries, $indices_information);
+ = Texinfo::Indices::sort_indices_by_letter($document, $registrar,
+                                            $main_configuration);
 
 my @letter_entries_ref = (
    {'!' => [ '!' ]},
@@ -146,9 +143,8 @@ $index_entries_sort_strings
   = Texinfo::Indices::format_index_entries_sort_strings($indices_sort_strings);
 
 $sorted_index_entries
-  = Texinfo::Indices::sort_indices_by_index($registrar, $main_configuration,
-                                          undef, undef,
-                                          $index_entries, 
$indices_information);
+  = Texinfo::Indices::sort_indices_by_index($document, $registrar,
+                                            $main_configuration);
 
 @entries = ();
 foreach my $entry (@{$sorted_index_entries->{'cp'}}) {
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 2caf479210..4f899ab679 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -953,7 +953,8 @@ sub test($$)
   }
 
   foreach my $structuring_option ('CHECK_NORMAL_MENU_STRUCTURE',
-                                  'FORMAT_MENU', 'USE_UNICODE_COLLATION') {
+                                  'FORMAT_MENU', 'USE_UNICODE_COLLATION',
+                                  'COLLATION_LANGUAGE') {
     if (defined($parser_options->{$structuring_option})) {
       $added_main_configurations->{$structuring_option}
         = $parser_options->{$structuring_option};
@@ -1204,11 +1205,9 @@ sub test($$)
                                                      $indices_sort_strings);
 
     $sorted_index_entries
-      = Texinfo::Indices::sort_indices_by_index($registrar,
+      = Texinfo::Indices::sort_indices_by_index($document, $registrar,
                                                 $main_configuration,
-                                 $use_unicode_collation, $locale_lang,
-                                   $merged_index_entries,
-                                   $indices_information, $document);
+                                 $use_unicode_collation, $locale_lang);
     $indices_sorted_sort_strings = {};
     foreach my $index_name (keys(%$sorted_index_entries)) {
       # index entries sort strings sorted in the order of the index entries



reply via email to

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