texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp TODO Texinfo/Parser.pm t/results/mac...


From: Patrice Dumas
Subject: texinfo/tp TODO Texinfo/Parser.pm t/results/mac...
Date: Thu, 07 Oct 2010 07:22:42 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        10/10/07 07:22:42

Modified files:
        tp             : TODO 
        tp/Texinfo     : Parser.pm 
        tp/t/results/macro: too_much_args.pl 

Log message:
        Error when a user defined macro is called with too much args.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/TODO?cvsroot=texinfo&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.49&r2=1.50
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/macro/too_much_args.pl?cvsroot=texinfo&r1=1.1&r2=1.2

Patches:
Index: TODO
===================================================================
RCS file: /sources/texinfo/texinfo/tp/TODO,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- TODO        4 Oct 2010 07:02:40 -0000       1.7
+++ TODO        7 Oct 2010 07:22:42 -0000       1.8
@@ -13,8 +13,6 @@
 
 test invalid, especially commands not closed/bad nesting
 test root_commands, like nodes and sections
-values and user defined macro expansion in line @-commands, line
address@hidden argument checking.
 
 Test @set with an argument but no space following it. In ifset tests.
 

Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- Texinfo/Parser.pm   6 Oct 2010 22:26:12 -0000       1.49
+++ Texinfo/Parser.pm   7 Oct 2010 07:22:42 -0000       1.50
@@ -916,6 +916,7 @@
   my $arguments = [ '' ];
   my $arg_nr = 0;
   my $args_total = scalar(@{$macro->{'args'}}) -1;
+  my $name = $macro->{'args'}->[0]->{'text'};
 
   my $line_nr_orig = $line_nr;
 
@@ -937,11 +938,20 @@
           print STDERR "MACRO ARG: $separator\n" if ($self->{'debug'});
         }
       } elsif ($separator eq ',') {
-        if (scalar(@$arguments) < $args_total and $braces_level == 1) {
+        if ($braces_level == 1) {
+          if (scalar(@$arguments) < $args_total) {
           push @$arguments, '';
           $line =~ s/^\s*//;
           print STDERR "MACRO NEW ARG\n" if ($self->{'debug'});
         } else {
+            # implicit quoting when there is one argument.
+            if ($args_total != 1) {
+              _line_error ($self, sprintf($self->__("Macro `%s' called with 
too many args"), 
+                                $name), $line_nr);
+            }
+            $arguments->[-1] .= ',';
+          }
+        } else {
           $arguments->[-1] .= ',';
         }
       } elsif ($separator eq '}') {
@@ -960,11 +970,15 @@
         ($line, $line_nr) = _new_line($text, $lines_array);
       } else {
         _line_error ($self, sprintf($self->__("address@hidden missing close 
brace"), 
-           $macro->{'args'}->[0]->{'text'}), $line_nr_orig);
+           $name), $line_nr_orig);
         return ($arguments, "\n", $line_nr);
       }
     }
   }
+  if ($args_total == 0 and $arguments->[0] =~ /\S/) {
+    _line_error ($self, sprintf($self->__("Macro `%s' declared without 
argument called with an argument"), 
+                                $name), $line_nr);
+  }
   print STDERR "END MACRO ARGS EXPANSION(".scalar(@$arguments)."): ".
                   join("|\n", @$arguments) ."|\n" if ($self->{'debug'});
   return ($arguments, $line, $line_nr);

Index: t/results/macro/too_much_args.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/macro/too_much_args.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- t/results/macro/too_much_args.pl    3 Oct 2010 11:51:37 -0000       1.1
+++ t/results/macro/too_much_args.pl    7 Oct 2010 07:22:42 -0000       1.2
@@ -92,6 +92,16 @@
 second arg: two, three.
 ';
 
-$result_errors{'too_much_args'} = [];
+$result_errors{'too_much_args'} = [
+  {
+    'error_line' => ':6: Macro `twoargs\' called with too many args
+',
+    'file_name' => '',
+    'line_nr' => 6,
+    'macro' => '',
+    'text' => 'Macro `twoargs\' called with too many args',
+    'type' => 'error'
+  }
+];
 
 



reply via email to

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