summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorJan Dubois <jand@activestate.com>2006-04-06 11:37:21 -0700
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-09-21 14:52:15 +0000
commitff1e38834cd604970c075bd632ce9b1b3ec84bd9 (patch)
tree61589d5407068c802bd552726beced4a191b5dd9 /perlio.c
parent7d88d72a02dca27b7731d674d4257f7875ae0155 (diff)
downloadperl-ff1e38834cd604970c075bd632ce9b1b3ec84bd9.tar.gz
RE: Combining UTF-16 output with :crlf is awkward
From: "Jan Dubois" <jand@ActiveState.com> Message-ID: <0bbe01c659e3$d0c334a0$2217a8c0@candy> p4raw-id: //depot/perl@28879
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/perlio.c b/perlio.c
index 8f6947faf0..a3ff71d889 100644
--- a/perlio.c
+++ b/perlio.c
@@ -4192,6 +4192,21 @@ typedef struct {
* buffer */
} PerlIOCrlf;
+/* Inherit the PERLIO_F_UTF8 flag from previous layer.
+ * Otherwise the :crlf layer would always revert back to
+ * raw mode.
+ */
+static void
+S_inherit_utf8_flag(PerlIO *f)
+{
+ PerlIO *g = PerlIONext(f);
+ if (PerlIOValid(g)) {
+ if (PerlIOBase(g)->flags & PERLIO_F_UTF8) {
+ PerlIOBase(f)->flags |= PERLIO_F_UTF8;
+ }
+ }
+}
+
IV
PerlIOCrlf_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab)
{
@@ -4209,17 +4224,19 @@ PerlIOCrlf_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab)
* any given moment at most one CRLF-capable layer being enabled
* in the whole layer stack. */
PerlIO *g = PerlIONext(f);
- while (g && *g) {
+ while (PerlIOValid(g)) {
PerlIOl *b = PerlIOBase(g);
if (b && b->tab == &PerlIO_crlf) {
if (!(b->flags & PERLIO_F_CRLF))
b->flags |= PERLIO_F_CRLF;
+ S_inherit_utf8_flag(g);
PerlIO_pop(aTHX_ f);
return code;
}
g = PerlIONext(g);
}
}
+ S_inherit_utf8_flag(f);
return code;
}