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 ## Terminals are still 80 columns wide in my world. I refuse to
39 ## accept double-line lines. Except, of course, svn Id tags
40 ## can make us go long.
41 if (/^.{80}/ && !/\$Id: /) {
42 print " Wide:$fn:$.\n";
44 ### Juju to skip over comments and strings, since the tests
45 ### we're about to do are okay there.
62 s!"(?:[^\"]+|\\.)*"!"X"!g;
64 ## Warn about C++-style comments.
66 # print " //:$fn:$.\n";
69 ## Warn about braces preceded by non-space.
71 print " $1\{:$fn:$.\n";
73 ## Warn about multiple internal spaces.
74 #if (/[^\s,:]\s{2,}[^\s\\=]/) {
75 # print " X X:$fn:$.\n";
77 ## Warn about { with stuff after.
80 # print " {X:$fn:$.\n";
82 ## Warn about function calls with space before parens.
83 if (/(\w+)\s\(([A-Z]*)/) {
84 if ($1 ne "if" and $1 ne "while" and $1 ne "for" and
85 $1 ne "switch" and $1 ne "return" and $1 ne "int" and
86 $1 ne "elsif" and $1 ne "WINAPI" and $2 ne "WINAPI" and
87 $1 ne "void" and $1 ne "__attribute__") {
88 print " fn ():$fn:$.\n";
91 ## Warn about functions not declared at start of line.
93 ($fn !~ /\.h$/ && /^[a-zA-Z0-9_]/ &&
94 ! /^(?:const |static )*(?:typedef|struct|union)[^\(]*$/ &&
95 ! /= *\{$/ && ! /;$/)) {
97 print "fn() {:$fn:$.\n";
99 } elsif (/^\S[^\(]* +\**[a-zA-Z0-9_]+\(/) {
100 $in_func_head = -1; # started with tp fn
104 if ($in_func_head == -1) {
105 print "tp fn():$fn:$.\n";
113 print " EOL\@EOF:$fn:$.\n";