Codebase list libconfig-properties-perl-upstream / a124582
don't use binmode when there is not real file handle behind; translate \r\n into \n; prepare for release Salvador Fandino 10 years ago
2 changed file(s) with 17 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
00 Revision history for Perl extension Config::Properties.
1
2 1.77 Apr 27, 2014
3 - binmode doesn't work on IO::String and others tied objects (bug
4 report by Mithun Ayachit)
15
26 1.76 Feb 13, 2014
37 - add encoding feature
22 use strict;
33 use warnings;
44
5 our $VERSION = '1.76';
5 our $VERSION = '1.77';
66
77 use IO::Handle;
88 use Carp;
236236 sub load {
237237 my ($self, $file) = @_;
238238 _t_file $file;
239 unless (grep /^(?:encoding|utf8)\b/, PerlIO::get_layers($file)) {
240 binmode $file, ":encoding($self->{encoding})"
241 or croak "Unable to set file encoding layer: $!";
239
240 # check whether it is a real file handle
241 my $fn = do {
242 local $@;
243 eval { fileno($file) }
244 };
245 if (defined $fn and $fn >0) {
246 unless (grep /^(?:encoding|utf8)\b/, PerlIO::get_layers($file)) {
247 binmode $file, ":encoding($self->{encoding})"
248 or croak "Unable to set file encoding layer: $!";
249 }
242250 }
243251 $self->{properties}={};
244252 $self->{property_line_numbers}={};
286294 sub process_line {
287295 my ($self, $file) = @_;
288296 my $line=<$file>;
289
290297 defined $line or return undef;
298 $line =~ s/\r\n/\n/g;
291299 my $ln = $self->{line_number} = $file->input_line_number;
292300 if ($ln == 1) {
293301 # remove utf8 byte order mark