summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-06-03 08:04:39 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-06-03 08:04:39 +0000
commit245468ebf9e9a3ea7e3600e1d4513bdc24459c6b (patch)
treea401369700632acba7b1a5611531bb2a5a9accec /perlio.c
parentcab02963b8a3a0067a2c0c2a6edd2ef2af19842f (diff)
downloadperl-245468ebf9e9a3ea7e3600e1d4513bdc24459c6b.tar.gz
Retract #19667, #19660, #19659, #19658, #19657, #19656,
#19655, #19418; File::Temp no more used internally. Some parts of these will be salvaged later. p4raw-id: //depot/perl@19670
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/perlio.c b/perlio.c
index 1cdd8c461d..feee1b0a21 100644
--- a/perlio.c
+++ b/perlio.c
@@ -4814,13 +4814,35 @@ PerlIO_stdoutf(const char *fmt, ...)
PerlIO *
PerlIO_tmpfile(void)
{
- dTHX;
- PerlIO *f = Perl_my_tmpfp(aTHX);
-
- if (f)
- PerlIOBase(f)->flags |= PERLIO_F_TEMP;
-
- return f;
+ /*
+ * I have no idea how portable mkstemp() is ...
+ */
+#if defined(WIN32) || !defined(HAVE_MKSTEMP)
+ dTHX;
+ PerlIO *f = NULL;
+ FILE *stdio = PerlSIO_tmpfile();
+ if (stdio) {
+ if ((f = PerlIO_push(aTHX_(PerlIO_allocate(aTHX)), &PerlIO_stdio, "w+", Nullsv))) {
+ PerlIOStdio *s = PerlIOSelf(f, PerlIOStdio);
+ s->stdio = stdio;
+ }
+ }
+ return f;
+#else
+ dTHX;
+ SV *sv = newSVpv("/tmp/PerlIO_XXXXXX", 0);
+ int fd = mkstemp(SvPVX(sv));
+ PerlIO *f = NULL;
+ if (fd >= 0) {
+ f = PerlIO_fdopen(fd, "w+");
+ if (f) {
+ PerlIOBase(f)->flags |= PERLIO_F_TEMP;
+ }
+ PerlLIO_unlink(SvPVX(sv));
+ SvREFCNT_dec(sv);
+ }
+ return f;
+#endif
}
#undef HAS_FSETPOS
@@ -4949,3 +4971,11 @@ PerlIO_sprintf(char *s, int n, const char *fmt, ...)
return result;
}
#endif
+
+
+
+
+
+
+
+