]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
singleuse: make `git grep` faster, add Apple `nm` support
authorViktor Szakats <commit@vsz.me>
Thu, 26 Sep 2024 19:16:21 +0000 (21:16 +0200)
committerViktor Szakats <commit@vsz.me>
Fri, 27 Sep 2024 08:27:08 +0000 (10:27 +0200)
- avoid regexp in grep to make it run faster.
- add support for parsing Apple `nm` output:
  - skip leading underscore from function names.
  - pick object name from output.

Closes #15070

scripts/singleuse.pl

index 3731edc85b59839484fda9e37f6e9089a3ff3a08..42c5d27d8fa58702493314676268669cee1b46bf 100755 (executable)
@@ -152,7 +152,7 @@ my %api = (
 
 sub doublecheck {
     my ($f, $used) = @_;
-    open(F, "git grep -le '$f\\W' -- lib ${unittests}packages|");
+    open(F, "git grep -Fwle '$f' -- lib ${unittests}packages|");
     my @also;
     while(<F>) {
         my $e = $_;
@@ -180,13 +180,17 @@ while (<N>) {
     if($l =~ /^([0-9a-z_-]+)\.o:/) {
         $file = $1;
     }
-    if($l =~ /^([0-9a-f]+) T (.*)/) {
+    # libcurl.a(unity_0_c.c.o):
+    elsif($l =~ /\(([0-9a-z_.-]+)\.o\):/) {  # Apple nm
+        $file = $1;
+    }
+    if($l =~ /^([0-9a-f]+) T _?(.*)/) {
         my ($name)=($2);
         #print "Define $name in $file\n";
         $file =~ s/^libcurl_la-//;
         $exist{$name} = $file;
     }
-    elsif($l =~ /^                 U (.*)/) {
+    elsif($l =~ /^                 U _?(.*)/) {
         my ($name)=($1);
         #print "Uses $name in $file\n";
         $uses{$name} .= "$file, ";