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/xta...


From: Patrice Dumas
Subject: texinfo/tp TODO Texinfo/Parser.pm t/results/xta...
Date: Mon, 19 Sep 2011 19:10:20 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/09/19 19:10:20

Modified files:
        tp             : TODO 
        tp/Texinfo     : Parser.pm 
        tp/t/results/xtable: text_between_item_itemx.pl 

Log message:
        Check that @itemx is only preceded by @item and no text.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/TODO?cvsroot=texinfo&r1=1.170&r2=1.171
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.296&r2=1.297
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/xtable/text_between_item_itemx.pl?cvsroot=texinfo&r1=1.6&r2=1.7

Patches:
Index: TODO
===================================================================
RCS file: /sources/texinfo/texinfo/tp/TODO,v
retrieving revision 1.170
retrieving revision 1.171
diff -u -b -r1.170 -r1.171
--- TODO        18 Sep 2011 17:58:17 -0000      1.170
+++ TODO        19 Sep 2011 19:10:20 -0000      1.171
@@ -36,9 +36,6 @@
 
 remove _*directions('This' and replace with new API. Done?
 
-There should be an error message (report by Tom Tromey) in 
-t/results/xtable/text_between_item_itemx.pl
-
 There should be a warning when beginning a table item with @itemx.
 
 There should be a warning with something like

Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.296
retrieving revision 1.297
diff -u -b -r1.296 -r1.297
--- Texinfo/Parser.pm   19 Sep 2011 17:53:44 -0000      1.296
+++ Texinfo/Parser.pm   19 Sep 2011 19:10:20 -0000      1.297
@@ -38,21 +38,19 @@
 
 # to detect if an encoding may be used to open the files
 use Encode;
-# for i18n
-use Locale::Messages;
 
 #use POSIX qw(setlocale LC_ALL LC_CTYPE LC_MESSAGES);
 
 # commands definitions
 use Texinfo::Common;
-# Error reporting and counting, and translation of strings.
+# Error reporting and counting, translation of strings.
 use Texinfo::Report;
 
-# to expand file names in @include
+# to expand file names in @include and similar @-commands
 use Texinfo::Convert::Text;
 # to normalize node name, anchor, float arg, listoffloats and first *ref 
argument.
 use Texinfo::Convert::NodeNameNormalization;
-# in error messages
+# in error messages, and for macro body expansion
 use Texinfo::Convert::Texinfo;
 
 require Exporter;
@@ -1126,11 +1124,40 @@
   return $current;
 }
 
+# check that there are no text holding environment (currently
+# checking only paragraphs and preformatted) in contents
+sub _check_no_text($)
+{
+  my $current = shift;
+  my $after_paragraph = 0;
+  foreach my $content (@{$current->{'contents'}}) {
+    if ($content->{'type'} and $content->{'type'} eq 'paragraph') {
+      $after_paragraph = 1;
+      last;
+    } elsif ($content->{'type'} and $content->{'type'} eq 'preformatted') {
+      foreach my $preformatted_content (@{$content->{'contents'}}) {
+        if ((defined($preformatted_content->{'text'}) 
+             and $preformatted_content->{'text'} =~ /\S/)
+            or ($preformatted_content->{'cmdname'} 
+                and ($preformatted_content->{'cmdname'} ne 'c'
+                     and $preformatted_content->{'cmdname'} ne 'comment'))) {
+          $after_paragraph = 1;
+          last;
+        }
+      }
+      last if ($after_paragraph);
+    }
+  }
+  return $after_paragraph;
+}
+
 # put everything after the last @item/@itemx in an item_table type container.
-sub _gather_previous_item($;$)
+sub _gather_previous_item($$;$$)
 {
+  my $self = shift;
   my $current = shift;
   my $next_command = shift;
+  my $line_nr = shift;
 
   # nothing to do in that case.
   if ($current->{'contents'}->[-1]->{'type'}
@@ -1199,7 +1226,10 @@
     }
   } else {
   # FIXME keep table_item with only comments and/or empty lines?
-  # FIXME check that there are only comments, empty preformatted and indices
+    my $after_paragraph = _check_no_text($table_gathered);
+    if ($after_paragraph) {
+      $self->line_error($self->__("address@hidden must follow 
address@hidden"), $line_nr);
+    }
     if (scalar(@{$table_gathered->{'contents'}})) {
       push @{$current->{'contents'}}, $table_gathered;
       $table_gathered->{'parent'} = $current;
@@ -1305,7 +1335,7 @@
     #    if (!$end->{'cmdname'} or $end->{'cmdname'} ne 'end');
     #}
     if (@{$current->{'contents'}}) {
-      _gather_previous_item($current);
+      $self->_gather_previous_item($current);
     }
     #push @{$current->{'contents'}}, $end if ($end);
   }
@@ -3779,7 +3809,7 @@
                 if ($command eq 'item' or $command eq 'itemx') {
                   print STDERR "ITEM_LINE\n" if ($self->{'DEBUG'});
                   $current = $parent;
-                  _gather_previous_item($current, $command);
+                  $self->_gather_previous_item($current, $command, $line_nr);
                   $misc = { 'cmdname' => $command, 'parent' => $current };
                   push @{$current->{'contents'}}, $misc;
                   $line_arg = 1;
@@ -3851,25 +3881,7 @@
                 $base_command =~ s/x$//;
                 # check that the def*x is first after @def*, no paragraph
                 # in-between.
-                my $after_paragraph = 0;
-                foreach my $content (@{$current->{'contents'}}) {
-                  if ($content->{'type'} and $content->{'type'} eq 
'paragraph') {
-                    $after_paragraph = 1;
-                    last;
-                  } elsif ($content->{'type'} and $content->{'type'} eq 
'preformatted') {
-                    foreach my $preformatted_content 
(@{$content->{'contents'}}) {
-                      if ((defined($preformatted_content->{'text'}) 
-                           and $preformatted_content->{'text'} =~ /\S/)
-                          or ($preformatted_content->{'cmdname'} 
-                              and ($preformatted_content->{'cmdname'} ne 'c'
-                                   and $preformatted_content->{'cmdname'} ne 
'comment'))) {
-                        $after_paragraph = 1;
-                        last;
-                      }
-                    }
-                    last if ($after_paragraph);
-                  }
-                }
+                my $after_paragraph = _check_no_text ($current);
                 push @{$self->{'context_stack'}}, 'def';
                 $current->{'contents'}->[-1]->{'type'} = 'def_line';
                 $current->{'contents'}->[-1]->{'extra'} = 

Index: t/results/xtable/text_between_item_itemx.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/xtable/text_between_item_itemx.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- t/results/xtable/text_between_item_itemx.pl 3 Sep 2011 10:29:44 -0000       
1.6
+++ t/results/xtable/text_between_item_itemx.pl 19 Sep 2011 19:10:20 -0000      
1.7
@@ -255,7 +255,17 @@
 in itemx
 ';
 
-$result_errors{'text_between_item_itemx'} = [];
+$result_errors{'text_between_item_itemx'} = [
+  {
+    'error_line' => ':4: @itemx must follow @item
+',
+    'file_name' => '',
+    'line_nr' => 4,
+    'macro' => '',
+    'text' => '@itemx must follow @item',
+    'type' => 'error'
+  }
+];
 
 
 1;



reply via email to

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