diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 2002-05-08 17:56:43 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 2002-05-08 17:56:43 +0000 |
commit | 8dcb57838133afcca1063f491fdd55188f1d84ed (patch) | |
tree | 4c0e1fd2b11ca232b972b6b1e7957708e011016c /perlio.c | |
parent | ef9da7543400a2b6afaa028ae2ebbbc64cd7ceb0 (diff) | |
download | perl-8dcb57838133afcca1063f491fdd55188f1d84ed.tar.gz |
PerlIO/XS interface routine and doc updates from
lupe@lupe-christoph.de (Lupe Christoph) in mail
Subject: [For Review] Patch for perlio.c and pods
Message-Id: <20020505084315.GA23900@lupe-christoph.de>
Date: Sun, 5 May 2002 10:43:15 +0200
(Minor tweaks to follow.)
p4raw-id: //depot/perlio@16495
Diffstat (limited to 'perlio.c')
-rw-r--r-- | perlio.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -2433,10 +2433,14 @@ PerlIO_importFILE(FILE *stdio, int fl) dTHX; PerlIO *f = NULL; if (stdio) { + int mode = fcntl(fileno(stdio), F_GETFL); PerlIOStdio *s = PerlIOSelf(PerlIO_push (aTHX_(f = PerlIO_allocate(aTHX)), &PerlIO_stdio, - "r+", Nullsv), PerlIOStdio); + (mode&O_ACCMODE) == O_RDONLY ? "r" + : (mode&O_ACCMODE) == O_WRONLY ? "w" + : "r+", + Nullsv), PerlIOStdio); s->stdio = stdio; } return f; @@ -2828,11 +2832,12 @@ PerlIO_exportFILE(PerlIO *f, int fl) { dTHX; FILE *stdio; + char buf[8]; PerlIO_flush(f); - stdio = fdopen(PerlIO_fileno(f), "r+"); + stdio = fdopen(PerlIO_fileno(f), PerlIO_modestr(f,buf)); if (stdio) { PerlIOStdio *s = - PerlIOSelf(PerlIO_push(aTHX_ f, &PerlIO_stdio, "r+", Nullsv), + PerlIOSelf(PerlIO_push(aTHX_ f, &PerlIO_stdio, buf, Nullsv), PerlIOStdio); s->stdio = stdio; } |