texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/main/output_unit.c (units_directi


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/output_unit.c (units_directions): verify that directions lists exit before using them. Initialize section_childs.
Date: Sat, 21 Oct 2023 05:56:25 -0400

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 0656bd1c5a * tp/Texinfo/XS/main/output_unit.c (units_directions): 
verify that directions lists exit before using them.  Initialize section_childs.
0656bd1c5a is described below

commit 0656bd1c5a678adf2be1770d7535bfc5d5c0a585
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Oct 21 11:56:23 2023 +0200

    * tp/Texinfo/XS/main/output_unit.c (units_directions): verify that
    directions lists exit before using them.  Initialize section_childs.
---
 ChangeLog                        |  5 ++++
 tp/Texinfo/Convert/HTML.pm       |  4 +--
 tp/Texinfo/Structuring.pm        |  4 +--
 tp/Texinfo/XS/main/output_unit.c | 65 +++++++++++++++++++++++-----------------
 4 files changed, 47 insertions(+), 31 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e1d641f04c..f5a60da7cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-10-21  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/output_unit.c (units_directions): verify that
+       directions lists exit before using them.  Initialize section_childs.
+
 2023-10-21  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Structuring.pm (output_unit_texi)
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index e830bc9f54..04355eb644 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -9289,8 +9289,8 @@ sub _prepare_units_directions_files($$$$$$$$)
   my $output_filename = shift;
   my $document_name = shift;
 
-  if (0 and $self->{'converter_descriptor'}) {
-  #if ($self->{'converter_descriptor'}) {
+  #if (0 and $self->{'converter_descriptor'}) {
+  if ($self->{'converter_descriptor'}) {
     my $encoded_converter = $self->encode_converter_for_output();
     my $encoded_document_name = Encode::encode('UTF-8', $document_name);
 
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index 7384a28e23..8953cadfa2 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -2174,6 +2174,8 @@ sub units_directions($$$)
                        ne $section->{'associated_unit'}));
       }
 
+      # fastforward is the next element on same level than the upper parent
+      # element.
       my $up = $section;
       while ($up->{'extra'}->{'section_level'} > 1
              and $up->{'extra'}->{'section_directions'}
@@ -2181,8 +2183,6 @@ sub units_directions($$$)
         $up = $up->{'extra'}->{'section_directions'}->{'up'};
       }
 
-      # fastforward is the next element on same level than the upper parent
-      # element.
       if ($up->{'extra'}->{'section_level'} < 1
           and $up->{'cmdname'} and $up->{'cmdname'} eq 'top'
           and $up->{'extra'}->{'section_childs'}
diff --git a/tp/Texinfo/XS/main/output_unit.c b/tp/Texinfo/XS/main/output_unit.c
index 04b2cedbcd..a56a8de3b6 100644
--- a/tp/Texinfo/XS/main/output_unit.c
+++ b/tp/Texinfo/XS/main/output_unit.c
@@ -506,12 +506,15 @@ units_directions (OPTIONS *customization_information,
           ELEMENT *menu_child = first_menu_node(node, identifiers_target);
           enum directions d;
           node_directions = lookup_extra_element (node, "node_directions");
-          for (d = 0; d < directions_length; d++)
+          if (node_directions)
             {
-              ELEMENT *node_direction = node_directions->contents.list[d];
-              if (node_direction)
-                directions[node_unit_directions[d]]
-                  = label_target_unit_element (node_direction);
+              for (d = 0; d < directions_length; d++)
+                {
+                  ELEMENT *node_direction = node_directions->contents.list[d];
+                  if (node_direction)
+                    directions[node_unit_directions[d]]
+                      = label_target_unit_element (node_direction);
+                }
             }
      /*  Now do NodeForward which is something like the following node. */
           if (menu_child)
@@ -524,7 +527,7 @@ units_directions (OPTIONS *customization_information,
               int automatic_directions = (node->args.number <= 1);
               ELEMENT *associated_section = lookup_extra_element (node,
                                                    "associated_section");
-              ELEMENT *section_childs;
+              ELEMENT *section_childs = 0;
               if (associated_section)
                 section_childs = lookup_extra_element (associated_section,
                                                          "section_childs");
@@ -534,11 +537,12 @@ units_directions (OPTIONS *customization_information,
                   directions[RUD_type_NodeForward]
                    = section_childs->contents.list[0]->associated_unit;
                 }
-              else if (node_directions->contents.list[D_next])
+              else if (node_directions
+                       && node_directions->contents.list[D_next])
                directions[RUD_type_NodeForward]
                  = label_target_unit_element(
                          node_directions->contents.list[D_next]);
-              else if (node_directions->contents.list[D_up])
+              else if (node_directions && node_directions->contents.list[D_up])
                 {
                   ELEMENT *up = node_directions->contents.list[D_up];
                   ELEMENT *up_list = new_element (ET_NONE);
@@ -559,7 +563,8 @@ units_directions (OPTIONS *customization_information,
 
                       up_node_directions = lookup_extra_element (up,
                                                    "node_directions");
-                      if (up_node_directions->contents.list[D_next])
+                      if (up_node_directions
+                          && up_node_directions->contents.list[D_next])
                         {
                            directions[RUD_type_NodeForward]
                              = label_target_unit_element(
@@ -567,7 +572,8 @@ units_directions (OPTIONS *customization_information,
                            break;
                         }
                       add_to_contents_as_array (up_list, up);
-                      if (up_node_directions->contents.list[D_up])
+                      if (up_node_directions
+                          && up_node_directions->contents.list[D_up])
                         up = up_node_directions->contents.list[D_up];
                       else
                         break;
@@ -625,23 +631,26 @@ units_directions (OPTIONS *customization_information,
           enum directions d;
           ELEMENT *section_directions = lookup_extra_element (section,
                                                    "section_directions");
-          for (d = 0; d < directions_length; d++)
+          if (section_directions)
             {
-        /* in most cases $section->{'extra'}->{'section_directions'}
-                   ->{$direction->[1]}
-                          ->{'associated_unit'} is defined
-          but it may not be the case for the up of @top.
-          The section may be its own up in cases like
-           @part part
-           @chapter chapter
-          in that cas the direction is not set up */
-              if (section_directions->contents.list[d]
-                  && section_directions->contents.list[d]->associated_unit
-                  && (!section->associated_unit
-                      || section->associated_unit
-                  != section_directions->contents.list[d]->associated_unit))
-              directions[section_unit_directions[d]]
-                = section_directions->contents.list[d]->associated_unit;
+              for (d = 0; d < directions_length; d++)
+                {
+            /* in most cases $section->{'extra'}->{'section_directions'}
+                       ->{$direction->[1]}
+                              ->{'associated_unit'} is defined
+              but it may not be the case for the up of @top.
+              The section may be its own up in cases like
+               @part part
+               @chapter chapter
+             in that cas the direction is not set up */
+                  if (section_directions->contents.list[d]
+                      && section_directions->contents.list[d]->associated_unit
+                      && (!section->associated_unit
+                          || section->associated_unit
+                     != section_directions->contents.list[d]->associated_unit))
+                  directions[section_unit_directions[d]]
+                    = section_directions->contents.list[d]->associated_unit;
+                }
             }
 
      /* fastforward is the next element on same level than the upper parent
@@ -654,6 +663,7 @@ units_directions (OPTIONS *customization_information,
               ELEMENT *up_section_directions = lookup_extra_element (up,
                                                    "section_directions");
               if (status >= 0 && up_section_level > 1
+                  && up_section_directions
                   && up_section_directions->contents.list[D_up])
                 up = up_section_directions->contents.list[D_up];
               else
@@ -680,7 +690,8 @@ units_directions (OPTIONS *customization_information,
                 {
                   ELEMENT *up_section_directions = lookup_extra_element (up,
                                                    "section_directions");
-                  if (up_section_directions->contents.list[D_next])
+                  if (up_section_directions
+                      && up_section_directions->contents.list[D_next])
                     directions[RUD_type_FastForward]
                       = up_section_directions->contents.list[D_next]
                                                      ->associated_unit;



reply via email to

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