From d9800f9fa910fa93af3ac12b394e031fbe916d61 Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Mon, 25 Oct 2004 21:50:50 +0000 Subject: [PATCH] Fix string handling. Enable perl warnings Add a proper --help option and usage. --- tools/winedump/function_grep.pl | 40 +++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/tools/winedump/function_grep.pl b/tools/winedump/function_grep.pl index 81f3bd8af29..71cd6b1f026 100755 --- a/tools/winedump/function_grep.pl +++ b/tools/winedump/function_grep.pl @@ -1,4 +1,4 @@ -#! /usr/bin/perl +#! /usr/bin/perl -w # # Copyright 2000 Patrik Stridvall # @@ -19,23 +19,39 @@ use strict; +my $name0=$0; +$name0 =~ s%^.*/%%; + my $invert = 0; my $pattern; my @files = (); +my $usage; while(defined($_ = shift)) { - if(/^-/) { - if(/^-v$/) { - $invert = 1; - } + if (/^-v$/) { + $invert = 1; + } elsif (/^--?(\?|h|help)$/) { + $usage=0; + } elsif (/^-/) { + print STDERR "$name0:error: unknown option '$_'\n"; + $usage=2; + last; + } elsif(!defined($pattern)) { + $pattern = $_; } else { - if(!defined($pattern)) { - $pattern = $_; - } else { - push @files, $_; - } + 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) { open(IN, "< $file"); @@ -266,9 +282,9 @@ foreach my $file (@files) { } } } - } elsif(/\'[^\']*\'/s) { + } elsif(/\'(?:[^\\\']*|\\.)*\'/s) { $_ = $'; $again = 1; - } elsif(/\"[^\"]*\"/s) { + } elsif(/\"(?:[^\\\"]*|\\.)*\"/s) { $_ = $'; $again = 1; } elsif(/;/s) { $_ = $'; $again = 1;