user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 25/24] tighten up digit matches to ASCII for git output
  @ 2019-06-05  2:18  7% ` Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2019-06-05  2:18 UTC (permalink / raw)
  To: meta

While I don't expect git to suddenly start spewing non-ASCII
digits in places I'd expect ASCII, this would make things easier
for future hackers and reviewers.
---
 lib/PublicInbox/Git.pm      |  4 ++--
 lib/PublicInbox/Import.pm   | 10 +++++-----
 script/public-inbox-convert |  6 +++---
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index 9014e02..68445b3 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -141,7 +141,7 @@ again:
 		}
 		return;
 	}
-	$head =~ /^[0-9a-f]{40} \S+ (\d+)$/ or
+	$head =~ /^[0-9a-f]{40} \S+ ([0-9]+)$/ or
 		fail($self, "Unexpected result from git cat-file: $head");
 
 	my $size = $1;
@@ -319,7 +319,7 @@ sub modified ($) {
 	foreach my $oid (<$fh>) {
 		chomp $oid;
 		my $buf = cat_file($self, $oid) or next;
-		$$buf =~ /^committer .*?> (\d+) [\+\-]?\d+/sm or next;
+		$$buf =~ /^committer .*?> ([0-9]+) [\+\-]?[0-9]+/sm or next;
 		my $cmt_time = $1;
 		$modified = $cmt_time if $cmt_time > $modified;
 	}
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 81a38fb..2c4bad9 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -106,7 +106,7 @@ sub _cat_blob ($$$) {
 	local $/ = "\n";
 	my $info = <$r>;
 	defined $info or die "EOF from fast-import / cat-blob: $!";
-	$info =~ /\A[a-f0-9]{40} blob (\d+)\n\z/ or return;
+	$info =~ /\A[a-f0-9]{40} blob ([0-9]+)\n\z/ or return;
 	my $left = $1;
 	my $offset = 0;
 	my $buf = '';
@@ -493,9 +493,9 @@ sub clean_purge_buffer {
 
 	foreach my $i (0..$#$buf) {
 		my $l = $buf->[$i];
-		if ($l =~ /^author .* (\d+ [\+-]?\d+)$/) {
+		if ($l =~ /^author .* ([0-9]+ [\+-]?[0-9]+)$/) {
 			$buf->[$i] = "author <> $1\n";
-		} elsif ($l =~ /^data (\d+)/) {
+		} elsif ($l =~ /^data ([0-9]+)/) {
 			$buf->[$i++] = "data " . length($cmt_msg) . "\n";
 			$buf->[$i] = $cmt_msg;
 			last;
@@ -525,7 +525,7 @@ sub purge_oids {
 				@buf = ();
 			}
 			push @buf, "commit $tmp\n";
-		} elsif (/^data (\d+)/) {
+		} elsif (/^data ([0-9]+)/) {
 			# only commit message, so $len is small:
 			my $len = $1; # + 1 for trailing "\n"
 			push @buf, $_;
@@ -557,7 +557,7 @@ sub purge_oids {
 			@buf = ();
 		} elsif ($_ eq "done\n") {
 			$done = 1;
-		} elsif (/^mark :(\d+)$/) {
+		} elsif (/^mark :([0-9]+)$/) {
 			push @buf, $_;
 			$mark = $1;
 		} else {
diff --git a/script/public-inbox-convert b/script/public-inbox-convert
index bd8fb98..99480c3 100755
--- a/script/public-inbox-convert
+++ b/script/public-inbox-convert
@@ -103,7 +103,7 @@ while (<$rd>) {
 		$state = 'blob';
 	} elsif (/^commit /) {
 		$state = 'commit';
-	} elsif (/^data (\d+)/) {
+	} elsif (/^data ([0-9]+)/) {
 		my $len = $1;
 		$w->print($_) or $im->wfail;
 		while ($len) {
@@ -114,7 +114,7 @@ while (<$rd>) {
 		}
 		next;
 	} elsif ($state eq 'commit') {
-		if (m{^M 100644 :(\d+) (${h}{2}/${h}{38})}o) {
+		if (m{^M 100644 :([0-9]+) (${h}{2}/${h}{38})}o) {
 			my ($mark, $path) = ($1, $2);
 			$D{$path} = $mark;
 			if ($last && $last ne 'm') {
@@ -134,7 +134,7 @@ while (<$rd>) {
 			$last = 'd';
 			next;
 		}
-		if (m{^from (:\d+)}) {
+		if (m{^from (:[0-9]+)}) {
 			$prev = $from;
 			$from = $1;
 			# no next
-- 
EW


^ permalink raw reply related	[relevance 7%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2019-06-04 11:27     [PATCH 00/24] fix IDN linkification, add paranoia Eric Wong
2019-06-05  2:18  7% ` [PATCH 25/24] tighten up digit matches to ASCII for git output Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).