3 if ($ARGV[0] =~ /^-/) {
6 # $TXT = ($lang eq '-txt');
14 ## Warn about windows-style newlines.
20 print " TAB:$fn:$.\n";
22 ## Warn about trailing whitespace.
24 print "Space\@EOL:$fn:$.\n";
26 ## Warn about control keywords without following space.
27 if ($C && /\s(?:if|while|for|switch)\(/) {
28 print " KW(:$fn:$.\n";
30 ## Warn about multiple empty lines.
31 if ($lastnil && /^$/) {
32 print " DoubleNL:$fn:$.\n";
38 ### Juju to skip over comments and strings, since the tests
39 ### we're about to do are okay there.
56 s!"(?:[^\"]+|\\.)*"!"X"!g;
58 ## Warn about C++-style comments.
60 # print " //:$fn:$.\n";
63 ## Warn about braces preceded by non-space.
65 print " $1\{:$fn:$.\n";
67 ## Warn about multiple internal spaces.
68 #if (/[^\s,:]\s{2,}[^\s\\=]/) {
69 # print " X X:$fn:$.\n";
71 ## Warn about { with stuff after.
74 # print " {X:$fn:$.\n";
76 ## Warn about function calls with space before parens.
78 if ($1 ne "if" and $1 ne "while" and $1 ne "for" and
79 $1 ne "switch" and $1 ne "return" and $1 ne "int" and
80 $1 ne "void" and $1 ne "__attribute__") {
81 print " fn ():$fn:$.\n";
84 ## Warn about functions not declared at start of line.
86 ($fn !~ /\.h$/ && /^[a-zA-Z0-9_]/ &&
87 ! /^(?:static )?(?:typedef|struct|union)[^\(]*$/ &&
88 ! /= *\{$/ && ! /;$/)) {
91 print "fn() {:$fn:$.\n";
93 } elsif (/^\S[^\(]* +\**[a-zA-Z0-9_]+\(/) {
94 $in_func_head = -1; # started with tp fn
98 if ($in_func_head == -1) {
99 print "tp fn():$fn:$.\n";
107 print " EOL\@EOF:$fn:$.\n";