3 if ($ARGV[0] =~ /^-/) {
6 # $TXT = ($lang eq '-txt');
15 ## Warn about windows-style newlines.
21 print " TAB:$fn:$.\n";
23 ## Warn about markers that don't have a space in front of them
24 if (/^[a-zA-Z_][a-zA-Z_0-9]*:/) {
25 print "nosplabel:$fn:$.\n";
27 ## Warn about trailing whitespace.
29 print "Space\@EOL:$fn:$.\n";
31 ## Warn about control keywords without following space.
32 if ($C && /\s(?:if|while|for|switch)\(/) {
33 print " KW(:$fn:$.\n";
35 ## Warn about #else #if instead of #elif.
36 if (($lastline =~ /^\# *else/) and ($_ =~ /^\# *if/)) {
37 print " #else#if:$fn:$.\n";
40 ## Warn about unnecessary empty lines.
41 if ($lastnil && /^\s*}\n/) {
42 print " UnnecNL:$fn:$.\n";
44 ## Warn about multiple empty lines.
45 if ($lastnil && /^$/) {
46 print " DoubleNL:$fn:$.\n";
52 ## Terminals are still 80 columns wide in my world. I refuse to
53 ## accept double-line lines.
55 print " Wide:$fn:$.\n";
57 ### Juju to skip over comments and strings, since the tests
58 ### we're about to do are okay there.
75 s!"(?:[^\"]+|\\.)*"!"X"!g;
77 ## Warn about C++-style comments.
79 # print " //:$fn:$.\n";
82 ## Warn about unquoted braces preceded by non-space.
84 print " $1\{:$fn:$.\n";
86 ## Warn about multiple internal spaces.
87 #if (/[^\s,:]\s{2,}[^\s\\=]/) {
88 # print " X X:$fn:$.\n";
90 ## Warn about { with stuff after.
93 # print " {X:$fn:$.\n";
95 ## Warn about function calls with space before parens.
96 if (/(\w+)\s\(([A-Z]*)/) {
97 if ($1 ne "if" and $1 ne "while" and $1 ne "for" and
98 $1 ne "switch" and $1 ne "return" and $1 ne "int" and
99 $1 ne "elsif" and $1 ne "WINAPI" and $2 ne "WINAPI" and
100 $1 ne "void" and $1 ne "__attribute__") {
101 print " fn ():$fn:$.\n";
104 ## Warn about functions not declared at start of line.
106 ($fn !~ /\.h$/ && /^[a-zA-Z0-9_]/ &&
107 ! /^(?:const |static )*(?:typedef|struct|union)[^\(]*$/ &&
108 ! /= *\{$/ && ! /;$/)) {
110 print "fn() {:$fn:$.\n";
112 } elsif (/^\S[^\(]* +\**[a-zA-Z0-9_]+\(/) {
113 $in_func_head = -1; # started with tp fn
117 if ($in_func_head == -1) {
118 print "tp fn():$fn:$.\n";
126 print " EOL\@EOF:$fn:$.\n";