From fcc89619d99a7d2473d63fe92b8e4cd820c91ebf Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 26 Sep 2024 21:16:21 +0200 Subject: [PATCH] singleuse: make `git grep` faster, add Apple `nm` support - 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 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/singleuse.pl b/scripts/singleuse.pl index 3731edc85b..42c5d27d8f 100755 --- a/scripts/singleuse.pl +++ b/scripts/singleuse.pl @@ -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() { my $e = $_; @@ -180,13 +180,17 @@ while () { 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, "; -- 2.47.3