Make ‘make regen’ regenerate the tree in perllexwarn
authorFather Chrysostomos <sprout@cpan.org>
Mon, 10 Jun 2013 06:27:19 +0000 (23:27 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 10 Jun 2013 06:31:02 +0000 (23:31 -0700)
‘perl regen/warnings.pl tree’ would already generate the tree, but it
had to be run separately and then copied and pasted into perllexwarn.
Now regen/warnings.pl modifies perllexwarn in place as part of its
regeneration.  The ‘tree’ command line argument will still cause the
tree to be output to STDOUT.

This causes the three missing experimental categories to be listed in
perllexwarn, resolving ticket #118369.

pod/perllexwarn.pod
regen/warnings.pl
t/porting/regen.t

index c6494db..b193e3c 100644 (file)
@@ -212,6 +212,12 @@ to be enabled/disabled in isolation.
 
 The current hierarchy is:
 
+=for comment
+This tree is generated by regen/warnings.pl.  Any changes made here
+will be lost.
+
+=for warnings.pl begin
+
     all -+
          |
          +- closure
@@ -223,6 +229,12 @@ The current hierarchy is:
          +- experimental --+
          |                 |
          |                 +- experimental::lexical_subs
+         |                 |
+         |                 +- experimental::lexical_topic
+         |                 |
+         |                 +- experimental::regex_sets
+         |                 |
+         |                 +- experimental::smartmatch
          |
          +- glob
          |
@@ -318,6 +330,8 @@ The current hierarchy is:
          |
          +- void
 
+=for warnings.pl end
+
 Just like the "strict" pragma any of these categories can be combined
 
     use warnings qw(void redefine);
index dd3c49b..72d9a0b 100644 (file)
@@ -3,10 +3,13 @@
 # Regenerate (overwriting only if changed):
 #
 #    lib/warnings.pm
+#    pod/perllexwarn.pod
 #    warnings.h
 #
 # from information hardcoded into this script (the $tree hash), plus the
-# template for warnings.pm in the DATA section.
+# template for warnings.pm in the DATA section.  Only part of
+# pod/perllexwarn.pod (the warnings category hierarchy) is generated,
+# the other parts remaining untouched.
 #
 # When changing the number of warnings, t/op/caller.t should change to
 # correspond with the value of $BYTES in lib/warnings.pm
@@ -440,6 +443,25 @@ while (<DATA>) {
 
 read_only_bottom_close_and_rename($pm);
 
+my $lexwarn = open_new 'pod/perllexwarn.pod', '>';
+open my $oldlexwarn, "pod/perllexwarn.pod"
+  or die "$0 cannot open pod/perllexwarn.pod for reading: $!";
+select +(select($lexwarn), do {
+    while(<$oldlexwarn>) {
+       print;
+       last if /=for warnings.pl begin/;
+    }
+    print "\n";
+    printTree($tree, "    ") ;
+    print "\n";
+    while(<$oldlexwarn>) {
+       last if /=for warnings.pl end/;
+    }
+    do { print } while <$oldlexwarn>;
+})[0];
+
+close_and_rename($lexwarn);
+
 __END__
 package warnings;
 
index ec8e62d..194f80e 100644 (file)
@@ -16,7 +16,7 @@ if ( $^O eq "VMS" ) {
   skip_all( "- regen.pl needs porting." );
 }
 
-my $in_regen_pl = 23; # I can't see a clean way to calculate this automatically.
+my $in_regen_pl = 24; # I can't see a clean way to calculate this automatically.
 my @files = qw(perly.act perly.h perly.tab keywords.c keywords.h uconfig.h);
 my @progs = qw(regen/regcharclass.pl regen/mk_PL_charclass.pl
                regen/unicode_constants.pl regen/genpacksizetables.pl);