mirror of
https://github.com/bitcoin/bips.git
synced 2026-02-23 15:38:22 +00:00
scripted-diff: fix BIP 2 field order violations
-BEGIN VERIFY SCRIPT-
set -e
perl <<'-END PERL-'
use strict;
use warnings;
my $topbip = 9999;
my @FieldOrder = qw(
BIP
Layer
Title
Author
Authors
Editor
Deputies
Discussions-To
Comments-Summary
Comments-URI
Status
Type
Created
License
License-Code
Discussion
Post-History
Version
Requires
Replaces
Proposed-Replacement
Superseded-By
);
my $bipnum = 0;
while (++$bipnum <= $topbip) {
my $fn = sprintf "bip-%04d.mediawiki", $bipnum;
my $is_markdown = 0;
if (!-e $fn) {
$fn = sprintf "bip-%04d.md", $bipnum;
$is_markdown = 1;
}
-e $fn || next;
open my $F, "<", $fn or die "$!";
my (@before, %preamble, @after);
if ($is_markdown) {
while (<$F>) {
push @before, $_;
last if m[^(?:\xef\xbb\xbf)?```$]
}
die "No ``` in $fn" if eof $F;
} else {
while (<$F>) {
push @before, $_;
last if m[^(?:\xef\xbb\xbf)?<pre>$];
}
die "No <pre> in $fn" if eof $F;
}
my %found;
my ($title, $author, $status, $type, $layer);
my ($field, $val, @field_order);
while (<$F>) {
push @after, $_ and last if ($is_markdown && m[^```$]);
push @after, $_ and last if (!$is_markdown && m[^</pre>$]);
if (m[^ ([\w-]+)\: (.*\S)$]) {
$field = $1;
$val = $2;
} elsif (m[^ ( +)(.*\S)$]) {
$val = $2;
} else {
die "Bad line in $fn preamble";
}
push @{$preamble{$field} ||= []}, $_;
}
push @after, <$F>;
close $F or die $!;
open my $W, ">", "$fn" or die "$!";
print $W @before;
print $W map { @$_ } grep { defined } delete @preamble{@FieldOrder};
die "Unknown fields: @{[ keys %preamble ]}" if %preamble;
print $W @after;
close $W or die $!;
}
-END PERL-
-END VERIFY SCRIPT-
This commit is contained in:
@@ -9,8 +9,8 @@
|
||||
Type: Standards Track
|
||||
Created: 2020-12-16
|
||||
License: BSD-2-Clause
|
||||
Replaces: 173
|
||||
Post-History: 2021-01-05: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-January/018338.html [bitcoin-dev] Bech32m BIP: new checksum, and usage for segwit address
|
||||
Replaces: 173
|
||||
</pre>
|
||||
|
||||
==Introduction==
|
||||
|
||||
Reference in New Issue
Block a user