[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3e8d8a3bcde7b0a2f4f1587c6febf88b7261db05.camel@perches.com>
Date: Wed, 04 Aug 2021 23:33:36 -0700
From: Joe Perches <joe@...ches.com>
To: Kai-Heng Feng <kai.heng.feng@...onical.com>
Cc: open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] get_maintainer: Append parenthesis back to trimmed
subsystem name
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@...ches.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@...ts.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@...ts.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@...ts.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);
Powered by blists - more mailing lists