summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--op.c4
-rw-r--r--perl.h10
-rw-r--r--perlio.c6
3 files changed, 17 insertions, 3 deletions
diff --git a/op.c b/op.c
index 2226a947f9..75aae398bd 100644
--- a/op.c
+++ b/op.c
@@ -8621,6 +8621,7 @@ Perl_ck_anoncode(pTHX_ OP *o)
static void
S_io_hints(pTHX_ OP *o)
{
+#ifdef PERLIO_BINARY_AND_TEXT_DIFFERENT_AND_EFFECTIVE
HV * const table =
PL_hints & HINT_LOCALIZE_HH ? GvHV(PL_hintgv) : NULL;;
if (table) {
@@ -8646,6 +8647,9 @@ S_io_hints(pTHX_ OP *o)
o->op_private |= OPpOPEN_OUT_CRLF;
}
}
+#else
+ PERL_UNUSED_ARG(o);
+#endif
}
OP *
diff --git a/perl.h b/perl.h
index 7bfc4455cb..ab95db74cf 100644
--- a/perl.h
+++ b/perl.h
@@ -5665,7 +5665,7 @@ int flock(int fd, int op);
#endif
#if O_TEXT != O_BINARY
- /* If you have different O_TEXT and O_BINARY and you are a CLRF shop,
+ /* If you have different O_TEXT and O_BINARY and you are a CRLF shop,
* that is, you are somehow DOSish. */
# if defined(__HAIKU__) || defined(__VOS__) || defined(__CYGWIN__)
/* Haiku has O_TEXT != O_BINARY but O_TEXT and O_BINARY have no effect;
@@ -5679,6 +5679,14 @@ int flock(int fd, int op);
/* If you really are DOSish. */
# define PERLIO_USING_CRLF 1
# endif
+# if O_TEXT != 0 && O_BINARY != 0
+# if !defined(__HAIKU__)
+ /* If you have O_TEXT different from your O_BINARY and
+ * they are both not zero (being zero would make testing
+ * with bit-and interesting) and they have an effect. */
+# define PERLIO_BINARY_AND_TEXT_DIFFERENT_AND_EFFECTIVE
+# endif
+# endif
#endif
#ifdef I_LIBUTIL
diff --git a/perlio.c b/perlio.c
index c3767f0c15..4dc3ec36b5 100644
--- a/perlio.c
+++ b/perlio.c
@@ -199,8 +199,10 @@ PerlIO_intmode2str(int rawmode, char *mode, int *writing)
mode[ix++] = '+';
}
}
+#ifdef PERLIO_BINARY_AND_TEXT_DIFFERENT_AND_EFFECTIVE
if (rawmode & O_BINARY)
mode[ix++] = 'b';
+#endif
mode[ix] = '\0';
return ptype;
}
@@ -2529,6 +2531,7 @@ PerlIOUnix_oflags(const char *mode)
oflags |= O_WRONLY;
break;
}
+#ifdef PERLIO_BINARY_AND_TEXT_DIFFERENT_AND_EFFECTIVE
if (*mode == 'b') {
oflags |= O_BINARY;
oflags &= ~O_TEXT;
@@ -2540,14 +2543,13 @@ PerlIOUnix_oflags(const char *mode)
mode++;
}
else {
-#ifdef PERLIO_USING_CRLF
/*
* If neither "t" nor "b" was specified, open the file
* in O_BINARY mode.
*/
oflags |= O_BINARY;
-#endif
}
+#endif
if (*mode || oflags == -1) {
SETERRNO(EINVAL, LIB_INVARG);
oflags = -1;