texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: Check for missing menu entries before structure c


From: Gavin D. Smith
Subject: branch master updated: Check for missing menu entries before structure check
Date: Thu, 05 Jun 2025 13:27:00 -0400

This is an automated email from the git hooks/post-receive script.

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new a347d4032a Check for missing menu entries before structure check
a347d4032a is described below

commit a347d4032aec9f805155645ac192eff168993910
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Thu Jun 5 18:26:47 2025 +0100

    Check for missing menu entries before structure check
    
    * tta/C/structuring_transfo/structuring.c (check_node_tree_menu_structure),
    * tta/perl/Texinfo/Structuring.pm (check_node_tree_menu_structure):
    Move check for missing menu entries (controlled by CHECK_MISSING_MENU_ENTRY)
    before structure check (controlled by CHECK_NORMAL_MENU_STRUCTURE).
---
 ChangeLog                                          |   9 ++
 tta/C/structuring_transfo/structuring.c            | 162 +++++++++++----------
 tta/perl/Texinfo/Structuring.pm                    |  83 ++++++-----
 .../moresectioning/lowered_subsubsection.pl        |  14 +-
 tta/perl/t/results/sectioning/menutextorder.pl     |  14 +-
 .../t/results/sectioning/nodename_parentheses.pl   |  14 +-
 6 files changed, 158 insertions(+), 138 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6d6f3c62eb..03c933aeb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-06-05  Gavin Smith <gavinsmith0123@gmail.com>
+
+       Check for missing menu entries before structure check
+
+       * tta/C/structuring_transfo/structuring.c 
(check_node_tree_menu_structure),
+       * tta/perl/Texinfo/Structuring.pm (check_node_tree_menu_structure):
+       Move check for missing menu entries (controlled by 
CHECK_MISSING_MENU_ENTRY)
+       before structure check (controlled by CHECK_NORMAL_MENU_STRUCTURE).
+
 2025-06-04  Patrice Dumas  <pertusus@free.fr>
 
        * tta/perl/Texinfo/ManipulateTree.pm (_print_text_element)
diff --git a/tta/C/structuring_transfo/structuring.c 
b/tta/C/structuring_transfo/structuring.c
index 737e324ada..d42b3cab96 100644
--- a/tta/C/structuring_transfo/structuring.c
+++ b/tta/C/structuring_transfo/structuring.c
@@ -1101,16 +1101,93 @@ check_node_tree_menu_structure (DOCUMENT *document)
   if (nodes_list->number < 1)
     return;
 
+  /* check for node up / menu up mismatch */
+  if ((!options)
+      || options->CHECK_MISSING_MENU_ENTRY.o.integer > 0)
+    for (i = 0; i < nodes_list->number; i++)
+      {
+        NODE_RELATIONS *node_relations = nodes_list->list[i];
+        ELEMENT *node = (ELEMENT *)node_relations->element;
+        const ELEMENT * const *node_directions
+                         = node_relations->node_directions;
+
+        const ELEMENT *up_node = 0;
+        if (node_directions && node_directions[D_up])
+          up_node = node_directions[D_up];
+        if (up_node)
+          {
+            const ELEMENT *manual_content = lookup_extra_container (up_node,
+                                                     AI_key_manual_content);
+            int is_target = (node->flags & EF_is_target);
+
+            /* No check if node up is an external manual */
+            if (!manual_content
+          /* no check for a redundant node, the node registered in the menu
+             was the main equivalent node */
+                && is_target)
+              {
+                int status;
+                size_t up_node_number
+                  = lookup_extra_integer (up_node,
+                                          AI_key_node_number, &status);
+                const NODE_RELATIONS *up_node_relations
+                  = nodes_list->list[up_node_number -1];
+                const CONST_ELEMENT_LIST *menus = up_node_relations->menus;
+                int found = 0;
+                /* check only if there are menus */
+                if (menus)
+                  {
+                    size_t j;
+                    for (j = 0; j < menus->number; j++)
+                      {
+                        const ELEMENT *menu = menus->list[j];
+                        size_t k;
+                        for (k = 0; k < menu->e.c->contents.number; k++)
+                          {
+                            const ELEMENT *menu_content = 
menu->e.c->contents.list[k];
+                            if (menu_content->type == ET_menu_entry)
+                              {
+                                const ELEMENT *menu_node
+                                  = normalized_entry_associated_internal_node (
+                                                           menu_content,
+                                                            
identifiers_target);
+                                if (menu_node == node)
+                                  {
+                                    found = 1;
+                                    break;
+                                  }
+                              }
+                          }
+                        if (found)
+                          break;
+                      }
+                    if (!found)
+                      {
+                        char *up_texi = target_element_to_texi_label (up_node);
+                        char *node_texi = target_element_to_texi_label (node);
+                        message_list_command_warn (error_messages,
+                           (options && options->DEBUG.o.integer > 0),
+                                up_node, 0,
+         "node `%s' lacks menu item for `%s' despite being its Up target",
+                                up_texi, node_texi);
+                        free (up_texi);
+                        free (node_texi);
+                      }
+                  }
+              }
+          }
+      }
+
   /* Node-by-node structure checking. */
-  for (i = 0; i < nodes_list->number; i++)
+  if (!options
+      || options->CHECK_NORMAL_MENU_STRUCTURE.o.integer > 0)
     {
-      NODE_RELATIONS *node_relations = nodes_list->list[i];
-      ELEMENT *node = (ELEMENT *)node_relations->element;
-      const ELEMENT * const *node_directions
-                       = node_relations->node_directions;
-      if (!options
-          || options->CHECK_NORMAL_MENU_STRUCTURE.o.integer > 0)
+      for (i = 0; i < nodes_list->number; i++)
         {
+          NODE_RELATIONS *node_relations = nodes_list->list[i];
+          ELEMENT *node = (ELEMENT *)node_relations->element;
+          const ELEMENT * const *node_directions
+                           = node_relations->node_directions;
           const char *normalized = lookup_extra_string (node, 
AI_key_normalized);
           if (!strcmp (normalized, "Top"))
             continue;
@@ -1278,78 +1355,7 @@ check_node_tree_menu_structure (DOCUMENT *document)
                   }
               }
         }
-      /* check for node up / menu up mismatch */
-      if ((!options)
-          || options->CHECK_MISSING_MENU_ENTRY.o.integer > 0)
-        {
-          const ELEMENT *up_node = 0;
-          if (node_directions && node_directions[D_up])
-            up_node = node_directions[D_up];
-          if (up_node)
-            {
-              const ELEMENT *manual_content = lookup_extra_container (up_node,
-                                                       AI_key_manual_content);
-              int is_target = (node->flags & EF_is_target);
-
-              /* No check if node up is an external manual */
-              if (!manual_content
-            /* no check for a redundant node, the node registered in the menu
-               was the main equivalent node */
-                  && is_target)
-                {
-                  int status;
-                  size_t up_node_number
-                    = lookup_extra_integer (up_node,
-                                            AI_key_node_number, &status);
-                  const NODE_RELATIONS *up_node_relations
-                    = nodes_list->list[up_node_number -1];
-                  const CONST_ELEMENT_LIST *menus = up_node_relations->menus;
-                  int found = 0;
-                  /* check only if there are menus */
-                  if (menus)
-                    {
-                      size_t j;
-                      for (j = 0; j < menus->number; j++)
-                        {
-                          const ELEMENT *menu = menus->list[j];
-                          size_t k;
-                          for (k = 0; k < menu->e.c->contents.number; k++)
-                            {
-                              const ELEMENT *menu_content = 
menu->e.c->contents.list[k];
-                              if (menu_content->type == ET_menu_entry)
-                                {
-                                  const ELEMENT *menu_node
-                                    = 
normalized_entry_associated_internal_node (
-                                                             menu_content,
-                                                              
identifiers_target);
-                                  if (menu_node == node)
-                                    {
-                                      found = 1;
-                                      break;
-                                    }
-                                }
-                            }
-                          if (found)
-                            break;
-                        }
-                      if (!found)
-                        {
-                          char *up_texi = target_element_to_texi_label 
(up_node);
-                          char *node_texi = target_element_to_texi_label 
(node);
-                          message_list_command_warn (error_messages,
-                             (options && options->DEBUG.o.integer > 0),
-                                  up_node, 0,
-           "node `%s' lacks menu item for `%s' despite being its Up target",
-                                  up_texi, node_texi);
-                          free (up_texi);
-                          free (node_texi);
-                        }
-                    }
-                }
-            }
-        }
     }
-
 }
 
 /* As mentioned in the manual, the node next pointer for the Top
diff --git a/tta/perl/Texinfo/Structuring.pm b/tta/perl/Texinfo/Structuring.pm
index 6ffbe6a826..b05f81b99a 100644
--- a/tta/perl/Texinfo/Structuring.pm
+++ b/tta/perl/Texinfo/Structuring.pm
@@ -771,12 +771,52 @@ sub check_node_tree_menu_structure($)
 
   my %cached_menu_nodes;
 
+  # check for node up / menu up mismatch
+  if ($customization_information->get_conf('CHECK_MISSING_MENU_ENTRY')) {
+    foreach my $node_relations (@{$nodes_list}) {
+      my $node = $node_relations->{'element'};
+      my $node_directions = $node_relations->{'node_directions'};
+
+      my $up_node;
+      if ($node_directions
+          and $node_directions->{'up'}) {
+        $up_node = $node_directions->{'up'};
+      }
+      if ($up_node
+          # No check if node up is an external manual
+          and not $up_node->{'extra'}->{'manual_content'}
+          # no check for a redundant node, the node registered in the menu
+          # was the main equivalent node
+          and $node->{'extra'}->{'is_target'}) {
+        my $up_node_relations
+          = $nodes_list->[$up_node->{'extra'}->{'node_number'} -1];
+
+        # check only if there are menus
+        if ($up_node_relations->{'menus'}) {
+          if (!$cached_menu_nodes{$up_node}) {
+            $cached_menu_nodes{$up_node} = {};
+            _register_menu_node_targets($identifier_target, $up_node_relations,
+                                        $cached_menu_nodes{$up_node});
+          }
+          if (!$cached_menu_nodes{$up_node}->{$node}) {
+            $registrar->line_warn(sprintf(
+               __("node `%s' lacks menu item for `%s' despite being its Up 
target"),
+               target_element_to_texi_label($up_node),
+               target_element_to_texi_label($node)),
+                                $up_node->{'source_info'}, 0,
+                                $customization_information->get_conf('DEBUG'));
+          }
+        }
+      }
+    }
+  }
+
   # Node-by-node structure checking
-  foreach my $node_relations (@{$nodes_list}) {
-    my $node = $node_relations->{'element'};
-    my $node_directions = $node_relations->{'node_directions'};
+  if ($customization_information->get_conf('CHECK_NORMAL_MENU_STRUCTURE')) {
+    foreach my $node_relations (@{$nodes_list}) {
+      my $node = $node_relations->{'element'};
+      my $node_directions = $node_relations->{'node_directions'};
 
-    if ($customization_information->get_conf('CHECK_NORMAL_MENU_STRUCTURE')) {
       next if $node->{'extra'}->{'normalized'} eq 'Top';
 
       my $menu_directions = $node_relations->{'menu_directions'};
@@ -886,41 +926,6 @@ sub check_node_tree_menu_structure($)
         }
       }
     }
-
-    # check for node up / menu up mismatch
-    if ($customization_information->get_conf('CHECK_MISSING_MENU_ENTRY')) {
-      my $up_node;
-      if ($node_directions
-          and $node_directions->{'up'}) {
-        $up_node = $node_directions->{'up'};
-      }
-      if ($up_node
-          # No check if node up is an external manual
-          and not $up_node->{'extra'}->{'manual_content'}
-          # no check for a redundant node, the node registered in the menu
-          # was the main equivalent node
-          and $node->{'extra'}->{'is_target'}) {
-        my $up_node_relations
-          = $nodes_list->[$up_node->{'extra'}->{'node_number'} -1];
-
-        # check only if there are menus
-        if ($up_node_relations->{'menus'}) {
-          if (!$cached_menu_nodes{$up_node}) {
-            $cached_menu_nodes{$up_node} = {};
-            _register_menu_node_targets($identifier_target, $up_node_relations,
-                                        $cached_menu_nodes{$up_node});
-          }
-          if (!$cached_menu_nodes{$up_node}->{$node}) {
-            $registrar->line_warn(sprintf(
-               __("node `%s' lacks menu item for `%s' despite being its Up 
target"),
-               target_element_to_texi_label($up_node),
-               target_element_to_texi_label($node)),
-                                $up_node->{'source_info'}, 0,
-                                $customization_information->get_conf('DEBUG'));
-          }
-        }
-      }
-    }
   }
 }
 
diff --git a/tta/perl/t/results/moresectioning/lowered_subsubsection.pl 
b/tta/perl/t/results/moresectioning/lowered_subsubsection.pl
index 766c5f4c71..b8491a119d 100644
--- a/tta/perl/t/results/moresectioning/lowered_subsubsection.pl
+++ b/tta/perl/t/results/moresectioning/lowered_subsubsection.pl
@@ -458,6 +458,13 @@ $result_texts{'lowered_subsubsection'} = '
 ';
 
 $result_errors{'lowered_subsubsection'} = [
+  {
+    'error_line' => 'warning: node `Subsection\' lacks menu item for `Lowered 
subsubsection\' despite being its Up target
+',
+    'line_nr' => 22,
+    'text' => 'node `Subsection\' lacks menu item for `Lowered subsubsection\' 
despite being its Up target',
+    'type' => 'warning'
+  },
   {
     'error_line' => 'warning: node next for `Lowered subsec\' is `Lowered 
subsubsection\' in sectioning but not in menu
 ',
@@ -478,13 +485,6 @@ $result_errors{'lowered_subsubsection'} = [
     'line_nr' => 41,
     'text' => 'node up for `Lowered subsubsection\' is `Subsection\' in 
sectioning but `Lowered subsec\' in menu',
     'type' => 'warning'
-  },
-  {
-    'error_line' => 'warning: node `Subsection\' lacks menu item for `Lowered 
subsubsection\' despite being its Up target
-',
-    'line_nr' => 22,
-    'text' => 'node `Subsection\' lacks menu item for `Lowered subsubsection\' 
despite being its Up target',
-    'type' => 'warning'
   }
 ];
 
diff --git a/tta/perl/t/results/sectioning/menutextorder.pl 
b/tta/perl/t/results/sectioning/menutextorder.pl
index 499753c479..6a9fe5d7d5 100644
--- a/tta/perl/t/results/sectioning/menutextorder.pl
+++ b/tta/perl/t/results/sectioning/menutextorder.pl
@@ -405,6 +405,13 @@ $result_texts{'menutextorder'} = '* foo::
 ';
 
 $result_errors{'menutextorder'} = [
+  {
+    'error_line' => 'warning: node `bar\' lacks menu item for `onesub1\' 
despite being its Up target
+',
+    'line_nr' => 6,
+    'text' => 'node `bar\' lacks menu item for `onesub1\' despite being its Up 
target',
+    'type' => 'warning'
+  },
   {
     'error_line' => 'warning: node next for `onesub1\' is `onesub2\' in 
sectioning but not in menu
 ',
@@ -419,13 +426,6 @@ $result_errors{'menutextorder'} = [
     'text' => 'node up for `onesub1\' is `bar\' in sectioning but not in menu',
     'type' => 'warning'
   },
-  {
-    'error_line' => 'warning: node `bar\' lacks menu item for `onesub1\' 
despite being its Up target
-',
-    'line_nr' => 6,
-    'text' => 'node `bar\' lacks menu item for `onesub1\' despite being its Up 
target',
-    'type' => 'warning'
-  },
   {
     'error_line' => 'warning: node prev for `onesub2\' is `onesub1\' in 
sectioning but not in menu
 ',
diff --git a/tta/perl/t/results/sectioning/nodename_parentheses.pl 
b/tta/perl/t/results/sectioning/nodename_parentheses.pl
index 4f8bee45fe..00fd559318 100644
--- a/tta/perl/t/results/sectioning/nodename_parentheses.pl
+++ b/tta/perl/t/results/sectioning/nodename_parentheses.pl
@@ -292,6 +292,13 @@ $result_errors{'nodename_parentheses'} = [
     'text' => 'syntax for an external node used for `(manual)anchor\'',
     'type' => 'error'
   },
+  {
+    'error_line' => 'warning: node `Top\' lacks menu item for `(manual)node\' 
despite being its Up target
+',
+    'line_nr' => 1,
+    'text' => 'node `Top\' lacks menu item for `(manual)node\' despite being 
its Up target',
+    'type' => 'warning'
+  },
   {
     'error_line' => 'warning: node prev for `(manual)node\' is `Other node\' 
in sectioning but not in menu
 ',
@@ -305,13 +312,6 @@ $result_errors{'nodename_parentheses'} = [
     'line_nr' => 22,
     'text' => 'node up for `(manual)node\' is `Top\' in sectioning but not in 
menu',
     'type' => 'warning'
-  },
-  {
-    'error_line' => 'warning: node `Top\' lacks menu item for `(manual)node\' 
despite being its Up target
-',
-    'line_nr' => 1,
-    'text' => 'node `Top\' lacks menu item for `(manual)node\' despite being 
its Up target',
-    'type' => 'warning'
   }
 ];
 



reply via email to

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