Fix a case where mtags got into an infinite loop on a ugly type

Branches: main

Fix a case where mtags got into an infinite loop on a ugly type
definition, where the file was in CR/LF format.

    :- type stupid --->
                    % moron
                    idiot(useless)
                    % imbecile
                ;   retard(string, string)
                .

scripts/mtags.in:
        As above.

	Add an option `--debug' to help narrow down the problematic file in
	future.
This commit is contained in:
Peter Wang
2009-03-13 05:34:29 +00:00
parent 874ea1be34
commit f2c2ced6ef

View File

@@ -118,6 +118,10 @@ Options:
Output extra attributes as for `--vim-extended-attributes',
but in the format required by elvis.
--debug
Output the name of each source file as it is being processed
to standard error.
-h, --help
Display this help message and exit.
@@ -131,6 +135,7 @@ $emacs = 0;
$extended_attributes = "vim";
$keep_dups = 1;
$search_definitions = 1;
$debug = 0;
OPTION:
while ($#ARGV >= 0 && $ARGV[0] =~ /^-/) {
@@ -203,6 +208,11 @@ while ($#ARGV >= 0 && $ARGV[0] =~ /^-/) {
shift(@ARGV);
next OPTION;
}
if ($ARGV[0] eq "--debug") {
$debug = 1;
shift(@ARGV);
next OPTION;
}
if ($ARGV[0] eq "-h" || $ARGV[0] eq "--help") {
print "$help";
exit(0);
@@ -347,6 +357,10 @@ while ($#ARGV >= 0)
open(OUT, ">> TAGS") ||
die "mtags: error opening pipe: $!\n";
}
if ($debug) {
print STDERR "Processing $file\n";
}
$module = $file;
$module =~ s/.*\///; # Delete the directory name, if any.
@@ -500,7 +514,7 @@ while ($#ARGV >= 0)
}
}
last if $_ =~ /^[^%]*\.[ \t]*$/ || $_ =~ /\.[ \t]*%.*$/;
last if $_ =~ /^[^%]*\.[ \t\r]*$/ || $_ =~ /\.[ \t]*%.*$/;
$_ = <SRCFILE> || last;
chop;
$body = $_;