[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Tue, 13 Feb 2024 11:00:58 -0500 (EST) |
branch: master
commit ac083f104000eebc4fa1c7044ff35429df99a8bf
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Feb 13 17:00:52 2024 +0100
* tp/Texinfo/Convert/Converter.pm (%XS_overrides)
(get_converter_indices_sorted_by_letter),
tp/Texinfo/XS/convert/ConvertXS.xs
(get_converter_indices_sorted_by_letter),
tp/Texinfo/XS/main/build_perl_info.c (build_sorted_indices_by_letter):
override directly get_converter_indices_sorted_by_letter, find indices
information in XS through perl hashes. Remove
_XS_get_converter_indices_sorted_by_letter. Have
build_sorted_indices_by_letter use HV in argument and return HV
instead of SV.
---
ChangeLog | 13 +++++++++++++
tp/Texinfo/Convert/Converter.pm | 22 ++++------------------
tp/Texinfo/XS/convert/ConvertXS.xs | 35 ++++++++++++++++++++++++++++-------
tp/Texinfo/XS/main/build_perl_info.c | 11 ++++-------
tp/Texinfo/XS/main/build_perl_info.h | 4 ++--
5 files changed, 51 insertions(+), 34 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 45485587da..4eb0a3bba0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-02-13 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/Converter.pm (%XS_overrides)
+ (get_converter_indices_sorted_by_letter),
+ tp/Texinfo/XS/convert/ConvertXS.xs
+ (get_converter_indices_sorted_by_letter),
+ tp/Texinfo/XS/main/build_perl_info.c (build_sorted_indices_by_letter):
+ override directly get_converter_indices_sorted_by_letter, find indices
+ information in XS through perl hashes. Remove
+ _XS_get_converter_indices_sorted_by_letter. Have
+ build_sorted_indices_by_letter use HV in argument and return HV
+ instead of SV.
+
2024-02-13 Patrice Dumas <pertusus@free.fr>
Use DOCUMENTLANGUAGE_COLLATION.
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 6d295714a8..15267fa16e 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -96,7 +96,7 @@ my %XS_overrides = (
=> "Texinfo::Convert::ConvertXS::get_conf",
"Texinfo::Convert::Converter::_XS_set_document"
=> "Texinfo::Convert::ConvertXS::converter_set_document",
- "Texinfo::Convert::Converter::_XS_get_converter_indices_sorted_by_letter"
+ "Texinfo::Convert::Converter::get_converter_indices_sorted_by_letter"
=> "Texinfo::Convert::ConvertXS::get_converter_indices_sorted_by_letter",
# fully overriden for all the converters
@@ -1729,17 +1729,7 @@ sub comma_index_subentries_tree {
return undef;
}
-# Perl version should not be called, only used for the XS override.
-sub _XS_get_converter_indices_sorted_by_letter($$)
-{
- my $converter = shift;
- my $indices_information = shift;
-
- return undef;
-}
-
-# TODO document? Or should Texinfo::Document::sorted_indices_by_letter
-# be called directly?
+# TODO document?
sub get_converter_indices_sorted_by_letter($)
{
my $self = shift;
@@ -1747,13 +1737,8 @@ sub get_converter_indices_sorted_by_letter($)
my $indices_information;
if ($self->{'document'}) {
$indices_information = $self->{'document'}->indices_information();
- }
- if ($indices_information) {
- if (!$self->{'converter_descriptor'} and $XS_convert) {
- return _XS_get_converter_indices_sorted_by_letter($self,
- $indices_information);
- } else {
+ if ($indices_information) {
my $use_unicode_collation
= $self->get_conf('USE_UNICODE_COLLATION');
my $locale_lang;
@@ -1773,6 +1758,7 @@ sub get_converter_indices_sorted_by_letter($)
return undef;
}
+# TODO document?
sub get_converter_indices_sorted_by_index($)
{
my $self = shift;
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index e8b91de8dd..e0e6073040 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -181,21 +181,42 @@ converter_document_warn (SV *converter_in, text, ...)
}
SV *
-get_converter_indices_sorted_by_letter (SV *converter_sv, SV
*indices_information)
+get_converter_indices_sorted_by_letter (SV *converter_sv)
PREINIT:
CONVERTER *self;
+ INDEX_SORTED_BY_LETTER *index_entries_by_letter = 0;
+ HV *converter_hv;
+ SV **document_sv;
CODE:
self = get_sv_converter (converter_sv,
"get_converter_indices_sorted_by_letter");
if (self)
+ index_entries_by_letter
+ = get_converter_indices_sorted_by_letter (self);
+
+ converter_hv = (HV *) SvRV (converter_sv);
+ document_sv = hv_fetch (converter_hv, "document",
+ strlen ("document"), 0);
+ RETVAL = 0;
+ if (document_sv)
{
- INDEX_SORTED_BY_LETTER *index_entries_by_letter
- = get_converter_indices_sorted_by_letter (self);
- RETVAL
- = build_sorted_indices_by_letter (index_entries_by_letter,
- indices_information);
+ SV **indices_information_sv;
+ HV *document_hv = (HV *) SvRV (*document_sv);
+ indices_information_sv
+ = hv_fetch (document_hv, "indices", strlen ("indices"), 0);
+
+ if (index_entries_by_letter && indices_information_sv)
+ {
+ HV *indices_information_hv
+ = (HV *) SvRV (*indices_information_sv);
+ HV *index_entries_by_letter_hv
+ = build_sorted_indices_by_letter (index_entries_by_letter,
+ indices_information_hv);
+ RETVAL
+ = newRV_inc ((SV *) index_entries_by_letter_hv);
+ }
}
- else
+ if (!RETVAL)
RETVAL = newSV (0);
OUTPUT:
RETVAL
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index d53e17b64f..9a2acf0120 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -2079,21 +2079,18 @@ build_indices_sort_strings (const INDICES_SORT_STRINGS
*indices_sort_strings,
return indices_sort_strings_hv;
}
-SV *
+HV *
build_sorted_indices_by_letter (
const INDEX_SORTED_BY_LETTER *index_entries_by_letter,
- SV *indices_information)
+ HV *indices_information_hv)
{
HV *indices_hv;
- HV *indices_information_hv;
const INDEX_SORTED_BY_LETTER *idx;
dTHX;
if (!index_entries_by_letter)
- return newSV (0);
-
- indices_information_hv = (HV *) SvRV (indices_information);
+ return 0;
indices_hv = newHV ();
@@ -2149,7 +2146,7 @@ build_sorted_indices_by_letter (
}
}
}
- return newRV_noinc ((SV *)indices_hv);
+ return indices_hv;
}
SV *
diff --git a/tp/Texinfo/XS/main/build_perl_info.h
b/tp/Texinfo/XS/main/build_perl_info.h
index 9cf6baed78..e9416e8f79 100644
--- a/tp/Texinfo/XS/main/build_perl_info.h
+++ b/tp/Texinfo/XS/main/build_perl_info.h
@@ -56,9 +56,9 @@ void build_output_files_information (SV *converter_sv,
HV *build_indices_sort_strings (
const INDICES_SORT_STRINGS *indices_sort_strings,
HV *indices_information_hv);
-SV *build_sorted_indices_by_letter (
+HV *build_sorted_indices_by_letter (
const INDEX_SORTED_BY_LETTER *index_entries_by_letter,
- SV *indices_information);
+ HV *indices_information_hv);
SV *html_build_direction_icons (CONVERTER *converter,
DIRECTION_ICON_LIST *direction_icons);