scripts: get_abi.pl: better generate regex from what fields
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 30 Sep 2021 09:40:00 +0000 (11:40 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 5 Oct 2021 14:23:38 +0000 (16:23 +0200)
Using repeating sequencies of .* seem to slow down the
processing speed on some cases. Also, currently, a "."
character is not properly handled as such.

Change the way regexes are created, in order to produce
better search expressions.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/c69c01c12b1b30466177dcb17e45f833fb47713d.1632994565.git.mchehab+huawei@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
scripts/get_abi.pl

index 2f3674b..6212f58 100755 (executable)
@@ -842,8 +842,8 @@ sub undefined_symbols {
 
                        # Convert what into regular expressions
 
-                       $what =~ s,/\.\.\./,/*/,g;
-                       $what =~ s,\*,.*,g;
+                       # Escape dot characters
+                       $what =~ s/\./\xf6/g;
 
                        # Temporarily change [0-9]+ type of patterns
                        $what =~ s/\[0\-9\]\+/\xff/g;
@@ -859,6 +859,8 @@ sub undefined_symbols {
                        $what =~ s/[\{\<\[]([\w_]+)(?:[,|]+([\w_]+)){1,}[\}\>\]]/($1|$2)/g;
 
                        # Handle wildcards
+                       $what =~ s,\*,.*,g;
+                       $what =~ s,/\xf6..,/.*,g;
                        $what =~ s/\<[^\>]+\>/.*/g;
                        $what =~ s/\{[^\}]+\}/.*/g;
                        $what =~ s/\[[^\]]+\]/.*/g;
@@ -891,6 +893,13 @@ sub undefined_symbols {
                        # Special case: IIO ABI which a parenthesis.
                        $what =~ s/sqrt(.*)/sqrt\(.*\)/;
 
+                       # Simplify regexes with multiple .*
+                       $what =~ s#(?:\.\*){2,}##g;
+#                      $what =~ s#\.\*/\.\*#.*#g;
+
+                       # Recover dot characters
+                       $what =~ s/\xf6/\./g;
+
                        my $leave = get_leave($what);
 
                        my $added = 0;