? (--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);
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
}
}
}