diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2003-06-02 18:44:34 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2003-06-02 18:44:34 +0000 |
commit | 3a8ae1affddf8a9aac8746965f2ae13c7af42aba (patch) | |
tree | d36a43ec45b7cbc3b84eed59b4d0bfc171cc457d | |
parent | dc694082e66bcad1c2faeb08a1c5832719339050 (diff) | |
download | perl-3a8ae1affddf8a9aac8746965f2ae13c7af42aba.tar.gz |
don't use File::Temp to implement PerlIO_tmpfile() on windows;
reuse the straightforward native implementation instead
this fixes the warning from io_xs.t
NOTE: File::Temp has a less-than-robust implementation on windows
that relies on END blocks being run (this may not happen always)
p4raw-id: //depot/perl@19667
-rw-r--r-- | op.c | 18 | ||||
-rw-r--r-- | win32/win32.c | 15 | ||||
-rw-r--r-- | win32/win32iop.h | 1 |
3 files changed, 25 insertions, 9 deletions
@@ -6511,15 +6511,21 @@ const_sv_xsub(pTHX_ CV* cv) XSRETURN(1); } +/* XXX this belongs in doio.c, not here */ PerlIO* Perl_my_tmpfp(pTHX) { PerlIO *f = NULL; int fd = -1; -#ifdef PERL_EXTERNAL_GLOB +#ifdef WIN32 + fd = win32_tmpfd(); + if (fd >= 0) + f = PerlIO_fdopen(fd, "w+b"); +#else +# ifdef PERL_EXTERNAL_GLOB /* File::Temp pulls in Fcntl, which may not be available with * e.g. miniperl, use mkstemp() or stdio tmpfile() instead. */ -# if defined(WIN32) || !defined(HAS_MKSTEMP) +# if defined(WIN32) || !defined(HAS_MKSTEMP) FILE *stdio = PerlSIO_tmpfile(); if (stdio) { @@ -6531,7 +6537,7 @@ Perl_my_tmpfp(pTHX) s->stdio = stdio; } } -# else /* !WIN32 && HAS_MKSTEMP */ +# else /* !WIN32 && HAS_MKSTEMP */ SV *sv = newSVpv("/tmp/PerlIO_XXXXXX", 0); if (sv) { @@ -6544,8 +6550,8 @@ Perl_my_tmpfp(pTHX) } } } -# endif /* WIN32 || !HAS_MKSTEMP */ -#else +# endif /* !HAS_MKSTEMP */ +# else /* We have internal glob, which probably also means that we * can also use File::Temp (which uses Fcntl) with impunity. */ GV *gv = gv_fetchpv("File::Temp::tempfile", FALSE, SVt_PVCV); @@ -6582,8 +6588,8 @@ Perl_my_tmpfp(pTHX) FREETMPS; LEAVE; } +# endif #endif return f; } - diff --git a/win32/win32.c b/win32/win32.c index c40920332d..d059fe2773 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -2615,8 +2615,8 @@ win32_rewind(FILE *pf) return; } -DllExport FILE* -win32_tmpfile(void) +DllExport int +win32_tmpfd(void) { dTHX; char prefix[MAX_PATH+1]; @@ -2640,11 +2640,20 @@ win32_tmpfile(void) #endif DEBUG_p(PerlIO_printf(Perl_debug_log, "Created tmpfile=%s\n",filename)); - return fdopen(fd, "w+b"); + return fd; } } } } + return -1; +} + +DllExport FILE* +win32_tmpfile(void) +{ + int fd = win32_tmpfd(); + if (fd >= 0) + return win32_fdopen(fd, "w+b"); return NULL; } diff --git a/win32/win32iop.h b/win32/win32iop.h index e835b2eea6..1683e97e54 100644 --- a/win32/win32iop.h +++ b/win32/win32iop.h @@ -67,6 +67,7 @@ DllExport int win32_fseek(FILE *pf,Off_t offset,int origin); DllExport int win32_fgetpos(FILE *pf,fpos_t *p); DllExport int win32_fsetpos(FILE *pf,const fpos_t *p); DllExport void win32_rewind(FILE *pf); +DllExport int win32_tmpfd(void); DllExport FILE* win32_tmpfile(void); DllExport void win32_abort(void); DllExport int win32_fstat(int fd,Stat_t *sbufptr); |