12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- use strict;
- my $filename = $ARGV[0];
- if (!$filename) {
- print "Usage: modified_otb.pl <filename>\n";
- exit(1);
- }
- my @results = ();
- my $line_num = 0;
- my ($NONE, $BRACE, $PAREN) = (0, 1, 2);
- my $looking_for = $NONE;
- my $last_func_name = "";
- open(HANDLE, "<", $filename) or die "Cannot open $filename\n";
- while (<HANDLE>) {
- $line_num++;
-
-
- chomp;
- if (!$looking_for &&
- ($_ =~ /^\s*function/) &&
- ($_ =~ /\{/)) {
-
-
- ($last_func_name) = $_ =~ /function\s*(.*)\(/;
- push @results, "'$last_func_name' prototype ends with opening ".
- "brace, line $line_num";
- } elsif (!$looking_for &&
- ($_ =~ /^\s*function/) &&
- ($_ !~ /\)/)) {
- ($last_func_name) = $_ =~ /function\s*(.*)\(/;
- $looking_for = $PAREN;
- } elsif (($looking_for == $PAREN) &&
- ($_ =~ /\)/) &&
- ($_ =~ /\{/)) {
-
-
- push @results, "'$last_func_name' prototype ends with with ".
- "opening brace, line $line_num";
- $looking_for = $NONE;
- } elsif (($looking_for == $PAREN) &&
- ($_ =~ /\)/) &&
- ($_ !~ /\{/)) {
- $looking_for = $BRACE;
- } elsif (!$looking_for &&
- ($_ =~ /^\s*function/) &&
- ($_ =~ /\)/) &&
- ($_ !~ /\{/)) {
- ($last_func_name) = $_ =~ /function\s*(.*)\(/;
- $looking_for = $BRACE;
- } elsif (($looking_for == $BRACE) &&
- ($_ eq "{")) {
- $looking_for = $NONE;
-
-
- } else {
-
-
- $looking_for = $NONE;
- }
- }
- if (@results) {
- foreach my $result (@results) {
- print "$filename: $result\n";
- }
- exit(1);
- } else {
- exit(0);
- }
|