texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: @ref, @xref, @pxref nesting checking.


From: Gavin D. Smith
Subject: branch master updated: @ref, @xref, @pxref nesting checking.
Date: Sat, 21 Jan 2023 20:48:02 -0500

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 ed02b79400 @ref, @xref, @pxref nesting checking.
ed02b79400 is described below

commit ed02b7940064ac274a60272919bf81aa7dac9503
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun Jan 22 01:47:54 2023 +0000

    @ref, @xref, @pxref nesting checking.
    
    * tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting_context):
    Check if one cross-reference command is used inside another.
    
    * tp/Texinfo/XS/parsetexi/separator.c (handle_open_brace)
    Increment nesting_context.xref for cross-reference command.
    * tp/Texinfo/XS/parsetexi/separator.c (handle_close_brace),
    Decrement nesting_context.xref for cross-reference command.
    
    * tp/Texinfo/XS/parsetexi/close.c (close_all_style_commands):
    Add a FIXME comment saying that nesting_context is not touched.
---
 ChangeLog                                   | 19 +++++++++++++++++--
 tp/Texinfo/XS/parsetexi/close.c             |  2 ++
 tp/Texinfo/XS/parsetexi/context_stack.h     |  1 +
 tp/Texinfo/XS/parsetexi/parser.c            |  6 ++++++
 tp/Texinfo/XS/parsetexi/separator.c         |  5 +++++
 tp/t/results/invalid_nestings/ref_in_ref.pl |  9 +++++++++
 6 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e903a88eb9..450d830e84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2023-01-22  Gavin Smith  <gavinsmith0123@gmail.com>
+
+       @ref, @xref, @pxref nesting checking.
+
+       * tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting_context):
+       Check if one cross-reference command is used inside another.
+
+       * tp/Texinfo/XS/parsetexi/separator.c (handle_open_brace)
+       Increment nesting_context.xref for cross-reference command.
+       * tp/Texinfo/XS/parsetexi/separator.c (handle_close_brace),
+       Decrement nesting_context.xref for cross-reference command.
+
+       * tp/Texinfo/XS/parsetexi/close.c (close_all_style_commands):
+       Add a FIXME comment saying that nesting_context is not touched.
+
 2023-01-22  Gavin Smith  <gavinsmith0123@gmail.com>
 
        @caption, @shortcaption nesting checking
@@ -6,10 +21,10 @@
        Check if @caption or @shortcaption is called in caption context.
 
        * tp/Texinfo/XS/parsetexi/separator.c (handle_open_brace)
-       Increment nesting_context.footnote for @caption, @shortcaption.
+       Increment nesting_context.caption for @caption, @shortcaption.
        * tp/Texinfo/XS/parsetexi/close.c (close_current),
        * tp/Texinfo/XS/parsetexi/separator.c (handle_close_brace),
-       Decrement nesting_context.footnote for @caption, @shortcaption.
+       Decrement nesting_context.caption for @caption, @shortcaption.
 
 2023-01-21  Gavin Smith <gavinsmith0123@gmail.com>
 
diff --git a/tp/Texinfo/XS/parsetexi/close.c b/tp/Texinfo/XS/parsetexi/close.c
index ff47ba88e4..e4df60b60e 100644
--- a/tp/Texinfo/XS/parsetexi/close.c
+++ b/tp/Texinfo/XS/parsetexi/close.c
@@ -76,6 +76,8 @@ close_all_style_commands (ELEMENT *current,
     current = close_brace_command (current->parent,
                                    closed_block_command, interrupting_command);
 
+  /* FIXME: we don't touch nesting_context here which may lead to erroneous
+     warnings. */
   return current;
 }
 
diff --git a/tp/Texinfo/XS/parsetexi/context_stack.h 
b/tp/Texinfo/XS/parsetexi/context_stack.h
index cb92746455..6bed3b23d6 100644
--- a/tp/Texinfo/XS/parsetexi/context_stack.h
+++ b/tp/Texinfo/XS/parsetexi/context_stack.h
@@ -57,6 +57,7 @@ void reset_region_stack (void);
 typedef struct {
     int footnote;
     int caption;
+    int xref;
 } NESTING_CONTEXT;
 
 extern NESTING_CONTEXT nesting_context;
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index e22951fb0a..1aaf3f860c 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -1152,6 +1152,12 @@ check_valid_nesting_context (enum command_id cmd)
       line_warn ("@%s should not appear anywhere inside caption",
         command_name(cmd));
     }
+  else if ((command_data(cmd).flags & CF_ref) && nesting_context.xref > 0)
+    {
+      line_warn
+        ("@%s should not appear anywhere inside cross-reference",
+         command_name(cmd));
+    }
 
   if (invalid_context)
     {
diff --git a/tp/Texinfo/XS/parsetexi/separator.c 
b/tp/Texinfo/XS/parsetexi/separator.c
index 33e7a163e1..f5f5518157 100644
--- a/tp/Texinfo/XS/parsetexi/separator.c
+++ b/tp/Texinfo/XS/parsetexi/separator.c
@@ -155,6 +155,10 @@ handle_open_brace (ELEMENT *current, char **line_inout)
               if (command == CM_inlineraw)
                 push_context (ct_inlineraw, command);
             }
+          if (command_data(command).flags & CF_ref)
+            {
+              nesting_context.xref++;
+            }
         }
       debug ("OPENED");
     }
@@ -292,6 +296,7 @@ handle_close_brace (ELEMENT *current, char **line_inout)
       else if (command_data(closed_command).flags & CF_ref)
         {
           ELEMENT *ref = current->parent;
+          nesting_context.xref--;
           if (ref->args.number > 0)
             {
               if ((closed_command == CM_inforef
diff --git a/tp/t/results/invalid_nestings/ref_in_ref.pl 
b/tp/t/results/invalid_nestings/ref_in_ref.pl
index 4a1ae9040e..c73eab99fb 100644
--- a/tp/t/results/invalid_nestings/ref_in_ref.pl
+++ b/tp/t/results/invalid_nestings/ref_in_ref.pl
@@ -149,6 +149,15 @@ $result_errors{'ref_in_ref'} = [
     'text' => '@ref should not appear in @ref',
     'type' => 'warning'
   },
+  {
+    'error_line' => 'warning: @ref should not appear anywhere inside 
cross-reference
+',
+    'file_name' => '',
+    'line_nr' => 2,
+    'macro' => '',
+    'text' => '@ref should not appear anywhere inside cross-reference',
+    'type' => 'warning'
+  },
   {
     'error_line' => 'warning: @ref to `@ref{Top}\', different from node name 
`Top\'
 ',



reply via email to

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