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 09:35:47 -0400 (EDT)

branch: master
commit c5b625afd632843897cf44e7e192bb2451a5ed1a
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Mar 10 14:35:46 2024 +0100

    * tp/Texinfo/XS/convert/ConvertXS.xs (html_prepare_conversion_units):
    setup the Perl Texinfo tree before building output units to Perl as
    output units refer to the root commands.
    
    * tp/Texinfo/XS/main/build_perl_info.c (element_to_perl_hash): allow
    element associated_unit hv not to be already set, in case the tree is
    rebuilt before the output units, while there are already output units
    in XS/C.
---
 ChangeLog                            | 11 +++++++++++
 tp/TODO                              | 10 ++++++++++
 tp/Texinfo/XS/convert/ConvertXS.xs   | 13 ++++++++++++-
 tp/Texinfo/XS/main/build_perl_info.c | 12 ++++++++++--
 4 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 66d356c17f..20bab9a2dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-03-10  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/ConvertXS.xs (html_prepare_conversion_units):
+       setup the Perl Texinfo tree before building output units to Perl as
+       output units refer to the root commands.
+
+       * tp/Texinfo/XS/main/build_perl_info.c (element_to_perl_hash): allow
+       element associated_unit hv not to be already set, in case the tree is
+       rebuilt before the output units, while there are already output units
+       in XS/C.
+
 2024-03-10  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/Converter.pm (determine_files_and_directory),
diff --git a/tp/TODO b/tp/TODO
index d86dacc9a7..ef9d93e64b 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -12,6 +12,16 @@ Before next release
 
 Check if LABEL identifier should be const
 
+Remove the need for Texinfo::Structuring::rebuild_output_units, currently seems
+to be called in t/test_utils.pl only.
+
+output units building in C is also called in convert/ConvertXS.xs, with output
+units built in html_prepare_conversion_units and rebuilt afterwards in 2 other
+functions.  Building output units requires a call to store_texinfo_tree, it
+would be better to hold only a reference to C output units data instead of
+building perl structures.  Perl structures would still need to be built if
+output units are actually accessed.
+
 Bugs
 ====
 
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 86ec51a8e0..ce733c154a 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -1861,6 +1861,7 @@ html_prepare_conversion_units (SV *converter_in, ...)
          SV *special_units_sv;
          SV *associated_special_units_sv;
          HV *output_units_hv;
+         SV **document_sv;
       PPCODE:
          if (items > 2 && SvOK(ST(2)))
            document_name = SvPVutf8_nolen (ST(2));
@@ -1878,12 +1879,22 @@ html_prepare_conversion_units (SV *converter_in, ...)
               &output_units_descriptor, &special_units_descriptor,
               &associated_special_units_descriptor);
 
+         /* need to setup the Perl tree before rebuilding the output units as
+            they refer to Perl root command elements */
+         converter_hv = (HV *) SvRV (converter_in);
+         document_sv
+           = hv_fetch (converter_hv, "document", strlen ("document"), 0);
+         if (document_sv)
+           {
+             HV *document_hv = (HV *) SvRV (*document_sv);
+             store_texinfo_tree (self->document, document_hv);
+           }
+
          output_units_sv = build_output_units_list (output_units_descriptor);
          special_units_sv = build_output_units_list (special_units_descriptor);
          associated_special_units_sv
            = build_output_units_list (associated_special_units_descriptor);
 
-         converter_hv = (HV *) SvRV (converter_in);
          output_units_hv = (HV *) SvRV (output_units_sv);
          hv_store (converter_hv, "document_units", strlen ("document_units"),
                    newRV_inc ((SV *) output_units_hv), 0);
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index b2bcf592e8..8f6e0dac12 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -678,8 +678,16 @@ element_to_perl_hash (ELEMENT *e, int avoid_recursion)
 
   if (e->associated_unit)
     {
-      hv_store (e->hv, "associated_unit", strlen ("associated_unit"),
-                newRV_inc ((SV *) e->associated_unit->hv), 0);
+      /* output_unit_to_perl_hash uses the unit_contents elements hv,
+         so we may want to setup the tree hv before building the output
+         units.  In that case, the output unit hv is not ready, so here
+         we do not error out if the hv is not set.
+          */
+      if (e->associated_unit->hv)
+        {
+          hv_store (e->hv, "associated_unit", strlen ("associated_unit"),
+                    newRV_inc ((SV *) e->associated_unit->hv), 0);
+        }
     }
 
   store_source_mark_list (e);



reply via email to

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