[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp Texinfo/Parser.pm t/60macro.t t/resu...
From: |
Patrice Dumas |
Subject: |
texinfo/tp Texinfo/Parser.pm t/60macro.t t/resu... |
Date: |
Sat, 15 Oct 2011 19:52:47 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 11/10/15 19:52:47
Modified files:
tp/Texinfo : Parser.pm
tp/t : 60macro.t
Added files:
tp/t/results/macro: macro_with_error_at_end_line_after_macro.pl
Log message:
Use more systematically line number associated with command and not
the current line number.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.315&r2=1.316
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/60macro.t?cvsroot=texinfo&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/macro/macro_with_error_at_end_line_after_macro.pl?cvsroot=texinfo&rev=1.1
Patches:
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.315
retrieving revision 1.316
diff -u -b -r1.315 -r1.316
--- Texinfo/Parser.pm 15 Oct 2011 16:11:14 -0000 1.315
+++ Texinfo/Parser.pm 15 Oct 2011 19:52:46 -0000 1.316
@@ -1039,6 +1039,42 @@
return $current;
}
+sub _command_warn($$$$;@)
+{
+ my $self = shift;
+ my $current = shift;
+ my $line_nr = shift;
+ my $message = shift;
+
+ if ($current->{'line_nr'}) {
+ $line_nr = $current->{'line_nr'};
+ }
+ if (@_) {
+ $self->line_warn(sprintf($message, @_), $line_nr);
+ } else {
+ $self->line_warn($message, $line_nr);
+ }
+}
+
+sub _command_error($$$$;@)
+{
+ my $self = shift;
+ my $current = shift;
+ my $line_nr = shift;
+ my $message = shift;
+
+ # use the beginning of the @-command for the error message
+ # line number if available. FIXME currently not done for regular brace
commands
+ if ($current->{'line_nr'}) {
+ $line_nr = $current->{'line_nr'};
+ }
+ if (@_) {
+ $self->line_error(sprintf($message, @_), $line_nr);
+ } else {
+ $self->line_error($message, $line_nr);
+ }
+}
+
# currently doesn't do much more than
# return $_[1]->{'parent'}
sub _close_brace_command($$$)
@@ -1047,16 +1083,13 @@
my $current = shift;
my $line_nr = shift;
- my $located_line_nr = $line_nr;
- # use the beginning of the @-command for the error message
- # line number if available. FIXME currently not done for regular brace
commands
- $located_line_nr = $current->{'line_nr'}
- if ($current->{'line_nr'});
if ($current->{'cmdname'} ne 'verb' or $current->{'type'} eq '') {
- $self->line_error (sprintf($self->__("%c%s missing close brace"),
- ord('@'), $current->{'cmdname'}), $located_line_nr);
+ $self->_command_error($current, $line_nr,
+ $self->__("%c%s missing close brace"), ord('@'), $current->{'cmdname'});
} else {
- $self->line_error (sprintf($self->__("address@hidden missing closing
delimiter sequence: %s}"), $current->{'cmdname'}, $current->{'type'}),
$located_line_nr);
+ $self->_command_error($current, $line_nr,
+ $self->__("address@hidden missing closing delimiter sequence: %s}"),
+ $current->{'cmdname'}, $current->{'type'});
}
$current = $current->{'parent'};
return $current;
@@ -2420,12 +2453,14 @@
$current->{'parent'}, $index_contents,
$index_contents_normalized, $line_nr);
} else {
- $self->line_warn (sprintf($self->__('Missing name for @%s'),
- $current->{'parent'}->{'extra'}->{'original_def_cmdname'}),
$line_nr);
+ $self->_command_warn($current->{'parent'}, $line_nr,
+ $self->__('Missing name for @%s'),
+ $current->{'parent'}->{'extra'}->{'original_def_cmdname'});
}
} else {
- $self->line_warn (sprintf($self->__('Missing category for @%s'),
- $current->{'parent'}->{'extra'}->{'original_def_cmdname'}),
$line_nr);
+ $self->_command_warn($current->{'parent'}, $line_nr,
+ $self->__('Missing category for @%s'),
+ $current->{'parent'}->{'extra'}->{'original_def_cmdname'});
}
$current = $current->{'parent'}->{'parent'};
$current = $self->_begin_preformatted($current);
@@ -2456,11 +2491,10 @@
}
} else {
if (!$content->{'cmdname'}) {
- $self->line_warn (sprintf($self->
- __("Unexpected argument on address@hidden line: %s"),
+ $self->_command_warn($current, $line_nr,
+ $self->__("Unexpected argument on address@hidden line: %s"),
$current->{'cmdname'},
- Texinfo::Convert::Texinfo::convert({ $content->{'contents'} })),
- $line_nr);
+ Texinfo::Convert::Texinfo::convert({ $content->{'contents'} }));
} elsif ($content->{'cmdname'} eq 'c'
or $content->{'cmdname'} eq 'comment') {
} else {
@@ -2472,7 +2506,8 @@
my $multitable = $current->{'parent'};
$multitable->{'extra'}->{'max_columns'} = scalar(@prototype_row);
if (!scalar(@prototype_row)) {
- $self->line_warn ($self->__("empty multitable"), $line_nr);
+ $self->_command_warn($multitable, $line_nr,
+ $self->__("empty multitable"));
}
$multitable->{'extra'}->{'prototypes'} = address@hidden;
@@ -2527,13 +2562,15 @@
if ($current->{'extra'}->{'block_command_line_contents'}
and
defined($current->{'extra'}->{'block_command_line_contents'}->[0])) {
if
(scalar(@{$current->{'extra'}->{'block_command_line_contents'}->[0]}) > 1) {
- $self->line_error (sprintf($self->__("Superfluous argument to
address@hidden"),
- $current->{'cmdname'}), $line_nr);
+ $self->_command_error($current, $line_nr,
+ $self->__("Superfluous argument to address@hidden"),
+ $current->{'cmdname'});
}
my $arg =
$current->{'extra'}->{'block_command_line_contents'}->[0]->[0];
if (!defined($arg->{'text'}) or $arg->{'text'} !~ /^[[:alnum:]]$/) {
- $self->line_error (sprintf($self->
- __("Bad argument to address@hidden"), $current->{'cmdname'}),
$line_nr);
+ $self->_command_error($current, $line_nr,
+ $self->__("Bad argument to address@hidden"),
+ $current->{'cmdname'});
} else {
$spec = $arg->{'text'};
}
@@ -2542,15 +2579,15 @@
} elsif ($item_line_commands{$current->{'cmdname'}}) {
if (!$current->{'extra'}
or !$current->{'extra'}->{'command_as_argument'}) {
- $self->line_error(sprintf($self->__("%s requires an argument: the
formatter for %citem"),
- $current->{'cmdname'}, ord('@')),
$line_nr);
+ $self->_command_error($current, $line_nr,
+ $self->__("%s requires an argument: the formatter for %citem"),
+ $current->{'cmdname'}, ord('@'));
} elsif
(!$brace_commands{$current->{'extra'}->{'command_as_argument'}->{'cmdname'}}
and
!$self->{'definfoenclose'}->{$current->{'extra'}->{'command_as_argument'}->{'cmdname'}})
{
- $self->line_error (sprintf($self->
- __("Command address@hidden not accepting argument in brace should
not be on address@hidden line"),
+ $self->_command_error($current, $line_nr,
+ $self->__("Command address@hidden not accepting argument in
brace should not be on address@hidden line"),
$current->{'extra'}->{'command_as_argument'}->{'cmdname'},
- $current->{'cmdname'}),
- $line_nr);
+ $current->{'cmdname'});
delete $current->{'extra'}->{'command_as_argument'};
}
}
@@ -2582,11 +2619,10 @@
and
$accent_commands{$current->{'extra'}->{'command_as_argument'}->{'cmdname'}}
and ($current->{'cmdname'} eq 'itemize'
or $item_line_commands{$current->{'cmdname'}})) {
- $self->line_warn (sprintf($self->
- __("Accent command address@hidden' not allowed as address@hidden
argument"),
+ $self->_command_warn($current, $line_nr,
+ $self->__("Accent command address@hidden' not allowed as
address@hidden argument"),
$current->{'extra'}->{'command_as_argument'}->{'cmdname'},
- $current->{'cmdname'}),
- $line_nr);
+ $current->{'cmdname'});
delete $current->{'extra'}->{'command_as_argument'};
delete $current->{'extra'}->{'block_command_line_contents'};
}
@@ -2661,8 +2697,8 @@
{'code' => 1,
Texinfo::Common::_convert_text_options($self)});
if ($text eq '') {
- $self->line_warn (sprintf($self->__("address@hidden missing
argument"),
- $command), $line_nr);
+ $self->_command_warn($current, $line_nr,
+ $self->__("address@hidden missing argument"),
$command);
$current->{'extra'}->{'missing_argument'} = 1;
} else {
$current->{'extra'}->{'text_arg'} = $text;
@@ -2673,9 +2709,8 @@
$end_command = $1;
if (!exists $block_commands{$end_command}) {
- $self->line_warn (
- sprintf($self->__("Unknown address@hidden %s"), $end_command),
$line_nr);
- #$current = _merge_text ($self, $current, "address@hidden
$end_command");
+ $self->_command_warn($current, $line_nr,
+ $self->__("Unknown address@hidden %s"),
$end_command);
$end_command = undef;
} else {
print STDERR "END BLOCK $end_command\n" if ($self->{'DEBUG'});
@@ -2684,8 +2719,8 @@
and $self->{'conditionals_stack'}->[-1] eq $end_command) {
pop @{$self->{'conditionals_stack'}};
} else {
- $self->line_error (sprintf($self->__("Unmatched `%c%s'"),
- ord('@'), 'end'), $line_nr);
+ $self->_command_error($current, $line_nr,
+ $self->__("Unmatched `%c%s'"), ord('@'), 'end');
$end_command = undef;
}
}
@@ -2696,11 +2731,14 @@
my $texi_line
= Texinfo::Convert::Texinfo::convert($current->{'args'}->[0]);
$texi_line =~ s/^\s*([[:alnum:]][[:alnum:]-]+)//;
- $self->line_error (sprintf($self->__("Superfluous argument to
address@hidden %s: %s"),
- $command, $end_command, $texi_line),
$line_nr);
+ $self->_command_error($current, $line_nr,
+ $self->__("Superfluous argument to address@hidden
%s: %s"),
+ $command, $end_command, $texi_line);
}
} else {
- $self->line_error (sprintf($self->__("Bad argument to
address@hidden: %s"), $command, $line), $line_nr);
+ $self->_command_error($current, $line_nr,
+ $self->__("Bad argument to address@hidden: %s"),
+ $command, $line);
}
} elsif ($command eq 'include') {
my $file = Texinfo::Common::locate_include_file($self, $text) ;
@@ -2718,22 +2756,25 @@
'pending' => [],
'fh' => $filehandle };
} else {
- $self->line_error (sprintf($self->__("address@hidden: Cannot
open %s: %s"),
- $command, $text, $!), $line_nr);
+ $self->_command_error($current, $line_nr,
+ $self->__("address@hidden: Cannot open %s: %s"),
+ $command, $text, $!);
}
} else {
- $self->line_error (sprintf($self->__("address@hidden: Cannot find
%s"),
- $command, $text), $line_nr);
+ $self->_command_error($current, $line_nr,
+ $self->__("address@hidden: Cannot find %s"),
+ $command, $text);
}
} elsif ($command eq 'documentencoding') {
my ($texinfo_encoding, $perl_encoding, $output_encoding)
= Texinfo::Encoding::encoding_alias($text);
- $self->line_warn (sprintf($self->__("Encoding `%s' is not a
canonical texinfo encoding"),
- $text), $line_nr)
+ $self->_command_warn($current, $line_nr,
+ $self->__("Encoding `%s' is not a canonical texinfo
encoding"),
+ $text)
if (!$texinfo_encoding or $texinfo_encoding ne lc($text));
if (!$perl_encoding) {
- $self->line_warn (sprintf($self->__("unrecognized encoding name
`%s'"),
- $text), $line_nr);
+ $self->_command_warn($current, $line_nr,
+ $self->__("unrecognized encoding name `%s'"), $text);
} else {
if ($output_encoding) {
$current->{'extra'}->{'encoding_name'} = $output_encoding;
@@ -2754,7 +2795,7 @@
my @messages = Texinfo::Common::warn_unknown_language($text,
$self->{'gettext'});
foreach my $message(@messages) {
- $self->line_warn ($message, $line_nr);
+ $self->_command_warn($current, $line_nr, $message);
}
if (!$self->{'set'}->{'documentlanguage'}) {
$self->{'documentlanguage'} = $text;
@@ -2788,8 +2829,8 @@
_trim_spaces_comment_from_content(address@hidden);
# empty @top is allowed
if (!scalar(@contents) and $command ne 'top') {
- $self->line_warn (sprintf($self->__("address@hidden missing
argument"),
- $command), $line_nr);
+ $self->_command_warn($current, $line_nr,
+ $self->__("address@hidden missing argument"), $command);
$current->{'extra'}->{'missing_argument'} = 1;
} else {
$current->{'extra'}->{'misc_content'} = address@hidden;
@@ -2874,8 +2915,9 @@
# in a multitable, we are in a block_line_arg
if (!$current->{'parent'} or !$current->{'parent'}->{'cmdname'}
or $current->{'parent'}->{'cmdname'} ne 'multitable') {
- $self->line_error (sprintf($self->__("address@hidden only meaningful
on a address@hidden line"),
- $command), $line_nr);
+ $self->_command_error($current, $line_nr,
+ $self->__("address@hidden only meaningful on a address@hidden
line"),
+ $command);
} else {
# This is the multitable block_line_arg line context
my $context = pop @{$self->{'context_stack'}};
@@ -4636,8 +4678,8 @@
_trim_spaces_comment_from_content(address@hidden);
if (! @contents) {
- $self->line_error (sprintf($self->__("address@hidden missing argument"),
- $command), $line_nr);
+ $self->_command_error($line_command, $line_nr,
+ $self->__("address@hidden missing argument"), $command);
$line_command->{'extra'}->{'missing_argument'} = 1;
return undef;
}
Index: t/60macro.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/60macro.t,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- t/60macro.t 17 Sep 2011 20:28:19 -0000 1.34
+++ t/60macro.t 15 Oct 2011 19:52:46 -0000 1.35
@@ -929,7 +929,13 @@
['unknown_macro_on_line_command',
'@setfilename @begin{}file'
],
+['macro_with_error_at_end_line_after_macro',
+'@macro witherror{string}
address@hidden
address@hidden macro
address@hidden
+']
);
my @todo =(
Index: t/results/macro/macro_with_error_at_end_line_after_macro.pl
===================================================================
RCS file: t/results/macro/macro_with_error_at_end_line_after_macro.pl
diff -N t/results/macro/macro_with_error_at_end_line_after_macro.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ t/results/macro/macro_with_error_at_end_line_after_macro.pl 15 Oct 2011
19:52:47 -0000 1.1
@@ -0,0 +1,138 @@
+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);
+
+use utf8;
+
+$result_trees{'macro_with_error_at_end_line_after_macro'} = {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'parent' => {},
+ 'text' => 'witherror',
+ 'type' => 'macro_name'
+ },
+ {
+ 'parent' => {},
+ 'text' => 'string',
+ 'type' => 'macro_arg'
+ }
+ ],
+ 'cmdname' => 'macro',
+ 'contents' => [
+ {
+ 'parent' => {},
+ 'text' => '@center',
+ 'type' => 'raw'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'last_raw_newline'
+ }
+ ],
+ 'extra' => {
+ 'arg_line' => ' witherror{string}
+',
+ 'args_index' => {
+ 'string' => 0
+ },
+ 'macrobody' => '@center
+'
+ },
+ 'line_nr' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ },
+ 'parent' => {}
+ },
+ {
+ 'extra' => {
+ 'command' => {}
+ },
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line_after_command'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'extra' => {
+ 'command' => {}
+ },
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line_after_command'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'misc_line_arg'
+ }
+ ],
+ 'cmdname' => 'center',
+ 'extra' => {
+ 'missing_argument' => 1
+ },
+ 'line_nr' => {
+ 'file_name' => '',
+ 'line_nr' => 5,
+ 'macro' => 'witherror'
+ },
+ 'parent' => {}
+ }
+ ],
+ 'type' => 'text_root'
+};
+$result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[0]{'args'}[0]{'parent'}
= $result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[0];
+$result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[0]{'args'}[1]{'parent'}
= $result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[0];
+$result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[0]{'contents'}[0]{'parent'}
= $result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[0];
+$result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[0]{'contents'}[1]{'parent'}
= $result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[0];
+$result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[0]{'parent'}
= $result_trees{'macro_with_error_at_end_line_after_macro'};
+$result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[1]{'extra'}{'command'}
= $result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[0];
+$result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[1]{'parent'}
= $result_trees{'macro_with_error_at_end_line_after_macro'};
+$result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[2]{'parent'}
= $result_trees{'macro_with_error_at_end_line_after_macro'};
+$result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[3]{'args'}[0]{'contents'}[0]{'extra'}{'command'}
= $result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[3];
+$result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[3]{'args'}[0]{'contents'}[0]{'parent'}
=
$result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[3]{'args'}[0];
+$result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[3]{'args'}[0]{'parent'}
= $result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[3];
+$result_trees{'macro_with_error_at_end_line_after_macro'}{'contents'}[3]{'parent'}
= $result_trees{'macro_with_error_at_end_line_after_macro'};
+
+$result_texis{'macro_with_error_at_end_line_after_macro'} = '@macro
witherror{string}
address@hidden
address@hidden macro
+
address@hidden
+';
+
+
+$result_texts{'macro_with_error_at_end_line_after_macro'} = '
+
+';
+
+$result_errors{'macro_with_error_at_end_line_after_macro'} = [
+ {
+ 'error_line' => ':5: warning: @center missing argument (possibly involving
@witherror)
+',
+ 'file_name' => '',
+ 'line_nr' => 5,
+ 'macro' => 'witherror',
+ 'text' => '@center missing argument',
+ 'type' => 'warning'
+ }
+];
+
+
+1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp Texinfo/Parser.pm t/60macro.t t/resu...,
Patrice Dumas <=