summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2002-05-08 17:56:43 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2002-05-08 17:56:43 +0000
commit8dcb57838133afcca1063f491fdd55188f1d84ed (patch)
tree4c0e1fd2b11ca232b972b6b1e7957708e011016c /perlio.c
parentef9da7543400a2b6afaa028ae2ebbbc64cd7ceb0 (diff)
downloadperl-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.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/perlio.c b/perlio.c
index bcfa2568e2..e6d0908fae 100644
--- a/perlio.c
+++ b/perlio.c
@@ -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;
}