Mon Sep 02 09:04:14 2013: Request 88297 was acted upon.
Transaction: Correspondence added by RSCHUPP
Queue: PAR-Packer
Subject: -M crashes pp if option contains backslashes
Broken in: 1.014
Severity: (no value)
Owner: RSCHUPP
Requestors: [email protected]
Status: new
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=88297 >
On 2013-08-30 20:11:35, NGLENN wrote:
> Doing `pp -M path\to\my\Lib.pm` causes a failure:
I can reproduce the failure, but this command is kinda pointless:
it would result in path\to\my\Lib.pm being packed as module path::to::my::Lib
which is probably not want you want. And if you wanted it,
why not say -M path::to::my::Lib?
> ... Then when it
> called $zip->member($in), the member with the given name didn't exist.
> I'm including a patch to fix this
Your patch only pampers over the problem.
Also it's very bad style to modify the parameters ($in in this case)
of a function (except when it's to provide a default value).
The formulation in the original code is also lacking, though:
addString and addFile already return an Archive::Zip::Member object,
so why not use this to set compression options etc.
I applied the attached fix instead, will be in the next release of PAR::Packer.
Cheers, Roderich
Index: lib/PAR/Packer.pm
===================================================================
--- lib/PAR/Packer.pm (revision 1414)
+++ lib/PAR/Packer.pm (working copy)
@@ -1090,9 +1090,9 @@
$manifest->{ $alias } = [ file => $file ];
$oldsize += -s $file;
- $zip->addFile($file, $alias);
- $zip->memberNamed($alias)->desiredCompressionMethod($method);
- $zip->memberNamed($alias)->desiredCompressionLevel($level);
+ my $member = $zip->addFile($file, $alias);
+ $member->desiredCompressionMethod($method);
+ $member->desiredCompressionLevel($level);
}
}
elsif (-e $fn and -r $fn) {
@@ -1103,9 +1103,9 @@
$self->_vprint(1, "... adding $fn as $in\n");
$oldsize += -s $fn;
- $zip->addFile($fn => $in);
- $zip->memberNamed($in)->desiredCompressionMethod($method);
- $zip->memberNamed($in)->desiredCompressionLevel($level);
+ my $member = $zip->addFile($fn => $in);
+ $member->desiredCompressionMethod($method);
+ $member->desiredCompressionLevel($level);
}
}
else {
@@ -1117,9 +1117,10 @@
$oldsize += length($str);
$self->_vprint(1, "... adding <string> as $in");
- $zip->addString($str => $in)->unixFileAttributes(0644);
- $zip->memberNamed($in)->desiredCompressionMethod($method);
- $zip->memberNamed($in)->desiredCompressionLevel($level);
+ my $member = $zip->addString($str => $in);
+ $member->unixFileAttributes(0644);
+ $member->desiredCompressionMethod($method);
+ $member->desiredCompressionLevel($level);
}
$self->{pack_attrib}{old_size} = $oldsize;