summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-08-13 11:57:47 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-08-13 11:57:47 +0000
commit8229d19fa9e50fd15985d19cead1fb292012b9f9 (patch)
tree8d5e6ae61dea1706ac3573e968df1efc9232cd4e /perlio.c
parent86feb2c5020849c60df097178dd21ab793b7c689 (diff)
downloadperl-8229d19fa9e50fd15985d19cead1fb292012b9f9.tar.gz
Make (hopefully) the Windows CR CR LF bug go away
by making the CRLF layer repel any other CRLF layers. In other words: binmode(FH, ":crlf") in e.g. Win32 is effectively a no-op since there already is one CRLF layer in the stack by default. p4raw-id: //depot/perl@20674
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/perlio.c b/perlio.c
index fa2cd8372c..a508b645fe 100644
--- a/perlio.c
+++ b/perlio.c
@@ -4038,6 +4038,23 @@ PerlIOCrlf_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab)
f, PerlIOBase(f)->tab->name, (mode) ? mode : "(Null)",
PerlIOBase(f)->flags);
#endif
+ {
+ /* Enable the first CRLF capable layer you can find, but if none
+ * found, the one we just pushed is fine. This results in at
+ * any given moment at most one CRLF-capable layer being enabled
+ * in the whole layer stack. */
+ PerlIO *g = PerlIONext(f);
+ while (g && *g) {
+ PerlIOl *b = PerlIOBase(g);
+ if (b && b->tab == &PerlIO_crlf) {
+ if (!(b->flags & PERLIO_F_CRLF))
+ b->flags |= PERLIO_F_CRLF;
+ PerlIO_pop(aTHX_ f);
+ return code;
+ }
+ g = PerlIONext(g);
+ }
+ }
return code;
}