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";
39 ## Warn about some K&R violations
40 if (/^\s+\{/ and $lastline =~ /^\s*(if|while|for|else if)/ and
42 print "non-K&R {:$fn:$.\n";
44 if (/^\s*else/ and $lastline =~ /\}$/) {
45 print " }\\nelse:$fn:$.\n";
48 ## Warn about unnecessary empty lines.
49 if ($lastnil && /^\s*}\n/) {
50 print " UnnecNL:$fn:$.\n";
52 ## Warn about multiple empty lines.
53 if ($lastnil && /^$/) {
54 print " DoubleNL:$fn:$.\n";
60 ## Terminals are still 80 columns wide in my world. I refuse to
61 ## accept double-line lines.
63 print " Wide:$fn:$.\n";
65 ### Juju to skip over comments and strings, since the tests
66 ### we're about to do are okay there.
83 s!"(?:[^\"]+|\\.)*"!"X"!g;
85 ## Warn about C++-style comments.
87 # print " //:$fn:$.\n";
90 ## Warn about unquoted braces preceded by non-space.
92 print " $1\{:$fn:$.\n";
94 ## Warn about multiple internal spaces.
95 #if (/[^\s,:]\s{2,}[^\s\\=]/) {
96 # print " X X:$fn:$.\n";
98 ## Warn about { with stuff after.
100 #if (/\{[^\}\\]+$/) {
101 # print " {X:$fn:$.\n";
103 ## Warn about function calls with space before parens.
104 if (/(\w+)\s\(([A-Z]*)/) {
105 if ($1 ne "if" and $1 ne "while" and $1 ne "for" and
106 $1 ne "switch" and $1 ne "return" and $1 ne "int" and
107 $1 ne "elsif" and $1 ne "WINAPI" and $2 ne "WINAPI" and
108 $1 ne "void" and $1 ne "__attribute__" and $1 ne "op") {
109 print " fn ():$fn:$.\n";
112 ## Warn about functions not declared at start of line.
114 ($fn !~ /\.h$/ && /^[a-zA-Z0-9_]/ &&
115 ! /^(?:const |static )*(?:typedef|struct|union)[^\(]*$/ &&
116 ! /= *\{$/ && ! /;$/)) {
118 print "fn() {:$fn:$.\n";
120 } elsif (/^\S[^\(]* +\**[a-zA-Z0-9_]+\(/) {
121 $in_func_head = -1; # started with tp fn
125 if ($in_func_head == -1) {
126 print "tp fn():$fn:$.\n";
134 print " EOL\@EOF:$fn:$.\n";