[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Document.pm (indices_sort_strings),
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Document.pm (indices_sort_strings), tp/Texinfo/XS/main/DocumentXS.xs (indices_sort_strings), tp/Texinfo/XS/main/document.c (document_indices_sort_strings): change arguments order, to have document first. Update callers. |
Date: |
Mon, 12 Feb 2024 18:35:00 -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 fe13d17e6c * tp/Texinfo/Document.pm (indices_sort_strings),
tp/Texinfo/XS/main/DocumentXS.xs (indices_sort_strings),
tp/Texinfo/XS/main/document.c (document_indices_sort_strings): change arguments
order, to have document first. Update callers.
fe13d17e6c is described below
commit fe13d17e6c798efd779ba04a113890f444ea7339
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Feb 13 00:34:49 2024 +0100
* tp/Texinfo/Document.pm (indices_sort_strings),
tp/Texinfo/XS/main/DocumentXS.xs (indices_sort_strings),
tp/Texinfo/XS/main/document.c (document_indices_sort_strings): change
arguments order, to have document first. Update callers.
* tp/Texinfo/XS/main/call_perl_function.c: remove
get_call_index_entries_sorted_by_letter, which is not used anymore.
---
ChangeLog | 10 +++++++
tp/Texinfo/Document.pm | 2 +-
tp/Texinfo/Indices.pm | 10 ++-----
tp/Texinfo/XS/main/DocumentXS.xs | 22 +++++++-------
tp/Texinfo/XS/main/call_perl_function.c | 52 ---------------------------------
tp/Texinfo/XS/main/call_perl_function.h | 3 +-
tp/Texinfo/XS/main/document.c | 6 ++--
tp/Texinfo/XS/main/document.h | 4 +--
tp/Texinfo/XS/main/manipulate_indices.c | 12 ++++----
tp/t/test_utils.pl | 12 +++++---
tp/texi2any.pl | 4 +--
11 files changed, 47 insertions(+), 90 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d7fb177a5f..90a1aa48e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-02-12 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Document.pm (indices_sort_strings),
+ tp/Texinfo/XS/main/DocumentXS.xs (indices_sort_strings),
+ tp/Texinfo/XS/main/document.c (document_indices_sort_strings): change
+ arguments order, to have document first. Update callers.
+
+ * tp/Texinfo/XS/main/call_perl_function.c: remove
+ get_call_index_entries_sorted_by_letter, which is not used anymore.
+
2024-02-12 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/options_data.txt (DOCUMENTLANGUAGE_COLLATION)
diff --git a/tp/Texinfo/Document.pm b/tp/Texinfo/Document.pm
index 269a3ecabc..9209dc04fe 100644
--- a/tp/Texinfo/Document.pm
+++ b/tp/Texinfo/Document.pm
@@ -210,9 +210,9 @@ sub merged_indices($)
# call setup_index_entries_sort_strings and cache the result.
sub indices_sort_strings($$$;$)
{
+ my $document = shift;
my $registrar = shift;
my $customization_information = shift;
- my $document = shift;
my $prefer_reference_element = shift;
if (!$document->{'index_entries_sort_strings'}) {
diff --git a/tp/Texinfo/Indices.pm b/tp/Texinfo/Indices.pm
index 9b524ddf87..6f266ad804 100644
--- a/tp/Texinfo/Indices.pm
+++ b/tp/Texinfo/Indices.pm
@@ -420,12 +420,6 @@ sub format_index_entries_sort_strings($)
return $index_entries_sort_strings;
}
-# There is no strict need for document information in Perl, however, in XS
-# it is needed to retrieve the Tree elements in the C structures.
-# $CUSTOMIZATION_INFORMATION is used as the source of document
-# information. It should already be set if it is a converter based
-# on Texinfo::Convert::Converter, but otherwise it should be set by
-# the caller, setting 'document_descriptor' to document->document_descriptor().
sub setup_sortable_index_entries($$)
{
my $collator = shift;
@@ -478,8 +472,8 @@ sub _setup_sort_sortable_strings_collator($$$$;$$$)
if ($document) {
# simple wrapper around setup_index_entries_sort_strings that caches the
# result
- $indices_sort_strings = Texinfo::Document::indices_sort_strings($registrar,
- $customization_information, $document);
+ $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,
diff --git a/tp/Texinfo/XS/main/DocumentXS.xs b/tp/Texinfo/XS/main/DocumentXS.xs
index 3fc4e4e923..ff702b5ac1 100644
--- a/tp/Texinfo/XS/main/DocumentXS.xs
+++ b/tp/Texinfo/XS/main/DocumentXS.xs
@@ -61,9 +61,8 @@ rebuild_document (SV *document_in, ...)
char *descriptor_key = "document_descriptor";
HV *hv_in;
CODE:
- if (items > 1)
- if (SvOK(ST(1)))
- no_store = SvIV (ST(1));
+ if (items > 1 && SvOK(ST(1)))
+ no_store = SvIV (ST(1));
hv_in = (HV *)SvRV (document_in);
document_descriptor_sv = hv_fetch (hv_in, descriptor_key,
@@ -128,9 +127,8 @@ rebuild_tree (SV *tree_in, ...)
int no_store = 0;
DOCUMENT *document = 0;
CODE:
- if (items > 1)
- if (SvOK(ST(1)))
- no_store = SvIV (ST(1));
+ if (items > 1 && SvOK(ST(1)))
+ no_store = SvIV (ST(1));
document = get_sv_tree_document (tree_in, "rebuild_tree");
if (document)
@@ -176,21 +174,25 @@ set_document_options (SV *sv_options_in, SV *document_in)
register_document_options (document, options);
}
+# registrar, main_configuration, prefer_reference_element
SV *
-indices_sort_strings (SV *registrar, SV *main_configuration, SV *document_in,
int prefer_reference_element=0)
+indices_sort_strings (SV *document_in, ...)
+ PROTOTYPE: $$$;$
PREINIT:
DOCUMENT *document = 0;
const INDICES_SORT_STRINGS *indices_sort_strings = 0;
SV **indices_information_sv;
HV *document_hv;
+ int prefer_reference_element = 0;
CODE:
document = get_sv_document_document (document_in,
"indices_sort_strings");
+ if (items > 3 && SvOK(ST(3)))
+ prefer_reference_element = SvIV (ST(3));
if (document)
indices_sort_strings
- = document_indices_sort_strings (document->error_messages,
- document->options, document,
- prefer_reference_element);
+ = document_indices_sort_strings (document, document->error_messages,
+ document->options, prefer_reference_element);
document_hv = (HV *) SvRV (document_in);
indices_information_sv
diff --git a/tp/Texinfo/XS/main/call_perl_function.c
b/tp/Texinfo/XS/main/call_perl_function.c
index 7ddc0c8ef0..8cca57c671 100644
--- a/tp/Texinfo/XS/main/call_perl_function.c
+++ b/tp/Texinfo/XS/main/call_perl_function.c
@@ -36,8 +36,6 @@
#include "converter_types.h"
#include "document_types.h"
#include "build_perl_info.h"
-/* for get_sv_index_entries_sorted_by_letter */
-#include "get_perl_info.h"
#include "call_perl_function.h"
/* The NOTE in build_perl_info.c about not using malloc/free should
@@ -159,56 +157,6 @@ call_latex_convert_to_latex_math (CONVERTER *self, ELEMENT
*element)
return result;
}
-INDEX_SORTED_BY_LETTER *
-get_call_index_entries_sorted_by_letter (CONVERTER *self)
-{
- int count;
- INDEX_SORTED_BY_LETTER *result = 0;
- SV *index_entries_sorted_by_letter_sv;
-
- dTHX;
-
- if (!self->hv)
- return 0;
-
- dSP;
-
- ENTER;
- SAVETMPS;
-
- PUSHMARK(SP);
- EXTEND(SP, 1);
-
- PUSHs(sv_2mortal (newRV_inc (self->hv)));
- PUSHs(sv_2mortal (newSVpv ("index_entries_by_letter", 0)));
-
- PUTBACK;
-
- count = call_pv (
- "Texinfo::Convert::Converter::get_converter_indices_sorted_by_letter",
- G_SCALAR);
-
- SPAGAIN;
-
- if (count != 1)
- croak("get_converter_indices_sorted_by_letter should return 1 item\n");
-
- index_entries_sorted_by_letter_sv = POPs;
- if (SvOK (index_entries_sorted_by_letter_sv))
- {
- result
- = get_sv_index_entries_sorted_by_letter (self->document->index_names,
- index_entries_sorted_by_letter_sv);
- }
-
- PUTBACK;
-
- FREETMPS;
- LEAVE;
-
- return result;
-}
-
const void *
call_setup_collator (int use_unicode_collation, const char *locale_lang)
{
diff --git a/tp/Texinfo/XS/main/call_perl_function.h
b/tp/Texinfo/XS/main/call_perl_function.h
index 1aad256ea0..8b9757c63b 100644
--- a/tp/Texinfo/XS/main/call_perl_function.h
+++ b/tp/Texinfo/XS/main/call_perl_function.h
@@ -3,6 +3,7 @@
#define CALL_PERL_FUNCTION_H
#include "tree_types.h"
+#include "document_types.h"
#include "converter_types.h"
char *call_nodenamenormalization_unicode_to_transliterate (char *text);
@@ -15,6 +16,4 @@ const void *call_setup_collator (int use_unicode_collation,
BYTES_STRING *call_collator_getSortKey (const void *collator_sv,
const char *string);
-INDEX_SORTED_BY_LETTER *get_call_index_entries_sorted_by_letter
- (CONVERTER *self);
#endif
diff --git a/tp/Texinfo/XS/main/document.c b/tp/Texinfo/XS/main/document.c
index c082a2695e..c03b35ba19 100644
--- a/tp/Texinfo/XS/main/document.c
+++ b/tp/Texinfo/XS/main/document.c
@@ -158,9 +158,9 @@ register_document_convert_index_text_options (DOCUMENT
*document,
}
const INDICES_SORT_STRINGS *
-document_indices_sort_strings (ERROR_MESSAGE_LIST *error_messages,
- OPTIONS *options, DOCUMENT *document,
- int prefer_reference_element)
+document_indices_sort_strings (DOCUMENT *document,
+ ERROR_MESSAGE_LIST *error_messages,
+ OPTIONS *options, int prefer_reference_element)
{
if (!document->indices_sort_strings)
{
diff --git a/tp/Texinfo/XS/main/document.h b/tp/Texinfo/XS/main/document.h
index 2682dd7e63..709d92c0be 100644
--- a/tp/Texinfo/XS/main/document.h
+++ b/tp/Texinfo/XS/main/document.h
@@ -32,9 +32,9 @@ void register_document_convert_index_text_options (DOCUMENT
*document,
const MERGED_INDICES *document_merged_indices (DOCUMENT *document);
const INDICES_SORT_STRINGS *document_indices_sort_strings (
+ DOCUMENT *document,
ERROR_MESSAGE_LIST *error_messages,
- OPTIONS *options, DOCUMENT *document,
- int prefer_reference_element);
+ OPTIONS *options, int prefer_reference_element);
INDEX_SORTED_BY_LETTER *sorted_indices_by_letter (
ERROR_MESSAGE_LIST *error_messages,
OPTIONS *options, DOCUMENT *document,
diff --git a/tp/Texinfo/XS/main/manipulate_indices.c
b/tp/Texinfo/XS/main/manipulate_indices.c
index 450029a18c..63a7c02145 100644
--- a/tp/Texinfo/XS/main/manipulate_indices.c
+++ b/tp/Texinfo/XS/main/manipulate_indices.c
@@ -267,8 +267,8 @@ typedef struct INDEX_COLLATOR {
};
} INDEX_COLLATOR;
-static BYTES_STRING *get_sort_key (INDEX_COLLATOR *collator,
- const char *sort_string)
+static BYTES_STRING *
+get_sort_key (INDEX_COLLATOR *collator, const char *sort_string)
{
BYTES_STRING *sort_key;
switch (collator->type)
@@ -695,8 +695,8 @@ setup_sort_sortable_strings_collator (
if (document)
{
- indices_sort_strings = document_indices_sort_strings (error_messages,
- options, document, 0);
+ indices_sort_strings = document_indices_sort_strings (document,
+ error_messages, options, 0);
}
else
{
@@ -1112,6 +1112,8 @@ sort_indices_by_letter (ERROR_MESSAGE_LIST
*error_messages,
return sorted_index_entries;
}
+
+
static INDEX_ENTRY_TEXT_OR_COMMAND *
new_index_entry_text_or_command (const char *text, ELEMENT *command)
{
@@ -1127,8 +1129,6 @@ new_index_entry_text_or_command (const char *text,
ELEMENT *command)
return result;
}
-
-
/* Return the first non empty text or textual @-command.
To be freed by caller.
NOTE quotes and dash are not handled especially and it is not known
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index fb1553fc6d..4408d9a01d 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -1148,8 +1148,12 @@ sub test($$)
}
}
- Texinfo::Document::indices_sort_strings($registrar,
- $main_configuration, $document);
+ # Here the sort strings are generated, both in Perl and XS.
+ # The Perl structure cannot be built yet from XS as the document
+ # index information have not been rebuilt yet, but it is
+ # not needed at that point.
+ Texinfo::Document::indices_sort_strings($document, $registrar,
+ $main_configuration);
# could be in a if !$XS_structuring, but the function should not be
# overriden already in that case
@@ -1191,8 +1195,8 @@ sub test($$)
}
my $indices_sort_strings
- = Texinfo::Document::indices_sort_strings($registrar,
- $main_configuration, $document);
+ = Texinfo::Document::indices_sort_strings($document, $registrar,
+ $main_configuration);
$index_entries_sort_strings
= Texinfo::Indices::format_index_entries_sort_strings(
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 8577b6a008..d2e807810a 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1676,8 +1676,8 @@ while(@input_files) {
}
if ($formats_table{$converted_format}->{'setup_index_entries_sort_strings'})
{
- Texinfo::Document::indices_sort_strings($registrar, $main_configuration,
- $document);
+ Texinfo::Document::indices_sort_strings($document, $registrar,
+ $main_configuration);
}
$document = Texinfo::Document::rebuild_document($document);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Document.pm (indices_sort_strings), tp/Texinfo/XS/main/DocumentXS.xs (indices_sort_strings), tp/Texinfo/XS/main/document.c (document_indices_sort_strings): change arguments order, to have document first. Update callers.,
Patrice Dumas <=