Il giorno dom 1 mar 2026 alle ore 17:42 Joe Perches <[email protected]>
ha scritto:
>
> On Sun, 2026-03-01 at 12:17 +0100, Matteo Croce wrote:
> > BTW at this point it would be useful to implement the ** glob operator,
> > but maybe it's not worth it.
>
> Hi Matteo.
>
> Given you've now touched get_maintainer, you are welcome to do it.
> Maybe change "sub file_match_pattern {".
> But I believe this is the first actual use case so I will not.

Mmm not really the first usage, I see this pattern being already used:

$ grep -F '/*/*/' MAINTAINERS
F: Documentation/devicetree/bindings/*/*/*ma35*
F: drivers/*/*/*ma35*
F: Documentation/devicetree/bindings/*/*/*npcm*
F: drivers/*/*/*npcm*
F: arch/*/*/*/*ftrace*
F: arch/*/*/*ftrace*
F: drivers/net/ethernet/*/*/*/*/*xdp*
F: drivers/net/ethernet/*/*/*xdp*

I tried to implement it and seems easier than expected, the chunk below does it
(validated with: scripts/get_maintainer.pl --self-test=patterns)

--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -375,7 +375,9 @@ sub read_maintainer_file {
      ##Filename pattern matching
      if ($type eq "F" || $type eq "X") {
  $value =~ s@\.@\\\.@g;       ##Convert . to \.
- $value =~ s/\*/\.\*/g;       ##Convert * to .*
+ $value =~ s/\*\*/\x00/g;     ##Convert ** to placeholder
+ $value =~ s/\*/[^\/]*/g;     ##Convert * to [^/]*
+ $value =~ s/\x00/.*/g;       ##Convert placeholder to .*
  $value =~ s/\?/\./g;         ##Convert ? to .
  ##if pattern is a directory and it lacks a trailing slash, add one
  if ((-d $value)) {
@@ -919,6 +921,8 @@ sub get_maintainers {
  if ($type eq 'F') {
      if (file_match_pattern($file, $value)) {
  my $value_pd = ($value =~ tr@/@@);
+ ## Discount slashes inside [^/] character classes
+ $value_pd -= (() = $value =~ /\[\^\/\]/g);
  my $file_pd = ($file  =~ tr@/@@);
  $value_pd++ if (substr($value,-1,1) ne "/");
  $value_pd = -1 if ($value =~ /^\.\*/);
@@ -955,7 +959,8 @@ sub get_maintainers {
  $line =~ s/([^\\])\.([^\*])/$1\?$2/g;
  $line =~ s/([^\\])\.$/$1\?/g; ##Convert . back to ?
  $line =~ s/\\\./\./g;        ##Convert \. to .
- $line =~ s/\.\*/\*/g;        ##Convert .* to *
+ $line =~ s/\[\^\/\]\*/\*/g; ##Convert [^/]* to *
+ $line =~ s/\.\*/\*\*/g;      ##Convert .* to **
      }
      my $count = $line =~ s/^([A-Z]):/$1:\t/g;
      if ($letters eq "" || (!$count || $letters =~ /$1/i)) {
@@ -1045,12 +1050,8 @@ sub file_match_pattern {
      return 1;
  }
     } else {
- if ($file =~ m@^$pattern@) {
-     my $s1 = ($file =~ tr@/@@);
-     my $s2 = ($pattern =~ tr@/@@);
-     if ($s1 == $s2) {
- return 1;
-     }
+ if ($file =~ m@^$pattern$@) {
+     return 1;
  }
     }
     return 0;

Regards,
-- 
Matteo Croce

perl -e 'for($t=0;;$t++){print chr($t*($t>>8|$t>>13)&255)}' |aplay

Reply via email to