I modified Layers.pm to dump the flags.
sub _has_flags {
my $check_flag = _names_to_flags(@_);
return sub {
my ($fh, $layer) = @_;
my $iterator = natatime(3, PerlIO::get_layers($fh, details =>
+1));
while (my ($name, $arguments, $flags) = $iterator->()) {
next if defined $layer and $name ne $layer;
print('FL='.unpack('H8',pack('N',$flags)).','.unpack('B32'
+,pack('N',$flags))."\n");
print('CK='.unpack('H8',pack('N',$check_flag)).','.unpack(
+'B32',pack('N',$check_flag))."\n");
my $entry = $flags & $check_flag;
return 1 if $entry;
}
return 0;
}
}
And the problem is, 5.10 has different flags than 5.12. I dont know yet if 5.10 has different C consts, or just different api design, and if the 16XXX/0x4000 flag is plain wrong. I havent looked if 0x4000 is hard coded in Layers the module or not.
On 5.10.
$VAR1 = {
"\$mode" => "<:encoding(utf8)",
"\$fh" => \*{"main::\$fh"},
"\$test_type" => "crlf",
"\$result_for{\$test_type}" => 1
};
FL=00408400,00000000010000001000010000000000
CK=00004000,00000000000000000100000000000000
FL=00408400,00000000010000001000010000000000
CK=00004000,00000000000000000100000000000000
FL=00408400,00000000010000001000010000000000
CK=00004000,00000000000000000100000000000000
not ok 51 - File opened with <:encoding(utf8) should return 1 on test
+crlf
# Failed test 'File opened with <:encoding(utf8) should return 1 on
+test crlf'
# at 10-basics.t line 77.
# got: '0'
# expected: '1'
# $VAR1 = [
# "unix",
# undef,
# [
# "UTF8",
# "CANREAD",
# "FASTGETS"
# ]
# ];
# $VAR2 = [
# "crlf",
# undef,
# [
# "UTF8",
# "CANREAD",
# "FASTGETS"
# ]
# ];
# $VAR3 = [
# "encoding",
# "utf8",
# [
# "UTF8",
# "CANREAD",
# "FASTGETS"
# ]
# ];
On 5.12
$VAR1 = {
"\$fh" => \*{"main::\$fh"},
"\$mode" => "<:encoding(utf8)",
"\$result_for{\$test_type}" => 1,
"\$test_type" => "crlf"
};
FL=00200400,00000000001000000000010000000000
CK=00004000,00000000000000000100000000000000
FL=00404400,00000000010000000100010000000000
CK=00004000,00000000000000000100000000000000
I will keep looking.
I made this. Dont know what to think about it.
http://pastebin.com/SSDrPpDD
update, the flags come from XS in Layers.xs not hard coded consts in the PM, the flags of the layers come from
http://perl5.git.perl.org/perl.git/blob/HEAD:/universal.c#l960 I dont have a C debugging enabled 5.10 so I cant give you any more advice. Search perlio.c in perl.git for changes between 5.10 and 5.12 or dont do the PIO::Layers test on 5.10. Its a design issue with 5.10, not a Layers.pm issue. |