Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: PerlIO::via::xz

by Tux (Canon)
on Oct 04, 2020 at 07:35 UTC ( #11122530=note: print w/replies, xml ) Need Help??


in reply to Re: PerlIO::via::xz
in thread PerlIO::via::xz

Change $/ = "\xff\xfe\xff\xfe" x 16 to undef in t/10-xz.t. (trice).

sandbox/xz-undef.pl shows it is not the underlying IO modules to blame.

$ perl -Mblib -MPerlIO::via::xz -wE'open my $fh, "<:via(xz)", "files/p +lain.xz";print scalar<$fh>' Lorem ipsum dolor sit amet, consectetur adipiscing elit, $ perl -Mblib -MPerlIO::via::xz -wE'open my $fh, "<:via(xz)", "files/p +lain.xz";$/=undef;print scalar<$fh>'

or replace t/10-xz.t with this:

# Tests for PerlIO::via::xz use 5.12.0; use warnings; use Test::More; use File::Copy; use_ok ("PerlIO::via::xz"); my $txz = "test.xz"; END { unlink $txz } my %txt; my %xz; for my $type (qw( plain banner )) { local $/; open my $fh, "<", "files/$type.txt" or die "$type.txt: $!\n"; $txt{$type} = <$fh>; close $fh; open $fh, "<", "files/$type.xz" or die "$type.xz: $!\n"; $xz{$type} = <$fh>; close $fh; } # Check defaults #cmp_ok(PerlIO::via::xz->level, "==", 1, "default worklevel"); my $fh; # Opening/closing ok ( open ($fh, "<:via(xz)", "files/plain.xz"), "open for read +ing"); ok ( close ($fh), "close file"); ok (!open ($fh, "+<:via(xz)", "files/plain.xz"), "read+write is + impossible"); ok ( open ($fh, ">:via(xz)", $txz), "open for writ +e"); ok ( close ($fh), "close file"); ok (!open ($fh, "+>:via(xz)", $txz), "write+read is + impossible"); ok (!open ($fh, ">>:via(xz)", $txz), "append is not + supported"); foreach my $rs ("\xff\xfe\xff\xfe" x 16, undef) { local $/ = $rs; # Decompression for my $type (qw( plain banner )) { ok (open (my $fz, "<:via(xz)", "files/$type.xz"), "Open $type" +); is (scalar <$fz>, $txt{$type}, "$type decompression"); } # Compression for my $type (qw( plain banner )) { my $fh; ok (open ($fh, ">:via(xz)", $txz), "Open $type compress"); ok ((print { $fh } $txt{$type}), "Write"); ok (close ($fh), "Close"); } # Roundtrip for my $type (qw( plain banner )) { my $fh; ok (open ($fh, ">:via(xz)", $txz), "Open $type compress"); ok ((print { $fh } $txt{$type}), "Write"); ok (close ($fh), "Close"); ok (open ($fh, "<:via(xz)", $txz), "Open $type uncompress"); is (scalar <$fh>, $txt{$type}, "Compare"); } } done_testing;

Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^3: PerlIO::via::xz
by choroba (Archbishop) on Oct 04, 2020 at 08:45 UTC
    I tried to debug it, the reading happens at IO::Uncompress::Base line 73. $$out is not populated. I'm at my wits' end.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11122530]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2021-04-22 18:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?