texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Makefile.tres, tp/t/60macro.t (line_end_acce


From: Patrice Dumas
Subject: branch master updated: * tp/Makefile.tres, tp/t/60macro.t (line_end_accent_command_macro_call): add test for a command with braces expanded in a macro followed by end of line one line command.
Date: Fri, 28 Jul 2023 18:23:07 -0400

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

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new d086968499 * tp/Makefile.tres, tp/t/60macro.t 
(line_end_accent_command_macro_call): add test for a command with braces 
expanded in a macro followed by end of line one line command.
d086968499 is described below

commit d0869684990d318939d60e77cd6cff9c2a26da6e
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jul 29 00:22:37 2023 +0200

    * tp/Makefile.tres, tp/t/60macro.t
    (line_end_accent_command_macro_call): add test for a command with
    braces expanded in a macro followed by end of line one line command.
    
    * tp/Texinfo/Common.pm (modify_tree): error out if argument not
    defined or not a HASH.
---
 ChangeLog                                          |   9 +
 tp/Makefile.tres                                   |   1 +
 tp/Texinfo/Common.pm                               |   6 +-
 tp/Texinfo/ParserNonXS.pm                          |   6 +-
 tp/t/60macro.t                                     |  16 +
 .../macro/line_end_accent_command_macro_call.pl    | 368 +++++++++++++++++++++
 6 files changed, 403 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 69bab3aca7..6ab14bb02b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,15 @@
        * doc/texinfo.tex (\deftypeline): Read arguments correctly, in
        the same way as \deftypefn.
 
+2023-07-28  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Makefile.tres, tp/t/60macro.t
+       (line_end_accent_command_macro_call): add test for a command with
+       braces expanded in a macro followed by end of line one line command.
+
+       * tp/Texinfo/Common.pm (modify_tree): error out if argument not
+       defined or not a HASH.
+
 2023-07-28  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Common.pm (element_associated_processing_encoding):
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index d3ab682858..be210a4f7b 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -1291,6 +1291,7 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/macro/include_after_empty_line_arg.pl \
   t/results/macro/leading_spaces_no_ignore.pl \
   t/results/macro/line_after_recursive_call.pl \
+  t/results/macro/line_end_accent_command_macro_call.pl \
   t/results/macro/macro_after_paragraph.pl \
   t/results/macro/macro_alias_definfoenclose_defindex.pl \
   t/results/macro/macro_before_specific_line_command_args.pl \
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index c34a574c39..c8cb0f7d89 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -2146,8 +2146,10 @@ sub modify_tree($$;$)
   my $argument = shift;
   #print STDERR "modify_tree tree: $tree\n";
 
-  # TODO warn?
-  return undef if (!$tree or ref($tree) ne 'HASH');
+  if (!defined($tree) or ref($tree) ne 'HASH') {
+    cluck "tree ".(!defined($tree) ? 'UNDEF' : "not a hash: $tree");
+    return undef;
+  }
 
   if ($tree->{'args'}) {
     my @args = @{$tree->{'args'}};
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 62587a1011..98c115d5b7 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -6922,7 +6922,11 @@ sub _process_remaining_on_line($$$$)
           # the @-command and the argument if at the end of a
           # line or block @-command.
           if ($current->{'contents'}) {
-            # TODO specific case not tested
+            # this can only happen if the spaces gathered after the command
+            # before the braces were interrupted before the end of line, which
+            # can happen if there is a macro expansion that ends before the end
+            # of line.
+            # Tested in macro line_end_accent_command_macro_call
             _gather_spaces_after_cmd_before_arg($self, $current);
           }
           $current = $current->{'parent'};
diff --git a/tp/t/60macro.t b/tp/t/60macro.t
index bffc96316d..88957b3b7b 100644
--- a/tp/t/60macro.t
+++ b/tp/t/60macro.t
@@ -589,6 +589,22 @@ second: \b\
 
 @mycommand {@verb{: in }, verb :}, other, last}
 
+'],
+['line_end_accent_command_macro_call',
+'@macro expand {}
+@center A @ringaccent 
+@end macro
+
+@expand{}
+ a
+
+@macro nospace {}
+@center B @ringaccent
+@end macro
+
+@nospace{}
+ A
+
 '],
 # tests a source mark on empty line after paragraph transfer in a focused way
 ['macro_after_paragraph',
diff --git a/tp/t/results/macro/line_end_accent_command_macro_call.pl 
b/tp/t/results/macro/line_end_accent_command_macro_call.pl
new file mode 100644
index 0000000000..827df3859e
--- /dev/null
+++ b/tp/t/results/macro/line_end_accent_command_macro_call.pl
@@ -0,0 +1,368 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted %result_converted_errors 
+   %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'line_end_accent_command_macro_call'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'args' => [
+            {
+              'text' => 'expand',
+              'type' => 'macro_name'
+            }
+          ],
+          'cmdname' => 'macro',
+          'contents' => [
+            {
+              'text' => '@center A @ringaccent 
+',
+              'type' => 'raw'
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => 'macro'
+                    }
+                  ],
+                  'info' => {
+                    'spaces_after_argument' => {
+                      'text' => '
+'
+                    }
+                  },
+                  'type' => 'line_arg'
+                }
+              ],
+              'cmdname' => 'end',
+              'extra' => {
+                'text_arg' => 'macro'
+              },
+              'info' => {
+                'spaces_before_argument' => {
+                  'text' => ' '
+                }
+              },
+              'source_info' => {
+                'file_name' => '',
+                'line_nr' => 3,
+                'macro' => ''
+              }
+            }
+          ],
+          'info' => {
+            'arg_line' => ' expand {}
+'
+          },
+          'source_info' => {
+            'file_name' => '',
+            'line_nr' => 1,
+            'macro' => ''
+          }
+        },
+        {
+          'source_marks' => [
+            {
+              'counter' => 1,
+              'element' => {
+                'args' => [
+                  {
+                    'type' => 'brace_command_arg'
+                  }
+                ],
+                'extra' => {
+                  'name' => 'expand'
+                },
+                'type' => 'macro_call'
+              },
+              'position' => 1,
+              'sourcemark_type' => 'macro_expansion',
+              'status' => 'start'
+            }
+          ],
+          'text' => '
+',
+          'type' => 'empty_line'
+        },
+        {
+          'args' => [
+            {
+              'contents' => [
+                {
+                  'text' => 'A '
+                },
+                {
+                  'cmdname' => 'ringaccent',
+                  'info' => {
+                    'spaces_after_cmd_before_arg' => {
+                      'source_marks' => [
+                        {
+                          'counter' => 1,
+                          'position' => 1,
+                          'sourcemark_type' => 'macro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
+                      'text' => ' '
+                    }
+                  },
+                  'source_info' => {
+                    'file_name' => '',
+                    'line_nr' => 5,
+                    'macro' => 'expand'
+                  }
+                }
+              ],
+              'info' => {
+                'spaces_after_argument' => {
+                  'text' => '
+'
+                }
+              },
+              'type' => 'line_arg'
+            }
+          ],
+          'cmdname' => 'center',
+          'info' => {
+            'spaces_before_argument' => {
+              'text' => ' '
+            }
+          },
+          'source_info' => {
+            'file_name' => '',
+            'line_nr' => 5,
+            'macro' => 'expand'
+          }
+        },
+        {
+          'text' => ' ',
+          'type' => 'spaces_before_paragraph'
+        },
+        {
+          'contents' => [
+            {
+              'text' => 'a
+'
+            }
+          ],
+          'type' => 'paragraph'
+        },
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        },
+        {
+          'args' => [
+            {
+              'text' => 'nospace',
+              'type' => 'macro_name'
+            }
+          ],
+          'cmdname' => 'macro',
+          'contents' => [
+            {
+              'text' => '@center B @ringaccent
+',
+              'type' => 'raw'
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => 'macro'
+                    }
+                  ],
+                  'info' => {
+                    'spaces_after_argument' => {
+                      'text' => '
+'
+                    }
+                  },
+                  'type' => 'line_arg'
+                }
+              ],
+              'cmdname' => 'end',
+              'extra' => {
+                'text_arg' => 'macro'
+              },
+              'info' => {
+                'spaces_before_argument' => {
+                  'text' => ' '
+                }
+              },
+              'source_info' => {
+                'file_name' => '',
+                'line_nr' => 10,
+                'macro' => ''
+              }
+            }
+          ],
+          'info' => {
+            'arg_line' => ' nospace {}
+'
+          },
+          'source_info' => {
+            'file_name' => '',
+            'line_nr' => 8,
+            'macro' => ''
+          }
+        },
+        {
+          'source_marks' => [
+            {
+              'counter' => 2,
+              'element' => {
+                'args' => [
+                  {
+                    'type' => 'brace_command_arg'
+                  }
+                ],
+                'extra' => {
+                  'name' => 'nospace'
+                },
+                'type' => 'macro_call'
+              },
+              'position' => 1,
+              'sourcemark_type' => 'macro_expansion',
+              'status' => 'start'
+            }
+          ],
+          'text' => '
+',
+          'type' => 'empty_line'
+        },
+        {
+          'args' => [
+            {
+              'contents' => [
+                {
+                  'text' => 'B '
+                },
+                {
+                  'cmdname' => 'ringaccent',
+                  'info' => {
+                    'spaces_after_cmd_before_arg' => {
+                      'source_marks' => [
+                        {
+                          'counter' => 2,
+                          'sourcemark_type' => 'macro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
+                      'text' => ''
+                    }
+                  },
+                  'source_info' => {
+                    'file_name' => '',
+                    'line_nr' => 12,
+                    'macro' => 'nospace'
+                  }
+                }
+              ],
+              'info' => {
+                'spaces_after_argument' => {
+                  'text' => '
+'
+                }
+              },
+              'type' => 'line_arg'
+            }
+          ],
+          'cmdname' => 'center',
+          'info' => {
+            'spaces_before_argument' => {
+              'text' => ' '
+            }
+          },
+          'source_info' => {
+            'file_name' => '',
+            'line_nr' => 12,
+            'macro' => 'nospace'
+          }
+        },
+        {
+          'text' => ' ',
+          'type' => 'spaces_before_paragraph'
+        },
+        {
+          'contents' => [
+            {
+              'text' => 'A
+'
+            }
+          ],
+          'type' => 'paragraph'
+        },
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        }
+      ],
+      'type' => 'before_node_section'
+    }
+  ],
+  'type' => 'document_root'
+};
+
+$result_texis{'line_end_accent_command_macro_call'} = '@macro expand {}
+@center A @ringaccent 
+@end macro
+
+@center A @ringaccent 
+ a
+
+@macro nospace {}
+@center B @ringaccent
+@end macro
+
+@center B @ringaccent
+ A
+
+';
+
+
+$result_texts{'line_end_accent_command_macro_call'} = '
+A *
+a
+
+
+B *
+A
+
+';
+
+$result_errors{'line_end_accent_command_macro_call'} = [
+  {
+    'error_line' => 'warning: command `@ringaccent\' must not be followed by 
new line
+',
+    'file_name' => '',
+    'line_nr' => 5,
+    'macro' => '',
+    'text' => 'command `@ringaccent\' must not be followed by new line',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: command `@ringaccent\' must not be followed by 
new line
+',
+    'file_name' => '',
+    'line_nr' => 12,
+    'macro' => '',
+    'text' => 'command `@ringaccent\' must not be followed by new line',
+    'type' => 'warning'
+  }
+];
+
+
+$result_floats{'line_end_accent_command_macro_call'} = {};
+
+
+1;



reply via email to

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