Misc function_grep enhancements

Francois Gouget fgouget at free.fr
Mon Oct 25 08:25:40 CDT 2004


Changelog:

  * tools/winedump/function_grep.pl

    Fix string handling.
    Enable perl warnings
    Add a proper --help option and usage.


-- 
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
                             $live{free} || die "";
-------------- next part --------------
Index: tools/winedump/function_grep.pl
===================================================================
RCS file: /var/cvs/wine/tools/winedump/function_grep.pl,v
retrieving revision 1.3
diff -u -r1.3 function_grep.pl
--- tools/winedump/function_grep.pl	1 Jun 2002 02:55:53 -0000	1.3
+++ tools/winedump/function_grep.pl	25 Oct 2004 13:14:38 -0000
@@ -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 @@
 		    }
 		}
 	    }
-        } elsif(/\'[^\']*\'/s) {
+        } elsif(/\'(?:[^\\\']*|\\.)*\'/s) {
             $_ = $'; $again = 1;
-        } elsif(/\"[^\"]*\"/s) {
+        } elsif(/\"(?:[^\\\"]*|\\.)*\"/s) {
             $_ = $'; $again = 1;
         } elsif(/;/s) {
             $_ = $'; $again = 1;


More information about the wine-patches mailing list