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, 10 Mar 2024 04:51:20 -0400 (EDT)

branch: master
commit 7d744f19769f39f8fe3c2f91bea58cad6f2ee6d3
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Mar 10 00:55:49 2024 +0100

    Do not call rebuild_document
    
    * tp/texi2any.pl, tp/t/test_utils.pl (test): do not call
    rebuild_document, the document information should be built to Perl
    when called through the accessors.
    
    * tp/texi2any.pl: remove a useless call to labels_information.
    
    * t/test_utils.pl: remove a useless call to
    global_commands_information.
    
    * tp/Texinfo/Document.pm (global_information),
    tp/Texinfo/XS/main/DocumentXS.xs (document_global_information),
    tp/Texinfo/XS/main/build_perl_info.c (document_global_information),
    tp/texi2any.pl, t/test_utils.pl: add an argument to
    global_information/document_global_information such that only
    information that do not require building the Perl tree is returned if
    set.  Similar to calling only get_document, called that way from the
    main program.
---
 ChangeLog                            | 22 ++++++++++++++++++++++
 tp/TODO                              |  4 ++++
 tp/Texinfo/Document.pm               |  2 +-
 tp/Texinfo/XS/main/DocumentXS.xs     |  2 +-
 tp/Texinfo/XS/main/build_perl_info.c | 19 ++++++++++++++++++-
 tp/Texinfo/XS/main/build_perl_info.h |  2 +-
 tp/t/test_utils.pl                   |  5 ++---
 tp/texi2any.pl                       | 10 ++++------
 8 files changed, 53 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fe9eb0761f..a37371ae34 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2024-03-09  Patrice Dumas  <pertusus@free.fr>
+
+       Do not call rebuild_document
+
+       * tp/texi2any.pl, tp/t/test_utils.pl (test): do not call
+       rebuild_document, the document information should be built to Perl
+       when called through the accessors.
+
+       * tp/texi2any.pl: remove a useless call to labels_information.
+
+       * t/test_utils.pl: remove a useless call to
+       global_commands_information.
+
+       * tp/Texinfo/Document.pm (global_information),
+       tp/Texinfo/XS/main/DocumentXS.xs (document_global_information),
+       tp/Texinfo/XS/main/build_perl_info.c (document_global_information),
+       tp/texi2any.pl, t/test_utils.pl: add an argument to
+       global_information/document_global_information such that only
+       information that do not require building the Perl tree is returned if
+       set.  Similar to calling only get_document, called that way from the
+       main program.
+
 2024-03-09  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Document.pm (%XS_structure_overrides)
diff --git a/tp/TODO b/tp/TODO
index d86dacc9a7..bbec7977bb 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -12,6 +12,10 @@ Before next release
 
 Check if LABEL identifier should be const
 
+Add setfilename
+$global_commands->{'setfilename'}->{'extra'}->{'text_arg'}
+to global_info / build_global_info
+
 Bugs
 ====
 
diff --git a/tp/Texinfo/Document.pm b/tp/Texinfo/Document.pm
index 46d3fda102..0653219976 100644
--- a/tp/Texinfo/Document.pm
+++ b/tp/Texinfo/Document.pm
@@ -195,7 +195,7 @@ sub global_commands_information($)
   return $self->{'commands_info'};
 }
 
-sub global_information($)
+sub global_information($;$)
 {
   my $self = shift;
   return $self->{'global_info'};
diff --git a/tp/Texinfo/XS/main/DocumentXS.xs b/tp/Texinfo/XS/main/DocumentXS.xs
index 7dfc1c114b..ae443e8926 100644
--- a/tp/Texinfo/XS/main/DocumentXS.xs
+++ b/tp/Texinfo/XS/main/DocumentXS.xs
@@ -221,7 +221,7 @@ document_tree (SV *document_in, int handler_only=0)
         RETVAL
 
 SV *
-document_global_information (SV *document_in)
+document_global_information (SV *document_in, int simple_info=0)
 
 SV *
 document_indices_information (SV *document_in)
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index b45513ff9b..ca73595169 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -1690,8 +1690,11 @@ 
BUILD_PERL_DOCUMENT_LIST(labels_list,labels_list,labels_list,build_target_elemen
 
 #undef BUILD_PERL_DOCUMENT_LIST
 
+/* if SIMPLE_INFO is set, do not return information that requires buildin
+   the Perl tree and add information on few commands such that commands
+   information needs not to be called */
 SV *
-document_global_information (SV *document_in)
+document_global_information (SV *document_in, int simple_info)
 {
   HV *document_hv;
   SV *result_sv = 0;
@@ -1703,6 +1706,20 @@ document_global_information (SV *document_in)
 
   DOCUMENT *document = get_sv_document_document (document_in,
                                      "document_global_information");
+  if (simple_info)
+    { /* no caching in that case, but no need of building the
+         full document.  Should only be called with this argument
+         from the main program */
+      if (document)
+        {
+          HV *result_hv = build_global_info (document->global_info,
+                                             document->global_commands);
+          return newRV_inc ((SV *) result_hv);
+        }
+      else
+        return newSV (0);
+    }
+
   if (document)
     {
       store_texinfo_tree (document, document_hv);
diff --git a/tp/Texinfo/XS/main/build_perl_info.h 
b/tp/Texinfo/XS/main/build_perl_info.h
index 80d881513f..7de78707a4 100644
--- a/tp/Texinfo/XS/main/build_perl_info.h
+++ b/tp/Texinfo/XS/main/build_perl_info.h
@@ -59,7 +59,7 @@ SV *document_floats_information (SV *document_in);
 SV *document_internal_references_information (SV *document_in);
 SV *document_labels_list (SV *document_in);
 
-SV *document_global_information (SV *document_in);
+SV *document_global_information (SV *document_in, int simple_info);
 
 void pass_document_parser_errors_to_registrar (int document_descriptor,
                                                SV *parser_sv);
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index f0bc2afb99..67fd32c4d2 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -1049,12 +1049,11 @@ sub test($$)
     Texinfo::Transformations::fill_gaps_in_sectioning($tree);
   }
 
-  my $document_information = $document->global_information();
+  my $document_information = $document->global_information(1);
 
   Texinfo::Common::set_output_encodings($main_configuration,
                                         $document);
 
-  my $global_commands = $document->global_commands_information();
   if ($document_information->{'novalidate'}) {
     $main_configuration->set_conf('novalidate', 1);
   }
@@ -1133,7 +1132,7 @@ sub test($$)
 
   # could be in a if !$XS_structuring, but the function should not be
   # overriden already in that case
-  Texinfo::Document::rebuild_document($document);
+  #Texinfo::Document::rebuild_document($document);
   $tree = $document->tree();
 
   my $indices_information = $document->indices_information();
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index f8e46b73a7..f8600004ba 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1511,7 +1511,7 @@ while(@input_files) {
     goto NEXT;
   }
 
-  my $document_information = $document->global_information();
+  my $document_information = $document->global_information(1);
   if (get_conf('TRACE_INCLUDES')) {
     handle_errors($parser->errors(), $error_count, \@opened_files);
     my $included_file_paths = $document_information->{'included_files'};
@@ -1528,8 +1528,6 @@ while(@input_files) {
     Texinfo::Transformations::fill_gaps_in_sectioning($tree);
   }
 
-  my $identifier_target = $document->labels_information();
-
   # setup a configuration object which defines get_conf and gives the same as
   # get_conf() in main program.  It is for Structuring/Transformations methods
   # needing access to the configuration information.
@@ -1554,10 +1552,10 @@ while(@input_files) {
 
   if (defined(get_conf('MACRO_EXPAND')) and $file_number == 0) {
     require Texinfo::Convert::Texinfo;
-    # no need to rebuild the tree here if convert_to_texinfo is XS code.
+    # if convert_to_texinfo is not XS code get Perl tree.
     if (not (defined $ENV{TEXINFO_XS_CONVERT}
              and $ENV{TEXINFO_XS_CONVERT} eq '1')) {
-      Texinfo::Document::rebuild_document($document);
+      #Texinfo::Document::rebuild_document($document);
       $tree = $document->tree();
     }
     my $texinfo_text = Texinfo::Convert::Texinfo::convert_to_texinfo($tree);
@@ -1681,7 +1679,7 @@ while(@input_files) {
                                                   $main_configuration);
   }
 
-  Texinfo::Document::rebuild_document($document);
+  #Texinfo::Document::rebuild_document($document);
 
   # parser errors
   my ($errors, $new_error_count) = $parser->errors();



reply via email to

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