texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: XS parse_texi_file only returns handle for buildi


From: Gavin D. Smith
Subject: branch master updated: XS parse_texi_file only returns handle for building tree on-demand
Date: Fri, 05 Apr 2024 09:02:20 -0400

This is an automated email from the git hooks/post-receive script.

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new a7d0de728d XS parse_texi_file only returns handle for building tree 
on-demand
a7d0de728d is described below

commit a7d0de728dc4aca5d170e546c45dba7b09766e61
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Fri Apr 5 14:02:09 2024 +0100

    XS parse_texi_file only returns handle for building tree on-demand
    
    * tp/Texinfo/XS/parsetexi/Parsetexi.pm (parse_texi_file): Eliminate
    optional argument to decide whether to build the Perl information
    or not.  Always call _get_parser_info with $no_build set.
    
    * tp/Texinfo/Document.pm (%XS_overrides, %XS_structure_overrides):
    Eliminate %XS_structure_overrides, and do not depend on the
    TEXINFO_XS_STRUCTURE variable.
    
    * tp/texi2any.pl, tp/t/test_utils.pl:
    Remove extra argument in call to parse_texi_file.
    Pass argument to Texinfo::Document::tree to control whether tree
    is built, depending on the setting of TEXINFO_XS_STRUCTURE.
    
    * tp/t/protect_character_in_texinfo.t:
    Only call Texinfo::Document::rebuld_tree if TEXINFO_XS_STRUCTURE is on.
---
 ChangeLog                            | 20 ++++++++++++++++++++
 tp/Texinfo/Document.pm               | 15 ---------------
 tp/Texinfo/XS/parsetexi/Parsetexi.pm |  5 ++---
 tp/t/protect_character_in_texinfo.t  | 12 +++++++++++-
 tp/t/test_utils.pl                   | 10 +++++++---
 tp/texi2any.pl                       | 12 ++++++------
 6 files changed, 46 insertions(+), 28 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 000aadcb14..74d5c5d8ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2024-04-05  Gavin Smith <gavinsmith0123@gmail.com>
+
+       XS parse_texi_file only returns handle for building tree on-demand
+
+       * tp/Texinfo/XS/parsetexi/Parsetexi.pm (parse_texi_file): Eliminate
+       optional argument to decide whether to build the Perl information
+       or not.  Always call _get_parser_info with $no_build set.
+
+       * tp/Texinfo/Document.pm (%XS_overrides, %XS_structure_overrides):
+       Eliminate %XS_structure_overrides, and do not depend on the
+       TEXINFO_XS_STRUCTURE variable.
+
+       * tp/texi2any.pl, tp/t/test_utils.pl:
+       Remove extra argument in call to parse_texi_file.
+       Pass argument to Texinfo::Document::tree to control whether tree
+       is built, depending on the setting of TEXINFO_XS_STRUCTURE.
+
+       * tp/t/protect_character_in_texinfo.t:
+       Only call Texinfo::Document::rebuld_tree if TEXINFO_XS_STRUCTURE is on.
+
 2024-04-04  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Makefile.tres, tp/t/formats_encodings.t
diff --git a/tp/Texinfo/Document.pm b/tp/Texinfo/Document.pm
index 4b8ceb1c99..b5335dcfb6 100644
--- a/tp/Texinfo/Document.pm
+++ b/tp/Texinfo/Document.pm
@@ -41,12 +41,6 @@ my $XS_parser = ((not defined($ENV{TEXINFO_XS})
                  and (not defined($ENV{TEXINFO_XS_PARSER})
                       or $ENV{TEXINFO_XS_PARSER} eq '1'));
 
-# XS parser and not explicitely unset
-my $XS_structuring = ($XS_parser
-                      and (not defined($ENV{TEXINFO_XS_STRUCTURE})
-                           or $ENV{TEXINFO_XS_STRUCTURE} ne '0'));
-
-# needed by parser
 our %XS_overrides = (
   "Texinfo::Document::remove_document"
     => "Texinfo::DocumentXS::remove_document",
@@ -54,10 +48,6 @@ our %XS_overrides = (
     => "Texinfo::DocumentXS::set_document_global_info",
   "Texinfo::Document::errors"
     => "Texinfo::DocumentXS::document_errors",
-);
-
-# needed by structure code
-our %XS_structure_overrides = (
   "Texinfo::Document::rebuild_document"
     => "Texinfo::DocumentXS::rebuild_document",
   "Texinfo::Document::rebuild_tree"
@@ -95,11 +85,6 @@ sub import {
       for my $sub (keys %XS_overrides) {
         Texinfo::XSLoader::override ($sub, $XS_overrides{$sub});
       }
-      if ($XS_structuring) {
-        for my $sub (keys %XS_structure_overrides) {
-          Texinfo::XSLoader::override ($sub, $XS_structure_overrides{$sub});
-        }
-      }
     }
     $module_loaded = 1;
   }
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm 
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index e7f9a65779..39aa31a2c2 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -231,11 +231,10 @@ sub _get_parser_info($$;$$) {
   return $document;
 }
 
-sub parse_texi_file ($$;$)
+sub parse_texi_file ($$)
 {
   my $self = shift;
   my $input_file_path = shift;
-  my $no_build = shift;
   my $tree_stream;
 
   # the file is already a byte string, taken as is from the command
@@ -259,7 +258,7 @@ sub parse_texi_file ($$;$)
     return undef;
   }
 
-  my $document = _get_parser_info($self, $document_descriptor, $no_build);
+  my $document = _get_parser_info($self, $document_descriptor, 1);
 
   return $document;
 }
diff --git a/tp/t/protect_character_in_texinfo.t 
b/tp/t/protect_character_in_texinfo.t
index 9df2d7ffa5..90c2a4a771 100644
--- a/tp/t/protect_character_in_texinfo.t
+++ b/tp/t/protect_character_in_texinfo.t
@@ -13,6 +13,14 @@ use Texinfo::Common qw(protect_comma_in_tree 
protect_colon_in_tree
 use Texinfo::Convert::Texinfo;
 use Texinfo::Document;
 
+# XS parser and not explicitly unset
+my $XS_structuring = ((not defined($ENV{TEXINFO_XS})
+                        or $ENV{TEXINFO_XS} ne 'omit')
+                       and (not defined($ENV{TEXINFO_XS_PARSER})
+                            or $ENV{TEXINFO_XS_PARSER} eq '1')
+                       and (not defined($ENV{TEXINFO_XS_STRUCTURE})
+                            or $ENV{TEXINFO_XS_STRUCTURE} ne '0'));
+
 ok(1);
 
 #my %avoided_keys_tree;
@@ -55,7 +63,9 @@ sub run_test($$$$)
   # rebuild tree
   $tree_as_text = $document->tree();
 
-  $tree_as_line = Texinfo::Document::rebuild_tree($tree_as_line);
+  if ($XS_structuring) {
+    $tree_as_line = Texinfo::Document::rebuild_tree($tree_as_line);
+  }
 
   my $texi_result_as_text
      = Texinfo::Convert::Texinfo::convert_to_texinfo($tree_as_text);
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index bdbafdfc04..85598b5ccc 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -112,7 +112,7 @@ Texinfo::Translations::configure($localesdir);
 
 Locale::Messages::bindtextdomain('texinfo', $localesdir);
 
-# XS parser and not explicitely unset
+# XS parser and not explicitly unset
 my $XS_structuring = ((not defined($ENV{TEXINFO_XS})
                         or $ENV{TEXINFO_XS} ne 'omit')
                        and (not defined($ENV{TEXINFO_XS_PARSER})
@@ -1029,8 +1029,9 @@ sub test($$)
     }
   } else {
     print STDERR "  TEST $test_name ($test_file)\n" if ($self->{'DEBUG'});
-    $document = $parser->parse_texi_file($test_file, $XS_structuring);
+    $document = $parser->parse_texi_file($test_file);
   }
+
   if (not defined($document)) {
     print STDERR "ERROR: parsing result undef\n";
     my ($parser_errors, $parser_error_count) = $parser->errors();
@@ -1039,7 +1040,10 @@ sub test($$)
         if ($error_message->{'type'} eq 'error');
     }
   }
-  my $tree = $document->tree(1);
+  # Get the tree object.  Note that if XS structuring in on, the argument
+  # prevents the tree being built as a Perl structure at this stage; only
+  # a "handle" is returned.
+  my $tree = $document->tree($XS_structuring);
 
   my ($errors, $error_nrs) = $parser->errors();
 
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 7f6327f504..e74f25b080 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1422,7 +1422,7 @@ die _encode_message(
    .sprintf(__("Try `%s --help' for more information.\n"), $real_command_name))
      unless (scalar(@input_files) >= 1);
 
-# XS parser and not explicitely unset
+# XS parser and not explicitly unset
 my $XS_structuring = ((not defined($ENV{TEXINFO_XS})
                         or $ENV{TEXINFO_XS} ne 'omit')
                        and (not defined($ENV{TEXINFO_XS_PARSER})
@@ -1490,7 +1490,7 @@ while(@input_files) {
           @prepended_include_directories;
 
   my $parser = Texinfo::Parser::parser($parser_file_options);
-  my $document = $parser->parse_texi_file($input_file_name, $XS_structuring);
+  my $document = $parser->parse_texi_file($input_file_name);
 
   if (defined($document)
       and (defined(get_conf('DUMP_TREE'))
@@ -1523,10 +1523,10 @@ while(@input_files) {
     goto NEXT;
   }
 
-  my $tree = $document->tree(1);
-  if ($tree_transformations{'fill_gaps_in_sectioning'}) {
-    Texinfo::Transformations::fill_gaps_in_sectioning($tree);
-  }
+  # Get the tree object.  Note that if XS structuring in on, the argument
+  # prevents the tree being built as a Perl structure at this stage; only
+  # a "handle" is returned.
+  my $tree = $document->tree($XS_structuring);
 
   # setup a configuration object which defines get_conf and gives the same as
   # get_conf() in main program.  It is for Structuring/Transformations methods



reply via email to

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