* [PATCH] get_maintainer: Append parenthesis back to trimmed subsystem name @ 2021-08-04 16:09 Kai-Heng Feng 2021-08-04 16:22 ` Joe Perches 0 siblings, 1 reply; 5+ messages in thread From: Kai-Heng Feng @ 2021-08-04 16:09 UTC (permalink / raw) To: joe; +Cc: Kai-Heng Feng, open list When a closing parenthesis gets trimmed, there can be unmatched parenthesis in the subsystem name. This doesn't play well with git-send-email: (cc-cmd) Adding cc: intel-gfx@lists.freedesktop.org (open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...) from: 'scripts/get_maintainer.pl' Unmatched () '(open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...)' '' at /usr/lib/git-core/git-send-email line 554. error: unable to extract a valid address from: intel-gfx@lists.freedesktop.org (open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...) So append parenthesis back if it was trimmed to make git-send-email work again: (cc-cmd) Adding cc: intel-gfx@lists.freedesktop.org (open list:INTEL DRM DRIVERS (excluding Poulsbo, Mooresto...)) from: 'scripts/get_maintainer.pl' Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com> --- scripts/get_maintainer.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index 2075db0c08b8e..5ebe6dfe250c9 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -1252,9 +1252,10 @@ sub get_subsystem_name { my $subsystem = $typevalue[$start]; if ($output_section_maxlen && length($subsystem) > $output_section_maxlen) { - $subsystem = substr($subsystem, 0, $output_section_maxlen - 3); + my $parenthesis = substr($subsystem, -1) eq ")"; + $subsystem = substr($subsystem, 0, $output_section_maxlen - ($parenthesis ? 4 : 3)); $subsystem =~ s/\s*$//; - $subsystem = $subsystem . "..."; + $subsystem = $subsystem . "..." . ($parenthesis ? ")" : ""); } return $subsystem; } -- 2.31.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] get_maintainer: Append parenthesis back to trimmed subsystem name 2021-08-04 16:09 [PATCH] get_maintainer: Append parenthesis back to trimmed subsystem name Kai-Heng Feng @ 2021-08-04 16:22 ` Joe Perches 2021-08-05 6:17 ` Kai-Heng Feng 0 siblings, 1 reply; 5+ messages in thread From: Joe Perches @ 2021-08-04 16:22 UTC (permalink / raw) To: Kai-Heng Feng; +Cc: open list On Thu, 2021-08-05 at 00:09 +0800, Kai-Heng Feng wrote: > When a closing parenthesis gets trimmed, there can be unmatched > parenthesis in the subsystem name. This doesn't play well with > git-send-email: > (cc-cmd) Adding cc: intel-gfx@lists.freedesktop.org (open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...) from: 'scripts/get_maintainer.pl' > Unmatched () '(open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...)' '' at /usr/lib/git-core/git-send-email line 554. > error: unable to extract a valid address from: intel-gfx@lists.freedesktop.org (open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...) > > So append parenthesis back if it was trimmed to make git-send-email > work again: > (cc-cmd) Adding cc: intel-gfx@lists.freedesktop.org (open list:INTEL DRM DRIVERS (excluding Poulsbo, Mooresto...)) from: 'scripts/get_maintainer.pl' Probably better just to add --norolestats to the invoking command-line. > diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl [] > @@ -1252,9 +1252,10 @@ sub get_subsystem_name { > > > my $subsystem = $typevalue[$start]; > if ($output_section_maxlen && length($subsystem) > $output_section_maxlen) { > - $subsystem = substr($subsystem, 0, $output_section_maxlen - 3); > + my $parenthesis = substr($subsystem, -1) eq ")"; > + $subsystem = substr($subsystem, 0, $output_section_maxlen - ($parenthesis ? 4 : 3)); > $subsystem =~ s/\s*$//; > - $subsystem = $subsystem . "..."; > + $subsystem = $subsystem . "..." . ($parenthesis ? ")" : ""); Given an $output_section_maxlen number of possible parentheses, this should probably use a while... ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] get_maintainer: Append parenthesis back to trimmed subsystem name 2021-08-04 16:22 ` Joe Perches @ 2021-08-05 6:17 ` Kai-Heng Feng 2021-08-05 6:33 ` Joe Perches 0 siblings, 1 reply; 5+ messages in thread From: Kai-Heng Feng @ 2021-08-05 6:17 UTC (permalink / raw) To: Joe Perches; +Cc: open list On Thu, Aug 5, 2021 at 12:22 AM Joe Perches <joe@perches.com> wrote: > > On Thu, 2021-08-05 at 00:09 +0800, Kai-Heng Feng wrote: > > When a closing parenthesis gets trimmed, there can be unmatched > > parenthesis in the subsystem name. This doesn't play well with > > git-send-email: > > (cc-cmd) Adding cc: intel-gfx@lists.freedesktop.org (open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...) from: 'scripts/get_maintainer.pl' > > Unmatched () '(open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...)' '' at /usr/lib/git-core/git-send-email line 554. > > error: unable to extract a valid address from: intel-gfx@lists.freedesktop.org (open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...) > > > > So append parenthesis back if it was trimmed to make git-send-email > > work again: > > (cc-cmd) Adding cc: intel-gfx@lists.freedesktop.org (open list:INTEL DRM DRIVERS (excluding Poulsbo, Mooresto...)) from: 'scripts/get_maintainer.pl' > > Probably better just to add --norolestats to the invoking command-line. This can solve the issue beautifully, thanks! > > > diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl > [] > > @@ -1252,9 +1252,10 @@ sub get_subsystem_name { > > > > > > my $subsystem = $typevalue[$start]; > > if ($output_section_maxlen && length($subsystem) > $output_section_maxlen) { > > - $subsystem = substr($subsystem, 0, $output_section_maxlen - 3); > > + my $parenthesis = substr($subsystem, -1) eq ")"; > > + $subsystem = substr($subsystem, 0, $output_section_maxlen - ($parenthesis ? 4 : 3)); > > $subsystem =~ s/\s*$//; > > - $subsystem = $subsystem . "..."; > > + $subsystem = $subsystem . "..." . ($parenthesis ? ")" : ""); > > Given an $output_section_maxlen number of possible parentheses, this should > probably use a while... Or maybe count the parentheses in two runs? diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index 2075db0c08b8e..08315074acffa 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -1252,9 +1252,21 @@ sub get_subsystem_name { my $subsystem = $typevalue[$start]; if ($output_section_maxlen && length($subsystem) > $output_section_maxlen) { + my $need_closing = 0; $subsystem = substr($subsystem, 0, $output_section_maxlen - 3); $subsystem =~ s/\s*$//; - $subsystem = $subsystem . "..."; + + if (substr($subsystem, -1) eq "(") { + $subsystem = substr($subsystem, 0, -2); + } else { + my $opening = () = $subsystem =~ /\(/g; + my $closing = () = $subsystem =~ /\)/g; + if ($opening != $closing) { + $need_closing = 1; + } + } + + $subsystem = $subsystem . "..." . ($need_closing ? ")" : ""); } return $subsystem; > > ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] get_maintainer: Append parenthesis back to trimmed subsystem name 2021-08-05 6:17 ` Kai-Heng Feng @ 2021-08-05 6:33 ` Joe Perches 2021-08-05 6:44 ` Kai-Heng Feng 0 siblings, 1 reply; 5+ messages in thread From: Joe Perches @ 2021-08-05 6:33 UTC (permalink / raw) To: Kai-Heng Feng; +Cc: open list On Thu, 2021-08-05 at 14:17 +0800, Kai-Heng Feng wrote: > On Thu, Aug 5, 2021 at 12:22 AM Joe Perches <joe@perches.com> wrote: > > > > On Thu, 2021-08-05 at 00:09 +0800, Kai-Heng Feng wrote: > > > When a closing parenthesis gets trimmed, there can be unmatched > > > parenthesis in the subsystem name. This doesn't play well with > > > git-send-email: > > > (cc-cmd) Adding cc: intel-gfx@lists.freedesktop.org (open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...) from: 'scripts/get_maintainer.pl' > > > Unmatched () '(open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...)' '' at /usr/lib/git-core/git-send-email line 554. > > > error: unable to extract a valid address from: intel-gfx@lists.freedesktop.org (open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...) > > > > > > So append parenthesis back if it was trimmed to make git-send-email > > > work again: > > > (cc-cmd) Adding cc: intel-gfx@lists.freedesktop.org (open list:INTEL DRM DRIVERS (excluding Poulsbo, Mooresto...)) from: 'scripts/get_maintainer.pl' > > > > Probably better just to add --norolestats to the invoking command-line. > > This can solve the issue beautifully, thanks! > > > > > > diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl > > [] > > > @@ -1252,9 +1252,10 @@ sub get_subsystem_name { > > > > > > > > > my $subsystem = $typevalue[$start]; > > > if ($output_section_maxlen && length($subsystem) > $output_section_maxlen) { > > > - $subsystem = substr($subsystem, 0, $output_section_maxlen - 3); > > > + my $parenthesis = substr($subsystem, -1) eq ")"; > > > + $subsystem = substr($subsystem, 0, $output_section_maxlen - ($parenthesis ? 4 : 3)); > > > $subsystem =~ s/\s*$//; > > > - $subsystem = $subsystem . "..."; > > > + $subsystem = $subsystem . "..." . ($parenthesis ? ")" : ""); > > > > Given an $output_section_maxlen number of possible parentheses, this should > > probably use a while... > > Or maybe count the parentheses in two runs? > > diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl > index 2075db0c08b8e..08315074acffa 100755 > --- a/scripts/get_maintainer.pl > +++ b/scripts/get_maintainer.pl > @@ -1252,9 +1252,21 @@ sub get_subsystem_name { > > my $subsystem = $typevalue[$start]; > if ($output_section_maxlen && length($subsystem) > > $output_section_maxlen) { > + my $need_closing = 0; > $subsystem = substr($subsystem, 0, $output_section_maxlen - 3); > $subsystem =~ s/\s*$//; > - $subsystem = $subsystem . "..."; > + > + if (substr($subsystem, -1) eq "(") { > + $subsystem = substr($subsystem, 0, -2); > + } else { > + my $opening = () = $subsystem =~ /\(/g; > + my $closing = () = $subsystem =~ /\)/g; > + if ($opening != $closing) { > + $need_closing = 1; > + } > + } > + > + $subsystem = $subsystem . "..." . ($need_closing ? ")" : ""); This wouldn't necessarily work as you need to have balanced parentheses... It could be something like: my $open_parens = () = $subsystem =~ /\(/g; my $close_parens = () = $subsystem =~ /\)/g; $subsystem .= ')' x ($open_parens - $close_parens); ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] get_maintainer: Append parenthesis back to trimmed subsystem name 2021-08-05 6:33 ` Joe Perches @ 2021-08-05 6:44 ` Kai-Heng Feng 0 siblings, 0 replies; 5+ messages in thread From: Kai-Heng Feng @ 2021-08-05 6:44 UTC (permalink / raw) To: Joe Perches; +Cc: open list On Thu, Aug 5, 2021 at 2:33 PM Joe Perches <joe@perches.com> wrote: > > On Thu, 2021-08-05 at 14:17 +0800, Kai-Heng Feng wrote: > > On Thu, Aug 5, 2021 at 12:22 AM Joe Perches <joe@perches.com> wrote: > > > > > > On Thu, 2021-08-05 at 00:09 +0800, Kai-Heng Feng wrote: > > > > When a closing parenthesis gets trimmed, there can be unmatched > > > > parenthesis in the subsystem name. This doesn't play well with > > > > git-send-email: > > > > (cc-cmd) Adding cc: intel-gfx@lists.freedesktop.org (open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...) from: 'scripts/get_maintainer.pl' > > > > Unmatched () '(open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...)' '' at /usr/lib/git-core/git-send-email line 554. > > > > error: unable to extract a valid address from: intel-gfx@lists.freedesktop.org (open list:INTEL DRM DRIVERS (excluding Poulsbo, Moorestow...) > > > > > > > > So append parenthesis back if it was trimmed to make git-send-email > > > > work again: > > > > (cc-cmd) Adding cc: intel-gfx@lists.freedesktop.org (open list:INTEL DRM DRIVERS (excluding Poulsbo, Mooresto...)) from: 'scripts/get_maintainer.pl' > > > > > > Probably better just to add --norolestats to the invoking command-line. > > > > This can solve the issue beautifully, thanks! > > > > > > > > > diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl > > > [] > > > > @@ -1252,9 +1252,10 @@ sub get_subsystem_name { > > > > > > > > > > > > my $subsystem = $typevalue[$start]; > > > > if ($output_section_maxlen && length($subsystem) > $output_section_maxlen) { > > > > - $subsystem = substr($subsystem, 0, $output_section_maxlen - 3); > > > > + my $parenthesis = substr($subsystem, -1) eq ")"; > > > > + $subsystem = substr($subsystem, 0, $output_section_maxlen - ($parenthesis ? 4 : 3)); > > > > $subsystem =~ s/\s*$//; > > > > - $subsystem = $subsystem . "..."; > > > > + $subsystem = $subsystem . "..." . ($parenthesis ? ")" : ""); > > > > > > Given an $output_section_maxlen number of possible parentheses, this should > > > probably use a while... > > > > Or maybe count the parentheses in two runs? > > > > diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl > > index 2075db0c08b8e..08315074acffa 100755 > > --- a/scripts/get_maintainer.pl > > +++ b/scripts/get_maintainer.pl > > @@ -1252,9 +1252,21 @@ sub get_subsystem_name { > > > > my $subsystem = $typevalue[$start]; > > if ($output_section_maxlen && length($subsystem) > > > $output_section_maxlen) { > > + my $need_closing = 0; > > $subsystem = substr($subsystem, 0, $output_section_maxlen - 3); > > $subsystem =~ s/\s*$//; > > - $subsystem = $subsystem . "..."; > > + > > + if (substr($subsystem, -1) eq "(") { > > + $subsystem = substr($subsystem, 0, -2); > > + } else { > > + my $opening = () = $subsystem =~ /\(/g; > > + my $closing = () = $subsystem =~ /\)/g; > > + if ($opening != $closing) { > > + $need_closing = 1; > > + } > > + } > > + > > + $subsystem = $subsystem . "..." . ($need_closing ? ")" : ""); > > This wouldn't necessarily work as you need to have balanced parentheses... > > It could be something like: > > my $open_parens = () = $subsystem =~ /\(/g; > my $close_parens = () = $subsystem =~ /\)/g; > $subsystem .= ')' x ($open_parens - $close_parens); OK, let me think how do it without exceeding $output_section_maxlen. Kai-Heng > > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-08-05 6:45 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-08-04 16:09 [PATCH] get_maintainer: Append parenthesis back to trimmed subsystem name Kai-Heng Feng 2021-08-04 16:22 ` Joe Perches 2021-08-05 6:17 ` Kai-Heng Feng 2021-08-05 6:33 ` Joe Perches 2021-08-05 6:44 ` Kai-Heng Feng
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).