From: Jarkko Hietaniemi Date: Tue, 3 Jun 2003 08:04:39 +0000 (+0000) Subject: Retract #19667, #19660, #19659, #19658, #19657, #19656, X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=245468ebf9e9a3ea7e3600e1d4513bdc24459c6b;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/MANIFEST b/MANIFEST index 76dbe58..eb1e628 100644 --- a/MANIFEST +++ b/MANIFEST @@ -564,7 +564,6 @@ ext/PerlIO/scalar/scalar.xs PerlIO layer for scalars ext/PerlIO/t/encoding.t See if PerlIO encoding conversion works ext/PerlIO/t/fail.t See if bad layers fail ext/PerlIO/t/fallback.t See if PerlIO fallbacks work -ext/PerlIO/t/open.t See if PerlIO certain special opens work ext/PerlIO/t/scalar.t See if PerlIO::scalar works ext/PerlIO/t/via.t See if PerlIO::via works ext/PerlIO/via/Makefile.PL PerlIO layer for layers in perl diff --git a/embed.fnc b/embed.fnc index a7ea6df..be08619 100644 --- a/embed.fnc +++ b/embed.fnc @@ -962,8 +962,6 @@ Adp |void |sv_nolocking |SV * Adp |void |sv_nounlocking |SV * Adp |int |nothreadhook -p |PerlIO*|my_tmpfp - END_EXTERN_C #if defined(PERL_IN_DOOP_C) || defined(PERL_DECL_PROT) diff --git a/embed.h b/embed.h index fab4e1a..5907e20 100644 --- a/embed.h +++ b/embed.h @@ -1244,9 +1244,6 @@ #define sv_nolocking Perl_sv_nolocking #define sv_nounlocking Perl_sv_nounlocking #define nothreadhook Perl_nothreadhook -#ifdef PERL_CORE -#define my_tmpfp Perl_my_tmpfp -#endif #if defined(PERL_IN_DOOP_C) || defined(PERL_DECL_PROT) #ifdef PERL_CORE #define do_trans_simple S_do_trans_simple @@ -3719,9 +3716,6 @@ #define sv_nolocking(a) Perl_sv_nolocking(aTHX_ a) #define sv_nounlocking(a) Perl_sv_nounlocking(aTHX_ a) #define nothreadhook() Perl_nothreadhook(aTHX) -#ifdef PERL_CORE -#define my_tmpfp() Perl_my_tmpfp(aTHX) -#endif #if defined(PERL_IN_DOOP_C) || defined(PERL_DECL_PROT) #ifdef PERL_CORE #define do_trans_simple(a) S_do_trans_simple(aTHX_ a) diff --git a/op.c b/op.c index cbf19d2..efb94b6 100644 --- a/op.c +++ b/op.c @@ -6510,86 +6510,3 @@ const_sv_xsub(pTHX_ CV* cv) ST(0) = (SV*)XSANY.any_ptr; XSRETURN(1); } - -/* XXX this belongs in doio.c, not here */ -PerlIO* -Perl_my_tmpfp(pTHX) -{ - PerlIO *f = NULL; - int fd = -1; -#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) - FILE *stdio = PerlSIO_tmpfile(); - - if (stdio) { - if ((f = PerlIO_push(aTHX_(PerlIO_allocate(aTHX)), - &PerlIO_stdio, "w+", Nullsv))) { - PerlIOStdio *s = PerlIOSelf(f, PerlIOStdio); - - if (s) - s->stdio = stdio; - } - } -# else /* !WIN32 && HAS_MKSTEMP */ - SV *sv = newSVpv("/tmp/PerlIO_XXXXXX", 0); - - if (sv) { - fd = mkstemp(SvPVX(sv)); - if (fd >= 0) { - f = PerlIO_fdopen(fd, "w+"); - if (f) { - PerlLIO_unlink(SvPVX(sv)); - SvREFCNT_dec(sv); - } - } - } -# 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); - - if (!gv) { - ENTER; - Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, - newSVpvn("File::Temp", 10), Nullsv, Nullsv, Nullsv); - gv = gv_fetchpv("File::Temp::tempfile", FALSE, SVt_PVCV); - GvIMPORTED_CV_on(gv); - LEAVE; - } - if (gv && GvCV(gv)) { - dSP; - ENTER; - SAVETMPS; - PUSHMARK(SP); - PUTBACK; - if (call_sv((SV*)GvCV(gv), G_SCALAR)) { - GV *gv = (GV*)SvRV(newSVsv(*PL_stack_sp--)); - - if (gv) { - IO *io = GvIO(gv); - - if (io) { - fd = PerlIO_fileno(IoIFP(io)); - if (fd >= 0) - f = PerlIO_fdopen(fd, "w+"); - } - } - } - SPAGAIN; - PUTBACK; - FREETMPS; - LEAVE; - } -# endif -#endif - - return f; -} diff --git a/perlio.c b/perlio.c index 1cdd8c4..feee1b0 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 + + + + + + + + diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 8db00f8..3ad23c5 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -2860,12 +2860,7 @@ argument being C: open(TMP, "+>", undef) or die ... -opens a filehandle to an anonymous temporary file. Also using "+<" -works for symmetry, but you really should consider writing something -to the temporary file first. You will need to seek() to do the -reading. Starting from Perl 5.8.1 the temporary files are created -using the File::Temp module for greater portability, in Perl 5.8.0 the -mkstemp() system call (which has known bugs in some platforms) was used. +opens a filehandle to an anonymous temporary file. File handles can be opened to "in memory" files held in Perl scalars via: diff --git a/proto.h b/proto.h index 44d73be..1f03b3b 100644 --- a/proto.h +++ b/proto.h @@ -920,8 +920,6 @@ PERL_CALLCONV void Perl_sv_nolocking(pTHX_ SV *); PERL_CALLCONV void Perl_sv_nounlocking(pTHX_ SV *); PERL_CALLCONV int Perl_nothreadhook(pTHX); -PERL_CALLCONV PerlIO* Perl_my_tmpfp(pTHX); - END_EXTERN_C #if defined(PERL_IN_DOOP_C) || defined(PERL_DECL_PROT) diff --git a/win32/win32.c b/win32/win32.c index 083e98e..b022e0c 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -2615,8 +2615,8 @@ win32_rewind(FILE *pf) return; } -DllExport int -win32_tmpfd(void) +DllExport FILE* +win32_tmpfile(void) { dTHX; char prefix[MAX_PATH+1]; @@ -2640,20 +2640,11 @@ win32_tmpfd(void) #endif DEBUG_p(PerlIO_printf(Perl_debug_log, "Created tmpfile=%s\n",filename)); - return fd; + return fdopen(fd, "w+b"); } } } } - 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 1683e97..e835b2e 100644 --- a/win32/win32iop.h +++ b/win32/win32iop.h @@ -67,7 +67,6 @@ 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);