From: Ilya Zakharevich Date: Tue, 2 Apr 2002 00:37:08 +0000 (-0500) Subject: ASCII vs BINARY on OS/2 in perlio X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=23b847786cf7d86c6da9c7a772a1aef6918eee65;p=p5sagit%2Fp5-mst-13.2.git ASCII vs BINARY on OS/2 in perlio Message-ID: <20020402003708.A8648@math.ohio-state.edu> p4raw-id: //depot/perl@15682 --- diff --git a/os2/os2ish.h b/os2/os2ish.h index d1c45ad..360da42 100644 --- a/os2/os2ish.h +++ b/os2/os2ish.h @@ -370,6 +370,16 @@ void *emx_realloc (void *, size_t); ? (--FILE_ptr(fp), ++FILE_cnt(fp), (int)c) : ungetc(c,fp)) #endif +#define PERLIO_IS_BINMODE_FD(fd) _PERLIO_IS_BINMODE_FD(fd) + +static inline bool +_PERLIO_IS_BINMODE_FD(int fd) +{ + int *pflags = _fd_flags(fd); + + return pflags && (*pflags) & O_BINARY; +} + /* ctermid is missing from emx0.9d */ char *ctermid(char *s); diff --git a/perlio.c b/perlio.c index 1253696..0f34462 100644 --- a/perlio.c +++ b/perlio.c @@ -2891,18 +2891,23 @@ PerlIOBuf_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers, return NULL; } else { fd = PerlIO_fileno(f); -#ifdef PERLIO_USING_CRLF - /* - * do something about failing setmode()? --jhi - */ - PerlLIO_setmode(fd, O_BINARY); -#endif if (init && fd == 2) { /* * Initial stderr is unbuffered */ PerlIOBase(f)->flags |= PERLIO_F_UNBUF; } +#ifdef PERLIO_USING_CRLF +# ifdef PERLIO_IS_BINMODE_FD + if (PERLIO_IS_BINMODE_FD(fd)) + PerlIO_binmode(f, '<'/*not used*/, O_BINARY, Nullch); + else +# endif + /* + * do something about failing setmode()? --jhi + */ + PerlLIO_setmode(fd, O_BINARY); +#endif } } }