This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
dump.c: Dump op->op_s(labbed|avefree)
[perl5.git] / regen / regcomp.pl
index 2a1fb03..69643ca 100644 (file)
@@ -17,7 +17,6 @@ BEGIN {
     # Get function prototypes
     require 'regen/regen_lib.pl';
 }
-#use Fatal qw(open close rename chmod unlink);
 use strict;
 
 open DESC, 'regcomp.sym';
@@ -123,23 +122,12 @@ EXTCONST U8 PL_${varname}_bitmask[] = {
     $out_mask
 };
 #endif /* DOINIT */
-
 EOP
 }
 
-my $tmp_h = 'regnodes.h-new';
-
-unlink $tmp_h if -f $tmp_h;
-
-my $out = safer_open($tmp_h);
-
+my $out = open_new('regnodes.h', '>',
+                  { by => 'regen/regcomp.pl', from => 'regcomp.sym' });
 printf $out <<EOP,
-/* -*- buffer-read-only: t -*-
-   !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
-   This file is built by regen/regcomp.pl from regcomp.sym.
-   Any changes made here will be lost!
-*/
-
 /* Regops and State definitions */
 
 #define %*s\t%d
@@ -274,6 +262,10 @@ foreach my $file ("op_reg_common.h", "regexp.h") {
             foreach my $key (keys %definitions) {
                 s/\b$key\b/$definitions{$key}/g;
             }
+
+           # Remove the U suffix from unsigned int literals
+           s/\b([0-9]+)U\b/$1/g;
+
             my $newval = eval $_;   # Get numeric definition
 
             $definitions{$define} = $newval;
@@ -330,13 +322,9 @@ print $out process_flags('V', 'varies', <<'EOC');
 EOC
 
 print $out process_flags('S', 'simple', <<'EOC');
+
 /* The following always have a length of 1. U8 we can do strchr() on it. */
 /* (Note that length 1 means "one character" under UTF8, not "one octet".) */
 EOC
 
-print $out <<EOP;
-/* ex: set ro: */
-EOP
-safer_close($out);
-
-rename_if_different $tmp_h, 'regnodes.h';
+read_only_bottom_close_and_rename($out);