Add regen/uconfig_h.pl to regenerate uconfig.h
authorNicholas Clark <nick@ccl4.org>
Tue, 22 Mar 2011 15:53:20 +0000 (15:53 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 28 Mar 2011 09:21:47 +0000 (10:21 +0100)
Most of the work is done by config_h.SH, but the wrapper is needed to add the
digest lines, so that t/porting/regen.t can verify that it's up to date.
I think that we need to take the "digest" approach, rather than "build to a
temporary file during testing", as we can't rely on a working Unix shell on
all platforms, and we couldn't even be sure that we get the skip list correct.

MANIFEST
Porting/exec-bit.txt
regen/uconfig_h.pl [new file with mode: 0755]
t/porting/regen.t
uconfig.h

index 1e2189e..7ded3ce 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -4572,6 +4572,7 @@ regen/reentr.pl                   Reentrant interfaces
 regen/regcharclass.pl          Generate regcharclass.h from inline data
 regen/regcomp.pl               Builder of regnodes.h
 regen/regen_lib.pl             Common file routines for generator scripts
+regen/uconfig_h.pl             generate uconfig.h (requires /bin/sh)
 regen/warnings.pl              Program to write warnings.h and lib/warnings.pm
 regexec.c                      Regular expression evaluator
 regexp.h                       Public declarations for the above
index 854fcb9..5d45917 100644 (file)
@@ -21,6 +21,7 @@ regen/embed.pl
 regen/keywords.pl
 regen/opcode.pl
 regen/regcharclass.pl
+regen/uconfig_h.pl
 runtests.SH
 t/TEST
 vms/ext/filespec.t
diff --git a/regen/uconfig_h.pl b/regen/uconfig_h.pl
new file mode 100755 (executable)
index 0000000..8f714e2
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/perl -w
+#
+# Regenerate (overwriting only if changed):
+#
+#    uconfig.h
+#
+# from uconfig.h config_h.SH
+#
+# Accepts the standard regen_lib -q and -v args.
+
+use strict;
+use Config;
+require 'regen/regen_lib.pl';
+
+my ($uconfig_h, $uconfig_h_new, $config_h_sh)
+    = ('uconfig.h', 'uconfig.h-new', 'config_h.SH');
+
+$ENV{CONFIG_SH} = 'uconfig.sh';
+$ENV{CONFIG_H} = $uconfig_h_new;
+safer_unlink($uconfig_h_new);
+
+my $command = 'sh ./config_h.SH';
+system $command and die "`$command` failed, \$?=$?";
+
+open FH, ">>$uconfig_h_new" or die "Can't append to $uconfig_h_new: $!";
+
+print FH "\n", read_only_bottom([$ENV{CONFIG_SH}, 'config_h.SH']);
+
+safer_close(*FH);
+rename_if_different($uconfig_h_new, $uconfig_h);
index d5b3c52..78d0599 100644 (file)
@@ -28,7 +28,7 @@ if ( $^O eq "VMS" ) {
 }
 
 my $in_regen_pl = 17; # I can't see a clean way to calculate this automatically.
-my @files = qw(perly.act perly.h perly.tab keywords.c keywords.h);
+my @files = qw(perly.act perly.h perly.tab keywords.c keywords.h uconfig.h);
 my @progs = qw(Porting/makemeta regen/regcharclass.pl regen/mk_PL_charclass.pl);
 
 plan (tests => $in_regen_pl + @files + @progs);
index 6678e86..913ceed 100644 (file)
--- a/uconfig.h
+++ b/uconfig.h
 #define Uid_t int              /* UID type */
 
 #endif
+
+/* Generated from:
+ * 323778627146f2762cd41f4dd1db6659f59006ec9bcaaf6bcc645d0380dda938 config_h.SH
+ * 0a1e8a170495d354031144ac47835fc8f8fc03739bc761d973cc3a4aa347797e uconfig.sh
+ * ex: set ro: */