texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sun, 20 Oct 2024 18:04:57 -0400 (EDT)

branch: master
commit 31ecf355c0fe36c65d7f978a88489cad434ea2ca
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Oct 21 00:03:53 2024 +0200

    * tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_texi_piece): remove the
    no_store argument.
    
    * tp/Texinfo/Document.pm (%XS_overrides, new_document, parser_errors),
    tp/Texinfo/ParserNonXS.pm (parse_texi_line, parse_texi_file)
    (_line_warn, _line_error, _next_text, _parse_texi),
    tp/Texinfo/XS/main/DocumentXS.xs (document_parser_errors),
    tp/Texinfo/XS/main/build_perl_info.c,
    tp/Texinfo/XS/parsetexi/Parsetexi.xs (errors),
    tp/t/no_structure_test.t, tp/t/same_parser_multiple_files.t,
    tp/t/test_protect_hashchar_at_line_beginning.t, tp/t/test_tree_copy.t,
    tp/t/test_utils.pl, tp/texi2any.pl: store parsing errors in document
    in Perl in the parser_registrar key value Texinfo::Report.  Add
    parser_errors to get the parsing errors from a Document.  Keep the
    Parser registrar for parse_texi_line as there is no document in that
    case, so the parser need to be used.  Using the parser to get parsing
    errors is not documented.
    
    * tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_texi_file)
    (parse_texi_piece, parse_texi_text): call directly get_document.
    
    * tp/Texinfo/XS/main/build_perl_info.c,
    tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_texi_line): inline
    get_or_build_document in parse_texi_line, remove the function.
    
    * Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm (print_texinfo_errors):
    pass error_messages and error_count directly as the function to get
    errors may be errors or parser_errors.  Update callers.
---
 ChangeLog                                      | 31 ++++++++++++
 Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm   | 19 ++++---
 Pod-Simple-Texinfo/pod2texi.pl                 | 10 ++--
 doc/tp_api/api_includes/Texinfo-Parser.texi    | 12 ++---
 man/pod2texi.1                                 |  2 +-
 tp/Texinfo/Document.pm                         | 20 +++++++-
 tp/Texinfo/ParserNonXS.pm                      | 28 +++++++----
 tp/Texinfo/XS/main/DocumentXS.xs               | 34 +++++++++++++
 tp/Texinfo/XS/main/build_perl_info.c           | 25 ----------
 tp/Texinfo/XS/main/build_perl_info.h           |  2 -
 tp/Texinfo/XS/parsetexi/Parsetexi.xs           | 69 +++++++++-----------------
 tp/t/no_structure_test.t                       |  2 +-
 tp/t/same_parser_multiple_files.t              |  2 +-
 tp/t/test_protect_hashchar_at_line_beginning.t |  2 +-
 tp/t/test_tree_copy.t                          |  2 +-
 tp/t/test_utils.pl                             |  2 +-
 tp/texi2any.pl                                 | 10 ++--
 17 files changed, 159 insertions(+), 113 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 95c19b80df..0eac268104 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,37 @@
        * README-hacking: suggest running autopoint instead of gettextize
        and using --dry-run option
 
+2024-10-20  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_texi_piece): remove the
+       no_store argument.
+
+       * tp/Texinfo/Document.pm (%XS_overrides, new_document, parser_errors),
+       tp/Texinfo/ParserNonXS.pm (parse_texi_line, parse_texi_file)
+       (_line_warn, _line_error, _next_text, _parse_texi),
+       tp/Texinfo/XS/main/DocumentXS.xs (document_parser_errors),
+       tp/Texinfo/XS/main/build_perl_info.c,
+       tp/Texinfo/XS/parsetexi/Parsetexi.xs (errors),
+       tp/t/no_structure_test.t, tp/t/same_parser_multiple_files.t,
+       tp/t/test_protect_hashchar_at_line_beginning.t, tp/t/test_tree_copy.t,
+       tp/t/test_utils.pl, tp/texi2any.pl: store parsing errors in document
+       in Perl in the parser_registrar key value Texinfo::Report.  Add
+       parser_errors to get the parsing errors from a Document.  Keep the
+       Parser registrar for parse_texi_line as there is no document in that
+       case, so the parser need to be used.  Using the parser to get parsing
+       errors is not documented.
+
+       * tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_texi_file)
+       (parse_texi_piece, parse_texi_text): call directly get_document.
+
+       * tp/Texinfo/XS/main/build_perl_info.c,
+       tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_texi_line): inline
+       get_or_build_document in parse_texi_line, remove the function.
+
+       * Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm (print_texinfo_errors):
+       pass error_messages and error_count directly as the function to get
+       errors may be errors or parser_errors.  Update callers.
+
 2024-10-20  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Report.pm (new, clear): fix key names.
diff --git a/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm 
b/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm
index fddf693f56..9e9b20ad81 100644
--- a/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm
+++ b/Pod-Simple-Texinfo/lib/Pod/Simple/Texinfo.pm
@@ -424,12 +424,12 @@ sub _prepend_internal_section_manual($$$;$$)
 }
 
 # also used in pod2texi.pl, not public.
-sub print_texinfo_errors($;$)
+sub print_texinfo_errors($$;$)
 {
-  my $error_source = shift;
+  my $error_messages = shift;
+  my $error_count = shift;
   my $location = shift;
 
-  my ($error_messages, $error_count) = $error_source->errors();
   foreach my $error_message (@$error_messages) {
     my $type_string;
     if ($error_message->{'type'} eq 'error') {
@@ -480,11 +480,16 @@ sub _normalize_texinfo_name($$;$)
   }
   my $parser = Texinfo::Parser::parser($parser_options);
   my $document = $parser->parse_texi_piece($texinfo_text);
-  if (!defined($document)) {
+
+  my $tree = $document->tree();
+
+  my ($error_messages, $error_count) = $document->parser_errors();
+
+  if (!defined($tree)) {
     my $texinfo_text_str = $texinfo_text;
     chomp($texinfo_text_str);
     warn "ERROR: Texinfo parsing failed for: $texinfo_text_str\n";
-    print_texinfo_errors($parser);
+    print_texinfo_errors($error_messages, $error_count);
     return undef;
   # use a high debug number, as the errors and warnings are likely to be
   # redundant with the warnings and errors emitted when fixing the document
@@ -492,9 +497,9 @@ sub _normalize_texinfo_name($$;$)
   # not only to apply transformations, but also possibly to fix invalid
   # constructs.
   } elsif (defined($debug) and $debug > 3) {
-    print_texinfo_errors($parser, '_normalize_texinfo_name');
+    print_texinfo_errors($error_messages, $error_count,
+                         '_normalize_texinfo_name');
   }
-  my $tree = $document->tree();
   if ($command eq 'anchor') {
     Texinfo::Transformations::protect_first_parenthesis_in_targets($tree);
     # rebuild the tree
diff --git a/Pod-Simple-Texinfo/pod2texi.pl b/Pod-Simple-Texinfo/pod2texi.pl
index 0349651743..777ac16b21 100755
--- a/Pod-Simple-Texinfo/pod2texi.pl
+++ b/Pod-Simple-Texinfo/pod2texi.pl
@@ -321,8 +321,9 @@ sub _parsed_manual_tree($$$$$)
   my $tree = $document->tree();
 
   if ($debug > 1) {
-    Pod::Simple::Texinfo::print_texinfo_errors($texi_parser,
-                                           '_parsed_manual_tree');
+    my ($error_messages, $error_count) = $document->parser_errors();
+    Pod::Simple::Texinfo::print_texinfo_errors($error_messages,
+                               $error_count, '_parsed_manual_tree');
   }
 
   my $identifier_target = $document->labels_information();
@@ -363,8 +364,9 @@ sub _parsed_manual_tree($$$$$)
     if ($section_nodes and $do_node_menus);
 
   if ($debug > 1) {
-    Pod::Simple::Texinfo::print_texinfo_errors($document,
-                                      '_parsed_manual_tree document');
+    my ($error_messages, $error_count) = $document->errors();
+    Pod::Simple::Texinfo::print_texinfo_errors($error_messages,
+                       $error_count, '_parsed_manual_tree document');
   }
 
   return ($texi_parser, $document, $identifier_target);
diff --git a/doc/tp_api/api_includes/Texinfo-Parser.texi 
b/doc/tp_api/api_includes/Texinfo-Parser.texi
index 67f77fbadd..96b309351e 100644
--- a/doc/tp_api/api_includes/Texinfo-Parser.texi
+++ b/doc/tp_api/api_includes/Texinfo-Parser.texi
@@ -15,7 +15,7 @@ Texinfo::Parser - Parse Texinfo code into a Perl tree
   my $parser = Texinfo::Parser::parser();
   my $document = $parser->parse_texi_file("somefile.texi");
 
-  my ($errors, $errors_count) = $parser->errors();
+  my ($errors, $errors_count) = $document->parser_errors();
   foreach my $error_message (@$errors) {
     warn $error_message->{'error_line'};
   }
@@ -161,13 +161,13 @@ is parsed into a tree.  @emph{$file_name} should be a 
binary string.
 @end table
 
 The errors collected during the tree parsing are available with
-@code{errors}.  These errors are internally registered in a 
@code{Texinfo::Report}
-object.
+the resulting document @code{parser_errors}.  These errors are internally
+registered in a @code{Texinfo::Report} object.
 
 @table @asis
-@item ($error_warnings_list, $error_count) = $parser->errors()
-@anchor{Texinfo@asis{::}Parser ($error_warnings_list@comma{} $error_count) = 
$parser->errors()}
-@cindex @code{errors}
+@item ($error_warnings_list, $error_count) = $document->parser_errors()
+@anchor{Texinfo@asis{::}Parser ($error_warnings_list@comma{} $error_count) = 
$document->parser_errors()}
+@cindex @code{parser_errors}
 
 This function returns as @emph{$error_count} the count of parsing errors.
 The @emph{$error_warnings_list} is an array of hash references
diff --git a/man/pod2texi.1 b/man/pod2texi.1
index 1d6e251eed..6696d75541 100644
--- a/man/pod2texi.1
+++ b/man/pod2texi.1
@@ -55,7 +55,7 @@
 .\" ========================================================================
 .\"
 .IX Title "POD2TEXI 1"
-.TH POD2TEXI 1 2024-10-12 perl "User Contributed Perl Documentation"
+.TH POD2TEXI 1 2024-10-20 perl "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff --git a/tp/Texinfo/Document.pm b/tp/Texinfo/Document.pm
index c1f619d5aa..524027fbb6 100644
--- a/tp/Texinfo/Document.pm
+++ b/tp/Texinfo/Document.pm
@@ -50,6 +50,8 @@ our %XS_overrides = (
     => "Texinfo::DocumentXS::set_document_global_info",
   "Texinfo::Document::errors"
     => "Texinfo::DocumentXS::document_errors",
+  "Texinfo::Document::parser_errors"
+    => "Texinfo::DocumentXS::document_parser_errors",
   "Texinfo::Document::rebuild_tree"
     => "Texinfo::DocumentXS::rebuild_tree",
   "Texinfo::Document::tree"
@@ -110,7 +112,9 @@ sub new_document($)
     'commands_info' => {},
     'identifiers_target' => {},
     'labels_list' => [],
-     # New error registrar for the document for structuring, not for parsing
+     # error registrar for parsing
+    'parser_registrar' => Texinfo::Report::new(),
+     # error registrar for the document for structuring, not for parsing
     'registrar' => Texinfo::Report::new(),
   };
 
@@ -495,6 +499,19 @@ sub rebuild_tree($;$)
   return $tree;
 }
 
+sub parser_errors($)
+{
+  my $document = shift;
+
+  my $registrar = $document->{'parser_registrar'};
+
+  my ($error_warnings_list, $error_count) = $registrar->errors();
+
+  $registrar->clear();
+
+  return ($error_warnings_list, $error_count);
+}
+
 # The XS override pass C error messages to the document registrar and destroys
 # C associated data.
 sub errors($)
@@ -502,7 +519,6 @@ sub errors($)
   my $document = shift;
 
   my $registrar = $document->{'registrar'};
-  return if !defined($registrar);
 
   my ($error_warnings_list, $error_count) = $registrar->errors();
 
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index b09a74d65f..b290631d12 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -831,6 +831,14 @@ sub parse_texi_line($$;$)
   my $root = {'type' => 'root_line'};
   $self->_parse_texi($root, $root);
   get_parser_info($self);
+
+  # add the errors to the Parser registrar as there is no document
+  # returned to get the errors from.
+  push @{$self->{'registrar'}->{'errors_warnings'}},
+      @{$document->{'parser_registrar'}->{'errors_warnings'}};
+  $self->{'registrar'}->{'error_nrs'}
+     += $document->{'parser_registrar'}->{'error_nrs'};
+
   return $document->tree();
 }
 
@@ -952,7 +960,7 @@ sub parse_texi_file($$)
     if (defined($encoding)) {
       $decoded_input_file_path = decode($encoding, $input_file_path);
     }
-    $self->{'registrar'}->document_error(
+    $document->{'parser_registrar'}->document_error(
                  sprintf(__("could not open %s: %s"),
                                   $decoded_input_file_path, $error_message));
     return $document;
@@ -1088,7 +1096,7 @@ sub _line_warn
   my $error_location_info = shift;
   my $continuation = shift;
   my $debug = shift;
-  my $registrar = $self->{'registrar'};
+  my $registrar = $self->{'document'}->{'parser_registrar'};
   $registrar->line_warn($text, $error_location_info, $continuation,
                         $self->{'conf'}->{'DEBUG'});
 }
@@ -1100,7 +1108,7 @@ sub _line_error
   my $error_location_info = shift;
   my $continuation = shift;
 
-  my $registrar = $self->{'registrar'};
+  my $registrar = $self->{'document'}->{'parser_registrar'};
   $registrar->line_error($text, $error_location_info, $continuation,
                          $self->{'conf'}->{'DEBUG'});
 }
@@ -2594,7 +2602,7 @@ sub _next_text($;$)
             $decoded_file_name = decode($file_name_encoding,
                                         $input->{'input_file_path'});
           }
-          $self->{'registrar'}->document_warn(
+          $self->{'document'}->{'parser_registrar'}->document_warn(
                                sprintf(__("error on closing %s: %s"),
                                        $decoded_file_name, $!),
                                     $self->{'conf'}->{'PROGRAM'});
@@ -7820,7 +7828,7 @@ sub _parse_texi($$$)
 
   # Setup identifier target elements based on 'labels_list'
   Texinfo::Document::set_labels_identifiers_target($document,
-                  $self->{'registrar'}, $self->{'conf'}->{'DEBUG'});
+           $document->{'parser_registrar'}, $self->{'conf'}->{'DEBUG'});
   Texinfo::Translations::complete_indices($document->{'indices'},
                                           $self->{'conf'}->{'DEBUG'});
 
@@ -8293,7 +8301,7 @@ Texinfo::Parser - Parse Texinfo code into a Perl tree
   my $parser = Texinfo::Parser::parser();
   my $document = $parser->parse_texi_file("somefile.texi");
 
-  my ($errors, $errors_count) = $parser->errors();
+  my ($errors, $errors_count) = $document->parser_errors();
   foreach my $error_message (@$errors) {
     warn $error_message->{'error_line'};
   }
@@ -8423,13 +8431,13 @@ is parsed into a tree.  I<$file_name> should be a 
binary string.
 =back
 
 The errors collected during the tree parsing are available with
-C<errors>.  These errors are internally registered in a C<Texinfo::Report>
-object.
+the resulting document C<parser_errors>.  These errors are internally
+registered in a C<Texinfo::Report> object.
 
 =over
 
-=item ($error_warnings_list, $error_count) = $parser->errors()
-X<C<errors>>
+=item ($error_warnings_list, $error_count) = $document->parser_errors()
+X<C<parser_errors>>
 
 This function returns as I<$error_count> the count of parsing errors.
 The I<$error_warnings_list> is an array of hash references
diff --git a/tp/Texinfo/XS/main/DocumentXS.xs b/tp/Texinfo/XS/main/DocumentXS.xs
index e08379cb8e..69c04c4472 100644
--- a/tp/Texinfo/XS/main/DocumentXS.xs
+++ b/tp/Texinfo/XS/main/DocumentXS.xs
@@ -151,6 +151,40 @@ document_errors (SV *document_in)
         PUSHs(sv_2mortal(errors_warnings_sv));
         PUSHs(sv_2mortal(error_nrs_sv));
 
+void
+document_parser_errors (SV *document_in)
+    PREINIT:
+        DOCUMENT *document = 0;
+        SV *errors_warnings_sv = 0;
+        SV *error_nrs_sv = 0;
+        AV *av;
+     PPCODE:
+        /* if XS is used, a document should be found.  It could
+           also have been possible to abort if a document is not
+           found.
+         */
+        document = get_sv_document_document (document_in,
+                                             "document_parser_errors");
+        if (document)
+          {
+            ERROR_MESSAGE_LIST *error_messages
+                  = &document->parser_error_messages;
+            av = build_errors (error_messages->list,
+                               error_messages->number);
+            error_nrs_sv = newSViv (error_messages->error_nrs);
+            clear_error_message_list (error_messages);
+          }
+        else
+          {
+            /* Should never happen */
+            av = newAV ();
+            error_nrs_sv = newSViv (0);
+          }
+        errors_warnings_sv = newRV_noinc ((SV *) av);
+
+        EXTEND(SP, 2);
+        PUSHs(sv_2mortal(errors_warnings_sv));
+        PUSHs(sv_2mortal(error_nrs_sv));
 
 void
 register_document_options (SV *document_in, SV *sv_options_in)
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index d1a304b0c9..061e8d0927 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -1938,31 +1938,6 @@ build_document (size_t document_descriptor, int no_store)
   return sv;
 }
 
-SV *
-get_or_build_document (SV *parser_sv, size_t document_descriptor, int no_store)
-{
-  dTHX;
-
-  if (!no_store)
-    {
-      /* Keep an information on the document descriptor to be able to get the
-         parser errors */
-      HV *parser_hv = (HV *) SvRV (parser_sv);
-      hv_store (parser_hv, "last_document_descriptor",
-                strlen ("last_document_descriptor"),
-                newSViv (document_descriptor), 0);
-      return get_document (document_descriptor);
-    }
-  else
-    {
-      /* get hold of errors before calling build_document, as they will be
-         destroyed since no_store is set. */
-      pass_document_parser_errors_to_registrar (document_descriptor,
-                                                parser_sv);
-      return build_document (document_descriptor, 1);
-    }
-}
-
 /* Currently unused, but could be */
 void
 rebuild_document (SV *document_in, int no_store)
diff --git a/tp/Texinfo/XS/main/build_perl_info.h 
b/tp/Texinfo/XS/main/build_perl_info.h
index 872969c74c..45ad2bad1c 100644
--- a/tp/Texinfo/XS/main/build_perl_info.h
+++ b/tp/Texinfo/XS/main/build_perl_info.h
@@ -44,8 +44,6 @@ SV *pass_errors_to_registrar (const ERROR_MESSAGE_LIST 
*error_messages,
 
 SV *build_document (size_t document_descriptor, int no_store);
 SV *get_document (size_t document_descriptor);
-SV *get_or_build_document (SV *parser_sv, size_t document_descriptor,
-                           int no_store);
 
 SV *store_document_texinfo_tree (DOCUMENT *document, HV *document_hv);
 
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.xs 
b/tp/Texinfo/XS/parsetexi/Parsetexi.xs
index 45ab56869a..52ca7761aa 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.xs
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.xs
@@ -97,8 +97,7 @@ parse_texi_file (SV *parser_sv, input_file_path)
             int status;
             apply_sv_parser_conf (parser_sv);
             document_descriptor = parse_file (input_file_path, &status);
-            RETVAL
-              = get_or_build_document (parser_sv, document_descriptor, 0);
+            RETVAL = get_document (document_descriptor);
           }
       OUTPUT:
         RETVAL
@@ -108,7 +107,6 @@ SV *
 parse_texi_piece (SV *parser_sv, SV *string_sv, ...)
     PREINIT:
         size_t document_descriptor = 0;
-        int no_store = 0;
         int line_nr = 1;
       CODE:
         if (!SvOK(string_sv) || !SvOK(parser_sv))
@@ -118,12 +116,9 @@ parse_texi_piece (SV *parser_sv, SV *string_sv, ...)
             char *string = (char *)SvPVutf8_nolen (string_sv);
             if (items > 2 && SvOK(ST(2)))
               line_nr = SvIV (ST(2));
-            if (items > 3 && SvOK(ST(3)))
-              no_store = SvIV (ST(3));
             apply_sv_parser_conf (parser_sv);
             document_descriptor = parse_piece (string, line_nr);
-            RETVAL = get_or_build_document (parser_sv, document_descriptor,
-                                            no_store);
+            RETVAL = get_document (document_descriptor);
           }
       OUTPUT:
         RETVAL
@@ -147,8 +142,19 @@ parse_texi_line (SV *parser_sv, SV *string_sv, ...)
               no_store = SvIV (ST(3));
             apply_sv_parser_conf (parser_sv);
             document_descriptor = parse_string (string, line_nr);
-            document_sv = get_or_build_document (parser_sv, 
document_descriptor,
-                                                 no_store);
+
+       /* get hold of errors before calling build_document, as they will be
+          destroyed if no_store is set.
+
+          add the errors to the Parser registrar as there is no document
+          returned to get the errors from.
+        */
+            pass_document_parser_errors_to_registrar (document_descriptor,
+                                                      parser_sv);
+            if (!no_store)
+              document_sv = get_document (document_descriptor);
+            else
+              document_sv = build_document (document_descriptor, 1);
             RETVAL = document_tree (document_sv, 0);
           }
       OUTPUT:
@@ -170,7 +176,7 @@ parse_texi_text (SV *parser_sv, SV *string_sv, ...)
               line_nr = SvIV (ST(2));
             apply_sv_parser_conf (parser_sv);
             document_descriptor = parse_text (string, line_nr);
-            RETVAL = get_or_build_document (parser_sv, document_descriptor, 0);
+            RETVAL = get_document (document_descriptor);
           }
       OUTPUT:
         RETVAL
@@ -287,51 +293,22 @@ parser_conf_set_DEBUG (int i)
 void
 parser_conf_set_accept_internalvalue (int value)
 
-# two possibilities
-#   - errors should be in the last parsed document->parser_error_messages,
-#     which can be found with "last_document_descriptor"
-#   - errors were put as the "registrar" key value in the parser
 void
 errors (SV *parser_sv)
     PREINIT:
         SV *errors_warnings_sv = 0;
         SV *error_nrs_sv = 0;
-        SV **last_document_descriptor_sv;
         HV *parser_hv;
+        SV **registrar_sv;
     PPCODE:
         parser_hv = (HV *)SvRV (parser_sv);
-        last_document_descriptor_sv = hv_fetch (parser_hv,
-          "last_document_descriptor", strlen ("last_document_descriptor"), 0);
-
-        if (last_document_descriptor_sv)
+        registrar_sv = hv_fetch (parser_hv, "registrar",
+                                 strlen ("registrar"), 0);
+        if (registrar_sv)
           {
-            AV *av;
-            size_t document_descriptor = SvIV (*last_document_descriptor_sv);
-            DOCUMENT *document = retrieve_document (document_descriptor);
-            if (document)
-              {
-                ERROR_MESSAGE_LIST *error_messages
-                  = &document->parser_error_messages;
-                av = build_errors (error_messages->list,
-                                   error_messages->number);
-                error_nrs_sv = newSViv (error_messages->error_nrs);
-              }
-            else
-              {
-    /* This could theoretically happen if the document is destroyed before
-       getting the parser errors */
-                av = newAV ();
-                error_nrs_sv = newSViv (0);
-              }
-            errors_warnings_sv = newRV_noinc ((SV *) av);
-          }
-        else
-          {
-            SV **registrar_errors_warnings_sv;
             SV **registrar_error_nrs_sv;
             AV *empty_errors_warnings = newAV ();
-            SV **registrar_sv = hv_fetch (parser_hv, "registrar",
-                                          strlen ("registrar"), 0);
+            SV **registrar_errors_warnings_sv;
             HV *registrar_hv = (HV *)SvRV (*registrar_sv);
 
             registrar_errors_warnings_sv
@@ -348,8 +325,8 @@ errors (SV *parser_sv)
             hv_store (registrar_hv, "errors_warnings",
                       strlen ("errors_warnings"),
                       newRV_noinc ((SV *) empty_errors_warnings), 0);
-            hv_store (registrar_hv, "errors_nrs",
-                      strlen ("errors_nrs"), newSViv (0), 0);
+            hv_store (registrar_hv, "error_nrs",
+                      strlen ("error_nrs"), newSViv (0), 0);
           }
 
         EXTEND(SP, 2);
diff --git a/tp/t/no_structure_test.t b/tp/t/no_structure_test.t
index 824638f176..7e8cdd15e0 100644
--- a/tp/t/no_structure_test.t
+++ b/tp/t/no_structure_test.t
@@ -128,7 +128,7 @@ my $result_texi
 is ($result_texi, $texi, 'back to Texinfo');
 
 
-my ($test_parser_errors, $test_parser_error_count) = $test_parser->errors();
+my ($test_parser_errors, $test_parser_error_count) = 
$document->parser_errors();
 foreach my $error_message (@$test_parser_errors) {
   warn "W: ".$error_message->{'error_line'}
    ;# if ($debug);
diff --git a/tp/t/same_parser_multiple_files.t 
b/tp/t/same_parser_multiple_files.t
index e7fd47b4a3..691f7052fb 100644
--- a/tp/t/same_parser_multiple_files.t
+++ b/tp/t/same_parser_multiple_files.t
@@ -119,7 +119,7 @@ sub _run_test($$$)
     my $document = $test_parser->Texinfo::Parser::parse_texi_file($test_file);
 
     my $parsing_errors = '';
-    my ($test_parser_errors, $test_parser_error_count) = 
$test_parser->errors();
+    my ($test_parser_errors, $test_parser_error_count) = 
$document->parser_errors();
     foreach my $error_message (@$test_parser_errors) {
       $parsing_errors .= $error_message->{'error_line'};
     }
diff --git a/tp/t/test_protect_hashchar_at_line_beginning.t 
b/tp/t/test_protect_hashchar_at_line_beginning.t
index 03a353dac4..c2296bd1bf 100644
--- a/tp/t/test_protect_hashchar_at_line_beginning.t
+++ b/tp/t/test_protect_hashchar_at_line_beginning.t
@@ -48,7 +48,7 @@ sub run_test($$$;$)
     $reference_error_nrs = scalar(@$errors_references);
   }
 
-  my ($error_warnings_list, $parser_errors_count) = $parser->errors();
+  my ($error_warnings_list, $parser_errors_count) = $document->parser_errors();
   my ($document_errors, $document_errors_count)
       = $document->errors();
   push @$error_warnings_list, @$document_errors;
diff --git a/tp/t/test_tree_copy.t b/tp/t/test_tree_copy.t
index 9648abac69..ba6dc9b861 100644
--- a/tp/t/test_tree_copy.t
+++ b/tp/t/test_tree_copy.t
@@ -182,7 +182,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_errors, $test_parser_error_count) = $test_parser->errors();
+  my ($test_parser_errors, $test_parser_error_count) = 
$document->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 96c5d62e00..67d0849cf0 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -1087,7 +1087,7 @@ sub test($$)
   # a "handle" is returned.
   my $tree = $document->tree($XS_structuring);
 
-  my ($errors, $error_nrs) = $parser->errors();
+  my ($errors, $error_nrs) = $document->parser_errors();
 
   my ($sorted_index_entries, $index_entries_sort_strings);
   my $indices_sorted_sort_strings;
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index fffb876822..65ae74cb9b 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1753,18 +1753,18 @@ while(@input_files) {
   }
 
   if (!defined($tree)) {
-    handle_errors($parser->errors(), $error_count, \%opened_files);
+    handle_errors($document->parser_errors(), $error_count, \%opened_files);
     goto NEXT;
   }
 
   if ($output_format eq 'parse') {
-    handle_errors($parser->errors(), $error_count, \%opened_files);
+    handle_errors($document->parser_errors(), $error_count, \%opened_files);
     goto NEXT;
   }
 
   my $document_information = $document->global_information();
   if (get_conf('TRACE_INCLUDES')) {
-    handle_errors($parser->errors(), $error_count, \%opened_files);
+    handle_errors($document->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) {
@@ -1867,7 +1867,7 @@ while(@input_files) {
   }
   if (get_conf('DUMP_TEXI')
       or $formats_table{$output_format}->{'texi2dvi_format'}) {
-    handle_errors($parser->errors(), $error_count, \%opened_files);
+    handle_errors($document->parser_errors(), $error_count, \%opened_files);
     goto NEXT;
   }
 
@@ -1946,7 +1946,7 @@ while(@input_files) {
   #Texinfo::Document::rebuild_document($document);
 
   # parser errors
-  my ($errors, $new_error_count) = $parser->errors();
+  my ($errors, $new_error_count) = $document->parser_errors();
   $error_count += $new_error_count if ($new_error_count);
   # document/structuring errors
   my ($document_errors, $document_error_count) = $document->errors();



reply via email to

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