6 # Parse arguments, a simple state machine for input like:
8 # howto/*.txt config/*.txt --section=1 git.txt git-add.txt [...] --to-lint git-add.txt a-file.txt [...]
14 if (my ($sec) = $arg =~ /^--section=(\d+)$/s) {
19 my ($name) = $arg =~ /^(.*?)\.txt$/s;
20 unless (defined $section) {
25 $SECTION{$name} = $section;
30 my ($pos, $line, $target, $msg) = @_;
31 substr($line, $pos) = "' <-- HERE";
33 print "$ARGV:$.: error: $target: $msg, shown with 'HERE' below:\n";
34 print "$ARGV:$.:\t'$line\n";
38 @ARGV = sort values %TXT;
39 die "BUG: Nothing to process!" unless @ARGV;
42 while ($line =~ m/linkgit:((.*?)\[(\d)\])/g) {
44 my ($target, $page, $section) = ($1, $2, $3);
47 $page =~ s/{litdd}/--/g;
49 if (!exists $TXT{$page}) {
50 report
($pos, $line, $target, "link outside of our own docs");
53 if (!exists $SECTION{$page}) {
54 report
($pos, $line, $target, "link outside of our sectioned docs");
57 my $real_section = $SECTION{$page};
58 if ($section != $SECTION{$page}) {
59 report
($pos, $line, $target, "wrong section (should be $real_section)");
63 # this resets our $. for each file