[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sun, 3 Mar 2024 17:49:46 -0500 (EST) |
branch: master
commit 04f56d14d1c60e8d43d2a8e2ad8cf8f976742e5e
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Mar 3 21:50:13 2024 +0100
Change name of registrar variables to clarify the type of registrar
* tp/Texinfo/XS/parsetexi/Parsetexi.pm (_get_parser_error_registrar):
rename _get_error_registrar as _get_parser_error_registrar.
---
ChangeLog | 7 +++++
tp/Texinfo/Document.pm | 5 ++--
tp/Texinfo/Translations.pm | 4 +--
tp/Texinfo/XS/parsetexi/Parsetexi.pm | 22 +++++++++-------
tp/t/test_protect_hashchar_at_line_beginning.t | 8 +++---
tp/t/test_tree_copy.t | 7 ++---
tp/t/test_utils.pl | 36 +++++++++++++-------------
tp/texi2any.pl | 10 +++----
8 files changed, 54 insertions(+), 45 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 301b077645..ce38fec330 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,13 @@
* tp/Texinfo/XS/main/get_perl_info.c: Remove unnecessary #include.
+2024-03-03 Patrice Dumas <pertusus@free.fr>
+
+ Change name of registrar variables to clarify the type of registrar
+
+ * tp/Texinfo/XS/parsetexi/Parsetexi.pm (_get_parser_error_registrar):
+ rename _get_error_registrar as _get_parser_error_registrar.
+
2024-03-03 Patrice Dumas <pertusus@free.fr>
* tp/t/test_utils.pl (test): use document registrar in tree
diff --git a/tp/Texinfo/Document.pm b/tp/Texinfo/Document.pm
index c9f3bf185e..6ba9d468dd 100644
--- a/tp/Texinfo/Document.pm
+++ b/tp/Texinfo/Document.pm
@@ -441,9 +441,8 @@ sub clear_document_errors($)
{
}
-# NOTE could also add a parser_errors method to get the parser_registrar
-# errors. Something along those lines is done in XS, with a direct access
-# to document internal information.
+# NOTE similar code is used in the perl code associated to the XS parser to
+# get the errors from parser_errors.
sub errors($)
{
my $document = shift;
diff --git a/tp/Texinfo/Translations.pm b/tp/Texinfo/Translations.pm
index a8e1617390..e5fa0db094 100644
--- a/tp/Texinfo/Translations.pm
+++ b/tp/Texinfo/Translations.pm
@@ -323,8 +323,8 @@ sub _replace_convert_substrings($;$$)
}
my $tree = $parser->parse_texi_line($texinfo_line, undef, 0, 1);
- my $registrar = $parser->registered_errors();
- my ($errors, $errors_count) = $registrar->errors();
+ my $parser_registrar = $parser->registered_errors();
+ my ($errors, $errors_count) = $parser_registrar->errors();
if ($errors_count) {
warn "translation $errors_count error(s)\n";
warn "translated string: $translated_string\n";
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index 203825881d..4ce69073e1 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -183,7 +183,7 @@ sub parser (;$$)
return $parser;
}
-sub _get_error_registrar($)
+sub _get_parser_error_registrar($)
{
my $self = shift;
if (not $self->{'registrar'}) {
@@ -200,8 +200,8 @@ sub _get_parser_info($$;$$) {
my $no_build = shift;
my $no_store = shift;
- my ($registrar, $configuration_information)
- = _get_error_registrar($self);
+ my ($parser_registrar, $configuration_information)
+ = _get_parser_error_registrar($self);
my $document;
if ($no_build) {
@@ -215,22 +215,23 @@ sub _get_parser_info($$;$$) {
# Copy the errors into the error list in parser Texinfo::Report.
foreach my $error (@{$document->{'parser_errors'}}) {
- $registrar->add_formatted_message($error);
+ $parser_registrar->add_formatted_message($error);
}
@{$document->{'parser_errors'}} = ();
clear_document_parser_errors($document_descriptor);
- # New error registrar for document
- $document->{'registrar'} = Texinfo::Report::new();
-
# additional info relevant in perl only.
my $perl_encoding
= Texinfo::Common::get_perl_encoding($document->{'commands_info'},
- $registrar, $configuration_information);
+ $parser_registrar, $configuration_information);
$perl_encoding = 'utf-8' if (!defined($perl_encoding));
Texinfo::Document::set_document_global_info($document,
'input_perl_encoding', $perl_encoding);
+ # New error registrar for document to be used after parsing, for
+ # structuring and tree modifications
+ $document->{'registrar'} = Texinfo::Report::new();
+
return $document;
}
@@ -250,13 +251,14 @@ sub parse_texi_file ($$;$)
my $document_descriptor = parse_file ($input_file_path,
$basename, $directories);
if (!$document_descriptor) {
- my ($registrar, $configuration_information) = _get_error_registrar($self);
+ my ($parser_registrar, $configuration_information)
+ = _get_parser_error_registrar($self);
my $input_file_name = $input_file_path;
my $encoding = $self->get_conf('COMMAND_LINE_ENCODING');
if (defined($encoding)) {
$input_file_name = decode($encoding, $input_file_path);
}
- $registrar->document_error($configuration_information,
+ $parser_registrar->document_error($configuration_information,
sprintf(__("could not open %s: %s"), $input_file_name, $!));
return undef;
}
diff --git a/tp/t/test_protect_hashchar_at_line_beginning.t
b/tp/t/test_protect_hashchar_at_line_beginning.t
index 5c33a8aaf8..34cba65cdd 100644
--- a/tp/t/test_protect_hashchar_at_line_beginning.t
+++ b/tp/t/test_protect_hashchar_at_line_beginning.t
@@ -38,23 +38,23 @@ sub run_test($$$;$)
my $document = $parser->parse_texi_piece($in, 1);
my $tree = $document->tree();
- my $registrar = $parser->registered_errors();
+ my $parser_registrar = $parser->registered_errors();
my $corrected_tree =
Texinfo::Transformations::protect_hashchar_at_line_beginning($tree,
- $registrar, $parser);
+ $parser_registrar, $parser);
Texinfo::Document::rebuild_document($document);
$corrected_tree = $document->tree();
if ($with_XS) {
foreach my $error (@{$document->{'errors'}}) {
- $registrar->add_formatted_message($error);
+ $parser_registrar->add_formatted_message($error);
}
}
if (defined($error_message)) {
- my ($errors, $errors_count) = $registrar->errors();
+ my ($errors, $errors_count) = $parser_registrar->errors();
my ($error_line_nr_reference, $error_line_reference) = @$error_message;
if (!$error_line_reference) {
if ($errors and scalar(@$errors)) {
diff --git a/tp/t/test_tree_copy.t b/tp/t/test_tree_copy.t
index 33d84fe46a..96e819763e 100644
--- a/tp/t/test_tree_copy.t
+++ b/tp/t/test_tree_copy.t
@@ -137,7 +137,7 @@ T
my $test_parser = Texinfo::Parser::parser();
my $document = Texinfo::Parser::parse_texi_piece($test_parser, $text);
my $tree = $document->tree();
-my $test_registrar = $test_parser->registered_errors();
+my $test_parser_registrar = $test_parser->registered_errors();
my $copy = Texinfo::Common::copy_tree($tree);
my $texi_tree = Texinfo::Convert::Texinfo::convert_to_texinfo($tree);
@@ -179,8 +179,9 @@ foreach my $file_include (['Texinfo', $manual_file,
$manual_include_dir],
= Texinfo::Parser::parser({'INCLUDE_DIRECTORIES' => [$test_include_dir]});
my $document = $test_parser->Texinfo::Parser::parse_texi_file($test_file);
my $texinfo_test_tree = $document->tree();
- my $test_registrar = $test_parser->registered_errors();
- my ($test_parser_errors, $test_parser_error_count) =
$test_registrar->errors();
+ my $test_parser_registrar = $test_parser->registered_errors();
+ my ($test_parser_errors, $test_parser_error_count)
+ = $test_parser_registrar->errors();
foreach my $error_message (@$test_parser_errors) {
warn "$label: ".$error_message->{'error_line'}
if ($debug);
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index f5cb4f5c38..3b4ba121bf 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -545,12 +545,12 @@ sub convert_to_plaintext($$$$$)
}
my $converter_errors = $converter->get_converter_errors();
- my $registrar = Texinfo::Report::new();
+ my $converter_registrar = Texinfo::Report::new();
foreach my $error (@$converter_errors) {
- $registrar->add_formatted_message($error);
+ $converter_registrar->add_formatted_message($error);
}
- my ($errors, $error_nrs) = $registrar->errors();
+ my ($errors, $error_nrs) = $converter_registrar->errors();
return ($errors, $result, $converter);
}
@@ -572,12 +572,12 @@ sub convert_to_info($$$$$)
die if (!defined($converter_options->{'SUBDIR'}) and !defined($result));
my $converter_errors = $converter->get_converter_errors();
- my $registrar = Texinfo::Report::new();
+ my $converter_registrar = Texinfo::Report::new();
foreach my $error (@$converter_errors) {
- $registrar->add_formatted_message($error);
+ $converter_registrar->add_formatted_message($error);
}
- my ($errors, $error_nrs) = $registrar->errors();
+ my ($errors, $error_nrs) = $converter_registrar->errors();
return ($errors, $result, $converter);
}
@@ -608,13 +608,13 @@ sub convert_to_html($$$$$)
}
my $converter_errors = $converter->get_converter_errors();
- my $registrar = Texinfo::Report::new();
+ my $converter_registrar = Texinfo::Report::new();
foreach my $error (@$converter_errors) {
- $registrar->add_formatted_message($error);
+ $converter_registrar->add_formatted_message($error);
}
die if (!defined($converter_options->{'SUBDIR'}) and !defined($result));
- my ($errors, $error_nrs) = $registrar->errors();
+ my ($errors, $error_nrs) = $converter_registrar->errors();
return ($errors, $result, $converter);
}
@@ -643,12 +643,12 @@ sub convert_to_xml($$$$$)
}
my $converter_errors = $converter->get_converter_errors();
- my $registrar = Texinfo::Report::new();
+ my $converter_registrar = Texinfo::Report::new();
foreach my $error (@$converter_errors) {
- $registrar->add_formatted_message($error);
+ $converter_registrar->add_formatted_message($error);
}
- my ($errors, $error_nrs) = $registrar->errors();
+ my ($errors, $error_nrs) = $converter_registrar->errors();
return ($errors, $result, $converter);
}
@@ -697,12 +697,12 @@ sub convert_to_docbook($$$$$)
}
my $converter_errors = $converter->get_converter_errors();
- my $registrar = Texinfo::Report::new();
+ my $converter_registrar = Texinfo::Report::new();
foreach my $error (@$converter_errors) {
- $registrar->add_formatted_message($error);
+ $converter_registrar->add_formatted_message($error);
}
- my ($errors, $error_nrs) = $registrar->errors();
+ my ($errors, $error_nrs) = $converter_registrar->errors();
return ($errors, $result, $converter);
}
@@ -730,12 +730,12 @@ sub convert_to_latex($$$$$)
}
my $converter_errors = $converter->get_converter_errors();
- my $registrar = Texinfo::Report::new();
+ my $converter_registrar = Texinfo::Report::new();
foreach my $error (@$converter_errors) {
- $registrar->add_formatted_message($error);
+ $converter_registrar->add_formatted_message($error);
}
- my ($errors, $error_nrs) = $registrar->errors();
+ my ($errors, $error_nrs) = $converter_registrar->errors();
return ($errors, $result, $converter);
}
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index f361026a6b..945fef9661 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1509,15 +1509,15 @@ while(@input_files) {
print STDERR Data::Dumper->Dump([$tree]);
}
# object registering errors and warnings
- my $registrar = $parser->registered_errors();
+ my $parser_registrar = $parser->registered_errors();
if (!defined($tree) or $format eq 'parse') {
- handle_errors($registrar, $error_count, \@opened_files);
+ handle_errors($parser_registrar, $error_count, \@opened_files);
goto NEXT;
}
my $document_information = $document->global_information();
if (get_conf('TRACE_INCLUDES')) {
- handle_errors($registrar, $error_count, \@opened_files);
+ handle_errors($parser_registrar, $error_count, \@opened_files);
my $included_file_paths = $document_information->{'included_files'};
if (defined($included_file_paths)) {
foreach my $included_file (@$included_file_paths) {
@@ -1601,7 +1601,7 @@ while(@input_files) {
}
}
if (get_conf('DUMP_TEXI') or $formats_table{$format}->{'texi2dvi_format'}) {
- handle_errors($registrar, $error_count, \@opened_files);
+ handle_errors($parser_registrar, $error_count, \@opened_files);
goto NEXT;
}
@@ -1685,7 +1685,7 @@ while(@input_files) {
Texinfo::Document::rebuild_document($document);
# parser errors
- my ($errors, $new_error_count) = $registrar->errors();
+ my ($errors, $new_error_count) = $parser_registrar->errors();
$error_count += $new_error_count if ($new_error_count);
# document/structuring errors
my ($document_errors, $document_error_count) = $document->errors();