| 1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
| 2 |
# $Id: code-style.pl,v 1.11 2006/02/21 18:46:54 dries Exp $ |
# $Id: code-style.pl,v 1.12 2006/10/14 10:03:27 dries Exp $ |
| 3 |
|
|
| 4 |
# Author: Alexander Schwartz (alexander.schwartz@gmx.net) |
use Pod::Usage; |
| 5 |
# Licence: GPL |
use Getopt::Long qw(GetOptions); |
| 6 |
# First version: 2001-10-15 |
Getopt::Long::Configure ("bundling"); |
| 7 |
|
|
| 8 |
# Originally written for Drupal (http://drupal.org/) to ensure stylish |
my %opt = ( "help" => 0, |
| 9 |
# code. This program tries to show as many improvements as possible with |
'debug' => 0, |
| 10 |
# no false positives. |
); |
| 11 |
|
|
| 12 |
# $Id: code-style.pl,v 1.11 2006/02/21 18:46:54 dries Exp $ |
if(!GetOptions(\%opt, |
| 13 |
|
'help|?', |
| 14 |
$comment = 0; |
'debug', |
| 15 |
$program = 0; |
)) { |
| 16 |
if ($ARGV[0] eq '-debug') { |
pod2usage(-exitval => 1, 'verbose'=>0); |
|
$debug=1; |
|
|
shift (@ARGV); |
|
|
} |
|
|
else { |
|
|
$debug=0; |
|
| 17 |
} |
} |
| 18 |
|
|
| 19 |
|
pod2usage(-exitval => 0, -verbose => 2) if($opt{'help'}); |
| 20 |
|
|
| 21 |
|
$debug = $opt{'debug'}; |
| 22 |
|
|
| 23 |
|
$comment = 0; #flag used to signal we're inside /* */ |
| 24 |
|
$program = 0; #flag used to signal we're inside <?php ?> |
| 25 |
|
#read the file |
| 26 |
while (<>) { |
while (<>) { |
| 27 |
$org=$_; |
$org=$_; |
| 28 |
s/\\["']//g; |
s/\\["']//g; |
| 163 |
} continue { |
} continue { |
| 164 |
close ARGV if eof; |
close ARGV if eof; |
| 165 |
} |
} |
| 166 |
|
|
| 167 |
|
__END__ |
| 168 |
|
|
| 169 |
|
=head1 NAME |
| 170 |
|
|
| 171 |
|
code-style.pl - Review drupal code for style |
| 172 |
|
|
| 173 |
|
=head1 SYNOPSIS |
| 174 |
|
|
| 175 |
|
code-style.pl [options] <filename> |
| 176 |
|
|
| 177 |
|
Options: |
| 178 |
|
|
| 179 |
|
-? --help detailed help message |
| 180 |
|
|
| 181 |
|
=head1 DESCRIPTION |
| 182 |
|
|
| 183 |
|
Originally written for Drupal (http://drupal.org/) to ensure stylish |
| 184 |
|
code. This program reviews PHP code, and tries to show as many code |
| 185 |
|
improvements as possible with no false positives. |
| 186 |
|
|
| 187 |
|
=head1 OPTIONS |
| 188 |
|
|
| 189 |
|
--comment |
| 190 |
|
|
| 191 |
|
=head1 EXAMPLES |
| 192 |
|
|
| 193 |
|
./code-style.pl ../index.php |
| 194 |
|
|
| 195 |
|
=cut |