diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-01-02 16:40:38 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-01-02 22:10:39 -0800 |
commit | f1f5ddd71cb07728acb4aadf893409760e0891e9 (patch) | |
tree | 9ed249a2a49f621aae3bca63c83d72126386a327 | |
parent | ac8fb82cde5d19c3e2d783e97832e6d58855a23c (diff) | |
download | perl-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.
-rw-r--r-- | pod/perlguts.pod | 15 | ||||
-rw-r--r-- | regen/mg_vtable.pl | 29 |
2 files changed, 32 insertions, 12 deletions
diff --git a/pod/perlguts.pod b/pod/perlguts.pod index 4391975906..6206dadf0b 100644 --- a/pod/perlguts.pod +++ b/pod/perlguts.pod @@ -1041,6 +1041,12 @@ to change. The current kinds of Magic Virtual Tables are: +=for comment +This table is generated by regen/mg_vtable.pl. Any changes made here +will be lost. + +=for mg_vtable.pl begin + mg_type (old-style char and macro) MGVTBL Type of magic -------------------------- ------ ------------- @@ -1066,9 +1072,9 @@ The current kinds of Magic Virtual Tables are: element E PERL_MAGIC_env vtbl_env %ENV hash e PERL_MAGIC_envelem vtbl_envelem %ENV hash element - f PERL_MAGIC_fm vtbl_regdata Formline ('compiled' - format) - G PERL_MAGIC_study vtbl_regdata study()ed string + f PERL_MAGIC_fm vtbl_regdata Formline + ('compiled' format) + G PERL_MAGIC_study vtbl_regexp study()ed string g PERL_MAGIC_regex_global vtbl_mglob m//g target H PERL_MAGIC_hints vtbl_hints %^H hash h PERL_MAGIC_hintselem vtbl_hintselem %^H hash element @@ -1092,7 +1098,7 @@ The current kinds of Magic Virtual Tables are: extensions u PERL_MAGIC_uvar_elem (none) Reserved for use by extensions - V PERL_MAGIC_vstring (none) SV was vstring literal + V PERL_MAGIC_vstring vtbl_vstring SV was vstring literal v PERL_MAGIC_vec vtbl_vec vec() lvalue w PERL_MAGIC_utf8 vtbl_utf8 Cached UTF-8 information x PERL_MAGIC_substr vtbl_substr substr() lvalue @@ -1104,6 +1110,7 @@ The current kinds of Magic Virtual Tables are: ~ PERL_MAGIC_ext (none) Available for use by extensions +=for mg_vtable.pl end When an uppercase and lowercase letter both exist in the table, then the uppercase letter is typically used to represent some kind of composite type 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); |