Make :utf8 and :bytes MULTIARG
authorLeon Timmermans <fawaka@gmail.com>
Thu, 7 Apr 2011 10:33:21 +0000 (12:33 +0200)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 7 Apr 2011 14:56:09 +0000 (07:56 -0700)
PerlIO layer types have this property that flags if they can accept
multiple arguments or only one. Unfortunately, this always checks the
uppermost layer that has an Open method defined. This causes issues when
used with utf8 or bytes on top of a layer that uses multiple arguments.

For 5.15 I think abolishing this feature may make most sense. It's just
flat out wrong IMO, it's the layer that uses the arguments that should
validate them, not the topmost, which may not even touch them. In the
mean time adding the multiargs flag to :utf8 and :bytes is a reasonable
stop-gap.

This patch makes perl slightly more permissive, so it shouldn't break
any working code out there.

perlio.c

index f2f8729567675d1cdfb20b399377c2ff5e4737ea..e42a78fc286a9384010631c61e7f193224731523 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -1963,7 +1963,7 @@ PERLIO_FUNCS_DECL(PerlIO_utf8) = {
     sizeof(PerlIO_funcs),
     "utf8",
     0,
-    PERLIO_K_DUMMY | PERLIO_K_UTF8,
+    PERLIO_K_DUMMY | PERLIO_K_UTF8 | PERLIO_K_MULTIARG,
     PerlIOUtf8_pushed,
     NULL,
     PerlIOBase_open,
@@ -1994,7 +1994,7 @@ PERLIO_FUNCS_DECL(PerlIO_byte) = {
     sizeof(PerlIO_funcs),
     "bytes",
     0,
-    PERLIO_K_DUMMY,
+    PERLIO_K_DUMMY | PERLIO_K_MULTIARG,
     PerlIOUtf8_pushed,
     NULL,
     PerlIOBase_open,