I was interested in looking at old revisions of the Texinfo manual
for revising some of the chapters. I found that processing the manual
for Texinfo 2.15 (one of the oldest versions I have access to) with
recent texi2any would give a huge number of warnings. Some of these
are related to structure checks which may be hard to fix (possibly related
to the @detailmenu command being missing from the language at this stage),
but one major source of warnings, that should be easy to reduce, is
warning about deprecated commands: mainly @refill. texi2any warns about
@refill in this particular manual 1367 times.
I was hoping we could limit the number of times a deprecated command was
warned about. Here's my attempt at implementing this in the Perl code (at
bottom of this email).
With the input I was testing with, I reduced the number of such warnings
to six:
$ TEXINFO_XS=omit ../tta/perl/texi2any.pl structure-fail.texi
fail.texi:105: warning: @refill is obsolete
fail.texi:109: warning: @refill is obsolete
fail.texi:109: warning: further warnings for @refill suppressed
fail.texi:692: warning: @inforef is obsolete
fail.texi:718: warning: @inforef is obsolete
fail.texi:718: warning: further warnings for @inforef suppressed
Even if we don't aim for such old manuals to build error-free, reducing
the number of warnings from over 1000 to only a few makes it feasible to
manually fix the input so it can be built.
The main thing I wasn't sure about is whether %parsing_state_initialization
is the right place for this hash.
If this looks good I can try to do the corresponding C code (I'm happy for
somebody else to do it, though). I imagine we would keep an array of
warned-about commands and each time check through the array to see if the
command has already been warned about.
diff --git a/tta/perl/Texinfo/ParserNonXS.pm b/tta/perl/Texinfo/ParserNonXS.pm
index bb10054534..22463d1246 100644
--- a/tta/perl/Texinfo/ParserNonXS.pm
+++ b/tta/perl/Texinfo/ParserNonXS.pm
@@ -214,6 +214,7 @@ my %parsing_state_initialization = (
# be added each time a context is pushed on
# 'context_stack'. Could be undef if there
# is no @-command associated with the context.
+ 'warned_deprecated_commands' => {},
);
my %parser_state_initialization = (%parser_document_state_initialization,
@@ -7741,9 +7742,15 @@ sub _process_remaining_on_line($$$$) {
# goto funexit; # used in XS code
}
- if (defined($deprecated_commands{$command})) {
+ if (defined($deprecated_commands{$command})
+ and (!defined($self->{'warned_deprecated_commands'}->{$command})
+ or ($self->{'warned_deprecated_commands'}->{$command} < 2))) {
_line_warn($self, sprintf(__("\@%s is obsolete"),
$command), $source_info);
+ if (++($self->{'warned_deprecated_commands'}->{$command}) == 2) {
+ _line_warn($self, sprintf(__("further warnings for @%s suppressed"),
$command),
+ $source_info, 1);
+ }
}
# special case with @ followed by a newline protecting end of lines