[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Fri, 9 Feb 2024 03:19:53 -0500 (EST) |
branch: master
commit 542203d74e51bf7d68ca5ba62bff7d920eac4e1b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Feb 5 09:17:11 2024 +0100
* tp/Texinfo/Indices.pm (sort_indices_by_index)
(sort_indices_by_letter): get $use_unicode_collation and $locale_lang
information from the caller. Update callers.
---
ChangeLog | 6 ++++++
tp/Texinfo/Convert/Converter.pm | 8 ++++++++
tp/Texinfo/Convert/IXIN.pm | 7 +++++++
tp/Texinfo/Convert/Plaintext.pm | 7 +++++++
tp/Texinfo/Indices.pm | 24 ++++++------------------
tp/Texinfo/Structuring.pm | 3 ++-
tp/init/chm.pm | 12 +++++++++---
tp/t/test_sort.t | 3 +++
tp/t/test_utils.pl | 11 ++++++++++-
9 files changed, 58 insertions(+), 23 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8b163ff058..190ddf05e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,12 @@
* README-hacking: Advertise gperf dependency.
+2024-02-05 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Indices.pm (sort_indices_by_index)
+ (sort_indices_by_letter): get $use_unicode_collation and $locale_lang
+ information from the caller. Update callers.
+
2024-02-05 Patrice Dumas <pertusus@free.fr>
* tp/t/test_sort.t: no need to register the configuration in XS
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index fe8482b45a..fde854a37d 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -1763,9 +1763,17 @@ sub get_converter_indices_sorted_by_letter($)
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 $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);
}
diff --git a/tp/Texinfo/Convert/IXIN.pm b/tp/Texinfo/Convert/IXIN.pm
index 2568d42664..f9fdf1a688 100644
--- a/tp/Texinfo/Convert/IXIN.pm
+++ b/tp/Texinfo/Convert/IXIN.pm
@@ -709,8 +709,15 @@ sub output_ixin($$)
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);
# first do the dts_text as the counts are needed for the dts index
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 635113d464..09b43767db 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -1520,9 +1520,16 @@ sub process_printindex($$;$)
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 $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);
}
diff --git a/tp/Texinfo/Indices.pm b/tp/Texinfo/Indices.pm
index 3ad2d7937b..61f703cb98 100644
--- a/tp/Texinfo/Indices.pm
+++ b/tp/Texinfo/Indices.pm
@@ -442,20 +442,15 @@ 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;
+ my $use_unicode_collation = shift;
+ my $locale_lang = shift;
my $index_entries = shift;
my $indices_information = shift;
- my $use_unicode_collation
- = $customization_information->get_conf('USE_UNICODE_COLLATION');
- my $locale_lang;
- if (!(defined($use_unicode_collation) and !$use_unicode_collation)) {
- $locale_lang
- = $customization_information->get_conf('COLLATION_LANGUAGE');
- }
my $collator = _setup_collator($use_unicode_collation, $locale_lang);
my $sorted_index_entries;
@@ -593,22 +588,15 @@ 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;
+ my $use_unicode_collation = shift;
+ my $locale_lang = shift;
my $index_entries = shift;
my $indices_information = shift;
- my $use_unicode_collation
- = $customization_information->get_conf('USE_UNICODE_COLLATION');
- my $locale_lang;
- if (!(defined($use_unicode_collation) and !$use_unicode_collation)) {
- if (defined($customization_information->get_conf('COLLATION_LANGUAGE'))) {
- $locale_lang
- = $customization_information->get_conf('COLLATION_LANGUAGE');
- }
- }
my $collator = _setup_collator($use_unicode_collation, $locale_lang);
my $sorted_index_entries;
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index 9688f5029f..35b84774fb 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -30,7 +30,8 @@ use strict;
# Can be used to check that there is no incorrect autovivfication
# no autovivification qw(fetch delete exists store strict);
-# FIXME Could not do that because of sort_indices_by_letter, probably for uc().
+# FIXME Could not do that before index sorting was in that file, probably
+# for uc().
# stop \s from matching non-ASCII spaces, etc. \p{...} can still be
# used to match Unicode character classes.
#use if $] >= 5.014, re => '/a';
diff --git a/tp/init/chm.pm b/tp/init/chm.pm
index 33f0c1364a..7c1952cc55 100644
--- a/tp/init/chm.pm
+++ b/tp/init/chm.pm
@@ -251,12 +251,18 @@ sub chm_init($)
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 $index_entries_sort_strings;
($index_entries, $index_entries_sort_strings)
= Texinfo::Indices::sort_indices_by_index(undef, $self,
- $merged_index_entries,
- $indices_information);
+ $use_unicode_collation, $locale_lang,
+ $merged_index_entries,
+ $indices_information);
}
if ($index_entries) {
diff --git a/tp/t/test_sort.t b/tp/t/test_sort.t
index 0321b70be9..18ccd9258f 100644
--- a/tp/t/test_sort.t
+++ b/tp/t/test_sort.t
@@ -53,6 +53,7 @@ $main_configuration->{'document_descriptor'}
#$main_configuration->register_XS_document_main_configuration($document);
my ($sorted_index_entries, $index_entries_sort_strings)
= Texinfo::Indices::sort_indices_by_index($registrar, $main_configuration,
+ undef, undef,
$index_entries,
$indices_information);
my @entries = ();
@@ -69,6 +70,7 @@ cmp_deeply (\@entries, \@entries_ref, 'sorted index entries');
my ($sorted_index_entries_by_letter, $by_letter_index_entries_sort_strings)
= Texinfo::Indices::sort_indices_by_letter($registrar, $main_configuration,
+ undef, undef,
$index_entries, $indices_information);
my @letter_entries_ref = (
@@ -130,6 +132,7 @@ $main_configuration->{'document_descriptor'}
= $document->document_descriptor();
($sorted_index_entries, $index_entries_sort_strings)
= Texinfo::Indices::sort_indices_by_index($registrar, $main_configuration,
+ undef, undef,
$index_entries,
$indices_information);
@entries = ();
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 9822f1edf6..d9aad8cf4e 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -1179,9 +1179,18 @@ sub test($$)
if ($merged_index_entries) {
$main_configuration->{'document_descriptor'}
= $document->document_descriptor();
+ my $use_unicode_collation
+ = $main_configuration->get_conf('USE_UNICODE_COLLATION');
+ my $locale_lang;
+ if (!(defined($use_unicode_collation) and !$use_unicode_collation)) {
+ $locale_lang
+ = $main_configuration->get_conf('COLLATION_LANGUAGE');
+ }
+
($sorted_index_entries, $index_entries_sort_strings)
= Texinfo::Indices::sort_indices_by_index($registrar,
- $main_configuration,
+ $main_configuration,
+ $use_unicode_collation, $locale_lang,
$merged_index_entries,
$indices_information);
$indices_sorted_sort_strings = {};