texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/convert/indices_in_conversion.c (


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/convert/indices_in_conversion.c (index_content_element): def_command extra information is a string.
Date: Fri, 24 Nov 2023 14:11:17 -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 0968482b33 * tp/Texinfo/XS/convert/indices_in_conversion.c 
(index_content_element): def_command extra information is a string.
0968482b33 is described below

commit 0968482b3347a6fad8205ccc0c8a0a3fc7f45300
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Nov 24 20:11:05 2023 +0100

    * tp/Texinfo/XS/convert/indices_in_conversion.c
    (index_content_element): def_command extra information is a string.
    
    * tp/Texinfo/XS/main/extra.c (lookup_extra_element): runtime check for
    extra_* type.
    
    * tp/Texinfo/XS/main/build_perl_info.c (store_additional_info),
    tp/Texinfo/XS/main/debug.c (print_associate_info_debug),
    tp/Texinfo/XS/main/extra.c (add_extra_contents)
    (lookup_extra_contents), tp/Texinfo/XS/main/manipulate_tree.c
    (copy_associated_info, associate_info_references),
    tp/Texinfo/XS/main/tree.c (destroy_associated_info),
    tp/Texinfo/XS/main/tree_types.h (KEY_PAIR): use an ELEMENT_LIST to
    hold extra_contents extra information type data.
    
    * tp/Texinfo/XS/main/manipulate_tree.c (first_menu_node),
    tp/Texinfo/XS/main/output_unit.c (units_directions),
    tp/Texinfo/XS/parsetexi/handle_commands.c (handle_line_command)
    (handle_block_command),
    tp/Texinfo/XS/structuring_transfo/structuring.c (sectioning_structure)
    (get_node_node_childs_from_sectioning, check_nodes_are_referenced)
    (set_menus_node_directions, complete_node_tree_with_menus, nodes_tree)
    (print_down_menus, new_master_menu),
    tp/Texinfo/XS/structuring_transfo/transformations.c
    (reassociate_to_node, prepend_new_menu_in_node_section)
    (complete_node_menu, complete_tree_nodes_missing_menu)
    (regenerate_master_menu): use ELEMENT_LIST, lookup_extra_contents,
    add_extra_contents with extra_contents extra items.
---
 ChangeLog                                          |  31 +++++++
 tp/Texinfo/XS/convert/indices_in_conversion.c      |   2 +-
 tp/Texinfo/XS/main/build_perl_info.c               |   5 +-
 tp/Texinfo/XS/main/debug.c                         |  13 +++
 tp/Texinfo/XS/main/extra.c                         |  29 ++++--
 tp/Texinfo/XS/main/extra.h                         |   4 +-
 tp/Texinfo/XS/main/manipulate_tree.c               |  82 +++++++++++++----
 tp/Texinfo/XS/main/output_unit.c                   |  18 ++--
 tp/Texinfo/XS/main/tree.c                          |   2 +
 tp/Texinfo/XS/main/tree_types.h                    |  14 +--
 tp/Texinfo/XS/parsetexi/close.c                    |   2 +-
 tp/Texinfo/XS/parsetexi/handle_commands.c          |   8 +-
 tp/Texinfo/XS/structuring_transfo/structuring.c    | 102 +++++++++++----------
 tp/Texinfo/XS/structuring_transfo/structuring.h    |   2 +-
 .../XS/structuring_transfo/transformations.c       |  43 ++++-----
 15 files changed, 231 insertions(+), 126 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bf9d61fffb..dc504f29bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2023-11-24  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/indices_in_conversion.c
+       (index_content_element): def_command extra information is a string.
+
+       * tp/Texinfo/XS/main/extra.c (lookup_extra_element): runtime check for
+       extra_* type.
+
+       * tp/Texinfo/XS/main/build_perl_info.c (store_additional_info),
+       tp/Texinfo/XS/main/debug.c (print_associate_info_debug),
+       tp/Texinfo/XS/main/extra.c (add_extra_contents)
+       (lookup_extra_contents), tp/Texinfo/XS/main/manipulate_tree.c
+       (copy_associated_info, associate_info_references),
+       tp/Texinfo/XS/main/tree.c (destroy_associated_info),
+       tp/Texinfo/XS/main/tree_types.h (KEY_PAIR): use an ELEMENT_LIST to
+       hold extra_contents extra information type data.
+
+       * tp/Texinfo/XS/main/manipulate_tree.c (first_menu_node),
+       tp/Texinfo/XS/main/output_unit.c (units_directions),
+       tp/Texinfo/XS/parsetexi/handle_commands.c (handle_line_command)
+       (handle_block_command),
+       tp/Texinfo/XS/structuring_transfo/structuring.c (sectioning_structure)
+       (get_node_node_childs_from_sectioning, check_nodes_are_referenced)
+       (set_menus_node_directions, complete_node_tree_with_menus, nodes_tree)
+       (print_down_menus, new_master_menu),
+       tp/Texinfo/XS/structuring_transfo/transformations.c
+       (reassociate_to_node, prepend_new_menu_in_node_section)
+       (complete_node_menu, complete_tree_nodes_missing_menu)
+       (regenerate_master_menu): use ELEMENT_LIST, lookup_extra_contents,
+       add_extra_contents with extra_contents extra items.
+
 2023-11-24  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/build_perl_info.c (store_additional_info): readd
diff --git a/tp/Texinfo/XS/convert/indices_in_conversion.c 
b/tp/Texinfo/XS/convert/indices_in_conversion.c
index 3edff0ce67..3774dec70f 100644
--- a/tp/Texinfo/XS/convert/indices_in_conversion.c
+++ b/tp/Texinfo/XS/convert/indices_in_conversion.c
@@ -140,7 +140,7 @@ destroy_indices_sorted_by_letter (
 ELEMENT *
 index_content_element (const ELEMENT *element, int prefer_reference_element)
 {
-  const ELEMENT *def_command = lookup_extra_element (element, "def_command");
+  const char *def_command = lookup_extra_string (element, "def_command");
   if (def_command)
    {
      ELEMENT *def_index_element;
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index cd79b9e871..a220ccb826 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -311,8 +311,9 @@ store_additional_info (const ELEMENT *e, ASSOCIATED_INFO* 
a, char *key)
               break;
             case extra_contents:
               {
-              if (f)
-                STORE(build_perl_array (&f->contents));
+              ELEMENT_LIST *l = k->list;
+              if (l && l->number)
+                STORE(build_perl_array (l));
               break;
               }
             case extra_directions:
diff --git a/tp/Texinfo/XS/main/debug.c b/tp/Texinfo/XS/main/debug.c
index 31ab8dc362..c4e88fc552 100644
--- a/tp/Texinfo/XS/main/debug.c
+++ b/tp/Texinfo/XS/main/debug.c
@@ -176,6 +176,19 @@ char *print_associate_info_debug (const ASSOCIATED_INFO 
*info)
             break;
            }
         case extra_contents:
+          {
+            int j;
+            ELEMENT_LIST *l = k->list;
+            text_append (&text, "contents: ");
+            for (j = 0; j < l->number; j++)
+              {
+                const ELEMENT *e = l->list[j];
+                char *element_str = print_element_debug (e, 0);
+                text_printf (&text, "%p;%s|", e, element_str);
+                free (element_str);
+              }
+            break;
+          }
         case extra_container:
           {
             int j;
diff --git a/tp/Texinfo/XS/main/extra.c b/tp/Texinfo/XS/main/extra.c
index 0b5542e85f..1289a30792 100644
--- a/tp/Texinfo/XS/main/extra.c
+++ b/tp/Texinfo/XS/main/extra.c
@@ -101,11 +101,11 @@ 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
-add_extra_contents (ELEMENT *e, char *key, ELEMENT *value)
+add_extra_contents (ELEMENT *e, char *key, ELEMENT_LIST *value)
 {
   KEY_PAIR *k = get_associated_info_key (&e->extra_info, key,
                                          extra_contents);
-  k->element = value;
+  k->list = value;
 }
 
 /* similar to extra_contents, but holds 3 elements corresponding to
@@ -189,6 +189,15 @@ lookup_extra_element (const ELEMENT *e, char *key)
   k = lookup_associated_info (&e->extra_info, key);
   if (!k)
     return 0;
+  else if (k->type == extra_string || k->type == extra_integer
+      || k->type == extra_contents)
+    {
+      char *msg;
+      xasprintf (&msg, "Bad type for lookup_extra_element: %s: %d",
+                key, k->type);
+      fatal (msg);
+      free (msg);
+    }
   return k->element;
 }
 
@@ -229,17 +238,19 @@ lookup_extra_integer (const ELEMENT *e, char *key, int 
*ret)
 }
 
 /* if CREATE is true, create an extra contents element if there is none */
-ELEMENT *
+ELEMENT_LIST *
 lookup_extra_contents (ELEMENT *e, char *key, int create)
 {
-  ELEMENT *contents_e;
-  contents_e = lookup_extra_element (e, key);
-  if (!contents_e && create)
+  ELEMENT_LIST *e_list = 0;
+  KEY_PAIR *k = lookup_extra (e, key);
+  if (k)
+    e_list = k->list;
+  else if (create)
     {
-      contents_e = new_element (ET_NONE);
-      add_extra_contents (e, key, contents_e);
+      e_list = new_list ();
+      add_extra_contents (e, key, e_list);
     }
-  return contents_e;
+  return e_list;
 }
 
 /* if CREATE is true, create an extra directions element if there is none */
diff --git a/tp/Texinfo/XS/main/extra.h b/tp/Texinfo/XS/main/extra.h
index 772bfb9af1..22eeafc5d4 100644
--- a/tp/Texinfo/XS/main/extra.h
+++ b/tp/Texinfo/XS/main/extra.h
@@ -21,7 +21,7 @@
 
 void add_extra_element (ELEMENT *e, char *key, ELEMENT *value);
 void add_extra_element_oot (ELEMENT *e, char *key, ELEMENT *value);
-void add_extra_contents (ELEMENT *e, char *key, ELEMENT *value);
+void add_extra_contents (ELEMENT *e, char *key, ELEMENT_LIST *value);
 void add_extra_container (ELEMENT *e, char *key, ELEMENT *value);
 void add_extra_directions (ELEMENT *e, char *key, ELEMENT *value);
 void add_extra_text (ELEMENT *e, char *key, ELEMENT *value);
@@ -36,7 +36,7 @@ KEY_PAIR *lookup_extra (const ELEMENT *e, char *key);
 KEY_PAIR *lookup_info (const ELEMENT *e, char *key);
 ELEMENT *lookup_extra_element (const ELEMENT *e, char *key);
 ELEMENT *lookup_info_element (const ELEMENT *e, char *key);
-ELEMENT *lookup_extra_contents (ELEMENT *e, char *key, int create);
+ELEMENT_LIST *lookup_extra_contents (ELEMENT *e, char *key, int create);
 ELEMENT *lookup_extra_directions (ELEMENT *e, char *key, int create);
 int lookup_extra_integer (const ELEMENT *e, char *key, int *ret);
 char *lookup_extra_string (const ELEMENT *e, char *key);
diff --git a/tp/Texinfo/XS/main/manipulate_tree.c 
b/tp/Texinfo/XS/main/manipulate_tree.c
index f762ca3a87..b3af31ec79 100644
--- a/tp/Texinfo/XS/main/manipulate_tree.c
+++ b/tp/Texinfo/XS/main/manipulate_tree.c
@@ -37,17 +37,17 @@ copy_tree_internal (ELEMENT* current, ELEMENT *parent);
 
 void
 increase_ref_counter (ELEMENT *element)
-{           
+{
   KEY_PAIR *k_counter;
   intptr_t *counter_ptr;
-        
+
   k_counter = lookup_extra_by_index (element, "_counter", -1);
   if (!k_counter)
     add_extra_integer (element, "_counter", 0);
   k_counter = lookup_extra_by_index (element, "_counter", -1);
   counter_ptr = (intptr_t *) &k_counter->integer;
   (*counter_ptr) ++;
-}    
+}
 
 void
 copy_associated_info (ASSOCIATED_INFO *info, ASSOCIATED_INFO* new_info)
@@ -59,7 +59,8 @@ copy_associated_info (ASSOCIATED_INFO *info, ASSOCIATED_INFO* 
new_info)
       KEY_PAIR *k_ref = &info->info[i];
       char *key = k_ref->key;
       ELEMENT *f = k_ref->element;
-      ELEMENT *new_extra_contents;
+      ELEMENT *new_extra_element;
+      ELEMENT_LIST *new_extra_contents;
       KEY_PAIR *k_copy = 0;
       int j;
 
@@ -86,32 +87,55 @@ copy_associated_info (ASSOCIATED_INFO *info, 
ASSOCIATED_INFO* new_info)
           copy_tree_internal (f, 0);
           break;
         case extra_contents:
+          {
+          KEY_PAIR *k = get_associated_info_key (new_info, key, k_ref->type);
+          new_extra_contents = new_list ();
+          k->list = new_extra_contents;
+          for (j = 0; j < k_ref->list->number; j++)
+            {
+              ELEMENT *e = k_ref->list->list[j];
+              k_copy = lookup_extra_by_index (e, "_copy", -1);
+              if (k_copy)
+                add_to_element_list (new_extra_contents,
+                                     k_copy->element);
+              else
+                {
+                  increase_ref_counter (e);
+                  add_to_element_list (new_extra_contents, 0);
+                }
+              copy_tree_internal (e, 0);
+            }
+          break;
+          }
         case extra_directions:
         case extra_container:
+          {
           KEY_PAIR *k = get_associated_info_key (new_info, key, k_ref->type);
-          new_extra_contents = new_element (ET_NONE);
-          k->element = new_extra_contents;
+          new_extra_element = new_element (ET_NONE);
+          k->element = new_extra_element;
           for (j = 0; j < f->contents.number; j++)
             {
               ELEMENT *e = f->contents.list[j];
               if (!e && info->info[i].type == extra_directions)
                 {
-                  add_to_contents_as_array (new_extra_contents, 0);
+                  add_to_contents_as_array (new_extra_element, 0);
                 }
               else
                 {
                   k_copy = lookup_extra_by_index (e, "_copy", -1);
                   if (k_copy)
-                    add_to_contents_as_array (new_extra_contents,
+                    add_to_contents_as_array (new_extra_element,
                                               k_copy->element);
                   else
                     {
                       increase_ref_counter (e);
-                      add_to_contents_as_array (new_extra_contents, 0);
+                      add_to_contents_as_array (new_extra_element, 0);
                     }
                   copy_tree_internal (e, 0);
                 }
             }
+            break;
+          }
         default:
           break;
         }
@@ -196,7 +220,7 @@ associate_info_references (ASSOCIATED_INFO *info, 
ASSOCIATED_INFO *new_info)
       KEY_PAIR *k_ref = &info->info[i];
       char *key = k_ref->key;
       ELEMENT *f = k_ref->element;
-      ELEMENT *new_extra_contents;
+      ELEMENT *new_extra_element;
       int j;
 
       if (k_ref->type == extra_deleted)
@@ -225,16 +249,36 @@ associate_info_references (ASSOCIATED_INFO *info, 
ASSOCIATED_INFO *new_info)
             break;
           }
         case extra_contents:
+          {
+            KEY_PAIR *k = lookup_associated_info (new_info, key);
+            ELEMENT_LIST *new_extra_contents = k->list;
+            for (j = 0; j < k_ref->list->number; j++)
+              {
+                KEY_PAIR *k_copy;
+                ELEMENT *e = k_ref->list->list[j];
+                ELEMENT *new_e = new_extra_contents->list[j];
+                if (!new_e)
+                  {
+                    ELEMENT *new_ref = get_copy_ref (e);
+                    new_extra_contents->list[j] = new_ref;
+                  }
+
+                k_copy = lookup_extra_by_index (e, "_copy", -1);
+                if (k_copy)
+                  copy_extra_info (e, k_copy->element);
+              }
+              break;
+            }
         case extra_container:
         case extra_directions:
           {
             KEY_PAIR *k = lookup_associated_info (new_info, key);
-            new_extra_contents = k->element;
+            new_extra_element = k->element;
             for (j = 0; j < f->contents.number; j++)
               {
                 KEY_PAIR *k_copy;
                 ELEMENT *e = f->contents.list[j];
-                ELEMENT *new_e = new_extra_contents->contents.list[j];
+                ELEMENT *new_e = new_extra_element->contents.list[j];
                 if (!e && info->info[i].type == extra_directions)
                   {
                   }
@@ -243,7 +287,7 @@ associate_info_references (ASSOCIATED_INFO *info, 
ASSOCIATED_INFO *new_info)
                     if (!new_e)
                       {
                         ELEMENT *new_ref = get_copy_ref (e);
-                        new_extra_contents->contents.list[j] = new_ref;
+                        new_extra_element->contents.list[j] = new_ref;
                       }
 
                     k_copy = lookup_extra_by_index (e, "_copy", -1);
@@ -271,9 +315,9 @@ associate_info_references (ASSOCIATED_INFO *info, 
ASSOCIATED_INFO *new_info)
         case extra_misc_args:
           {
           int j;
-          new_extra_contents = new_element (ET_NONE);
+          new_extra_element = new_element (ET_NONE);
           KEY_PAIR *k = get_associated_info_key (new_info, key, k_ref->type);
-          k->element = new_extra_contents;
+          k->element = new_extra_element;
           for (j = 0; j < f->contents.number; j++)
             {
               ELEMENT *e = new_element (ET_NONE);
@@ -287,7 +331,7 @@ associate_info_references (ASSOCIATED_INFO *info, 
ASSOCIATED_INFO *new_info)
                   if (f->contents.list[j]->text.space > 0)
                     text_append (&e->text, f->contents.list[j]->text.text);
                 }
-              add_to_contents_as_array (new_extra_contents, e);
+              add_to_contents_as_array (new_extra_element, e);
             }
           break;
           }
@@ -760,13 +804,13 @@ normalized_entry_associated_internal_node (ELEMENT *entry,
 ELEMENT *
 first_menu_node (ELEMENT *node, LABEL_LIST *identifiers_target)
 {
-  ELEMENT *menus = lookup_extra_element (node, "menus");
+  ELEMENT_LIST *menus = lookup_extra_contents (node, "menus", 0);
   if (menus)
     {
       int i;
-      for (i = 0; i < menus->contents.number; i++)
+      for (i = 0; i < menus->number; i++)
         {
-          ELEMENT *menu = menus->contents.list[i];
+          ELEMENT *menu = menus->list[i];
           int j;
           for (j = 0; j < menu->contents.number; j++)
             {
diff --git a/tp/Texinfo/XS/main/output_unit.c b/tp/Texinfo/XS/main/output_unit.c
index a4fa71cefa..9be9d75c21 100644
--- a/tp/Texinfo/XS/main/output_unit.c
+++ b/tp/Texinfo/XS/main/output_unit.c
@@ -541,15 +541,15 @@ units_directions (OPTIONS *customization_information,
               int automatic_directions = (node->args.number <= 1);
               ELEMENT *associated_section = lookup_extra_element (node,
                                                    "associated_section");
-              ELEMENT *section_childs = 0;
+              ELEMENT_LIST *section_childs = 0;
               if (associated_section)
-                section_childs = lookup_extra_element (associated_section,
-                                                         "section_childs");
+                section_childs = lookup_extra_contents (associated_section,
+                                                        "section_childs", 0);
               if (automatic_directions
-                  && section_childs && section_childs->contents.number > 0)
+                  && section_childs && section_childs->number > 0)
                 {
                   directions[RUD_type_NodeForward]
-                   = section_childs->contents.list[0]->associated_unit;
+                   = section_childs->list[0]->associated_unit;
                 }
               else if (node_directions
                        && node_directions->contents.list[D_next])
@@ -641,7 +641,7 @@ units_directions (OPTIONS *customization_information,
       else
         {
           ELEMENT *up = section;
-          ELEMENT *up_section_childs;
+          ELEMENT_LIST *up_section_childs;
           int up_section_level;
           int status;
           enum directions d;
@@ -686,13 +686,13 @@ units_directions (OPTIONS *customization_information,
                 break;
             }
 
-          up_section_childs = lookup_extra_element (up, "section_childs");
+          up_section_childs = lookup_extra_contents (up, "section_childs", 0);
           if (status >= 0 && up_section_level < 1
               && up->cmd == CM_top && up_section_childs
-              && up_section_childs->contents.number > 0)
+              && up_section_childs->number > 0)
             {
               directions[RUD_type_FastForward]
-                = up_section_childs->contents.list[0]->associated_unit;
+                = up_section_childs->list[0]->associated_unit;
             }
           else
             {
diff --git a/tp/Texinfo/XS/main/tree.c b/tp/Texinfo/XS/main/tree.c
index cb1468fabe..799be9bd68 100644
--- a/tp/Texinfo/XS/main/tree.c
+++ b/tp/Texinfo/XS/main/tree.c
@@ -148,6 +148,8 @@ destroy_associated_info (ASSOCIATED_INFO *a)
           destroy_element_and_children (a->info[i].element);
           break;
         case extra_contents:
+          destroy_list (a->info[i].list);
+          break;
         case extra_container:
         case extra_directions:
           if (a->info[i].element)
diff --git a/tp/Texinfo/XS/main/tree_types.h b/tp/Texinfo/XS/main/tree_types.h
index 3bc6573d0b..392cfea5ec 100644
--- a/tp/Texinfo/XS/main/tree_types.h
+++ b/tp/Texinfo/XS/main/tree_types.h
@@ -29,7 +29,6 @@ enum extra_type {
    extra_contents,
    extra_container,
    extra_directions,
-   extra_text,
    extra_misc_args,
    extra_string,
    extra_integer,
@@ -113,22 +112,23 @@ enum relative_unit_direction_type {
 /* in main/output_unit.c */
 extern char *relative_unit_direction_name[];
 
+typedef struct ELEMENT_LIST {
+    struct ELEMENT **list;
+    size_t number;
+    size_t space;
+} ELEMENT_LIST;
+
 typedef struct KEY_PAIR {
     char *key;
     enum extra_type type;
     union {
       struct ELEMENT *element;
+      ELEMENT_LIST *list;
       char *string;
       long integer;
     };
 } KEY_PAIR;
 
-typedef struct ELEMENT_LIST {
-    struct ELEMENT **list;
-    size_t number;
-    size_t space;
-} ELEMENT_LIST;
-
 typedef struct SOURCE_INFO {
     int line_nr;
     char *file_name;
diff --git a/tp/Texinfo/XS/parsetexi/close.c b/tp/Texinfo/XS/parsetexi/close.c
index f19863ca53..4ed91e44cb 100644
--- a/tp/Texinfo/XS/parsetexi/close.c
+++ b/tp/Texinfo/XS/parsetexi/close.c
@@ -45,7 +45,7 @@ close_brace_command (ELEMENT *current,
                      int missing_brace)
 {
 
-  KEY_PAIR *k_delimiter;
+  char *delimiter;
 
   if (command_data(current->cmd).data == BRACE_context)
     {
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c 
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index 89b6b0f225..c2a428497f 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -941,8 +941,8 @@ handle_line_command (ELEMENT *current, char **line_inout,
               else if (parent->cmd == CM_quotation
                        || parent->cmd == CM_smallquotation)
                 {
-                  ELEMENT *e = lookup_extra_contents (parent, "authors", 1);
-                  add_to_contents_as_array (e, current);
+                  ELEMENT_LIST *l = lookup_extra_contents (parent, "authors", 
1);
+                  add_to_element_list (l, current);
                   add_extra_element (current, "quotation", parent);
                   found = 1; break;
                 }
@@ -1118,9 +1118,9 @@ handle_block_command (ELEMENT *current, char **line_inout,
                     line_warn ("@menu in invalid context");
                   else
                     {
-                      ELEMENT *e
+                      ELEMENT_LIST *l
                         = lookup_extra_contents (current_node, "menus", 1);
-                      add_to_contents_as_array (e, block);
+                      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 3063b996d6..6dd321c026 100644
--- a/tp/Texinfo/XS/structuring_transfo/structuring.c
+++ b/tp/Texinfo/XS/structuring_transfo/structuring.c
@@ -130,7 +130,7 @@ sectioning_structure (DOCUMENT *document)
           /* new command is below */
             {
               ELEMENT *section_directions = new_element (ET_NONE);
-              ELEMENT *section_childs = new_element (ET_NONE);
+              ELEMENT_LIST *section_childs = new_list ();
               if (level - prev_section_level > 1)
                 {
                   message_list_command_error (error_messages, content,
@@ -138,7 +138,7 @@ sectioning_structure (DOCUMENT *document)
                                  builtin_command_name (content->cmd));
                   level = prev_section_level + 1;
                 }
-              add_to_contents_as_array (section_childs, content);
+              add_to_element_list (section_childs, content);
               add_extra_contents (previous_section, "section_childs",
                                   section_childs);
               add_extra_directions (content, "section_directions",
@@ -227,10 +227,10 @@ sectioning_structure (DOCUMENT *document)
                   In that case the root level has to be updated because the
                   first 'part' just appeared, no direction to set.
                    */
-                  ELEMENT *sec_root_childs
-                    = lookup_extra_element (sec_root, "section_childs");
+                  ELEMENT_LIST *sec_root_childs
+                    = lookup_extra_contents (sec_root, "section_childs", 0);
                   add_extra_integer (sec_root, "section_level", level -1);
-                  add_to_contents_as_array (sec_root_childs, content);
+                  add_to_element_list (sec_root_childs, content);
                   number_top_level = level;
                   if (number_top_level == 0)
                     number_top_level = 1;
@@ -238,9 +238,10 @@ sectioning_structure (DOCUMENT *document)
               else
                 {
                   ELEMENT *section_directions = new_element (ET_NONE);
-                  ELEMENT *up_section_childs
-                    = lookup_extra_element (up, "section_childs");
-                  ELEMENT *prev = last_contents_child (up_section_childs);
+                  ELEMENT_LIST *up_section_childs
+                    = lookup_extra_contents (up, "section_childs", 0);
+                  ELEMENT *prev
+                    = up_section_childs->list[up_section_childs->number -1];
                   ELEMENT *prev_section_directions
                     = lookup_extra_directions (prev, "section_directions", 1);
                   add_extra_directions (content, "section_directions",
@@ -251,7 +252,7 @@ sectioning_structure (DOCUMENT *document)
                   section_directions->contents.list[D_prev] = prev;
 
                   prev_section_directions->contents.list[D_next] = content;
-                  add_to_contents_as_array (up_section_childs, content);
+                  add_to_element_list (up_section_childs, content);
                 }
               if (!(command_other_flags (content) & CF_unnumbered))
                 {
@@ -266,12 +267,12 @@ sectioning_structure (DOCUMENT *document)
         }
       else
         {
-          ELEMENT *sec_root_childs = new_element (ET_NONE);
+          ELEMENT_LIST *sec_root_childs = new_list ();
           sec_root = new_element (ET_NONE);
            /* first section determines the level of the root.  It is
               typically -1 when there is a @top. */
           add_extra_integer (sec_root, "section_level", level -1);
-          add_to_contents_as_array (sec_root_childs, content);
+          add_to_element_list (sec_root_childs, content);
           add_extra_contents (sec_root, "section_childs", sec_root_childs);
            /*
             in the tree as an out of tree element in extra */
@@ -454,14 +455,14 @@ get_node_node_childs_from_sectioning (ELEMENT *node)
   ELEMENT *associated_section = lookup_extra_element (node, 
"associated_section");
   if (associated_section)
     {
-      ELEMENT *section_childs = lookup_extra_element (associated_section,
-                                                      "section_childs");
+      ELEMENT_LIST *section_childs = lookup_extra_contents (associated_section,
+                                                          "section_childs", 0);
       if (section_childs)
         {
           int i;
-          for (i = 0; i < section_childs->contents.number; i++)
+          for (i = 0; i < section_childs->number; i++)
             {
-              ELEMENT *child = section_childs->contents.list[i];
+              ELEMENT *child = section_childs->list[i];
               ELEMENT *associated_node = lookup_extra_element (child,
                                                              
"associated_node");
               if (associated_node)
@@ -483,14 +484,14 @@ get_node_node_childs_from_sectioning (ELEMENT *node)
                   current = section_directions->contents.list[D_next];
                   if (current->cmd == CM_part)
                     {
-                      ELEMENT *section_childs = lookup_extra_element (current,
-                                                              
"section_childs");
+                      ELEMENT_LIST *section_childs
+                       = lookup_extra_contents (current, "section_childs", 0);
                       if (section_childs)
                         {
                           int i;
-                          for (i = 0; i < section_childs->contents.number; i++)
+                          for (i = 0; i < section_childs->number; i++)
                             {
-                              ELEMENT *child = 
section_childs->contents.list[i];
+                              ELEMENT *child = section_childs->list[i];
                               ELEMENT *associated_node
                                    = lookup_extra_element (child,
                                                            "associated_node");
@@ -604,7 +605,7 @@ check_nodes_are_referenced (DOCUMENT *document)
       int is_target = lookup_extra_integer (node, "is_target", &status);
       ELEMENT *node_directions = lookup_extra_element (node,
                                                     "node_directions");
-      ELEMENT *menus = lookup_extra_element (node, "menus");
+      ELEMENT_LIST *menus = lookup_extra_contents (node, "menus", 0);
 
       if (is_target)
         nr_nodes_to_find++;
@@ -626,9 +627,9 @@ check_nodes_are_referenced (DOCUMENT *document)
       if (menus)
         {
           int j;
-          for (j = 0; j < menus->contents.number; j++)
+          for (j = 0; j < menus->number; j++)
             {
-              ELEMENT *menu = menus->contents.list[j];
+              ELEMENT *menu = menus->list[j];
               int k;
               for (k = 0; k < menu->contents.number; k++)
                 {
@@ -821,25 +822,25 @@ set_menus_node_directions (DOCUMENT *document)
     {
       int j;
       ELEMENT *node = nodes_list->list[i];
-      ELEMENT *menus = lookup_extra_element (node, "menus");
+      ELEMENT_LIST *menus = lookup_extra_contents (node, "menus", 0);
 
       if (!menus)
         continue;
 
-      if (menus->contents.number > 1)
+      if (menus->number > 1)
         {
-          for (j = 1; j < menus->contents.number; j++)
+          for (j = 1; j < menus->number; j++)
             {
-               ELEMENT *menu = menus->contents.list[j];
+               ELEMENT *menu = menus->list[j];
                message_list_command_warn (error_messages,
                              menu, "multiple @%s",
                              builtin_command_name (menu->cmd));
             }
         }
 
-      for (j = 0; j < menus->contents.number; j++)
+      for (j = 0; j < menus->number; j++)
         {
-          ELEMENT *menu = menus->contents.list[j];
+          ELEMENT *menu = menus->list[j];
           ELEMENT *previous_node = 0;
           int k;
           for (k = 0; k < menu->contents.number; k++)
@@ -1047,7 +1048,7 @@ complete_node_tree_with_menus (DOCUMENT *document)
                                                   node_direction_section, d);
                       if (direction_associated_node)
                         {
-                          ELEMENT *menus = 0;
+                          ELEMENT_LIST *menus = 0;
                           ELEMENT *section_directions
                             = lookup_extra_element (node_direction_section,
                                                     "section_directions");
@@ -1060,11 +1061,11 @@ complete_node_tree_with_menus (DOCUMENT *document)
                                                             "associated_node");
                               if (up_node)
                                 menus
-                                  = lookup_extra_element (up_node, "menus");
+                                  = lookup_extra_contents (up_node, "menus", 
0);
                             }
 
                           if (menus
-                              && menus->contents.number > 0
+                              && menus->number > 0
                               && (!menu_directions
                                   || !menu_directions->contents.list[d]))
                             {
@@ -1233,7 +1234,8 @@ complete_node_tree_with_menus (DOCUMENT *document)
                                                           "manual_content");
               int is_target = lookup_extra_integer (node, "is_target",
                                                     &status);
-              ELEMENT *menus = lookup_extra_element (up_node, "menus");
+              ELEMENT_LIST *menus
+                   = lookup_extra_contents (up_node, "menus", 0);
 
               /* No check if node up is an external manual */
               if (!manual_content
@@ -1245,9 +1247,9 @@ complete_node_tree_with_menus (DOCUMENT *document)
                 {
                   int j;
                   int found = 0;
-                  for (j = 0; j < menus->contents.number; j++)
+                  for (j = 0; j < menus->number; j++)
                     {
-                      ELEMENT *menu = menus->contents.list[j];
+                      ELEMENT *menu = menus->list[j];
                       int k;
                       for (k = 0; k < menu->contents.number; k++)
                         {
@@ -1368,11 +1370,11 @@ nodes_tree (DOCUMENT *document)
               = lookup_extra_element (node, "associated_section");
             if (section)
               {
-                ELEMENT *section_childs
-                  = lookup_extra_element (section, "section_childs");
-                if (section_childs && section_childs->contents.number > 0)
+                ELEMENT_LIST *section_childs
+                  = lookup_extra_contents (section, "section_childs", 0);
+                if (section_childs && section_childs->number > 0)
                   {
-                    ELEMENT *first_sec = section_childs->contents.list[0];
+                    ELEMENT *first_sec = section_childs->list[0];
                     ELEMENT *top_node_section_child
                       = lookup_extra_element (first_sec, "associated_node");
                     if (top_node_section_child)
@@ -1806,12 +1808,12 @@ print_down_menus(ELEMENT *node, LABEL_LIST 
*identifiers_target,
                  int use_sections)
 {
   ELEMENT_LIST *master_menu_contents = new_list ();
-  ELEMENT *menus;
-  ELEMENT *node_menus = lookup_extra_element (node, "menus");
+  ELEMENT_LIST *menus;
+  ELEMENT_LIST *node_menus = lookup_extra_contents (node, "menus", 1);
   ELEMENT_LIST *node_children;
   int i;
 
-  if (node_menus && node_menus->contents.number > 0)
+  if (node_menus && node_menus->number > 0)
     menus = node_menus;
   else
     {
@@ -1819,8 +1821,8 @@ print_down_menus(ELEMENT *node, LABEL_LIST 
*identifiers_target,
       node_menus = 0;
       if (current_menu)
         {
-          menus = new_element (ET_NONE);
-          add_to_contents_as_array (menus, current_menu);
+          menus = new_list ();
+          add_to_element_list (menus, current_menu);
         }
       else
         return master_menu_contents;
@@ -1828,9 +1830,9 @@ print_down_menus(ELEMENT *node, LABEL_LIST 
*identifiers_target,
 
   node_children = new_list ();
 
-  for (i = 0; i < menus->contents.number; i++)
+  for (i = 0; i < menus->number; i++)
     {
-      ELEMENT *menu = menus->contents.list[i];
+      ELEMENT *menu = menus->list[i];
       int j;
       for (j = 0; j < menu->contents.number; j++)
         {
@@ -1902,25 +1904,25 @@ print_down_menus(ELEMENT *node, LABEL_LIST 
*identifiers_target,
   destroy_list (node_children);
 
   if (!node_menus)
-    destroy_element (menus);
+    destroy_list (menus);
 
   return master_menu_contents;
 }
 
 ELEMENT *
 new_master_menu (OPTIONS *options, LABEL_LIST *identifiers_target,
-                 ELEMENT *menus, int use_sections)
+                 ELEMENT_LIST *menus, int use_sections)
 {
   /*  only holds contents here, will be turned into a proper block
       in new_block_command */
   ELEMENT *master_menu = new_element (ET_NONE);
 
-  if (menus && menus->contents.number > 0)
+  if (menus && menus->number > 0)
     {
       int i;
-      for (i = 0; i < menus->contents.number; i++)
+      for (i = 0; i < menus->number; i++)
         {
-          ELEMENT *menu = menus->contents.list[i];
+          ELEMENT *menu = menus->list[i];
           int j;
           for (j = 0; j < menu->contents.number; j++)
             {
diff --git a/tp/Texinfo/XS/structuring_transfo/structuring.h 
b/tp/Texinfo/XS/structuring_transfo/structuring.h
index 6de4347f02..97cc7be30b 100644
--- a/tp/Texinfo/XS/structuring_transfo/structuring.h
+++ b/tp/Texinfo/XS/structuring_transfo/structuring.h
@@ -21,7 +21,7 @@ ELEMENT *new_node_menu_entry (ELEMENT *node, int 
use_sections);
 ELEMENT *new_complete_node_menu (ELEMENT *node, int use_sections);
 void new_block_command (ELEMENT *element, enum command_id cmd);
 ELEMENT *new_master_menu (OPTIONS *options, LABEL_LIST *identifiers_target,
-                          ELEMENT *menus, int use_sections);
+                          ELEMENT_LIST *menus, int use_sections);
 
 
 #endif
diff --git a/tp/Texinfo/XS/structuring_transfo/transformations.c 
b/tp/Texinfo/XS/structuring_transfo/transformations.c
index 5ba7913cdf..36c88dff92 100644
--- a/tp/Texinfo/XS/structuring_transfo/transformations.c
+++ b/tp/Texinfo/XS/structuring_transfo/transformations.c
@@ -745,17 +745,18 @@ reassociate_to_node (const char *type, ELEMENT *current, 
void *argument)
 
   if (current->cmd == CM_menu)
     {
-      ELEMENT *added_node_menus;
+      ELEMENT_LIST *added_node_menus;
       if (previous_node)
         {
-          ELEMENT *menus = lookup_extra_element (previous_node, "menus");
+          ELEMENT_LIST *menus
+            = lookup_extra_contents (previous_node, "menus", 0);
           int previous_idx = -1;
           if (menus)
             {
               int i;
-              for (i = 0; i < menus->contents.number; i++)
+              for (i = 0; i < menus->number; i++)
                 {
-                  if (menus->contents.list[i] == current)
+                  if (menus->list[i] == current)
                     {
                       previous_idx = i;
                       break;
@@ -768,18 +769,18 @@ reassociate_to_node (const char *type, ELEMENT *current, 
void *argument)
           else
             {
               /* removed element should be current */
-              remove_from_contents (menus, previous_idx);
-              if (menus->contents.number <= 0)
+              remove_from_element_list (menus, previous_idx);
+              if (menus->number <= 0)
                 {
                   KEY_PAIR *k = lookup_extra (previous_node, "menus");
                   k->key = "";
                   k->type = extra_deleted;
-                  destroy_element (menus);
+                  destroy_list (menus);
                 }
             }
         }
       added_node_menus = lookup_extra_contents (added_node, "menus", 1);
-      add_to_contents_as_array (added_node_menus, current);
+      add_to_element_list (added_node_menus, current);
     }
   else
     {
@@ -952,13 +953,13 @@ prepend_new_menu_in_node_section (ELEMENT * node, ELEMENT 
*section,
                                   ELEMENT *current_menu)
 {
   ELEMENT *empty_line = new_element (ET_empty_line);
-  ELEMENT *menus = lookup_extra_contents (node, "menus", 1);
+  ELEMENT_LIST *menus = lookup_extra_contents (node, "menus", 1);
 
   add_to_element_contents (section, current_menu);
   text_append (&empty_line->text, "\n");
   add_to_element_contents (section, empty_line);
 
-  add_to_contents_as_array (menus, current_menu);
+  add_to_element_list (menus, current_menu);
 }
 
 typedef struct EXISTING_ENTRY {
@@ -982,16 +983,16 @@ complete_node_menu (ELEMENT *node, int use_sections)
       ELEMENT *current_menu = 0;
 
       int i;
-      ELEMENT* menus = lookup_extra_element (node, "menus");
+      ELEMENT_LIST *menus = lookup_extra_contents (node, "menus", 0);
 
       if (menus)
         {
           existing_entries
            = malloc(existing_entries_space * sizeof (EXISTING_ENTRY));
 
-          for (i = 0; i < menus->contents.number; i++)
+          for (i = 0; i < menus->number; i++)
             {
-              ELEMENT *menu = menus->contents.list[i];
+              ELEMENT *menu = menus->list[i];
               int j;
               for (j = 0; j < menu->contents.number; j++)
                 {
@@ -1151,8 +1152,8 @@ complete_tree_nodes_missing_menu (ELEMENT *root, int 
use_sections)
   for (i = 0; i < non_automatic_nodes->number; i++)
     {
       ELEMENT *node = non_automatic_nodes->list[i];
-      ELEMENT *menus = lookup_extra_element (node, "menus");
-      if (!(menus && menus->contents.number > 0))
+      ELEMENT_LIST *menus = lookup_extra_contents (node, "menus", 0);
+      if (!(menus && menus->number > 0))
         {
           ELEMENT *section = lookup_extra_element (node, "associated_section");
           ELEMENT *current_menu = new_complete_node_menu (node, use_sections);
@@ -1174,7 +1175,7 @@ regenerate_master_menu (DOCUMENT *document, int 
use_sections)
   LABEL_LIST *identifiers_target = document->identifiers_target;
 
   ELEMENT *top_node = find_identifier_target (identifiers_target, "Top");
-  ELEMENT *menus;
+  ELEMENT_LIST *menus;
   ELEMENT *master_menu;
   ELEMENT *last_menu;
   ELEMENT *last_content;
@@ -1183,8 +1184,8 @@ regenerate_master_menu (DOCUMENT *document, int 
use_sections)
 
   if (top_node)
     {
-      menus = lookup_extra_element (top_node, "menus");
-      if (!menus || (menus->contents.number <= 0))
+      menus = lookup_extra_contents (top_node, "menus", 0);
+      if (!menus || (menus->number <= 0))
         return 0;
     }
   else
@@ -1197,10 +1198,10 @@ regenerate_master_menu (DOCUMENT *document, int 
use_sections)
   if (!master_menu)
     return 0;
 
-  for (i = 0; i < menus->contents.number; i++)
+  for (i = 0; i < menus->number; i++)
     {
       int detailmenu_index = 0;
-      ELEMENT *menu = menus->contents.list[i];
+      ELEMENT *menu = menus->list[i];
       for (detailmenu_index = 0; detailmenu_index < menu->contents.number;
            detailmenu_index++)
         {
@@ -1251,7 +1252,7 @@ regenerate_master_menu (DOCUMENT *document, int 
use_sections)
         }
     }
 
-  last_menu = last_contents_child (menus);
+  last_menu = menus->list[menus->number -1];
   index = last_menu->contents.number;
   last_content = last_contents_child (last_menu);
   if (last_content && last_content->cmd == CM_end)



reply via email to

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