This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update copyright year in embed.pl, and everything that it builds.
[perl5.git] / reentr.pl
index 84676d4..ea327a0 100644 (file)
--- a/reentr.pl
+++ b/reentr.pl
@@ -13,7 +13,7 @@ BEGIN {
 use strict;
 use Getopt::Std;
 my %opts;
-getopts('U', \%opts);
+getopts('Uv', \%opts);
 
 my %map = (
           V => "void",
@@ -40,10 +40,9 @@ my %map = (
 # Example #3: S_CBI   means type func_r(const char*, char*, int)
 
 
-safer_unlink 'reentr.h';
-die "reentr.h: $!" unless open(H, ">reentr.h");
-binmode H;
-select H;
+# safer_unlink 'reentr.h';
+my $h = safer_open("reentr.h-new");
+select $h;
 print <<EOF;
 /* -*- buffer-read-only: t -*-
  *
@@ -332,7 +331,7 @@ close DATA;
 
 # Prepare to continue writing the reentr.h.
 
-select H;
+select $h;
 
 {
     # Write out all the known prototype signatures.
@@ -788,14 +787,14 @@ typedef struct {
 /* ex: set ro: */
 EOF
 
-close(H);
+safer_close($h);
+rename_if_different('reentr.h-new', 'reentr.h');
 
 # Prepare to write the reentr.c.
 
-safer_unlink 'reentr.c';
-die "reentr.c: $!" unless open(C, ">reentr.c");
-binmode C;
-select C;
+# safer_unlink 'reentr.c';
+my $c = safer_open("reentr.c-new");
+select $c;
 print <<EOF;
 /* -*- buffer-read-only: t -*-
  *
@@ -857,7 +856,13 @@ Perl_reentrant_retry(const char *f, ...)
     dTHX;
     void *retptr = NULL;
     va_list ap;
+#ifdef USE_REENTRANT_API
+    /* Easier to special case this here than in embed.pl. (Look at what it
+       generates for proto.h) */
+    PERL_ARGS_ASSERT_REENTRANT_RETRY;
+#endif
     va_start(ap, f);
+    {
 #ifdef USE_REENTRANT_API
 #  if defined(USE_HOSTENT_BUFFER) || defined(USE_GRENT_BUFFER) || defined(USE_NETENT_BUFFER) || defined(USE_PWENT_BUFFER) || defined(USE_PROTOENT_BUFFER) || defined(USE_SERVENT_BUFFER)
     void *p0;
@@ -1076,6 +1081,7 @@ Perl_reentrant_retry(const char *f, ...)
 #else
     PERL_UNUSED_ARG(f);
 #endif
+    }
     va_end(ap);
     return retptr;
 }
@@ -1083,6 +1089,9 @@ Perl_reentrant_retry(const char *f, ...)
 /* ex: set ro: */
 EOF
 
+safer_close($c);
+rename_if_different('reentr.c-new', 'reentr.c');
+
 __DATA__
 asctime S      |time   |const struct tm|B_SB|B_SBI|I_SB|I_SBI
 crypt CC       |crypt  |struct crypt_data|B_CCS|B_CCD|D=CRYPTD*