Update the SHA256s where necessary in the generated files.
@dirs = map { " - $_" } sort { lc $a cmp lc $b } @dirs;
-my $fh = safer_open($new_file, $file);
+my $fh = open_new($file);
local $" = "\n";
print $fh <<"EOI";
}
/* Generated from:
- * 28d95638560707fb8bee100dab74c90107c3e000f635e3bd310d4e2501d3b073 regen/keywords.pl
+ * 1591f96938e2a916423e17015c46f40221214a9ba8670000a2bf43578af159c2 regen/keywords.pl
* ex: set ro: */
#define KEY_y 252
/* Generated from:
- * 28d95638560707fb8bee100dab74c90107c3e000f635e3bd310d4e2501d3b073 regen/keywords.pl
+ * 1591f96938e2a916423e17015c46f40221214a9ba8670000a2bf43578af159c2 regen/keywords.pl
* ex: set ro: */
/* Generated from:
* bd41fc813e5d2d23ff7edef2ab1ef88bbb054176476b7d989db7522dce1c9328 perly.y
- * dc72db91baa0a3c17a6c95718e5ad70e9ac7b75919df1317df7fe6c3f1649239 regen_perly.pl
+ * 7fdc8be39a1ba22bcb9eb32a5e4e483f3b6abc1a1c95fea864ae5b7d46aa744b regen_perly.pl
* ex: set ro: */
/* Generated from:
* bd41fc813e5d2d23ff7edef2ab1ef88bbb054176476b7d989db7522dce1c9328 perly.y
- * dc72db91baa0a3c17a6c95718e5ad70e9ac7b75919df1317df7fe6c3f1649239 regen_perly.pl
+ * 7fdc8be39a1ba22bcb9eb32a5e4e483f3b6abc1a1c95fea864ae5b7d46aa744b regen_perly.pl
* ex: set ro: */
/* Generated from:
* bd41fc813e5d2d23ff7edef2ab1ef88bbb054176476b7d989db7522dce1c9328 perly.y
- * dc72db91baa0a3c17a6c95718e5ad70e9ac7b75919df1317df7fe6c3f1649239 regen_perly.pl
+ * 7fdc8be39a1ba22bcb9eb32a5e4e483f3b6abc1a1c95fea864ae5b7d46aa744b regen_perly.pl
* ex: set ro: */
$F = $filename;
}
else {
- $F = safer_open("$filename-new", $filename);
+ $F = open_new($filename);
print $F do_not_edit ($filename);
}
foreach (@embed) {
# generate proto.h
{
- my $pr = safer_open('proto.h-new', 'proto.h');
+ my $pr = open_new('proto.h');
print $pr do_not_edit ("proto.h"), "START_EXTERN_C\n";
my $ret;
return hide("PL_$pre$sym", "PL_$sym");
}
-my $em = safer_open('embed.h-new', 'embed.h');
+my $em = open_new('embed.h');
print $em do_not_edit ("embed.h"), <<'END';
/* (Doing namespace management portably in C is really gross.) */
read_only_bottom_close_and_rename($em);
-$em = safer_open('embedvar.h-new', 'embedvar.h');
+$em = open_new('embedvar.h');
print $em do_not_edit ("embedvar.h"), <<'END';
/* (Doing namespace management portably in C is really gross.) */
read_only_bottom_close_and_rename($em);
-my $capi = safer_open('perlapi.c-new', 'perlapi.c');
-my $capih = safer_open('perlapi.h-new', 'perlapi.h');
+my $capi = open_new('perlapi.c');
+my $capih = open_new('perlapi.h');
print $capih do_not_edit ("perlapi.h"), <<'EOT';
/* declare accessor functions for Perl variables */
require 'regen/regen_lib.pl';
-my $h = safer_open('keywords.h-new', 'keywords.h');
-my $c = safer_open('keywords.c-new', 'keywords.c');
+my $h = open_new('keywords.h');
+my $c = open_new('keywords.c');
print $h read_only_top(lang => 'C', by => 'regen/keywords.pl',
from => 'its data', file => 'keywords.h', style => '*',
APC
);
-my $out_fh = safer_open('l1_char_class_tab.h-new', 'l1_char_class_tab.h');
+my $out_fh = open_new('l1_char_class_tab.h');
print $out_fh read_only_top(lang => 'C', style => '*', by => $0, from => $file);
# Output the table using fairly short names for each char.
require 'regen/regen_lib.pl';
}
-my $oc = safer_open('opcode.h-new', 'opcode.h');
-my $on = safer_open('opnames.h-new', 'opnames.h');
+my $oc = open_new('opcode.h');
+my $on = open_new('opnames.h');
# Read data.
}
}
-my $pp = safer_open('pp_proto.h-new', 'pp_proto.h');
+my $pp = open_new('pp_proto.h');
print $pp read_only_top(lang => 'C', by => 'opcode.pl', from => 'its data');
push @names, $name;
}
-my $c = safer_open('overload.c-new', 'overload.c');
-my $h = safer_open('overload.h-new', 'overload.h');
+my $c = open_new('overload.c');
+my $h = open_new('overload.h');
mkdir("lib/overload", 0777) unless -d 'lib/overload';
-my $p = safer_open('lib/overload/numbers.pm-new', 'lib/overload/numbers.pm');
+my $p = open_new('lib/overload/numbers.pm');
print $p read_only_top(lang => 'Perl', by => 'regen/overload.pl',
file => 'lib/overload/numbers.pm', copyright => [2008]);
# Example #3: S_CBI means type func_r(const char*, char*, int)
-my $h = safer_open('reentr.h-new', 'reentr.h');
+my $h = open_new('reentr.h');
print $h read_only_top(lang => 'C', by => 'regen/reentr.pl',
from => 'data in regen/reentr.pl',
file => 'reentr.h', style => '*',
# Prepare to write the reentr.c.
-my $c = safer_open('reentr.c-new', 'reentr.c');
+my $c = open_new('reentr.c');
my $top = read_only_top(lang => 'C', by => 'regen/reentr.pl',
from => 'data in regen/reentr.pl',
file => 'reentr.c', style => '*',
if ( $path eq '-' ) {
$out_fh= \*STDOUT;
} else {
- $out_fh = safer_open( "$path-new", $path );
+ $out_fh = open_new( $path );
}
print $out_fh read_only_top( lang => 'C', by => $0,
file => 'regcharclass.h', style => '*',
EOP
}
-my $out = safer_open('regnodes.h-new', 'regnodes.h');
+my $out = open_new('regnodes.h');
print $out read_only_top(lang => 'C', by => 'regen/regcomp.pl',
from => 'regcomp.sym');
safer_rename_silent($from, $to) or die "renaming $from to $to: $!";
}
-# Saf*er*, but not totally safe. And assumes always open for output.
-sub safer_open {
- my ($name, $final_name) = @_;
+# Open a new file.
+sub open_new {
+ my ($final_name) = @_;
+ my $name = $final_name . '-new';
if (-f $name) {
unlink $name or die "$name exists but can't unlink: $!";
}
my $fh = gensym;
open $fh, ">$name" or die "Can't create $name: $!";
*{$fh}->{name} = $name;
- if (defined $final_name) {
- *{$fh}->{final_name} = $final_name;
- *{$fh}->{lang} = ($final_name =~ /\.(?:c|h|tab|act)$/ ? 'C' : 'Perl');
- }
+ *{$fh}->{final_name} = $final_name;
+ *{$fh}->{lang} = ($final_name =~ /\.(?:c|h|tab|act)$/ ? 'C' : 'Perl');
binmode $fh;
$fh;
}
exit ;
}
-my $warn = safer_open('warnings.h-new', 'warnings.h');
-my $pm = safer_open('lib/warnings.pm-new', 'lib/warnings.pm');
+my $warn = open_new('warnings.h');
+my $pm = open_new('lib/warnings.pm');
print $pm read_only_top(lang => 'Perl', by => 'regen/warnings.pl');
print $warn read_only_top(lang => 'C', by => 'regen/warnings.pl'), <<'EOM';
my $read_only = read_only_top(lang => 'C', by => $0, from => $y_file);
-my $act_fh = safer_open("$act_file-new", $act_file);
+my $act_fh = open_new($act_file);
print $act_fh $read_only, $actlines;
-my $tab_fh = safer_open("$tab_file-new", $tab_file);
+my $tab_fh = open_new($tab_file);
print $tab_fh $read_only, $tablines;
unlink $tmpc_file;
# C<#line 188 "perlytmp.h"> gets picked up by make depend, so remove them.
open my $tmph_fh, '<', $tmph_file or die "Can't open $tmph_file: $!\n";
-my $h_fh = safer_open("$h_file-new", $h_file);
+my $h_fh = open_new($h_file);
print $h_fh $read_only;