texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: * tp/Texinfo/ParserNonXS.pm (errors), tp/Texinfo/


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/ParserNonXS.pm (errors), tp/Texinfo/XS/parsetexi/Parsetexi.pm (errors): add errors as the main way to get parser errors. Remove registered_errors. Update callers of registered_errors to call directly errors.
Date: Thu, 07 Mar 2024 15:28:04 -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 2a68c4fe8d * tp/Texinfo/ParserNonXS.pm (errors), 
tp/Texinfo/XS/parsetexi/Parsetexi.pm (errors): add errors as the main way to 
get parser errors.  Remove registered_errors.  Update callers of 
registered_errors to call directly errors.
2a68c4fe8d is described below

commit 2a68c4fe8d11588ae1b4e0b470b57aaa6fb841e9
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Mar 7 21:27:59 2024 +0100

    * tp/Texinfo/ParserNonXS.pm (errors),
    tp/Texinfo/XS/parsetexi/Parsetexi.pm (errors): add errors as the main
    way to get parser errors.  Remove registered_errors.  Update callers
    of registered_errors to call directly errors.
    
    * tp/Texinfo/ParserNonXS.pm (registrar),
    tp/Texinfo/XS/parsetexi/Parsetexi.pm (registrar): add Texinfo::Report
    registrar accessors to have the same interface as document, only
    currently used in a test.
---
 ChangeLog                                      | 12 +++++++
 Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm   |  3 +-
 tp/Texinfo/ParserNonXS.pm                      | 43 +++++++++++++-------------
 tp/Texinfo/Translations.pm                     |  3 +-
 tp/Texinfo/XS/parsetexi/Parsetexi.pm           | 15 +++++++--
 tp/t/automatic_menus.t                         |  1 -
 tp/t/automatic_nodes.t                         |  4 ---
 tp/t/convert_to_text.t                         |  1 -
 tp/t/do_master_menu.t                          |  4 ---
 tp/t/test_parse_texi_line.t                    |  3 +-
 tp/t/test_parser_registrar.t                   |  2 +-
 tp/t/test_protect_hashchar_at_line_beginning.t |  5 +--
 tp/t/test_sort.t                               | 10 +++---
 tp/t/test_tree_copy.t                          |  5 +--
 tp/t/test_utils.pl                             |  5 ++-
 tp/texi2any.pl                                 | 17 +++++-----
 16 files changed, 67 insertions(+), 66 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f8c73ac9e8..c190f59bd3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-03-07  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/ParserNonXS.pm (errors),
+       tp/Texinfo/XS/parsetexi/Parsetexi.pm (errors): add errors as the main
+       way to get parser errors.  Remove registered_errors.  Update callers
+       of registered_errors to call directly errors.
+
+       * tp/Texinfo/ParserNonXS.pm (registrar),
+       tp/Texinfo/XS/parsetexi/Parsetexi.pm (registrar): add Texinfo::Report
+       registrar accessors to have the same interface as document, only
+       currently used in a test.
+
 2024-03-07  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Document.pm (%XS_overrides, errors),
diff --git a/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm 
b/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm
index 3f08357a54..c008dfd428 100644
--- a/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm
+++ b/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm
@@ -434,8 +434,7 @@ sub _normalize_texinfo_name($$)
     my $texinfo_text_str = $texinfo_text;
     chomp($texinfo_text_str);
     warn "ERROR: Texinfo parsing failed for: $texinfo_text_str\n";
-    my $registrar = $parser->registered_errors();
-    my ($parser_errors, $parser_error_count) = $registrar->errors();
+    my ($parser_errors, $parser_error_count) = $parser->errors();
     foreach my $error_message (@$parser_errors) {
       if ($error_message->{'type'} eq 'error') {
         warn "ERROR: $error_message->{'error_line'}";
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 0c937b0d82..84a0bfde35 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -972,12 +972,22 @@ sub _parse_texi_document($)
   return $document;
 }
 
-sub registered_errors($)
+# Only used in a test, not documented, there for symmetry with document
+sub registrar($)
 {
-  my $self = shift;
   return $self->{'registrar'};
 }
 
+sub errors($)
+{
+  my $self = shift;
+  my $registrar = $self->{'registrar'};
+  if (!$registrar) {
+    return undef;
+  }
+  return $registrar->errors();
+}
+
 sub _setup_conf($$)
 {
   my ($parser, $conf) = @_;
@@ -7993,10 +8003,7 @@ Texinfo::Parser - Parse Texinfo code into a Perl tree
   use Texinfo::Parser;
   my $parser = Texinfo::Parser::parser();
   my $document = $parser->parse_texi_file("somefile.texi");
-  # a Texinfo::Report object in which the errors and warnings
-  # encountered while parsing are registered.
-  my $registrar = $parser->registered_errors();
-  my ($errors, $errors_count) = $registrar->errors();
+  my ($errors, $errors_count) = $parser->errors();
   foreach my $error_message (@$errors) {
     warn $error_message->{'error_line'};
   }
@@ -8070,10 +8077,6 @@ Maximal number of nested user-defined macro calls.  
Default is 100000.
 A string corresponding to a document language set by C<@documentlanguage>.
 It overrides the document C<@documentlanguage> information, if present.
 
-=item registrar
-
-L<Texinfo::Report> object reused by the parser to register errors.
-
 =item values
 
 A hash reference.  Keys are names, values are the corresponding values.
@@ -8134,21 +8137,19 @@ undef is returned if the file couldn't be read.
 
 =back
 
-The errors collected during the tree parsing are registered in a
-L<Texinfo::Report> object.  This object is available with
-C<registered_errors>.  The errors registered in the C<Texinfo::Report>
-object are available through the C<errors> method.  This method is
-described in L<Texinfo::Report::errors|Texinfo::Report/($error_warnings_list, 
$error_count) = errors($registrar)>.
+The errors collected during the tree parsing are available with
+C<errors>.  These errors are internally registered in a C<Texinfo::Report>
+object.
 
 =over
 
-=item $registrar = registered_errors($parser)
-X<C<registered_errors>>
+=item ($error_warnings_list, $error_count) = $parser->errors()
+X<C<errors>>
 
-I<$registrar> is a L<Texinfo::Report> object in which the errors
-and warnings encountered while parsing are registered.  If a I<registrar>
-is passed to the parser initialization options, it is reused, otherwise
-a new one is created.
+This function returns as I<$error_count> the count of parsing errors.
+The I<$error_warnings_list> is an array of hash references
+one for each error, warning or error line continuation.
+They are described in detail in 
L<Texinfo::Report::errors|Texinfo::Report/($error_warnings_list, $error_count) 
= errors($registrar)>.
 
 =back
 
diff --git a/tp/Texinfo/Translations.pm b/tp/Texinfo/Translations.pm
index e5fa0db094..837fb171d4 100644
--- a/tp/Texinfo/Translations.pm
+++ b/tp/Texinfo/Translations.pm
@@ -323,8 +323,7 @@ sub _replace_convert_substrings($;$$)
   }
 
   my $tree = $parser->parse_texi_line($texinfo_line, undef, 0, 1);
-  my $parser_registrar = $parser->registered_errors();
-  my ($errors, $errors_count) = $parser_registrar->errors();
+  my ($errors, $errors_count) = $parser->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 4ae7e191b4..76b9f10030 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -331,12 +331,23 @@ sub parse_texi_line($$;$$$)
   return $document->tree();
 }
 
-sub registered_errors($)
+# Only used in a test, not documented, there for symmetry with document
+sub registrar($)
 {
-  my $self = shift;
   return $self->{'registrar'};
 }
 
+sub errors($)
+{
+  my $self = shift;
+  my $registrar = $self->{'registrar'};
+  if (!$registrar) {
+    return undef;
+  }
+  return $registrar->errors();
+}
+
+
 1;
 __END__
 
diff --git a/tp/t/automatic_menus.t b/tp/t/automatic_menus.t
index eb352e5ac5..4a667cb639 100644
--- a/tp/t/automatic_menus.t
+++ b/tp/t/automatic_menus.t
@@ -28,7 +28,6 @@ sub test($$$;$$)
   my $parser = Texinfo::Parser::parser();
   my $document = $parser->parse_texi_text($in);
   my $tree = $document->tree();
-  my $registrar = $parser->registered_errors();
   Texinfo::Structuring::associate_internal_references($document, $parser);
 
   Texinfo::Structuring::sectioning_structure($document, $parser);
diff --git a/tp/t/automatic_nodes.t b/tp/t/automatic_nodes.t
index e7a2310bb3..51bca97e7f 100644
--- a/tp/t/automatic_nodes.t
+++ b/tp/t/automatic_nodes.t
@@ -35,7 +35,6 @@ sub test_new_node($$$$)
 
   my $parser = Texinfo::Parser::parser();
   my $node_tree = $parser->parse_texi_line ($in);
-  my $registrar = $parser->registered_errors();
   my $document = $parser->parse_texi_text ('');
   my $identifier_target = $document->labels_information();
   Texinfo::Structuring::associate_internal_references($document, $parser);
@@ -91,7 +90,6 @@ my $parser = Texinfo::Parser::parser();
 my $document = $parser->parse_texi_text('@node a node
 ');
 my $tree = $document->tree();
-my $registrar = $parser->registered_errors();
 my $line_tree = Texinfo::Parser::parse_texi_line (undef, 'a node');
 
 SKIP:
@@ -170,7 +168,6 @@ Text.
 
 $parser = Texinfo::Parser::parser();
 $document = $parser->parse_texi_text($sections_text);
-$registrar = $parser->registered_errors();
 Texinfo::Structuring::associate_internal_references($document, $parser);
 Texinfo::Transformations::insert_nodes_for_sectioning_commands($document,
                                                           $parser);
@@ -192,7 +189,6 @@ $document = $parser->parse_texi_text('@node Top
 * (some_manual)::
 @end menu
 ');
-$registrar = $parser->registered_errors();
 Texinfo::Structuring::associate_internal_references($document, $parser);
 Texinfo::Transformations::insert_nodes_for_sectioning_commands($document,
                                                           $parser);
diff --git a/tp/t/convert_to_text.t b/tp/t/convert_to_text.t
index d38b44ba53..a800b94a94 100644
--- a/tp/t/convert_to_text.t
+++ b/tp/t/convert_to_text.t
@@ -72,7 +72,6 @@ my $tree = $document->tree();
 #use Texinfo::DebugTree;
 #print STDERR Texinfo::DebugTree->convert_tree ($tree);
 
-my $registrar = $parser->registered_errors();
 my $main_configuration = Texinfo::MainConfig::new();
 # Setup sectioning commands numbers
 my $sections_list
diff --git a/tp/t/do_master_menu.t b/tp/t/do_master_menu.t
index 4f4551e117..69b2a76d88 100644
--- a/tp/t/do_master_menu.t
+++ b/tp/t/do_master_menu.t
@@ -125,7 +125,6 @@ my $no_detailmenu = _get_in('');
 
 my $parser = Texinfo::Parser::parser();
 my $document = $parser->parse_texi_piece($in_detailmenu);
-my $registrar = $parser->registered_errors();
 Texinfo::Structuring::associate_internal_references($document, $parser);
 Texinfo::Document::rebuild_document($document);
 my $identifier_target = $document->labels_information();
@@ -173,7 +172,6 @@ is ($out, $reference, 'master menu');
 
 $parser = Texinfo::Parser::parser();
 $document = $parser->parse_texi_piece($no_detailmenu);
-$registrar = $parser->registered_errors();
 Texinfo::Structuring::associate_internal_references($document, $parser);
 Texinfo::Document::rebuild_document($document);
 $identifier_target = $document->labels_information();
@@ -187,7 +185,6 @@ is ($out, $reference, 'master menu no detailmenu');
 
 $parser = Texinfo::Parser::parser();
 $document = $parser->parse_texi_piece($in_detailmenu);
-$registrar = $parser->registered_errors();
 Texinfo::Structuring::associate_internal_references($document, $parser);
 Texinfo::Transformations::regenerate_master_menu($document, $parser);
 Texinfo::Document::rebuild_document($document);
@@ -200,7 +197,6 @@ is ($out, _get_in($reference), 'regenerate with existing 
detailmenu');
 
 $parser = Texinfo::Parser::parser();
 $document = $parser->parse_texi_piece($no_detailmenu);
-$registrar = $parser->registered_errors();
 Texinfo::Structuring::associate_internal_references($document, $parser);
 Texinfo::Transformations::regenerate_master_menu($document, $parser);
 Texinfo::Document::rebuild_document($document);
diff --git a/tp/t/test_parse_texi_line.t b/tp/t/test_parse_texi_line.t
index c7324d4e74..c94cabd06b 100644
--- a/tp/t/test_parse_texi_line.t
+++ b/tp/t/test_parse_texi_line.t
@@ -34,8 +34,7 @@ sub test_line($$$$)
   my $check_texinfo = Texinfo::Convert::Texinfo::convert_to_texinfo($tree);
   is ($texinfo_line, $check_texinfo, $test_explanation);
 
-  my $parser_registrar = $parser->registered_errors();
-  my ($error_warnings_list, $error_count) = $parser_registrar->errors();
+  my ($error_warnings_list, $error_count) = $parser->errors();
   if (defined($errors_references)) {
     is (scalar(@$error_warnings_list), scalar(@$errors_references),
         "warning/errors nr $test_explanation");
diff --git a/tp/t/test_parser_registrar.t b/tp/t/test_parser_registrar.t
index f605c8cc98..a4a36f5232 100644
--- a/tp/t/test_parser_registrar.t
+++ b/tp/t/test_parser_registrar.t
@@ -27,7 +27,7 @@ my $parser = Texinfo::Parser::parser({'registrar' => 
$registrar});
 # this also tests errors with line_errors not defined
 my $document = $parser->parse_texi_piece("\@end format\n");
 
-my $parser_registrar = $parser->registered_errors();
+my $parser_registrar = $parser->registrar();
 ok ($parser_registrar eq $registrar, 'reused registrar');
 
 my ($error_warnings_list, $error_count) = $parser_registrar->errors();
diff --git a/tp/t/test_protect_hashchar_at_line_beginning.t 
b/tp/t/test_protect_hashchar_at_line_beginning.t
index 86b5c14145..b2b8e62e03 100644
--- a/tp/t/test_protect_hashchar_at_line_beginning.t
+++ b/tp/t/test_protect_hashchar_at_line_beginning.t
@@ -38,8 +38,6 @@ sub run_test($$$;$)
   my $document = $parser->parse_texi_piece($in, 1);
   my $tree = $document->tree();
 
-  my $parser_registrar = $parser->registered_errors();
-
   my $corrected_tree =
     Texinfo::Transformations::protect_hashchar_at_line_beginning($tree,
                                             $document->registrar(), $parser);
@@ -48,8 +46,7 @@ sub run_test($$$;$)
   $corrected_tree = $document->tree();
 
   if (defined($error_message)) {
-    my $parser_registrar = $parser->registered_errors();
-    my ($errors, $errors_count) = $parser_registrar->errors();
+    my ($errors, $errors_count) = $parser->errors();
     my ($document_errors, $document_errors_count)
       = $document->errors();
     $errors_count += $document_errors_count if ($document_errors_count);
diff --git a/tp/t/test_sort.t b/tp/t/test_sort.t
index d2a4f6409c..8338957ef2 100644
--- a/tp/t/test_sort.t
+++ b/tp/t/test_sort.t
@@ -43,7 +43,6 @@ my $document = $parser->parse_texi_text('@node Top
 @cindex @l{}
 ');
 
-my $registrar = $parser->registered_errors();
 my $main_configuration = Texinfo::MainConfig::new({});
 
 # To set $indices_sort_strings, calling
@@ -57,7 +56,7 @@ $main_configuration->{'document_descriptor'}
   = $document->document_descriptor();
 
 my $indices_sort_strings
-  = Texinfo::Indices::setup_index_entries_sort_strings($registrar,
+  = Texinfo::Indices::setup_index_entries_sort_strings($document->registrar(),
                                               $main_configuration,
                                       $index_entries, $indices_information);
 
@@ -65,7 +64,7 @@ my $index_entries_sort_strings
   = Texinfo::Indices::format_index_entries_sort_strings($indices_sort_strings);
 
 my $sorted_index_entries
-  = Texinfo::Indices::sort_indices_by_index($document, $registrar,
+  = Texinfo::Indices::sort_indices_by_index($document, $document->registrar(),
                                             $main_configuration);
 
 my @entries = ();
@@ -81,7 +80,7 @@ my @entries_ref = ('!', '"', 'aaaaaaaaaaaa', 'e', 'E', 'ẽ', 
'ł');
 cmp_deeply (\@entries, \@entries_ref, 'sorted index entries');
 
 my $sorted_index_entries_by_letter
- = Texinfo::Indices::sort_indices_by_letter($document, $registrar,
+ = Texinfo::Indices::sort_indices_by_letter($document, $document->registrar(),
                                             $main_configuration);
 
 my @letter_entries_ref = (
@@ -135,14 +134,13 @@ $document = $parser->parse_texi_text('@node Top
 @cindex hhh @subentry jjj @subentry lll @sortas{A}
 ');
 
-$registrar = $parser->registered_errors();
 $indices_sort_strings
   = Texinfo::Document::indices_sort_strings($document, $main_configuration);
 $index_entries_sort_strings
   = Texinfo::Indices::format_index_entries_sort_strings($indices_sort_strings);
 
 $sorted_index_entries
-  = Texinfo::Indices::sort_indices_by_index($document, $registrar,
+  = Texinfo::Indices::sort_indices_by_index($document, $document->registrar(),
                                             $main_configuration);
 
 @entries = ();
diff --git a/tp/t/test_tree_copy.t b/tp/t/test_tree_copy.t
index 96e819763e..602c969f3f 100644
--- a/tp/t/test_tree_copy.t
+++ b/tp/t/test_tree_copy.t
@@ -137,7 +137,6 @@ T
 my $test_parser = Texinfo::Parser::parser();
 my $document = Texinfo::Parser::parse_texi_piece($test_parser, $text);
 my $tree = $document->tree();
-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,9 +178,7 @@ 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_parser_registrar = $test_parser->registered_errors();
-  my ($test_parser_errors, $test_parser_error_count)
-        = $test_parser_registrar->errors();
+  my ($test_parser_errors, $test_parser_error_count) = $test_parser->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 ad69ab2651..927820b9b0 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -1034,17 +1034,16 @@ sub test($$)
     $document = $parser->parse_texi_file($test_file, $XS_structuring);
   }
   my $tree = $document->tree();
-  my $parser_registrar = $parser->registered_errors();
 
   if (not defined($tree)) {
     print STDERR "ERROR: parsing result undef\n";
-    my ($parser_errors, $parser_error_count) = $parser_registrar->errors();
+    my ($parser_errors, $parser_error_count) = $parser->errors();
     foreach my $error_message (@$parser_errors) {
       warn $error_message->{'error_line'}
         if ($error_message->{'type'} eq 'error');
     }
   }
-  my ($errors, $error_nrs) = $parser_registrar->errors();
+  my ($errors, $error_nrs) = $parser->errors();
 
   if ($tree_transformations{'fill_gaps_in_sectioning'}) {
     Texinfo::Transformations::fill_gaps_in_sectioning($tree);
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 945fef9661..d876280862 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1229,13 +1229,13 @@ sub _exit($$)
      or $error_count > get_conf('ERROR_LIMIT')));
 }
 
-sub handle_errors($$$)
+sub handle_errors(@)
 {
-  my $self = shift;
+  my $errors = shift;
+  my $new_error_count = shift;
   my $error_count = shift;
   my $opened_files = shift;
 
-  my ($errors, $new_error_count) = $self->errors();
   $error_count += $new_error_count if ($new_error_count);
   _handle_errors($errors);
 
@@ -1509,15 +1509,14 @@ while(@input_files) {
     print STDERR Data::Dumper->Dump([$tree]);
   }
   # object registering errors and warnings
-  my $parser_registrar = $parser->registered_errors();
   if (!defined($tree) or $format eq 'parse') {
-    handle_errors($parser_registrar, $error_count, \@opened_files);
+    handle_errors($parser->errors(), $error_count, \@opened_files);
     goto NEXT;
   }
 
   my $document_information = $document->global_information();
   if (get_conf('TRACE_INCLUDES')) {
-    handle_errors($parser_registrar, $error_count, \@opened_files);
+    handle_errors($parser->errors(), $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 +1600,7 @@ while(@input_files) {
     }
   }
   if (get_conf('DUMP_TEXI') or $formats_table{$format}->{'texi2dvi_format'}) {
-    handle_errors($parser_registrar, $error_count, \@opened_files);
+    handle_errors($parser->errors(), $error_count, \@opened_files);
     goto NEXT;
   }
 
@@ -1685,7 +1684,7 @@ while(@input_files) {
   Texinfo::Document::rebuild_document($document);
 
   # parser errors
-  my ($errors, $new_error_count) = $parser_registrar->errors();
+  my ($errors, $new_error_count) = $parser->errors();
   $error_count += $new_error_count if ($new_error_count);
   # document/structuring errors
   my ($document_errors, $document_error_count) = $document->errors();
@@ -1744,7 +1743,7 @@ while(@input_files) {
 
   push @opened_files, Texinfo::Common::output_files_opened_files(
                               $converter->output_files_information());
-  handle_errors($converter_registrar, $error_count, \@opened_files);
+  handle_errors($converter_registrar->errors(), $error_count, \@opened_files);
   my $converter_unclosed_files
        = Texinfo::Common::output_files_unclosed_files(
                                $converter->output_files_information());



reply via email to

[Prev in Thread] Current Thread [Next in Thread]