texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp Texinfo/Parser.pm t/results/macro/ma...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Parser.pm t/results/macro/ma...
Date: Sun, 10 Oct 2010 18:22:13 +0000

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

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

Log message:
        Remove everything after the @end if* lines.
        Don't take a whole line from the processed text, instead take what 
comes.
        Handle better void lines at the end of the document.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.58&r2=1.59
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/macro/macro_in_ifset_end_in_arg.pl?cvsroot=texinfo&r1=1.3&r2=1.4

Patches:
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -b -r1.58 -r1.59
--- Texinfo/Parser.pm   10 Oct 2010 00:59:22 -0000      1.58
+++ Texinfo/Parser.pm   10 Oct 2010 18:22:13 -0000      1.59
@@ -1300,8 +1300,8 @@
   
  NEXT_LINE:
   while (@$text) {
-    my $line;
-    ($line, $line_nr) = _new_line($text, $lines_array);
+    my $line = shift @$text;
+    $line_nr = shift @$lines_array;
 
     if ($self->{'debug'}) {
       $current->{'HERE !!!!'} = 1; # marks where we are in the tree
@@ -1381,8 +1381,12 @@
           }
           $current = $current->{'parent'};
           # don't store ignored @if*
-          pop @{$current->{'contents'}} 
-            if ($block_commands{$end_command} eq 'conditional');
+          if ($block_commands{$end_command} eq 'conditional') {
+            pop @{$current->{'contents'}};
+            # Ignore until end of line
+            ($line, $line_nr) = _new_line($text, $lines_array)
+               if (@$text);
+          }
           last unless ($line =~ /\S/);
         } else {
           push @{$current->{'contents'}}, 
@@ -1417,12 +1421,21 @@
         }
       }
 
-      if ($line eq '' and scalar(@$text))
+      # this mostly happens in the following cases:
+      #   after the expansion of a user defined macro
+      #   after a protection of @\n in @def* line
+      while ($line eq '')
       {
-        print STDERR "END OF TEXT not at end of line/text\n" 
+        print STDERR "END OF TEXT not at end of line (remaining 
".scalar(@$text).")\n" 
           if ($self->{'debug'});
+        if (scalar(@$text)) {
         $line = shift @$text;
         $line_nr = shift @$lines_array;
+        } else {
+          $current = _end_line($self, $current, $line_nr);
+          $current = _end_block_command($self, $current, $line_nr);
+          return $root;
+        }
       }
       # handle user defined macros before anything else since
       # their expansion may lead to changes in the line
@@ -1678,6 +1691,9 @@
               if (@{$self->{'conditionals_stack'}} 
                   and $self->{'conditionals_stack'}->[-1] eq $end_command) {
                 pop @{$self->{'conditionals_stack'}};
+                # Ignore until end of line
+                ($line, $line_nr) = _new_line($text, $lines_array)
+                  if (@$text);
               } else {
                 _line_error ($self, 
                   sprintf($self->__("Unmatched `%c%s'"), 
@@ -2041,7 +2057,7 @@
         if ($line =~ s/^(\n)//) {
           $current = _merge_text ($self, $current, $1);
         } else {
-          die if (scalar(@$text));
+          die "BUG: text remaining (@$text) and `$line'\n" if (scalar(@$text));
         }
         $current = _end_line($self, $current, $line_nr);
         last;

Index: t/results/macro/macro_in_ifset_end_in_arg.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/macro/macro_in_ifset_end_in_arg.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- t/results/macro/macro_in_ifset_end_in_arg.pl        9 Oct 2010 17:51:37 
-0000       1.3
+++ t/results/macro/macro_in_ifset_end_in_arg.pl        10 Oct 2010 18:22:13 
-0000      1.4
@@ -44,8 +44,7 @@
     {
       'parent' => {},
       'text' => '
-',
-      'type' => 'empty_line'
+'
     },
     {
       'contents' => [



reply via email to

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