Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Archive-Zip CPAN distribution.

Report information
The Basics
Id:
112580
Status:
new
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
daniel.smith [...] baesystems.com
Cc:
AdminCc:

BugTracker
Severity:
(no value)
Broken in:
(no value)
Fixed in:
(no value)

Attachments
image014.jpg image015.jpg image016.jpg image017.jpg image018.jpg Show all



Subject: Problem setting newline
Date: Mon, 29 Feb 2016 20:29:07 +0000
To: "bug-Archive-Zip@rt.cpan.org" <bug-Archive-Zip@rt.cpan.org>
From: "Smith, Daniel E (UK)" <daniel.smith@baesystems.com>

Hi, I have a problem with archive.zip::MemberRead and a suggested solution

 

I have a perl program which reads zip files that may have unix or windows line ends, I determine these by looking at the first 10000 characters and counting each type of line end. Then I need to set this up in archive::zip (because otherwise it assumes the newline is determinable by the host machine type)

 

There is the handy method MemberRead::SetLineEnd($eol_character) which my script then calls, this method sets this internal global variable $nl to the supplied character

 

However this does not change the behaviour of MemberRead  because the internal line recognising regexp is cached in $self->{sep_as_re} inside the function input_record_separator, and this function is not called when $nl changes.

 

As a workaround I call the method input_record_separator(‘’) manually after setting $nl up, but this also does not work on windows because it assumes that TWO $nls comprise an input record separator in the line:

Return “(?:$nl){2,}”;

 

Therefore, as well as calling two methods to get one thing done I have had to hack the input_record_separator function so the line says:

Return “(?:$nl)”;

 

I recommend that archive.zip::member read should determine the line end character correctly at startup by looking at the first N characters in the file via e.g.:

 

My $buffer;

$first_10000_chars = $fh->read($buffer,10000);

And then:

If ($first_10000_chars =~ /\015\012/) {

$self->{eol_char} = “015\012”; #its a pc file

}elsif( $first_10000_chars =~ /\015/) {

$self->{eol_char} = “/\015/”; #its a mac file

}elsif ($first_10000_chars =~ /\012/) {

               $self->{eol_char} = “/\012/”; #its a unix file

}

 

And then the stored regex should be corrected:

 

$self->{eol_regexp} = qr/$eol_char/;

              

Hope that makes sense!

 

By the way, I am sorry I have sent this to Archive-zip, but member_read itself seems to have a lot of unresolved bugs so I thought a response was unlikely.

 

 

Daniel Smith 
Radar Systems Engineer, Sampson
BAE Systems Maritime Services,

Newport Road,
Cowes,
Isle of Wight, PO31 8PF, UK

*: +44 (0) 198320 2937 
(: daniel.smith@baesystems.com / www.baesystems.com

 

BAE Systems Surface Ships Limited

Registered Office: Warwick House, PO Box 87, Farnborough Aerospace Centre,

Farnborough, Hampshire, GU14 6YU, UK

Registered in England & Wales, Registration No: 06160534

Connect with BAE Systems:  cid:image001.gif@01D0355E.1F422190 cid:image002.png@01D0355E.1F422190 cid:image003.png@01D0355E.1F422190 cid:image004.png@01D0355E.1F422190 cid:image005.png@01D0355E.1F422190 cid:image006.png@01D0355E.1F422190 www.baesystems.com

****************************************************************************
BAE SYSTEMS PROPRIETARY

 

This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
****************************************************************************

 

Image displayed inline above

Image displayed inline above

Image displayed inline above

Image displayed inline above

Image displayed inline above

Image displayed inline above



This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.