3 if ($ARGV[0] =~ /^-/) {
6 # $TXT = ($lang eq '-txt');
15 ## Warn about windows-style newlines.
21 print " TAB:$fn:$.\n";
23 ## Warn about trailing whitespace.
25 print "Space\@EOL:$fn:$.\n";
27 ## Warn about control keywords without following space.
28 if ($C && /\s(?:if|while|for|switch)\(/) {
29 print " KW(:$fn:$.\n";
31 ## Warn about #else #if instead of #elif.
32 if (($lastline =~ /^\# *else/) and ($_ =~ /^\# *if/)) {
33 print " #else#if:$fn:$.\n";
36 ## Warn about multiple empty lines.
37 if ($lastnil && /^$/) {
38 print " DoubleNL:$fn:$.\n";
44 ## Terminals are still 80 columns wide in my world. I refuse to
45 ## accept double-line lines.
47 print " Wide:$fn:$.\n";
49 ### Juju to skip over comments and strings, since the tests
50 ### we're about to do are okay there.
67 s!"(?:[^\"]+|\\.)*"!"X"!g;
69 ## Warn about C++-style comments.
71 # print " //:$fn:$.\n";
74 ## Warn about unquoted braces preceded by non-space.
76 print " $1\{:$fn:$.\n";
78 ## Warn about multiple internal spaces.
79 #if (/[^\s,:]\s{2,}[^\s\\=]/) {
80 # print " X X:$fn:$.\n";
82 ## Warn about { with stuff after.
85 # print " {X:$fn:$.\n";
87 ## Warn about function calls with space before parens.
88 if (/(\w+)\s\(([A-Z]*)/) {
89 if ($1 ne "if" and $1 ne "while" and $1 ne "for" and
90 $1 ne "switch" and $1 ne "return" and $1 ne "int" and
91 $1 ne "elsif" and $1 ne "WINAPI" and $2 ne "WINAPI" and
92 $1 ne "void" and $1 ne "__attribute__") {
93 print " fn ():$fn:$.\n";
96 ## Warn about functions not declared at start of line.
98 ($fn !~ /\.h$/ && /^[a-zA-Z0-9_]/ &&
99 ! /^(?:const |static )*(?:typedef|struct|union)[^\(]*$/ &&
100 ! /= *\{$/ && ! /;$/)) {
102 print "fn() {:$fn:$.\n";
104 } elsif (/^\S[^\(]* +\**[a-zA-Z0-9_]+\(/) {
105 $in_func_head = -1; # started with tp fn
109 if ($in_func_head == -1) {
110 print "tp fn():$fn:$.\n";
118 print " EOL\@EOF:$fn:$.\n";