From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id DC9C21FAD8 for ; Tue, 4 Jun 2019 11:27:51 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 19/24] solver|viewdiff: restrict digit matches to ASCII Date: Tue, 4 Jun 2019 11:27:43 +0000 Message-Id: <20190604112748.23598-20-e@80x24.org> In-Reply-To: <20190604112748.23598-1-e@80x24.org> References: <20190604112748.23598-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: git would not generate non-ASCII digits to describe hunk offsets, so don't waste more time than necessary to make sense of non-ASCII digit chars for line offsets. --- lib/PublicInbox/SolverGit.pm | 2 +- lib/PublicInbox/ViewDiff.pm | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm index 3841c56..81f9902 100644 --- a/lib/PublicInbox/SolverGit.pm +++ b/lib/PublicInbox/SolverGit.pm @@ -206,7 +206,7 @@ sub find_extract_diff ($$$) { } my $msgs = $srch->query($q, { relevance => 1 }); - my $re = qr/\Aindex ($pre[a-f0-9]*)\.\.($post[a-f0-9]*)(?: (\d+))?/; + my $re = qr/\Aindex ($pre[a-f0-9]*)\.\.($post[a-f0-9]*)(?: ([0-9]+))?/; my $di; foreach my $smsg (@$msgs) { diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm index 411ed2b..b7dab81 100644 --- a/lib/PublicInbox/ViewDiff.pm +++ b/lib/PublicInbox/ViewDiff.pm @@ -55,12 +55,12 @@ sub diff_hunk ($$$$) { (defined($spfx) && defined($oid_a) && defined($oid_b)) or return "@@ $ca $cb @@"; - my ($n) = ($ca =~ /^-(\d+)/); + my ($n) = ($ca =~ /^-([0-9]+)/); $n = defined($n) ? do { ++$n; "#n$n" } : ''; my $rv = qq(@@ {Q}$n">$ca); - ($n) = ($cb =~ /^\+(\d+)/); + ($n) = ($cb =~ /^\+([0-9]+)/); $n = defined($n) ? do { ++$n; "#n$n" } : ''; $rv .= qq( {Q}$n">$cb @@); -- EW