Fix string handling.

Enable perl warnings
Add a proper --help option and usage.
oldstable
Francois Gouget 2004-10-25 21:50:50 +00:00 committed by Alexandre Julliard
parent 1d691d5d70
commit d9800f9fa9
1 changed files with 28 additions and 12 deletions

View File

@ -1,4 +1,4 @@
#! /usr/bin/perl #! /usr/bin/perl -w
# #
# Copyright 2000 Patrik Stridvall # Copyright 2000 Patrik Stridvall
# #
@ -19,23 +19,39 @@
use strict; use strict;
my $name0=$0;
$name0 =~ s%^.*/%%;
my $invert = 0; my $invert = 0;
my $pattern; my $pattern;
my @files = (); my @files = ();
my $usage;
while(defined($_ = shift)) { while(defined($_ = shift)) {
if(/^-/) { if (/^-v$/) {
if(/^-v$/) { $invert = 1;
$invert = 1; } elsif (/^--?(\?|h|help)$/) {
} $usage=0;
} elsif (/^-/) {
print STDERR "$name0:error: unknown option '$_'\n";
$usage=2;
last;
} elsif(!defined($pattern)) {
$pattern = $_;
} else { } else {
if(!defined($pattern)) { push @files, $_;
$pattern = $_;
} else {
push @files, $_;
}
} }
} }
if (defined $usage)
{
print "Usage: $name0 [--help] [-v] pattern files...\n";
print "where:\n";
print "--help Prints this help message\n";
print "-v Return functions that do not match pattern\n";
print "pattern A regular expression for the function name\n";
print "files... A list of files to search the function in\n";
exit $usage;
}
foreach my $file (@files) { foreach my $file (@files) {
open(IN, "< $file"); open(IN, "< $file");
@ -266,9 +282,9 @@ foreach my $file (@files) {
} }
} }
} }
} elsif(/\'[^\']*\'/s) { } elsif(/\'(?:[^\\\']*|\\.)*\'/s) {
$_ = $'; $again = 1; $_ = $'; $again = 1;
} elsif(/\"[^\"]*\"/s) { } elsif(/\"(?:[^\\\"]*|\\.)*\"/s) {
$_ = $'; $again = 1; $_ = $'; $again = 1;
} elsif(/;/s) { } elsif(/;/s) {
$_ = $'; $again = 1; $_ = $'; $again = 1;