texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp Texinfo/Common.pm Texinfo/Parser.pm ...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Common.pm Texinfo/Parser.pm ...
Date: Fri, 30 Dec 2011 18:49:43 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/12/30 18:49:43

Modified files:
        tp/Texinfo     : Common.pm Parser.pm 
        tp/t           : 55conditionals.t 
        tp/t/results/conditionals: empty_ifset_in_ifset_set.pl 

Log message:
        Add a new preformatted context where matching lone brace commands are
        accepted.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Common.pm?cvsroot=texinfo&r1=1.109&r2=1.110
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.344&r2=1.345
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/55conditionals.t?cvsroot=texinfo&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/conditionals/empty_ifset_in_ifset_set.pl?cvsroot=texinfo&r1=1.5&r2=1.6

Patches:
Index: Texinfo/Common.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Common.pm,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -b -r1.109 -r1.110
--- Texinfo/Common.pm   29 Dec 2011 23:24:49 -0000      1.109
+++ Texinfo/Common.pm   30 Dec 2011 18:49:42 -0000      1.110
@@ -599,10 +599,16 @@
   $preformatted_commands{$preformatted_command} = 1;
 }
 
-our %raw_commands;
 our @out_formats = ('html', 'tex', 'xml', 'docbook');
+our %preformatted_raw_commands;
+foreach my $preformatted_raw_command(@out_formats) {
+#  $block_commands{$preformatted_raw_command} = 0;
+#  $preformatted_raw_commands{$preformatted_raw_command} = 1;
+}
+
+our %raw_commands;
 # macro/rmacro are special
-foreach my $raw_command (@out_formats, 'verbatim', 
+foreach my $raw_command ('verbatim', @out_formats,
                          'ignore', 'macro', 'rmacro') {
   $block_commands{$raw_command} = 'raw';
   $raw_commands{$raw_command} = 1;

Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.344
retrieving revision 1.345
diff -u -b -r1.344 -r1.345
--- Texinfo/Parser.pm   27 Dec 2011 22:29:27 -0000      1.344
+++ Texinfo/Parser.pm   30 Dec 2011 18:49:42 -0000      1.345
@@ -246,6 +246,7 @@
 my %def_aliases               = %Texinfo::Common::def_aliases;
 my %menu_commands             = %Texinfo::Common::menu_commands;
 my %preformatted_commands     = %Texinfo::Common::preformatted_commands;
+my %preformatted_raw_commands = %Texinfo::Common::preformatted_raw_commands;
 my %item_container_commands   = %Texinfo::Common::item_container_commands;
 my %item_line_commands        = %Texinfo::Common::item_line_commands;
 my %deprecated_commands       = %Texinfo::Common::deprecated_commands;
@@ -443,10 +444,15 @@
 $full_line_commands{'center'} = 1;
 $full_line_commands{'exdent'} = 1;
 
+my @preformatted_contexts = ('preformatted', 'rawpreformatted');
+my %preformatted_contexts;
+foreach my $preformatted_context (@preformatted_contexts) {
+  $preformatted_contexts{$preformatted_context} = 1;
+}
 # contexts on the context_stack stack where empty line don't trigger
 # paragraph
 my %no_paragraph_contexts;
-foreach my $no_paragraph_context ('math', 'preformatted', 'menu', 'def') {
+foreach my $no_paragraph_context ('math', 'menu', @preformatted_contexts, 
'def') {
   $no_paragraph_contexts{$no_paragraph_context} = 1;
 };
 
@@ -1041,9 +1047,10 @@
 {
   my $self = shift;
   my $current = shift;
-  if ($self->{'context_stack'}->[-1] eq 'preformatted') {
+  if ($preformatted_contexts{$self->{'context_stack'}->[-1]}) {
     push @{$current->{'contents'}}, 
-          { 'type' => 'preformatted', 'parent' => $current, 'contents' => [] };
+          { 'type' => $self->{'context_stack'}->[-1], 
+            'parent' => $current, 'contents' => [] };
     $current = $current->{'contents'}->[-1];
     print STDERR "PREFORMATTED\n" if ($self->{'DEBUG'});
   }
@@ -1159,7 +1166,7 @@
   my $line_nr = shift;
 
   $current = _close_all_style_commands($self, $current, $line_nr);
-  if ($current->{'type'} and $current->{'type'} eq 'preformatted') {
+  if ($current->{'type'} and $preformatted_contexts{$current->{'type'}}) {
     print STDERR "CLOSE PREFORMATTED\n" if ($self->{'DEBUG'});
     # completly remove void preformatted contexts
     if (address@hidden>{'contents'}}) {
@@ -1181,7 +1188,7 @@
     if ($content->{'type'} and $content->{'type'} eq 'paragraph') {
       $after_paragraph = 1;
       last;
-    } elsif ($content->{'type'} and $content->{'type'} eq 'preformatted') {
+    } elsif ($content->{'type'} and 
$preformatted_contexts{$content->{'type'}}) {
       foreach my $preformatted_content (@{$content->{'contents'}}) {
         if ((defined($preformatted_content->{'text'}) 
              and $preformatted_content->{'text'} =~ /\S/)
@@ -1472,7 +1479,7 @@
   my $self = shift;
   my $current = shift;
   my $line_nr = shift;
-  my $command = shift;
+  my $closed_command = shift;
   my $interrupting_command = shift;
 
   if ($current->{'cmdname'}) {
@@ -1481,9 +1488,9 @@
          if (exists $context_brace_commands{$current->{'cmdname'}});
       $current = _close_brace_command($self, $current, $line_nr);
     } elsif (exists($block_commands{$current->{'cmdname'}})) {
-      if (defined($command)) {
+      if (defined($closed_command)) {
         $self->line_error(sprintf($self->__("address@hidden' expected `%s', 
but saw `%s'"),
-                                   $current->{'cmdname'}, $command), $line_nr);
+                                   $current->{'cmdname'}, $closed_command), 
$line_nr);
       } elsif ($interrupting_command) {
         $self->line_error(sprintf($self->__("address@hidden seen before 
address@hidden %s"),
                                   $interrupting_command, 
$current->{'cmdname'}),
@@ -1534,7 +1541,7 @@
   return $current;
 }
 
-# a command arg means closing until that command is found.
+# a closed_command arg means closing until that command is found.
 # no command arg means closing until the root or a root_command
 # is found.
 sub _close_commands($$$;$$)
@@ -1542,15 +1549,15 @@
   my $self = shift;
   my $current = shift;
   my $line_nr = shift;
-  my $command = shift;
+  my $closed_command = shift;
   my $interrupting_command = shift;;
 
   $current = _end_paragraph($self, $current, $line_nr);
   $current = _end_preformatted($self, $current, $line_nr);
 
         # stop if the command is found
-  while (!($command and $current->{'cmdname'}
-           and $current->{'cmdname'} eq $command) 
+  while (!($closed_command and $current->{'cmdname'}
+           and $current->{'cmdname'} eq $closed_command) 
          # stop if at the root
          and $current->{'parent'}
      # stop if in a root command 
@@ -1561,38 +1568,42 @@
      # completly closing the stack.
          and !($current->{'cmdname'}
                and ($root_commands{$current->{'cmdname'}}
-                    or ($command and $current->{'parent'}->{'cmdname'}
+                    or ($closed_command and $current->{'parent'}->{'cmdname'}
                        and 
$context_brace_commands{$current->{'parent'}->{'cmdname'}})))){
     $self->_close_command_cleanup($current);
-    $current = $self->_close_current($current, $line_nr, $command, 
+    $current = $self->_close_current($current, $line_nr, $closed_command, 
                                      $interrupting_command);
   }
 
-  my $closed_command;
-  if ($command and $current->{'cmdname'} 
-    and $current->{'cmdname'} eq $command) {
+  my $closed_element;
+  if ($closed_command and $current->{'cmdname'} 
+    and $current->{'cmdname'} eq $closed_command) {
     if ($preformatted_commands{$current->{'cmdname'}}) {
       my $context = pop @{$self->{'context_stack'}};
-      warn "BUG: closing preformatted_command $command wrong context $context"
+      warn "BUG: closing preformatted_command $closed_command wrong context 
$context"
         if ($context ne 'preformatted');
+    } elsif ($preformatted_raw_commands{$current->{'cmdname'}}) {
+      my $context = pop @{$self->{'context_stack'}};
+      warn "BUG: closing preformatted_command $closed_command wrong context 
$context"
+        if ($context ne 'rawpreformatted');
     } elsif ($menu_commands{$current->{'cmdname'}}) {
       my $context = pop @{$self->{'context_stack'}};
       # may be in menu, but context is preformatted if in a preformatted too.
-      warn "BUG: closing menu command $command wrong context $context"
+      warn "BUG: closing menu command $closed_command wrong context $context"
         if ($context ne 'menu' and $context ne 'preformatted');
     }
     #print STDERR "close context $context for $current->{'cmdname'}\n"
     #  if ($self->{'DEBUG'});
     pop @{$self->{'regions_stack'}} 
        if ($region_commands{$current->{'cmdname'}});
-    $closed_command = $current;
+    $closed_element = $current;
     #$self->_close_command_cleanup($current);
     $current = $current->{'parent'};
-  } elsif ($command) {
+  } elsif ($closed_command) {
     $self->line_error (sprintf($self->__("Unmatched `%c%s'"), 
-                       ord('@'), "end $command"), $line_nr);
+                       ord('@'), "end $closed_command"), $line_nr);
   }
-  return ($closed_command, $current);
+  return ($closed_element, $current);
 }
 
 # begin paragraph if needed.  If not try to merge with the previous
@@ -2429,7 +2440,6 @@
         }
         $arg = undef;
       }
-      #push @{$self->{'context_stack'}}, 'preformatted';
       # MENU_COMMENT open
       $menu_entry = undef;
     } else {
@@ -2723,10 +2733,6 @@
                                        'parent' => $current,
                                        'contents' => [] };
       $current = $current->{'contents'}->[-1];
-     #push @{$current->{'contents'}}, {'type' => 'preformatted',
-     #                                 'parent' => $current,
-     #                                 'contents' => [] };
-     #$current = $current->{'contents'}->[-1];
       print STDERR "MENU_COMMENT OPEN\n" if ($self->{'DEBUG'});
       push @{$self->{'context_stack'}}, 'preformatted';
     }
@@ -3055,7 +3061,7 @@
     # empty line after a @menu or before a preformatted. Reparent to the menu
     # or other format
     if ($current->{'type'}
-        and $current->{'type'} eq 'preformatted') {
+        and $preformatted_contexts{$current->{'type'}}) {
       my $parent = $current->{'parent'};
       if ($parent->{'type'} and $parent->{'type'} eq 'menu_comment'
           and scalar(@{$parent->{'contents'}}) == 1) {
@@ -4225,8 +4231,11 @@
             $current = $current->{'contents'}->[-1];
 
             if ($block_arg_commands{$command}) {
-              push @{$self->{'context_stack'}}, 'preformatted' 
-                if ($preformatted_commands{$command});
+              if ($preformatted_commands{$command}) {
+                push @{$self->{'context_stack'}}, 'preformatted';
+              } elsif ($preformatted_raw_commands{$command}) {
+                push @{$self->{'context_stack'}}, 'rawpreformatted';
+              }
               if ($region_commands{$command}) {
                 if (@{$self->{'regions_stack'}}) {
                   $self->line_error (sprintf($self->__("Region %s inside 
region %s is not allowed"),
@@ -4418,7 +4427,8 @@
                  'text' => '' };
             print STDERR "BRACKETED in def/multitable\n" if ($self->{'DEBUG'});
 
-          } elsif ($self->{'context_stack'}->[-1] eq 'math') {
+          } elsif ($self->{'context_stack'}->[-1] eq 'math'
+                   or $self->{'context_stack'}->[-1] eq 'rawpreformatted') {
             push @{$current->{'contents'}},
                  { 'type' => 'bracketed', 'contents' => [],
                    'parent' => $current, 'line_nr' => $line_nr };

Index: t/55conditionals.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/55conditionals.t,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- t/55conditionals.t  15 Oct 2011 15:57:06 -0000      1.13
+++ t/55conditionals.t  30 Dec 2011 18:49:43 -0000      1.14
@@ -139,9 +139,9 @@
 ['empty_ifset_in_ifset_no_set',
 '
 @ifset notset
address@hidden
address@hidden
 @ifset
address@hidden html
address@hidden verbatim
 @end ifset
 '],
 ['ifclear_in_ifset',
@@ -219,9 +219,9 @@
 @set notset
 
 @ifset notset
address@hidden
address@hidden
 @ifset
address@hidden html
address@hidden verbatim
 @end ifset
 '],
 ['macro_in_ifset',

Index: t/results/conditionals/empty_ifset_in_ifset_set.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/conditionals/empty_ifset_in_ifset_set.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- t/results/conditionals/empty_ifset_in_ifset_set.pl  26 Sep 2011 17:15:47 
-0000      1.5
+++ t/results/conditionals/empty_ifset_in_ifset_set.pl  30 Dec 2011 18:49:43 
-0000      1.6
@@ -40,7 +40,7 @@
       'type' => 'empty_line'
     },
     {
-      'cmdname' => 'html',
+      'cmdname' => 'verbatim',
       'contents' => [
         {
           'extra' => {
@@ -53,14 +53,9 @@
         },
         {
           'parent' => {},
-          'text' => '@ifset',
-          'type' => 'raw'
-        },
-        {
-          'parent' => {},
-          'text' => '
+          'text' => '@ifset
 ',
-          'type' => 'last_raw_newline'
+          'type' => 'raw'
         }
       ],
       'line_nr' => {
@@ -90,7 +85,6 @@
 
$result_trees{'empty_ifset_in_ifset_set'}{'contents'}[3]{'contents'}[0]{'extra'}{'command'}
 = $result_trees{'empty_ifset_in_ifset_set'}{'contents'}[3];
 
$result_trees{'empty_ifset_in_ifset_set'}{'contents'}[3]{'contents'}[0]{'parent'}
 = $result_trees{'empty_ifset_in_ifset_set'}{'contents'}[3];
 
$result_trees{'empty_ifset_in_ifset_set'}{'contents'}[3]{'contents'}[1]{'parent'}
 = $result_trees{'empty_ifset_in_ifset_set'}{'contents'}[3];
-$result_trees{'empty_ifset_in_ifset_set'}{'contents'}[3]{'contents'}[2]{'parent'}
 = $result_trees{'empty_ifset_in_ifset_set'}{'contents'}[3];
 $result_trees{'empty_ifset_in_ifset_set'}{'contents'}[3]{'parent'} = 
$result_trees{'empty_ifset_in_ifset_set'};
 $result_trees{'empty_ifset_in_ifset_set'}{'contents'}[4]{'extra'}{'command'} = 
$result_trees{'empty_ifset_in_ifset_set'}{'contents'}[3];
 $result_trees{'empty_ifset_in_ifset_set'}{'contents'}[4]{'parent'} = 
$result_trees{'empty_ifset_in_ifset_set'};
@@ -98,14 +92,15 @@
 $result_texis{'empty_ifset_in_ifset_set'} = '
 @set notset
 
address@hidden
address@hidden
 @ifset
address@hidden html
address@hidden verbatim
 ';
 
 
 $result_texts{'empty_ifset_in_ifset_set'} = '
 
address@hidden
 ';
 
 $result_errors{'empty_ifset_in_ifset_set'} = [];



reply via email to

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