This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regex: Remove FOLDCHAR regnode type
[perl5.git] / regen / mg_vtable.pl
index 799be6b..605846b 100644 (file)
@@ -3,8 +3,11 @@
 # Regenerate (overwriting only if changed):
 #
 #    mg_vtable.h
+#    pod/perlguts.pod
 #
-# from information stored in this file.
+# from information stored in this file.  pod/perlguts.pod is not completely
+# regenerated.  Only the magic table is replaced; the other parts remain
+# untouched.
 #
 # Accepts the standard regen_lib -q and -v args.
 #
@@ -18,9 +21,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,
@@ -84,7 +84,7 @@ my %mg =
                    unknown_to_sv_magic => 1 },
      vec => { char => 'v', vtable => 'vec', value_magic => 1,
              desc => 'vec() lvalue' },
-     vstring => { char => 'V', value_magic => 1,
+     vstring => { char => 'V', value_magic => 1, vtable => 'vstring',
                  desc => 'SV was vstring literal' },
      utf8 => { char => 'w', vtable => 'utf8', value_magic => 1,
               desc => 'Cached UTF-8 information' },
@@ -144,12 +144,14 @@ my %sig =
                    cond => '#ifdef USE_LOCALE_COLLATE'},
      'hintselem' => {set => 'sethint', clear => 'clearhint'},
      'hints' => {clear => 'clearhints'},
+     'vstring' => {set => 'setvstring'},
 );
 
 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
@@ -215,7 +217,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) {
@@ -224,12 +226,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) {
@@ -248,7 +258,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;
@@ -341,3 +357,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);