From: Jarkko Hietaniemi Date: Mon, 28 Jan 2002 23:17:20 +0000 (+0000) Subject: Workaround for DJGPP broken F_GETFL from Laszlo. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a5936e02e328fcaa28fdb01e8a749a151ee539cf;p=p5sagit%2Fp5-mst-13.2.git Workaround for DJGPP broken F_GETFL from Laszlo. p4raw-id: //depot/perl@14485 --- diff --git a/djgpp/djgpp.c b/djgpp/djgpp.c index 0e465b0..4c53eb0 100644 --- a/djgpp/djgpp.c +++ b/djgpp/djgpp.c @@ -441,3 +441,16 @@ djgpp_fflush (FILE *fp) return res; } + +int djgpp_get_stream_mode(FILE *f) +{ + extern char *__file_handle_modes; + + int mode = __file_handle_modes[fileno(f)]; + if (f->_flag & _IORW) + return mode | O_RDWR; + if (f->_flag & _IOWRT) + return mode | O_WRONLY; + return mode | O_RDONLY; +} + diff --git a/perlio.c b/perlio.c index 999b5fb..b59737c 100644 --- a/perlio.c +++ b/perlio.c @@ -187,6 +187,9 @@ PerlIO_fdupopen(pTHX_ PerlIO *f, CLONE_PARAMS *param, int flags) if (fd >= 0) { char mode[8]; int omode = fcntl(fd, F_GETFL); +#ifdef DJGPP + omode = djgpp_get_stream_mode(f); +#endif PerlIO_intmode2str(omode,mode,NULL); /* the r+ is a hack */ return PerlIO_fdopen(fd, mode);