summaryrefslogtreecommitdiff
path: root/regen
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-01-02 16:40:38 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-01-02 22:10:39 -0800
commitf1f5ddd71cb07728acb4aadf893409760e0891e9 (patch)
tree9ed249a2a49f621aae3bca63c83d72126386a327 /regen
parentac8fb82cde5d19c3e2d783e97832e6d58855a23c (diff)
downloadperl-f1f5ddd71cb07728acb4aadf893409760e0891e9.tar.gz
Regenerate perlguts’ mg table automatically
regen/mg_vtable.pl was modified a while ago to generate the table for copying and pasting, but at least twice since then it has not been updated properly; once by me and once by the author of that part of regen/mg_vtable.pl.
Diffstat (limited to 'regen')
-rw-r--r--regen/mg_vtable.pl29
1 files changed, 21 insertions, 8 deletions
diff --git a/regen/mg_vtable.pl b/regen/mg_vtable.pl
index 3c3c4840cb..ba59fb02ab 100644
--- a/regen/mg_vtable.pl
+++ b/regen/mg_vtable.pl
@@ -18,9 +18,6 @@ BEGIN {
require 'regen/regen_lib.pl';
}
-# This generates the relevant section to paste into perlguts.pod to STDOUT
-my $output_guts = grep { $_ eq '-g' } @ARGV;
-
my %mg =
(
sv => { char => '\0', vtable => 'sv', readonly_acceptable => 1,
@@ -151,6 +148,7 @@ my ($vt, $raw, $names) = map {
open_new($_, '>',
{ by => 'regen/mg_vtable.pl', file => $_, style => '*' });
} 'mg_vtable.h', 'mg_raw.h', 'mg_names.c';
+my $guts = open_new("pod/perlguts.pod", ">");
print $vt <<'EOH';
/* These constants should be used in preference to raw characters
@@ -216,7 +214,7 @@ EOH
$data->{vtable} ? "vtbl_$data->{vtable}" : '(none)',
$data->{desc}];
}
- if ($output_guts) {
+ select +(select($guts), do {
my @header = ('(old-style char and macro)', 'MGVTBL', 'Type of magic');
my @widths = (0, 0);
foreach my $row (@rows) {
@@ -225,12 +223,20 @@ EOH
if length $row->[$_] > $widths[$_];
}
}
- my $indent = ' ';
+ my $indent = ' ';
my $format
= sprintf "$indent%%-%ds%%-%ds%%s\n", $widths[0] + 1, $widths[1] + 1;
- my $desc_wrap = 80 - (length $indent) - $widths[0] - $widths[1] - 2;
+ my $desc_wrap =
+ 79 - 7 - (length $indent) - $widths[0] - $widths[1] - 2;
+
+ open my $oldguts, "<", "pod/perlguts.pod"
+ or die "$0 cannot open pod/perlguts.pod for reading: $!";
+ while (<$oldguts>) {
+ print;
+ last if /^=for mg_vtable.pl begin/
+ }
- print $indent . "mg_type\n";
+ print "\n", $indent . "mg_type\n";
printf $format, @header;
printf $format, map {'-' x length $_} @header;
foreach (@rows) {
@@ -249,7 +255,13 @@ EOH
printf $format, $type, $vtbl, $desc;
printf $format, '', '', $_ foreach @cont;
}
- }
+ print "\n";
+
+ while (<$oldguts>) {
+ last if /^=for mg_vtable.pl end/;
+ }
+ do { print } while <$oldguts>;
+ })[0];
}
my @names = sort keys %sig;
@@ -342,3 +354,4 @@ print $vt "#define PL_vtbl_$_ PL_magic_vtables[want_vtbl_$_]\n"
die "Too many vtable names" if @vtable_names > 63;
read_only_bottom_close_and_rename($_) foreach $vt, $raw, $names;
+ close_and_rename($guts);