texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Fri, 9 Feb 2024 03:19:54 -0500 (EST)

branch: master
commit bd4d6c955a803103827d3bac778e5f2b8c71593a
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Feb 8 15:00:13 2024 +0100

    * tp/Texinfo/Document.pm (sorted_indices_by_letter)
    (sorted_indices_by_index), tp/init/chm.pm,
    tp/Texinfo/Convert/Plaintext.pm (process_printindex),
    tp/Texinfo/Convert/Converter.pm
    (get_converter_indices_sorted_by_letter), tp/Texinfo/Convert/IXIN.pm:
    add Texinfo::Document sorted_indices_by_letter and
    sorted_indices_by_index that call the corresponding methods in
    Texinfo::Indices and cache the result in a document, distinguishing
    unicode collation or not and collation locale/language if given.
    Call those methods in converters.
---
 ChangeLog                                          | 13 ++++
 tp/Texinfo/Convert/Converter.pm                    | 24 +++-----
 tp/Texinfo/Convert/IXIN.pm                         | 13 ++--
 tp/Texinfo/Convert/Plaintext.pm                    | 28 ++++-----
 tp/Texinfo/Document.pm                             | 72 ++++++++++++++++++++++
 tp/Texinfo/Indices.pm                              |  4 +-
 tp/init/chm.pm                                     | 10 ++-
 tp/t/results/indices/double_seeentry_seealso.pl    | 11 ----
 tp/t/results/indices/empty_string_index_entry.pl   | 32 ----------
 .../indices/ignored_sort_char_empty_entries.pl     | 18 ------
 tp/t/results/indices/sorted_subentries.pl          | 11 ----
 11 files changed, 118 insertions(+), 118 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 190ddf05e4..994f2b8812 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-02-08  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Document.pm (sorted_indices_by_letter)
+       (sorted_indices_by_index), tp/init/chm.pm,
+       tp/Texinfo/Convert/Plaintext.pm (process_printindex),
+       tp/Texinfo/Convert/Converter.pm
+       (get_converter_indices_sorted_by_letter), tp/Texinfo/Convert/IXIN.pm:
+       add Texinfo::Document sorted_indices_by_letter and
+       sorted_indices_by_index that call the corresponding methods in
+       Texinfo::Indices and cache the result in a document, distinguishing
+       unicode collation or not and collation locale/language if given.
+       Call those methods in converters.
+
 2024-02-08  Gavin Smith <gavinsmith0123@gmail.com>
 
        * README-hacking: update instructions on updating copyright
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index fde854a37d..031d659c3c 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -1738,15 +1738,12 @@ sub _XS_get_converter_indices_sorted_by_letter($$)
   return undef;
 }
 
-# TODO document
+# TODO document?  Or should Texinfo::Document::sorted_indices_by_letter
+# be called directly?
 sub get_converter_indices_sorted_by_letter($)
 {
   my $self = shift;
 
-  if ($self->{'index_entries_by_letter'}) {
-    return $self->{'index_entries_by_letter'};
-  }
-
   my $indices_information;
   if ($self->{'document'}) {
     $indices_information = $self->{'document'}->indices_information();
@@ -1756,13 +1753,14 @@ sub get_converter_indices_sorted_by_letter($)
     if (!$self->get_conf('TEST') and $self->{'converter_descriptor'}
         and $XS_convert) {
       # get from XS
+      if ($self->{'index_entries_by_letter'}) {
+        return $self->{'index_entries_by_letter'};
+      }
+
       $self->{'index_entries_by_letter'}
         = _XS_get_converter_indices_sorted_by_letter($self,
                                                      $indices_information);
     } else {
-      my $merged_index_entries
-        = $self->{'document'}->merged_indices();
-
       my $use_unicode_collation
         = $self->get_conf('USE_UNICODE_COLLATION');
       my $locale_lang;
@@ -1770,12 +1768,10 @@ sub get_converter_indices_sorted_by_letter($)
         $locale_lang = $self->get_conf('COLLATION_LANGUAGE');
       }
 
-      my $index_entries_sort_strings;
-      ($self->{'index_entries_by_letter'}, $index_entries_sort_strings)
-          = Texinfo::Indices::sort_indices_by_letter(undef, $self,
-                                        $use_unicode_collation, $locale_lang,
-                                           $merged_index_entries,
-                                           $indices_information);
+      $self->{'index_entries_by_letter'}
+        = Texinfo::Document::sorted_indices_by_letter(undef, $self,
+                                                 $self->{'document'},
+                                   $use_unicode_collation, $locale_lang);
     }
   }
   return $self->{'index_entries_by_letter'};
diff --git a/tp/Texinfo/Convert/IXIN.pm b/tp/Texinfo/Convert/IXIN.pm
index f9fdf1a688..2b84ba18e8 100644
--- a/tp/Texinfo/Convert/IXIN.pm
+++ b/tp/Texinfo/Convert/IXIN.pm
@@ -385,7 +385,7 @@ sub output_ixin($$)
   my $sections_list;
   my $identifiers_target;
   my $indices_information;
-  if ($self->->{'document'}) {
+  if ($self->{'document'}) {
     $document_info = $self->{'document'}->global_information();
     $floats = $self->{'document'}->floats_information();
     $sections_list = $self->{'document'}->sections_list();
@@ -707,19 +707,16 @@ sub output_ixin($$)
   my %dts_information;
 
   if ($indices_information) {
-    my $merged_index_entries
-        = $self->{'document'}->merged_indices();
     my $use_unicode_collation
       = $self->get_conf('USE_UNICODE_COLLATION');
     my $locale_lang;
     if (!(defined($use_unicode_collation) and !$use_unicode_collation)) {
       $locale_lang = $self->get_conf('COLLATION_LANGUAGE');
     }
-    my ($entries, $index_entries_sort_strings)
-      = Texinfo::Indices::sort_indices_by_index(undef, $self,
-                                        $use_unicode_collation, $locale_lang,
-                                           $merged_index_entries,
-                                           $indices_information);
+    my $entries
+      = Texinfo::Document::sorted_indices_by_index(undef, $self,
+                                                   $self->{'document'},
+                                        $use_unicode_collation, $locale_lang);
     # first do the dts_text as the counts are needed for the dts index
     foreach my $index_name (sort(keys(%$entries))) {
       $dts_information{$index_name} = {};
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 09b43767db..405d3eb551 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -1513,25 +1513,21 @@ sub process_printindex($$;$)
   my $indices_information;
   if ($self->{'document'}) {
     $indices_information = $self->{'document'}->indices_information();
-  }
 
-  # this is not redone for each index, only once
-  if (!defined($self->{'index_entries'}) and $indices_information) {
+    # this is not redone for each index, only once
+    if (!defined($self->{'index_entries'}) and $indices_information) {
 
-    my $merged_index_entries
-      = $self->{'document'}->merged_indices();
-    my $use_unicode_collation
-      = $self->get_conf('USE_UNICODE_COLLATION');
-    my $locale_lang;
-    if (!(defined($use_unicode_collation) and !$use_unicode_collation)) {
-      $locale_lang = $self->get_conf('COLLATION_LANGUAGE');
+      my $use_unicode_collation
+        = $self->get_conf('USE_UNICODE_COLLATION');
+      my $locale_lang;
+      if (!(defined($use_unicode_collation) and !$use_unicode_collation)) {
+        $locale_lang = $self->get_conf('COLLATION_LANGUAGE');
+      }
+      $self->{'index_entries'}
+        = Texinfo::Document::sorted_indices_by_index(undef, $self,
+                                                   $self->{'document'},
+                                        $use_unicode_collation, $locale_lang);
     }
-    my $index_entries_sort_strings;
-    ($self->{'index_entries'}, $index_entries_sort_strings)
-      = Texinfo::Indices::sort_indices_by_index(undef, $self,
-                                        $use_unicode_collation, $locale_lang,
-                                           $merged_index_entries,
-                                           $indices_information);
   }
   if (!$self->{'index_entries'} or !$self->{'index_entries'}->{$index_name}
       or ! @{$self->{'index_entries'}->{$index_name}}) {
diff --git a/tp/Texinfo/Document.pm b/tp/Texinfo/Document.pm
index d9eba4b212..f23b571f04 100644
--- a/tp/Texinfo/Document.pm
+++ b/tp/Texinfo/Document.pm
@@ -204,6 +204,78 @@ sub merged_indices($)
   return $self->{'merged_indices'};
 }
 
+# TODO document
+sub sorted_indices_by_letter($$$$$)
+{
+  my $registrar = shift;
+  my $customization_information = shift;
+  my $document = shift;
+  my $use_unicode_collation = shift;
+  my $locale_lang = shift;
+
+  my $lang_key;
+  if (!$use_unicode_collation) {
+    $lang_key = '';
+  } elsif (!defined($locale_lang)) {
+    # special name corresponding to Unicode Collation with 'Non-Ignorable'
+    # set for variable collation elements
+    $lang_key = '-';
+  } else {
+    $lang_key = $locale_lang;
+  }
+
+  $document->{'sorted_indices_by_letter'} = {}
+    if (!$document->{'sorted_indices_by_letter'});
+
+  if (!$document->{'sorted_indices_by_letter'}->{$lang_key}) {
+    my $index_entries_sort_strings;
+    ($document->{'sorted_indices_by_letter'}->{$lang_key},
+     $index_entries_sort_strings)
+      = Texinfo::Indices::sort_indices_by_letter($registrar,
+                               $customization_information,
+                        $use_unicode_collation, $locale_lang,
+                          $document->merged_indices(),
+                          $document->indices_information());
+  }
+  return $document->{'sorted_indices_by_letter'}->{$lang_key};
+}
+
+# TODO document
+sub sorted_indices_by_index($$$$$)
+{
+  my $registrar = shift;
+  my $customization_information = shift;
+  my $document = shift;
+  my $use_unicode_collation = shift;
+  my $locale_lang = shift;
+
+  my $lang_key;
+  if (!$use_unicode_collation) {
+    $lang_key = '';
+  } elsif (!defined($locale_lang)) {
+    # special name corresponding to Unicode Collation with 'Non-Ignorable'
+    # set for variable collation elements
+    $lang_key = '-';
+  } else {
+    $lang_key = $locale_lang;
+  }
+
+  $document->{'sorted_indices_by_index'} = {}
+    if (!$document->{'sorted_indices_by_index'});
+
+  if (!$document->{'sorted_indices_by_index'}->{$lang_key}) {
+    my $index_entries_sort_strings;
+    ($document->{'sorted_indices_by_index'}->{$lang_key},
+     $index_entries_sort_strings)
+      = Texinfo::Indices::sort_indices_by_index($registrar,
+                               $customization_information,
+                        $use_unicode_collation, $locale_lang,
+                          $document->merged_indices(),
+                          $document->indices_information());
+  }
+  return $document->{'sorted_indices_by_index'}->{$lang_key};
+}
+
 # only set if the Texinfo::Document object has been set up by XS code.
 sub document_descriptor($)
 {
diff --git a/tp/Texinfo/Indices.pm b/tp/Texinfo/Indices.pm
index 61f703cb98..ffc2e41034 100644
--- a/tp/Texinfo/Indices.pm
+++ b/tp/Texinfo/Indices.pm
@@ -442,7 +442,7 @@ sub setup_sortable_index_entries($$$$$)
   return ($index_sortable_index_entries, $index_entries_sort_strings);
 }
 
-sub sort_indices_by_index($$$$$$;$)
+sub sort_indices_by_index($$$$$$)
 {
   my $registrar = shift;
   my $customization_information = shift;
@@ -588,7 +588,7 @@ sub index_entry_first_letter_text_or_command($;$)
   }
 }
 
-sub sort_indices_by_letter($$$$$$;$)
+sub sort_indices_by_letter($$$$$$)
 {
   my $registrar = shift;
   my $customization_information = shift;
diff --git a/tp/init/chm.pm b/tp/init/chm.pm
index 7c1952cc55..7bd1f20c4b 100644
--- a/tp/init/chm.pm
+++ b/tp/init/chm.pm
@@ -257,12 +257,10 @@ sub chm_init($)
     if (!(defined($use_unicode_collation) and !$use_unicode_collation)) {
       $locale_lang = $self->get_conf('COLLATION_LANGUAGE');
     }
-    my $index_entries_sort_strings;
-    ($index_entries, $index_entries_sort_strings)
-       = Texinfo::Indices::sort_indices_by_index(undef, $self,
-                                   $use_unicode_collation, $locale_lang,
-                                    $merged_index_entries,
-                                    $indices_information);
+
+    $index_entries = Texinfo::Document::sorted_indices_by_index(undef,
+                                    $self, $self->{'document'},
+                                  $use_unicode_collation, $locale_lang);
   }
 
   if ($index_entries) {
diff --git a/tp/t/results/indices/double_seeentry_seealso.pl 
b/tp/t/results/indices/double_seeentry_seealso.pl
index 0e4af59895..e61b486cdc 100644
--- a/tp/t/results/indices/double_seeentry_seealso.pl
+++ b/tp/t/results/indices/double_seeentry_seealso.pl
@@ -747,17 +747,6 @@ 
$result_converted{'plaintext'}->{'double_seeentry_seealso'} = 'top
 
 ';
 
-$result_converted_errors{'plaintext'}->{'double_seeentry_seealso'} = [
-  {
-    'error_line' => 'warning: empty index key in @cindex
-',
-    'line_nr' => 10,
-    'text' => 'empty index key in @cindex',
-    'type' => 'warning'
-  }
-];
-
-
 
 $result_converted{'html_text'}->{'double_seeentry_seealso'} = '<div 
class="top-level-extent" id="Top">
 <div class="nav-panel">
diff --git a/tp/t/results/indices/empty_string_index_entry.pl 
b/tp/t/results/indices/empty_string_index_entry.pl
index b6a3508965..75359bda95 100644
--- a/tp/t/results/indices/empty_string_index_entry.pl
+++ b/tp/t/results/indices/empty_string_index_entry.pl
@@ -724,38 +724,6 @@ 
$result_converted{'plaintext'}->{'empty_string_index_entry'} = '‘’
 
 ';
 
-$result_converted_errors{'plaintext'}->{'empty_string_index_entry'} = [
-  {
-    'error_line' => 'warning: empty index key in @findex
-',
-    'line_nr' => 4,
-    'text' => 'empty index key in @findex',
-    'type' => 'warning'
-  },
-  {
-    'error_line' => 'warning: empty index key in @item
-',
-    'line_nr' => 7,
-    'text' => 'empty index key in @item',
-    'type' => 'warning'
-  },
-  {
-    'error_line' => 'warning: empty index key in @defun
-',
-    'line_nr' => 10,
-    'text' => 'empty index key in @defun',
-    'type' => 'warning'
-  },
-  {
-    'error_line' => 'warning: empty index key in @defunx
-',
-    'line_nr' => 11,
-    'text' => 'empty index key in @defunx',
-    'type' => 'warning'
-  }
-];
-
-
 
 $result_converted{'html_text'}->{'empty_string_index_entry'} = '<a 
class="node-id" id="Top"></a><div class="nav-panel">
 <p>
diff --git a/tp/t/results/indices/ignored_sort_char_empty_entries.pl 
b/tp/t/results/indices/ignored_sort_char_empty_entries.pl
index 6dd236514e..b9b6bebd66 100644
--- a/tp/t/results/indices/ignored_sort_char_empty_entries.pl
+++ b/tp/t/results/indices/ignored_sort_char_empty_entries.pl
@@ -516,24 +516,6 @@ 
$result_converted{'plaintext'}->{'ignored_sort_char_empty_entries'} = '* Menu:
 
 ';
 
-$result_converted_errors{'plaintext'}->{'ignored_sort_char_empty_entries'} = [
-  {
-    'error_line' => 'warning: empty index key in @findex
-',
-    'line_nr' => 8,
-    'text' => 'empty index key in @findex',
-    'type' => 'warning'
-  },
-  {
-    'error_line' => 'warning: empty index key in @findex
-',
-    'line_nr' => 9,
-    'text' => 'empty index key in @findex',
-    'type' => 'warning'
-  }
-];
-
-
 
 $result_converted{'html_text'}->{'ignored_sort_char_empty_entries'} = '
 <div class="top-level-extent" id="Top">
diff --git a/tp/t/results/indices/sorted_subentries.pl 
b/tp/t/results/indices/sorted_subentries.pl
index fd22620901..e4b3374294 100644
--- a/tp/t/results/indices/sorted_subentries.pl
+++ b/tp/t/results/indices/sorted_subentries.pl
@@ -2156,17 +2156,6 @@ $result_converted{'plaintext'}->{'sorted_subentries'} = 
'1 one
 
 ';
 
-$result_converted_errors{'plaintext'}->{'sorted_subentries'} = [
-  {
-    'error_line' => 'warning: empty index sub entry 1 key in @cindex
-',
-    'line_nr' => 16,
-    'text' => 'empty index sub entry 1 key in @cindex',
-    'type' => 'warning'
-  }
-];
-
-
 
 $result_converted{'html_text'}->{'sorted_subentries'} = '<div 
class="top-level-extent" id="Top">
 <div class="nav-panel">



reply via email to

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