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/extra.c (add_extra_contents)


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/extra.c (add_extra_contents) (lookup_extra_contents): remove create argument of lookup_extra_contents. If value is 0, create a list in add_extra_contents. Return the list from add_extra_contents. Update callers.
Date: Fri, 23 Feb 2024 19:43:21 -0500

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 a43cf25158 * tp/Texinfo/XS/main/extra.c (add_extra_contents) 
(lookup_extra_contents): remove create argument of lookup_extra_contents.  If 
value is 0, create a list in add_extra_contents.  Return the list from 
add_extra_contents. Update callers.
a43cf25158 is described below

commit a43cf25158bb2ac1e484aa5a2e2c64d50990a25e
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Feb 24 01:43:17 2024 +0100

    * tp/Texinfo/XS/main/extra.c (add_extra_contents)
    (lookup_extra_contents): remove create argument of
    lookup_extra_contents.  If value is 0, create a list in
    add_extra_contents.  Return the list from add_extra_contents.
    Update callers.
    
    * tp/Texinfo/XS/main/extra.c (add_extra_directions)
    (lookup_extra_directions, lookup_extra_element): remove create
    argument of lookup_extra_directions.  If value is 0, create an
    element in add_extra_directions.  Do not accept extra_directions as a
    possible type for lookup_extra_element.  Update callers and replace
    calls to lookup_extra_element for directions by calls to
    lookup_extra_directions.
---
 ChangeLog                                          |  16 +++
 tp/Texinfo/XS/convert/convert_html.c               |  24 ++--
 tp/Texinfo/XS/main/extra.c                         |  59 +++++-----
 tp/Texinfo/XS/main/extra.h                         |   9 +-
 tp/Texinfo/XS/main/manipulate_tree.c               |   2 +-
 tp/Texinfo/XS/main/output_unit.c                   |  16 +--
 tp/Texinfo/XS/parsetexi/handle_commands.c          |   8 +-
 tp/Texinfo/XS/structuring_transfo/structuring.c    | 130 +++++++++++++++------
 .../XS/structuring_transfo/transformations.c       |  16 ++-
 9 files changed, 182 insertions(+), 98 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0d3a980eec..666b132532 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2024-02-23  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/extra.c (add_extra_contents)
+       (lookup_extra_contents): remove create argument of
+       lookup_extra_contents.  If value is 0, create a list in
+       add_extra_contents.  Return the list from add_extra_contents.
+       Update callers.
+
+       * tp/Texinfo/XS/main/extra.c (add_extra_directions)
+       (lookup_extra_directions, lookup_extra_element): remove create
+       argument of lookup_extra_directions.  If value is 0, create an
+       element in add_extra_directions.  Do not accept extra_directions as a
+       possible type for lookup_extra_element.  Update callers and replace
+       calls to lookup_extra_element for directions by calls to
+       lookup_extra_directions.
+
 2024-02-23  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/call_html_perl_function.c: replace G_ARRAY by
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 54c2b2627c..bed2450c45 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -5086,7 +5086,8 @@ html_prepare_output_units_global_targets (CONVERTER *self,
                     break;
 
                   const ELEMENT *up_section_directions
-                    = lookup_extra_element (root_command, 
"section_directions");
+                    = lookup_extra_directions (root_command,
+                                               "section_directions");
                   if (up_section_directions
                       && up_section_directions->contents.list[D_up]
                       && up_section_directions->contents.list[D_up]
@@ -6056,7 +6057,7 @@ html_default_format_contents (CONVERTER *self, const enum 
command_id cmd,
   else
     return result.text;
 
-  root_children = lookup_extra_contents (section_root, "section_childs", 0);
+  root_children = lookup_extra_contents (section_root, "section_childs");
   min_root_level = lookup_extra_integer (root_children->list[0], 
"section_level",
                                          &status);
   max_root_level = min_root_level;
@@ -6126,7 +6127,7 @@ html_default_format_contents (CONVERTER *self, const enum 
command_id cmd,
          int section_level = lookup_extra_integer (section, "section_level",
                                                    &status);
          ELEMENT_LIST *section_childs
-           = lookup_extra_contents (section, "section_childs", 0);
+           = lookup_extra_contents (section, "section_childs");
          if (section->cmd != CM_top)
             {
               char *text;
@@ -6206,8 +6207,9 @@ html_default_format_contents (CONVERTER *self, const enum 
command_id cmd,
           else
             {
               ELEMENT *section_directions
-               = lookup_extra_element (section, "section_directions");
-              if (section_directions && 
section_directions->contents.list[D_next]
+               = lookup_extra_directions (section, "section_directions");
+              if (section_directions
+                  && section_directions->contents.list[D_next]
                   && section->cmd != CM_top)
                 {
                   text_append_n (&result, "</li>\n", 6);
@@ -6230,7 +6232,8 @@ html_default_format_contents (CONVERTER *self, const enum 
command_id cmd,
                       int i;
 
                       ELEMENT *section_directions
-                       = lookup_extra_element (section, "section_directions");
+                        = lookup_extra_directions (section,
+                                                   "section_directions");
                       if (!section_directions
                           || !section_directions->contents.list[D_up])
                         break;
@@ -6252,7 +6255,8 @@ html_default_format_contents (CONVERTER *self, const enum 
command_id cmd,
                           break;
                         }
                       section_directions
-                        = lookup_extra_element (section, "section_directions");
+                        = lookup_extra_directions (section,
+                                                   "section_directions");
                       if (section_directions
                           && section_directions->contents.list[D_next])
                         {
@@ -9762,7 +9766,7 @@ mini_toc_internal (CONVERTER *self, const ELEMENT 
*element, TEXT *result)
   /* drop the const with a cast, but we know that it is not modified, with
      0 as the third argument */
   ELEMENT_LIST *section_childs = lookup_extra_contents ((ELEMENT *) element,
-                                                        "section_childs", 0);
+                                                        "section_childs");
   if (section_childs && section_childs->number > 0)
     {
       char *attribute_class;
@@ -9933,7 +9937,7 @@ convert_heading_command (CONVERTER *self, const enum 
command_id cmd,
           if (node)
             {
               int automatic_directions = (node->args.number <= 1);
-              ELEMENT_LIST *menus = lookup_extra_contents (node, "menus", 0);
+              ELEMENT_LIST *menus = lookup_extra_contents (node, "menus");
               if (!menus && automatic_directions)
                 {
                   ELEMENT *menu_node
@@ -11278,7 +11282,7 @@ convert_quotation_command (CONVERTER *self, const enum 
command_id cmd,
     }
 
   /* the cast is here to discard const */
-  authors = lookup_extra_contents ((ELEMENT *) element, "authors", 0);
+  authors = lookup_extra_contents ((ELEMENT *) element, "authors");
   if (authors)
     {
       int i;
diff --git a/tp/Texinfo/XS/main/extra.c b/tp/Texinfo/XS/main/extra.c
index 7c7d4e0af2..12d62547a2 100644
--- a/tp/Texinfo/XS/main/extra.c
+++ b/tp/Texinfo/XS/main/extra.c
@@ -102,12 +102,15 @@ add_info_element_oot (ELEMENT *e, char *key, ELEMENT 
*value)
 
 /* Add an extra key that is a reference to an array of other
    elements (for example, 'section_childs'). */
-void
+ELEMENT_LIST *
 add_extra_contents (ELEMENT *e, const char *key, ELEMENT_LIST *value)
 {
+  if (!value)
+    value = new_list ();
   KEY_PAIR *k = get_associated_info_key (&e->extra_info, key,
                                          extra_contents);
   k->list = value;
+  return value;
 }
 
 /* similar to extra_contents, but holds 3 elements corresponding to
@@ -117,13 +120,16 @@ add_extra_contents (ELEMENT *e, const char *key, 
ELEMENT_LIST *value)
    In other elements, in general, all the pointer elements are non
    NULL in contents for the first contents.number elements.
 */
-void
+ELEMENT *
 add_extra_directions (ELEMENT *e, const char *key, ELEMENT *value)
 {
+  if (!value)
+    value = new_element (ET_NONE);
   element_set_empty_contents (value, directions_length);
   KEY_PAIR *k = get_associated_info_key (&e->extra_info, key,
                                          extra_directions);
   k->element = value;
+  return value;
 }
 
 void
@@ -207,7 +213,7 @@ lookup_extra_element (const ELEMENT *e, const char *key)
   if (!k)
     return 0;
   else if (k->type == extra_string || k->type == extra_integer
-      || k->type == extra_contents)
+           || k->type == extra_contents || k->type == extra_directions)
     {
       char *msg;
       xasprintf (&msg, "Bad type for lookup_extra_element: %s: %d",
@@ -270,44 +276,39 @@ lookup_extra_integer (const ELEMENT *e, const char *key, 
int *ret)
   return k->integer;
 }
 
-/* if CREATE is true, create an extra contents element if there is none */
 ELEMENT_LIST *
-lookup_extra_contents (ELEMENT *e, const char *key, int create)
+lookup_extra_contents (const ELEMENT *e, const char *key)
 {
   ELEMENT_LIST *e_list = 0;
   KEY_PAIR *k = lookup_extra (e, key);
-  if (k)
-    {
-      if (k->type != extra_contents)
-        {
-          char *msg;
-          xasprintf (&msg, "Bad type for lookup_extra_contents: %s: %d",
-                     key, k->type);
-          fatal (msg);
-          free (msg);
-        }
-      e_list = k->list;
-    }
-  else if (create)
+  if (!k)
+    return 0;
+  else if (k->type != extra_contents)
     {
-      e_list = new_list ();
-      add_extra_contents (e, key, e_list);
+      char *msg;
+      xasprintf (&msg, "Bad type for lookup_extra_contents: %s: %d",
+                 key, k->type);
+      fatal (msg);
+      free (msg);
     }
-  return e_list;
+  return k->list;
 }
 
-/* if CREATE is true, create an extra directions element if there is none */
 ELEMENT *
-lookup_extra_directions (ELEMENT *e, const char *key, int create)
+lookup_extra_directions (ELEMENT *e, const char *key)
 {
-  ELEMENT *contents_e;
-  contents_e = lookup_extra_element (e, key);
-  if (!contents_e && create)
+  KEY_PAIR *k = lookup_extra (e, key);
+  if (!k)
+    return 0;
+  else if (k->type != extra_directions)
     {
-      contents_e = new_element (ET_NONE);
-      add_extra_directions (e, key, contents_e);
+      char *msg;
+      xasprintf (&msg, "Bad type for lookup_extra_directions: %s: %d",
+                 key, k->type);
+      fatal (msg);
+      free (msg);
     }
-  return contents_e;
+  return k->element;
 }
 
 ELEMENT *
diff --git a/tp/Texinfo/XS/main/extra.h b/tp/Texinfo/XS/main/extra.h
index 8c1e0dba7c..0d4a2d1f7f 100644
--- a/tp/Texinfo/XS/main/extra.h
+++ b/tp/Texinfo/XS/main/extra.h
@@ -21,9 +21,10 @@
 
 void add_extra_element (ELEMENT *e, const char *key, ELEMENT *value);
 void add_extra_element_oot (ELEMENT *e, char *key, ELEMENT *value);
-void add_extra_contents (ELEMENT *e, const char *key, ELEMENT_LIST *value);
+ELEMENT_LIST *add_extra_contents (ELEMENT *e, const char *key,
+                                  ELEMENT_LIST *value);
 void add_extra_container (ELEMENT *e, char *key, ELEMENT *value);
-void add_extra_directions (ELEMENT *e, const char *key, ELEMENT *value);
+ELEMENT *add_extra_directions (ELEMENT *e, const char *key, ELEMENT *value);
 void add_extra_text (ELEMENT *e, char *key, ELEMENT *value);
 void add_extra_misc_args (ELEMENT *e, char *key, ELEMENT *value);
 void add_extra_string (ELEMENT *e, const char *key, char *value);
@@ -40,8 +41,8 @@ KEY_PAIR *lookup_extra (const ELEMENT *e, const char *key);
 KEY_PAIR *lookup_info (const ELEMENT *e, const char *key);
 ELEMENT *lookup_extra_element (const ELEMENT *e, const char *key);
 ELEMENT *lookup_info_element (const ELEMENT *e, const char *key);
-ELEMENT_LIST *lookup_extra_contents (ELEMENT *e, const char *key, int create);
-ELEMENT *lookup_extra_directions (ELEMENT *e, const char *key, int create);
+ELEMENT_LIST *lookup_extra_contents (const ELEMENT *e, const char *key);
+ELEMENT *lookup_extra_directions (ELEMENT *e, const char *key);
 int lookup_extra_integer (const ELEMENT *e, const char *key, int *ret);
 char *lookup_extra_string (const ELEMENT *e, const char *key);
 char *lookup_info_string (const ELEMENT *e, const char *key);
diff --git a/tp/Texinfo/XS/main/manipulate_tree.c 
b/tp/Texinfo/XS/main/manipulate_tree.c
index a47ae8c52c..4c8493c9d6 100644
--- a/tp/Texinfo/XS/main/manipulate_tree.c
+++ b/tp/Texinfo/XS/main/manipulate_tree.c
@@ -1011,7 +1011,7 @@ normalized_entry_associated_internal_node (ELEMENT *entry,
 ELEMENT *
 first_menu_node (ELEMENT *node, LABEL_LIST *identifiers_target)
 {
-  ELEMENT_LIST *menus = lookup_extra_contents (node, "menus", 0);
+  ELEMENT_LIST *menus = lookup_extra_contents (node, "menus");
   if (menus)
     {
       int i;
diff --git a/tp/Texinfo/XS/main/output_unit.c b/tp/Texinfo/XS/main/output_unit.c
index 6084a7c549..7a8c5c87ed 100644
--- a/tp/Texinfo/XS/main/output_unit.c
+++ b/tp/Texinfo/XS/main/output_unit.c
@@ -530,7 +530,7 @@ 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");
+          node_directions = lookup_extra_directions (node, "node_directions");
           if (node_directions)
             {
               for (d = 0; d < directions_length; d++)
@@ -555,7 +555,7 @@ units_directions (OPTIONS *customization_information,
               ELEMENT_LIST *section_childs = 0;
               if (associated_section)
                 section_childs = lookup_extra_contents (associated_section,
-                                                        "section_childs", 0);
+                                                        "section_childs");
               if (automatic_directions
                   && section_childs && section_childs->number > 0)
                 {
@@ -587,7 +587,7 @@ units_directions (OPTIONS *customization_information,
                       if (in_up || (node_top && node_top == up))
                         break;
 
-                      up_node_directions = lookup_extra_element (up,
+                      up_node_directions = lookup_extra_directions (up,
                                                    "node_directions");
                       if (up_node_directions
                           && up_node_directions->contents.list[D_next])
@@ -656,7 +656,7 @@ units_directions (OPTIONS *customization_information,
           int up_section_level;
           int status;
           enum directions d;
-          ELEMENT *section_directions = lookup_extra_element (section,
+          ELEMENT *section_directions = lookup_extra_directions (section,
                                                    "section_directions");
           if (section_directions)
             {
@@ -687,7 +687,7 @@ units_directions (OPTIONS *customization_information,
               up_section_level
                 = lookup_extra_integer (up, "section_level", &status);
 
-              ELEMENT *up_section_directions = lookup_extra_element (up,
+              ELEMENT *up_section_directions = lookup_extra_directions (up,
                                                    "section_directions");
               if (status >= 0 && up_section_level > 1
                   && up_section_directions
@@ -697,7 +697,7 @@ units_directions (OPTIONS *customization_information,
                 break;
             }
 
-          up_section_childs = lookup_extra_contents (up, "section_childs", 0);
+          up_section_childs = lookup_extra_contents (up, "section_childs");
           if (status >= 0 && up_section_level < 1
               && up->cmd == CM_top && up_section_childs
               && up_section_childs->number > 0)
@@ -708,14 +708,14 @@ units_directions (OPTIONS *customization_information,
           else
             {
               ELEMENT *toplevel_directions
-               = lookup_extra_element (up, "toplevel_directions");
+               = lookup_extra_directions (up, "toplevel_directions");
               if (toplevel_directions
                   && toplevel_directions->contents.list[D_next])
                 directions[RUD_type_FastForward]
                   = 
toplevel_directions->contents.list[D_next]->associated_unit;
               else
                 {
-                  ELEMENT *up_section_directions = lookup_extra_element (up,
+                  ELEMENT *up_section_directions = lookup_extra_directions (up,
                                                    "section_directions");
                   if (up_section_directions
                       && up_section_directions->contents.list[D_next])
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c 
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index 9aff44a961..8d5411394d 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -940,7 +940,9 @@ handle_line_command (ELEMENT *current, char **line_inout,
               else if (parent->cmd == CM_quotation
                        || parent->cmd == CM_smallquotation)
                 {
-                  ELEMENT_LIST *l = lookup_extra_contents (parent, "authors", 
1);
+                  ELEMENT_LIST *l = lookup_extra_contents (parent, "authors");
+                  if (!l)
+                    l = add_extra_contents (parent, "authors", 0);
                   add_to_element_list (l, current);
                   add_extra_element (current, "quotation", parent);
                   found = 1; break;
@@ -1118,7 +1120,9 @@ handle_block_command (ELEMENT *current, char **line_inout,
                   else
                     {
                       ELEMENT_LIST *l
-                        = lookup_extra_contents (current_node, "menus", 1);
+                        = lookup_extra_contents (current_node, "menus");
+                      if (!l)
+                        l = add_extra_contents (current_node, "menus", 0);
                       add_to_element_list (l, block);
                     }
                 }
diff --git a/tp/Texinfo/XS/structuring_transfo/structuring.c 
b/tp/Texinfo/XS/structuring_transfo/structuring.c
index 71635d6291..c79177d70a 100644
--- a/tp/Texinfo/XS/structuring_transfo/structuring.c
+++ b/tp/Texinfo/XS/structuring_transfo/structuring.c
@@ -170,7 +170,7 @@ sectioning_structure (DOCUMENT *document)
               while (1)
                 {
                   ELEMENT *up_section_directions
-                    = lookup_extra_element (up, "section_directions");
+                    = lookup_extra_directions (up, "section_directions");
                   up_level = lookup_extra_integer (up, "section_level",
                                                    &status);
                   if (up_section_directions
@@ -229,7 +229,7 @@ sectioning_structure (DOCUMENT *document)
                   first 'part' just appeared, no direction to set.
                    */
                   ELEMENT_LIST *sec_root_childs
-                    = lookup_extra_contents (sec_root, "section_childs", 0);
+                    = lookup_extra_contents (sec_root, "section_childs");
                   add_extra_integer (sec_root, "section_level", level -1);
                   add_to_element_list (sec_root_childs, content);
                   number_top_level = level;
@@ -240,11 +240,11 @@ sectioning_structure (DOCUMENT *document)
                 {
                   ELEMENT *section_directions = new_element (ET_NONE);
                   ELEMENT_LIST *up_section_childs
-                    = lookup_extra_contents (up, "section_childs", 0);
+                    = lookup_extra_contents (up, "section_childs");
                   ELEMENT *prev
                     = up_section_childs->list[up_section_childs->number -1];
                   ELEMENT *prev_section_directions
-                    = lookup_extra_directions (prev, "section_directions", 1);
+                    = lookup_extra_directions (prev, "section_directions");
                   add_extra_directions (content, "section_directions",
                                         section_directions);
               /* do not set sec_root as up, but always put in section_childs */
@@ -252,6 +252,9 @@ sectioning_structure (DOCUMENT *document)
                     section_directions->contents.list[D_up] = up;
                   section_directions->contents.list[D_prev] = prev;
 
+                  if (!prev_section_directions)
+                    prev_section_directions = add_extra_directions (prev,
+                                                     "section_directions", 0);
                   prev_section_directions->contents.list[D_next] = content;
                   add_to_element_list (up_section_childs, content);
                 }
@@ -360,7 +363,12 @@ sectioning_structure (DOCUMENT *document)
                 {
                   ELEMENT *prev_toplvl_directions
                    = lookup_extra_directions (previous_toplevel,
-                                              "toplevel_directions", 1);
+                                              "toplevel_directions");
+                  if (!prev_toplvl_directions)
+                    prev_toplvl_directions
+                      = add_extra_directions (previous_toplevel,
+                                              "toplevel_directions", 0);
+ 
                   prev_toplvl_directions->contents.list[D_next] = content;
                   toplevel_directions->contents.list[D_prev] = 
previous_toplevel;
                 }
@@ -460,7 +468,7 @@ get_node_node_childs_from_sectioning (ELEMENT *node)
   if (associated_section)
     {
       ELEMENT_LIST *section_childs = lookup_extra_contents (associated_section,
-                                                          "section_childs", 0);
+                                                          "section_childs");
       if (section_childs)
         {
           int i;
@@ -480,7 +488,7 @@ get_node_node_childs_from_sectioning (ELEMENT *node)
           ELEMENT *current = associated_section;
           while (1)
             {
-              ELEMENT *section_directions = lookup_extra_element (current,
+              ELEMENT *section_directions = lookup_extra_directions (current,
                                                         "section_directions");
               if (section_directions
                   && section_directions->contents.list[D_next])
@@ -489,7 +497,7 @@ get_node_node_childs_from_sectioning (ELEMENT *node)
                   if (current->cmd == CM_part)
                     {
                       ELEMENT_LIST *section_childs
-                       = lookup_extra_contents (current, "section_childs", 0);
+                       = lookup_extra_contents (current, "section_childs");
                       if (section_childs)
                         {
                           int i;
@@ -608,9 +616,9 @@ check_nodes_are_referenced (DOCUMENT *document)
       int status;
       ELEMENT *node = nodes_list->list[i];
       int is_target = lookup_extra_integer (node, "is_target", &status);
-      ELEMENT *node_directions = lookup_extra_element (node,
+      ELEMENT *node_directions = lookup_extra_directions (node,
                                                     "node_directions");
-      ELEMENT_LIST *menus = lookup_extra_contents (node, "menus", 0);
+      ELEMENT_LIST *menus = lookup_extra_contents (node, "menus");
 
       if (is_target)
         nr_nodes_to_find++;
@@ -827,7 +835,7 @@ set_menus_node_directions (DOCUMENT *document)
     {
       int j;
       ELEMENT *node = nodes_list->list[i];
-      ELEMENT_LIST *menus = lookup_extra_contents (node, "menus", 0);
+      ELEMENT_LIST *menus = lookup_extra_contents (node, "menus");
 
       if (!menus)
         continue;
@@ -879,7 +887,11 @@ set_menus_node_directions (DOCUMENT *document)
                                     {
                                       ELEMENT *menu_directions
                                        = lookup_extra_directions (menu_node,
-                                                          "menu_directions", 
1);
+                                                          "menu_directions");
+                                      if (!menu_directions)
+                                        menu_directions
+                                          = add_extra_directions (menu_node,
+                                                           "menu_directions", 
0);
                                       menu_directions->contents.list[D_up]
                                         = node;
                                     }
@@ -905,15 +917,23 @@ set_menus_node_directions (DOCUMENT *document)
                             {
                               ELEMENT *menu_directions
                                 = lookup_extra_directions (menu_node,
-                                                    "menu_directions", 1);
-                               menu_directions->contents.list[D_prev]
+                                                      "menu_directions");
+                              if (!menu_directions)
+                                menu_directions
+                                  = add_extra_directions (menu_node,
+                                                      "menu_directions", 0);
+                              menu_directions->contents.list[D_prev]
                                  = previous_node;
                             }
                           if (!prev_manual_content)
                             {
                               ELEMENT *menu_directions
                                 = lookup_extra_directions (previous_node,
-                                                    "menu_directions", 1);
+                                                       "menu_directions");
+                              if (!menu_directions)
+                                menu_directions
+                                  = add_extra_directions (previous_node,
+                                                      "menu_directions", 0);
                               menu_directions->contents.list[D_next]
                                  = menu_node;
                             }
@@ -969,7 +989,7 @@ section_direction_associated_node (ELEMENT *section, enum 
directions direction)
   for (i = 0; i < sizeof (direction_bases) / sizeof (direction_bases[0]);
        i++)
     {
-      ELEMENT *directions = lookup_extra_element (section, direction_bases[i]);
+      ELEMENT *directions = lookup_extra_directions (section, 
direction_bases[i]);
       if (directions && directions->contents.list[direction])
         {
           ELEMENT *section_to = directions->contents.list[direction];
@@ -1009,13 +1029,13 @@ complete_node_tree_with_menus (DOCUMENT *document)
     {
       ELEMENT *node = nodes_list->list[i];
       char *normalized = lookup_extra_string (node, "normalized");
-      ELEMENT *menu_directions = lookup_extra_element (node,
+      ELEMENT *menu_directions = lookup_extra_directions (node,
                                                       "menu_directions");
       int automatic_directions = (node->args.number <= 1);
 
       if (automatic_directions)
         {
-          ELEMENT *node_directions = lookup_extra_element (node,
+          ELEMENT *node_directions = lookup_extra_directions (node,
                                                           "node_directions");
           if (strcmp (normalized, "Top"))
             {
@@ -1055,8 +1075,8 @@ complete_node_tree_with_menus (DOCUMENT *document)
                         {
                           ELEMENT_LIST *menus = 0;
                           ELEMENT *section_directions
-                            = lookup_extra_element (node_direction_section,
-                                                    "section_directions");
+                            = lookup_extra_directions (node_direction_section,
+                                                       "section_directions");
                           if (section_directions
                               && section_directions->contents.list[D_up])
                             {
@@ -1066,7 +1086,7 @@ complete_node_tree_with_menus (DOCUMENT *document)
                                                             "associated_node");
                               if (up_node)
                                 menus
-                                  = lookup_extra_contents (up_node, "menus", 
0);
+                                  = lookup_extra_contents (up_node, "menus");
                             }
 
                           if (menus
@@ -1124,7 +1144,10 @@ complete_node_tree_with_menus (DOCUMENT *document)
                             }
 
                           node_directions = lookup_extra_directions (node,
-                                                      "node_directions", 1);
+                                                      "node_directions");
+                          if (!node_directions)
+                            node_directions = add_extra_directions (node,
+                                                    "node_directions", 0);
                           node_directions->contents.list[d]
                              = elt_menu_direction;
                         }
@@ -1139,7 +1162,11 @@ complete_node_tree_with_menus (DOCUMENT *document)
               if (menu_child)
                 {
                   node_directions = lookup_extra_directions (node,
-                                                "node_directions", 1);
+                                                "node_directions");
+                  if (!node_directions)
+                    node_directions = add_extra_directions (node,
+                                                  "node_directions", 0);
+
                   node_directions->contents.list[D_next] = menu_child;
                   ELEMENT *menu_child_manual_content
                     = lookup_extra_element (menu_child, "manual_content");
@@ -1147,7 +1174,11 @@ complete_node_tree_with_menus (DOCUMENT *document)
                     {
                       ELEMENT *child_node_directions
                         = lookup_extra_directions (menu_child,
-                                                   "node_directions", 1);
+                                                   "node_directions");
+                      if (!child_node_directions)
+                        child_node_directions
+                          = add_extra_directions (menu_child,
+                                                   "node_directions", 0);
                       if (!child_node_directions->contents.list[D_prev])
                         child_node_directions->contents.list[D_prev] = node;
                     }
@@ -1163,7 +1194,10 @@ complete_node_tree_with_menus (DOCUMENT *document)
                       if (first_non_top_node != node)
                         {
                           node_directions = lookup_extra_directions (node,
-                                                      "node_directions", 1);
+                                                      "node_directions");
+                          if (!node_directions)
+                            node_directions = add_extra_directions (node,
+                                                      "node_directions", 0);
                           node_directions->contents.list[D_next]
                               = first_non_top_node;
                           int first_non_top_node_automatic
@@ -1172,7 +1206,11 @@ complete_node_tree_with_menus (DOCUMENT *document)
                             {
                               ELEMENT *non_top_node_directions
                                = lookup_extra_directions (first_non_top_node,
-                                                        "node_directions", 1);
+                                                        "node_directions");
+                              if (!non_top_node_directions)
+                                non_top_node_directions
+                                  = add_extra_directions (first_non_top_node,
+                                                      "node_directions", 0);
                               non_top_node_directions->contents.list[D_prev]
                                = node;
                             }
@@ -1187,7 +1225,7 @@ complete_node_tree_with_menus (DOCUMENT *document)
            || options->CHECK_NORMAL_MENU_STRUCTURE.integer > 0)
           && strcmp (normalized, "Top"))
         {
-          ELEMENT *node_directions = lookup_extra_element (node,
+          ELEMENT *node_directions = lookup_extra_directions (node,
                                                            "node_directions");
           if (node_directions && menu_directions)
             {
@@ -1228,7 +1266,7 @@ complete_node_tree_with_menus (DOCUMENT *document)
       if ((!options)
           || options->CHECK_MISSING_MENU_ENTRY.integer > 0)
         {
-          ELEMENT *node_directions = lookup_extra_element (node,
+          ELEMENT *node_directions = lookup_extra_directions (node,
                                                            "node_directions");
           ELEMENT *up_node = 0;
           if (node_directions && node_directions->contents.list[D_up])
@@ -1241,7 +1279,7 @@ complete_node_tree_with_menus (DOCUMENT *document)
               int is_target = lookup_extra_integer (node, "is_target",
                                                     &status);
               ELEMENT_LIST *menus
-                   = lookup_extra_contents (up_node, "menus", 0);
+                   = lookup_extra_contents (up_node, "menus");
 
               /* No check if node up is an external manual */
               if (!manual_content
@@ -1331,7 +1369,7 @@ nodes_tree (DOCUMENT *document)
         if (!top_node || node != top_node)
           {
             enum directions d;
-            ELEMENT *node_directions = lookup_extra_element (node,
+            ELEMENT *node_directions = lookup_extra_directions (node,
                                                    "node_directions");
             for (d = 0; d < directions_length; d++)
               {
@@ -1364,7 +1402,10 @@ nodes_tree (DOCUMENT *document)
                     if (direction_associated_node)
                       {
                         node_directions = lookup_extra_directions (node,
-                                                    "node_directions", 1);
+                                                    "node_directions");
+                        if (!node_directions)
+                          node_directions = add_extra_directions (node,
+                                                      "node_directions", 0);
                         node_directions->contents.list[d]
                            = direction_associated_node;
                       }
@@ -1378,7 +1419,7 @@ nodes_tree (DOCUMENT *document)
             if (section)
               {
                 ELEMENT_LIST *section_childs
-                  = lookup_extra_contents (section, "section_childs", 0);
+                  = lookup_extra_contents (section, "section_childs");
                 if (section_childs && section_childs->number > 0)
                   {
                     ELEMENT *first_sec = section_childs->list[0];
@@ -1387,14 +1428,21 @@ nodes_tree (DOCUMENT *document)
                     if (top_node_section_child)
                       {
                         ELEMENT *top_directions = lookup_extra_directions 
(node,
-                                                    "node_directions", 1);
+                                                    "node_directions");
+                        if (!top_directions)
+                          top_directions = add_extra_directions (node,
+                                                      "node_directions", 0);
                         top_directions->contents.list[D_next]
                           = top_node_section_child;
                         if (top_node_section_child->args.number <= 1)
                           {
                             ELEMENT *top_section_child_directions
                              = lookup_extra_directions (top_node_section_child,
-                                                         "node_directions", 1);
+                                                         "node_directions");
+                            if (!top_section_child_directions)
+                              top_section_child_directions
+                                = add_extra_directions (top_node_section_child,
+                                                      "node_directions", 0);
                             top_section_child_directions->contents.list[D_prev]
                               = node;
                           }
@@ -1415,7 +1463,10 @@ nodes_tree (DOCUMENT *document)
               if (manual_content)
                 {
                   ELEMENT *node_directions = lookup_extra_directions (node,
-                                                    "node_directions", 1);
+                                                    "node_directions");
+                  if (!node_directions)
+                    node_directions = add_extra_directions (node,
+                                                      "node_directions", 0);
                   node_directions->contents.list[direction]
                       = direction_element;
                 }
@@ -1432,7 +1483,10 @@ nodes_tree (DOCUMENT *document)
                         {
                           ELEMENT *node_directions
                             = lookup_extra_directions (node,
-                                                    "node_directions", 1);
+                                                    "node_directions");
+                          if (!node_directions)
+                            node_directions = add_extra_directions (node,
+                                                      "node_directions", 0);
                           node_directions->contents.list[direction]
                             = node_target;
                           if ((!options)
@@ -1615,7 +1669,7 @@ number_floats (DOCUMENT *document)
               while (1)
                 {
                   ELEMENT *section_directions
-                    = lookup_extra_element (up, "section_directions");
+                    = lookup_extra_directions (up, "section_directions");
                   if (section_directions
                       && section_directions->contents.list[D_up])
                     {
@@ -1926,7 +1980,7 @@ print_down_menus (ELEMENT *node, LABEL_LIST 
*identifiers_target,
 {
   ELEMENT_LIST *master_menu_contents = new_list ();
   ELEMENT_LIST *menus;
-  ELEMENT_LIST *node_menus = lookup_extra_contents (node, "menus", 0);
+  ELEMENT_LIST *node_menus = lookup_extra_contents (node, "menus");
   ELEMENT_LIST *node_children;
   ELEMENT *new_current_menu = 0;
   int i;
diff --git a/tp/Texinfo/XS/structuring_transfo/transformations.c 
b/tp/Texinfo/XS/structuring_transfo/transformations.c
index 36763fa934..6c64cc6ce3 100644
--- a/tp/Texinfo/XS/structuring_transfo/transformations.c
+++ b/tp/Texinfo/XS/structuring_transfo/transformations.c
@@ -690,7 +690,7 @@ reassociate_to_node (const char *type, ELEMENT *current, 
void *argument)
       if (previous_node)
         {
           ELEMENT_LIST *menus
-            = lookup_extra_contents (previous_node, "menus", 0);
+            = lookup_extra_contents (previous_node, "menus");
           int previous_idx = -1;
           if (menus)
             {
@@ -720,7 +720,9 @@ reassociate_to_node (const char *type, ELEMENT *current, 
void *argument)
                 }
             }
         }
-      added_node_menus = lookup_extra_contents (added_node, "menus", 1);
+      added_node_menus = lookup_extra_contents (added_node, "menus");
+      if (!added_node_menus)
+        added_node_menus = add_extra_contents (added_node, "menus", 0);
       add_to_element_list (added_node_menus, current);
     }
   else
@@ -906,7 +908,9 @@ prepend_new_menu_in_node_section (ELEMENT * node, ELEMENT 
*section,
                                   ELEMENT *current_menu)
 {
   ELEMENT *empty_line = new_element (ET_empty_line);
-  ELEMENT_LIST *menus = lookup_extra_contents (node, "menus", 1);
+  ELEMENT_LIST *menus = lookup_extra_contents (node, "menus");
+  if (!menus)
+    menus = add_extra_contents (node, "menus", 0);
 
   add_to_element_contents (section, current_menu);
   text_append (&empty_line->text, "\n");
@@ -936,7 +940,7 @@ complete_node_menu (ELEMENT *node, int use_sections)
       ELEMENT *current_menu = 0;
 
       int i;
-      ELEMENT_LIST *menus = lookup_extra_contents (node, "menus", 0);
+      ELEMENT_LIST *menus = lookup_extra_contents (node, "menus");
 
       if (menus)
         {
@@ -1106,7 +1110,7 @@ complete_tree_nodes_missing_menu (ELEMENT *root, DOCUMENT 
*document,
   for (i = 0; i < non_automatic_nodes->number; i++)
     {
       ELEMENT *node = non_automatic_nodes->list[i];
-      ELEMENT_LIST *menus = lookup_extra_contents (node, "menus", 0);
+      ELEMENT_LIST *menus = lookup_extra_contents (node, "menus");
       if (!(menus && menus->number > 0))
         {
           ELEMENT *section = lookup_extra_element (node, "associated_section");
@@ -1139,7 +1143,7 @@ regenerate_master_menu (DOCUMENT *document, int 
use_sections)
 
   if (top_node)
     {
-      menus = lookup_extra_contents (top_node, "menus", 0);
+      menus = lookup_extra_contents (top_node, "menus");
       if (!menus || (menus->number <= 0))
         return 0;
     }



reply via email to

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