[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Mon, 8 Apr 2024 17:35:54 -0400 (EDT) |
branch: master
commit 5c39dc7c82544cf8380b74a850428509c7dfe0f4
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Apr 8 23:35:38 2024 +0200
* tp/Texinfo/Document.pm (%XS_overrides),
tp/Texinfo/XS/main/DocumentXS.xs (document_get_conf): add an XS
override for Document.pm get_conf.
* tp/t/test_utils.pl (test), tp/texi2any.pl: use $document to provide
customization information.
---
ChangeLog | 9 +++++++++
tp/Texinfo/Document.pm | 2 ++
tp/Texinfo/XS/main/DocumentXS.xs | 15 +++++++++++++++
tp/t/test_utils.pl | 24 ++++++++++++++++--------
tp/texi2any.pl | 16 +++++++++-------
5 files changed, 51 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9b8a7b826a..e2a9c73d89 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-04-08 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Document.pm (%XS_overrides),
+ tp/Texinfo/XS/main/DocumentXS.xs (document_get_conf): add an XS
+ override for Document.pm get_conf.
+
+ * tp/t/test_utils.pl (test), tp/texi2any.pl: use $document to provide
+ customization information.
+
2024-04-08 Patrice Dumas <pertusus@free.fr>
* tp/t/test_utils.pl (test), tp/texi2any.pl: use $document as
diff --git a/tp/Texinfo/Document.pm b/tp/Texinfo/Document.pm
index 6902700ebd..996a88bc8a 100644
--- a/tp/Texinfo/Document.pm
+++ b/tp/Texinfo/Document.pm
@@ -53,6 +53,8 @@ our %XS_overrides = (
=> "Texinfo::DocumentXS::document_tree",
"Texinfo::Document::_XS_set_document_options"
=> "Texinfo::DocumentXS::set_document_options",
+ "Texinfo::Document::get_conf",
+ => "Texinfo::DocumentXS::document_get_conf",
"Texinfo::Document::global_information"
=> "Texinfo::DocumentXS::document_global_information",
"Texinfo::Document::indices_information"
diff --git a/tp/Texinfo/XS/main/DocumentXS.xs b/tp/Texinfo/XS/main/DocumentXS.xs
index 04e0a1d37c..7790f5fcda 100644
--- a/tp/Texinfo/XS/main/DocumentXS.xs
+++ b/tp/Texinfo/XS/main/DocumentXS.xs
@@ -145,6 +145,21 @@ set_document_options (SV *document_in, SV *sv_options_in)
register_document_options (document, options);
}
+SV *
+document_get_conf (SV *document_in, conf)
+ const char *conf = (char *)SvPVbyte_nolen($arg);
+ PREINIT:
+ DOCUMENT *document = 0;
+ CODE:
+ document = get_sv_document_document (document_in,
+ "document_get_conf");
+ if (document && document->options)
+ RETVAL = build_sv_option (document->options, conf, 0);
+ else
+ RETVAL = newSV (0);
+ OUTPUT:
+ RETVAL
+
void
set_document_global_info (SV *document_in, char *key, SV *value_sv)
PREINIT:
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index df8d21860c..ee7e9c9a29 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -1053,6 +1053,14 @@ sub test($$)
# Setup main configuration options, used for structuring.
my $document_information = $document->global_information();
+ # setup a configuration Perl object which defines get_conf and set_conf,
+ # use the test customization information with per-document
+ # customization. This allows to use functions calling get_conf and
+ # set_conf to manipulate customization information.
+ # After this is done, the customization information should not
+ # change enymore, and it is registered in the document and used by
+ # Structuring/Transformations methods needing access to configuration
+ # information.
foreach my $parser_and_structuring_option ('FORMAT_MENU', 'DEBUG') {
if (defined($parser_options->{$parser_and_structuring_option})) {
$main_configuration_options->{$parser_and_structuring_option}
@@ -1126,8 +1134,8 @@ sub test($$)
Texinfo::Structuring::set_menus_node_directions($document);
- if (not defined($main_configuration->get_conf('FORMAT_MENU'))
- or $main_configuration->get_conf('FORMAT_MENU') eq 'menu') {
+ if (not defined($document->get_conf('FORMAT_MENU'))
+ or $document->get_conf('FORMAT_MENU') eq 'menu') {
Texinfo::Structuring::complete_node_tree_with_menus($document);
Texinfo::Structuring::check_nodes_are_referenced($document);
@@ -1163,18 +1171,18 @@ sub test($$)
my ($sorted_index_entries, $index_entries_sort_strings);
my $indices_sorted_sort_strings;
if ($merged_index_entries) {
- $main_configuration->{'document_descriptor'}
+ $document->{'document_descriptor'}
= $document->document_descriptor();
my $use_unicode_collation
- = $main_configuration->get_conf('USE_UNICODE_COLLATION');
+ = $document->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');
+ = $document->get_conf('COLLATION_LANGUAGE');
}
my $indices_sort_strings
- = Texinfo::Document::indices_sort_strings($document,
$main_configuration);
+ = Texinfo::Document::indices_sort_strings($document, $document);
$index_entries_sort_strings
= Texinfo::Indices::format_index_entries_sort_strings(
@@ -1182,7 +1190,7 @@ sub test($$)
$sorted_index_entries
= Texinfo::Document::sorted_indices_by_index($document,
- $main_configuration,
+ $document,
$use_unicode_collation, $locale_lang);
$indices_sorted_sort_strings = {};
foreach my $index_name (keys(%$sorted_index_entries)) {
@@ -1393,7 +1401,7 @@ sub test($$)
}
if ($test_split) {
my $identifier_target = $document->labels_information();
- Texinfo::Structuring::units_directions($main_configuration,
+ Texinfo::Structuring::units_directions($document,
$identifier_target,
$output_units);
$directions_text = '';
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 731a72abf2..8d34563e06 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1525,17 +1525,19 @@ while(@input_files) {
# a "handle" is returned.
my $tree = $document->tree($XS_structuring);
- # setup a configuration Perl object which defines get_conf, use
- # the main program customization information for which per-document
- # customization can be set. This allows to call functions calling
- # get_conf and set_conf. After this is done, the customization
- # information is registered in the document and used by
+ # setup a configuration Perl object which defines get_conf and set_conf,
+ # use the main program customization information with per-document
+ # customization. This allows to use functions calling get_conf and
+ # set_conf to manipulate customization information.
+ # After this is done, the customization information should not
+ # change enymore, and it is registered in the document and used by
# Structuring/Transformations methods needing access to configuration
# information.
+ #
# OUTPUT_ENCODING_NAME is set and accessed in set_output_encodings.
# OUTPUT_PERL_ENCODING is set and accessed in set_output_encodings and
# accessed in output_files_open_out for the MACRO_EXPAND file name.
- # The following variables are directly used in Structuring/Transformations:
+ # The following variables are used in Structuring/Transformations:
# novalidate, FORMAT_MENU, CHECK_NORMAL_MENU_STRUCTURE,
# CHECK_MISSING_MENU_ENTRY. And DEBUG.
# documentlanguage is used in Structuring/Transformations for
@@ -1575,7 +1577,7 @@ while(@input_files) {
= Texinfo::Common::output_files_initialize();
my ($macro_expand_fh, $error_message)
= Texinfo::Common::output_files_open_out(
- $macro_expand_files_information, $main_configuration,
+ $macro_expand_files_information, $document,
$encoded_macro_expand_file_name);
my $error_macro_expand_file;
if (defined($macro_expand_fh)) {