Wed Mar 14 05:48:18 2012: Request 75750 was acted upon.
Transaction: Correspondence added by RSCHUPP
       Queue: PAR-Packer
     Subject: PAR::Filter::Bleach is broken
   Broken in: 0.969_01, 0.970, 0.973, 0.975, 0.976, 0.977, 0.978, 0.979, 0.980, 
0.982, 0.989_01, 0.991, 0.992_01, 0.992_02, 0.992_03, 0.992_04, 0.992_05, 
0.992_06, 1.000, 1.001, 1.002, 1.003, 1.004, 1.005, 1.006, 1.007, 1.008, 1.009, 
1.010, 1.011, 1.012, 1.013
    Severity: Normal
       Owner: Nobody
  Requestors: m...@cpan.org
      Status: new
 Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=75750 >


On 2012-03-13 18:17:26, MOB wrote:
> The apply method PAR::Filter::Bleach is missing a step that makes the 
> whole package useless (unless the purpose of the package is to make code 
> unrunnable, in which case it is fine ;-) ).

Nope, it works (at least with Perl 5.8.8, 5.10.1, 5.12.3).

> Before the "pack" statement in
>     $_=<<'';y;\r\n;;d;$_=pack'b*',$_;$_=eval;$@&&die$@;$_
> you need to convert the input string from whitespace back to binary 
> digits:
>     $_=<<'';y;\r\n;;d;y; \t;01;;$_=pack'b*',$_;$_=eval;$@&&die$@;$_

This looks reasonable, but the original statement works :)
It took me a couple minutes to figure out why e.g.
  pack "b*", "\t     \t "
returns "A". Here's a snippet from the perl source
(Perl 5.12.3, file pp_pack.c, function S_pack_rec):

  while (l++ < len) {
      if (*str++ & 1)
          bits |= 0x80;
      if (l & 7) 
          bits >>= 1;
      else {
          PUSH_BYTE(utf8, cur, bits);
          bits = 0;
      }
  }

(str points to the string to pack).
All that matters about the bytes to pack is their
least significant bit: 0 for '0', 1 for '1),
but also 0 for ' '=0x20, 1 for '\t'=0x09.

So technically, there's nothing wrong with the code,
but I'll apply the patch anyway, just for the fun moment
I had while pondering it.

Cheers, Roderich



Reply via email to