From: Lupe Christoph Date: Sat, 25 May 2002 15:45:34 +0000 (+0200) Subject: [Patch] Re: ./perl harness on Cygwin today failures X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f504ae08d9ea711c106835665711262bdaa326c7;p=p5sagit%2Fp5-mst-13.2.git [Patch] Re: ./perl harness on Cygwin today failures Message-ID: <20020525134534.GT6638@lupe-christoph.de> p4raw-id: //depot/perl@16778 --- diff --git a/perlio.c b/perlio.c index 23864b5..b41b6d2 100644 --- a/perlio.c +++ b/perlio.c @@ -2446,21 +2446,25 @@ PerlIO_importFILE(FILE *stdio, int fl) /* We need to probe to see how we can open the stream so start with read/write and then try write and read we dup() so that we can fclose without loosing the fd. + + Note that the errno value set by a failing fdopen + varies between stdio implementations. */ int fd = PerlLIO_dup(fileno(stdio)); char *mode = "r+"; FILE *f2 = fdopen(fd, mode); PerlIOStdio *s; - if (!f2 && errno == EINVAL) { + if (!f2) { mode = "w"; f2 = fdopen(fd, mode); } - if (!f2 && errno == EINVAL) { + if (!f2) { mode = "r"; f2 = fdopen(fd, mode); } if (!f2) { /* Don't seem to be able to open */ + PerlLIO_close(fd); return f; } fclose(f2); diff --git a/pod/perlapio.pod b/pod/perlapio.pod index 0597687..981ee20 100644 --- a/pod/perlapio.pod +++ b/pod/perlapio.pod @@ -315,6 +315,9 @@ code attempts to empirically determine the mode in which I is open. Once called the FILE * should I be closed by calling C on the returned PerlIO *. +The PerlIO is set to textmode. Use PerlIO_binmode if this is +not the desired mode. + =item B Given a PerlIO * create a 'native' FILE * suitable for passing to code