This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [PATCH: perl@20760] clean up quotation issue for use with MMS on VMS
[perl5.git] / regcomp.pl
index cfe59ad..1809da3 100644 (file)
@@ -1,3 +1,7 @@
+BEGIN {
+    # Get function prototypes
+    require 'regen_lib.pl';
+}
 #use Fatal qw(open close rename chmod unlink);
 open DESC, 'regcomp.sym';
 $ind = 0;
@@ -21,7 +25,7 @@ open OUT, ">$tmp_h";
 
 print OUT <<EOP;
 /* !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
-   This file is built by regcomp.pl from regcomp.sym.  
+   This file is built by regcomp.pl from regcomp.sym.
    Any changes made here will be lost!
 */
 
@@ -39,9 +43,9 @@ EOP
 print OUT <<EOP;
 
 #ifndef DOINIT
-EXTCONST U8 regkind[];
+EXTCONST U8 PL_regkind[];
 #else
-EXTCONST U8 regkind[] = {
+EXTCONST U8 PL_regkind[] = {
 EOP
 
 $ind = 0;
@@ -57,7 +61,7 @@ print OUT <<EOP;
 
 
 #ifdef REG_COMP_C
-const static U8 regarglen[] = {
+static const U8 regarglen[] = {
 EOP
 
 $ind = 0;
@@ -73,13 +77,13 @@ EOP
 print OUT <<EOP;
 };
 
-const static char reg_off_by_arg[] = {
+static const char reg_off_by_arg[] = {
 EOP
 
 $ind = 0;
 while (++$ind <= $tot) {
   $size = $longj[$ind] || 0;
-  
+
   print OUT <<EOP;
        $size,          /* $name[$ind] */
 EOP
@@ -87,12 +91,31 @@ EOP
 
 print OUT <<EOP;
 };
+
+#ifdef DEBUGGING
+static const char * const reg_name[] = {
+EOP
+
+$ind = 0;
+while (++$ind <= $tot) {
+  $hind = sprintf "%#4x", $ind-1;
+  $size = $longj[$ind] || 0;
+
+  print OUT <<EOP;
+       "$name[$ind]",          /* $hind */
+EOP
+}
+
+print OUT <<EOP;
+};
+
+static const int reg_num = $tot;
+
+#endif /* DEBUGGING */
 #endif /* REG_COMP_C */
 
 EOP
 
-close OUT;
+close OUT or die "close $tmp_h: $!";
 
-chmod 0666, 'regnodes.h';
-unlink 'regnodes.h';
-rename $tmp_h, 'regnodes.h';
+safer_rename $tmp_h, 'regnodes.h';