Lies, damn lies and end-of-block comments
[p5sagit/p5-mst-13.2.git] / reentr.pl
index ddbfab3..8cc4a5e 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.
@@ -752,13 +751,13 @@ EOF
 EOF
                }
            }
-           push @wrap, <<EOF;
-#  endif /* if defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1) */
+           push @wrap, <<EOF;  # !defined(xxx) && XXX_R_PROTO == REENTRANT_PROTO_Y_TS
+#   endif
 EOF
        }
 
-           push @wrap, <<EOF;
-#   endif /* HAS_\U$func */
+           push @wrap, <<EOF;  # defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1)
+#  endif
 EOF
 
        push @wrap, $endif, "\n";
@@ -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,6 +856,11 @@ 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
@@ -1085,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*