summaryrefslogtreecommitdiff
path: root/overload.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-03-17 00:17:26 +0000
committerNicholas Clark <nick@ccl4.org>2008-03-17 00:17:26 +0000
commit08858ed21b9a4d448437bdae35df5c42fbe1c8bd (patch)
treed27bb2954cf830c9866eaa74e228a0a358b0d119 /overload.pl
parent424a4936e3f61f4e8db394f496a116e698cede85 (diff)
downloadperl-08858ed21b9a4d448437bdae35df5c42fbe1c8bd.tar.gz
Drag autodoc.pl and overload.pl into the age of safer_open().
Thanks to the wisdom of london.pm, stuff the filename into the SCALAR slot of the typeglob created in safer_open(), so that ... Add safer_close(), that will die (with the filename) if the close fails. p4raw-id: //depot/perl@33539
Diffstat (limited to 'overload.pl')
-rw-r--r--overload.pl24
1 files changed, 11 insertions, 13 deletions
diff --git a/overload.pl b/overload.pl
index 0c25cdf494..da1f91b64e 100644
--- a/overload.pl
+++ b/overload.pl
@@ -22,10 +22,8 @@ while (<DATA>) {
}
safer_unlink ('overload.h', 'overload.c');
-die "overload.h: $!" unless open(C, ">overload.c");
-binmode C;
-die "overload.h: $!" unless open(H, ">overload.h");
-binmode H;
+my $c = safer_open("overload.c");
+my $h = safer_open("overload.h");
sub print_header {
my $file = shift;
@@ -46,10 +44,10 @@ sub print_header {
EOF
}
-select C;
+select $c;
print_header('overload.c');
-select H;
+select $h;
print_header('overload.h');
print <<'EOF';
@@ -67,7 +65,7 @@ print <<'EOF';
EOF
-print C <<'EOF';
+print $c <<'EOF';
#define AMG_id2name(id) (PL_AMG_names[id]+1)
#define AMG_id2namelen(id) (PL_AMG_namelens[id]-1)
@@ -77,10 +75,10 @@ EOF
my $last = pop @names;
-print C " $_,\n" foreach map { length $_ } @names;
+print $c " $_,\n" foreach map { length $_ } @names;
my $lastlen = length $last;
-print C <<"EOT";
+print $c <<"EOT";
$lastlen
};
@@ -92,15 +90,15 @@ const char * const PL_AMG_names[NofAMmeth] = {
overload.pm. */
EOT
-print C " \"$_\",\n" foreach map { s/(["\\"])/\\$1/g; $_ } @names;
+print $c " \"$_\",\n" foreach map { s/(["\\"])/\\$1/g; $_ } @names;
-print C <<"EOT";
+print $c <<"EOT";
"$last"
};
EOT
-close H or die $!;
-close C or die $!;
+safer_close($h);
+safer_close($c);
__DATA__
# Fallback should be the first