Hello community,

here is the log from the commit of package perl-File-Slurp for openSUSE:Factory 
checked in at 2018-12-08 11:19:44
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-File-Slurp (Old)
 and      /work/SRC/openSUSE:Factory/.perl-File-Slurp.new.19453 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-File-Slurp"

Sat Dec  8 11:19:44 2018 rev:22 rq:655763 version:9999.25

Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-File-Slurp/perl-File-Slurp.changes  
2018-11-13 16:31:32.322107987 +0100
+++ 
/work/SRC/openSUSE:Factory/.perl-File-Slurp.new.19453/perl-File-Slurp.changes   
    2018-12-08 11:19:46.782873266 +0100
@@ -1,0 +2,17 @@
+Thu Dec  6 15:41:21 UTC 2018 - Stephan Kulow <[email protected]>
+
+- updated to 9999.25
+   see /usr/share/doc/packages/perl-File-Slurp/Changes
+
+  9999.25     2018-10-29
+      - The previous release contained nothing but a documentation update. That
+        updated documentation errantly mentioned pseudo-files. Pseudo-files
+        are perfectly fine to use with File::Slurp.
+      - Add regression test for GLOB refs being slurped in. Thank you, James 
Keenan!
+        https://github.com/perhunter/slurp/pull/17#issuecomment-437174592
+      - Refactor read_file to use open and read rather than sysopen and 
sysread.
+      - Add a bugwards compatible feature to keep track of the cursor when
+        dealing with the DATA handle 
(https://github.com/perhunter/slurp/pull/17)
+      - Fix a typo in the docs.
+
+-------------------------------------------------------------------

Old:
----
  File-Slurp-9999.24.tar.gz

New:
----
  File-Slurp-9999.25.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ perl-File-Slurp.spec ++++++
--- /var/tmp/diff_new_pack.5MVdLg/_old  2018-12-08 11:19:47.590872493 +0100
+++ /var/tmp/diff_new_pack.5MVdLg/_new  2018-12-08 11:19:47.594872490 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           perl-File-Slurp
-Version:        9999.24
+Version:        9999.25
 Release:        0
 %define cpan_name File-Slurp
 Summary:        Perl module for reading/writing/modifying complete files
@@ -40,13 +40,14 @@
 
 %prep
 %setup -q -n %{cpan_name}-%{version}
+find . -type f ! -name \*.pl -print0 | xargs -0 chmod 644
 
 %build
 perl Makefile.PL INSTALLDIRS=vendor
-%{__make} %{?_smp_mflags}
+make %{?_smp_mflags}
 
 %check
-%{__make} test
+make test
 
 %install
 %perl_make_install

++++++ File-Slurp-9999.24.tar.gz -> File-Slurp-9999.25.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/File-Slurp-9999.24/Changes 
new/File-Slurp-9999.25/Changes
--- old/File-Slurp-9999.24/Changes      2018-10-30 03:39:39.000000000 +0100
+++ new/File-Slurp-9999.25/Changes      2018-11-16 17:07:49.000000000 +0100
@@ -1,5 +1,16 @@
 Revision history File::Slurp
 
+9999.25     2018-10-29
+    - The previous release contained nothing but a documentation update. That
+      updated documentation errantly mentioned pseudo-files. Pseudo-files
+      are perfectly fine to use with File::Slurp.
+    - Add regression test for GLOB refs being slurped in. Thank you, James 
Keenan!
+      https://github.com/perhunter/slurp/pull/17#issuecomment-437174592
+    - Refactor read_file to use open and read rather than sysopen and sysread.
+    - Add a bugwards compatible feature to keep track of the cursor when
+      dealing with the DATA handle (https://github.com/perhunter/slurp/pull/17)
+    - Fix a typo in the docs.
+
 9999.24     2018-10-29
     - Document the clear downfalls of using file handles of any kind rather
       than just the file's path string.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/File-Slurp-9999.24/MANIFEST 
new/File-Slurp-9999.25/MANIFEST
--- old/File-Slurp-9999.24/MANIFEST     2018-10-30 03:41:35.000000000 +0100
+++ new/File-Slurp-9999.25/MANIFEST     2018-11-16 17:08:54.000000000 +0100
@@ -18,6 +18,7 @@
 t/01-error_write_file.t
 t/append_null.t
 t/binmode.t
+t/data_glob.t
 t/data_section.t
 t/edit_file.t
 t/error.t
@@ -27,6 +28,7 @@
 t/large.t
 t/lib/FileSlurpTest.pm
 t/lib/FileSlurpTestOverride.pm
+t/lib/FSGlobby.pm
 t/newline.t
 t/no_clobber.t
 t/original.t
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/File-Slurp-9999.24/META.json 
new/File-Slurp-9999.25/META.json
--- old/File-Slurp-9999.24/META.json    2018-10-30 03:41:35.000000000 +0100
+++ new/File-Slurp-9999.25/META.json    2018-11-16 17:08:54.000000000 +0100
@@ -71,7 +71,7 @@
          "web" : "https://github.com/perhunter/slurp";
       }
    },
-   "version" : "9999.24",
+   "version" : "9999.25",
    "x_contributors" : [
       "Aristotle Pagaltzis <[email protected]>",
       "Chase Whitener <[email protected]>",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/File-Slurp-9999.24/META.yml 
new/File-Slurp-9999.25/META.yml
--- old/File-Slurp-9999.24/META.yml     2018-10-30 03:41:35.000000000 +0100
+++ new/File-Slurp-9999.25/META.yml     2018-11-16 17:08:53.000000000 +0100
@@ -44,7 +44,7 @@
   warnings: '0'
 resources:
   repository: https://github.com/perhunter/slurp.git
-version: '9999.24'
+version: '9999.25'
 x_contributors:
   - 'Aristotle Pagaltzis <[email protected]>'
   - 'Chase Whitener <[email protected]>'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/File-Slurp-9999.24/README.md 
new/File-Slurp-9999.25/README.md
--- old/File-Slurp-9999.24/README.md    2018-10-30 03:39:22.000000000 +0100
+++ new/File-Slurp-9999.25/README.md    2018-11-08 23:25:56.000000000 +0100
@@ -48,7 +48,7 @@
 ## WARNING - PENDING DOOM
 
 Although you technically _can_, do NOT use this module to work on file handles,
-pipes, sockets, standard IO, pseudo-files, or the `DATA` handle. These are
+pipes, sockets, standard IO, or the `DATA` handle. These are
 features implemented long ago that just really shouldn't be abused here.
 
 Be warned: this activity will lead to inaccurate encoding/decoding of data.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/File-Slurp-9999.24/lib/File/Slurp.pm 
new/File-Slurp-9999.25/lib/File/Slurp.pm
--- old/File-Slurp-9999.24/lib/File/Slurp.pm    2018-10-30 03:39:22.000000000 
+0100
+++ new/File-Slurp-9999.25/lib/File/Slurp.pm    2018-11-16 17:06:32.000000000 
+0100
@@ -3,7 +3,7 @@
 use strict;
 use warnings ;
 
-our $VERSION = '9999.24';
+our $VERSION = '9999.25';
 $VERSION = eval $VERSION;
 
 use Carp ;
@@ -59,188 +59,84 @@
 *rf = \&read_file ;
 
 sub read_file {
-
-       my $file_name = shift ;
-       my $opts = ( ref $_[0] eq 'HASH' ) ? shift : { @_ } ;
-
-# this is the optimized read_file for shorter files.
-# the test for -s > 0 is to allow pseudo files to be read with the
-# regular loop since they return a size of 0.
-
-       if ( !ref $file_name && -e $file_name && -s _ > 0 &&
-            -s _ < $max_fast_slurp_size && !%{$opts} && !wantarray ) {
-
-
-               my $fh ;
-               unless( sysopen( $fh, $file_name, O_RDONLY ) ) {
-
-                       @_ = ( $opts, "read_file '$file_name' - sysopen: $!");
-                       goto &_error ;
-               }
-
-               my $read_cnt = sysread( $fh, my $buf, -s _ ) ;
-
-               unless ( defined $read_cnt ) {
-
-                       @_ = ( $opts,
-                               "read_file '$file_name' - small sysread: $!");
-                       goto &_error ;
-               }
-
-               $buf =~ s/\015\012/\n/g if $is_win32 ;
-               return $buf ;
+       my $file_name = shift;
+       my $opts = (ref $_[0] eq 'HASH') ? shift : {@_};
+       # options we care about:
+       # array_ref binmode blk_size buf_ref chomp err_mode scalar_ref
+
+       # let's see if we have a stringified object before doing anything else
+       # We then only have to deal with when we are given a file handle/globref
+       if (ref($file_name)) {
+               my $ref_result = _check_ref($file_name, $opts);
+               if (ref($ref_result)) {
+                       @_ = ($opts, $ref_result);
+                       goto &_error;
+               }
+               $file_name = $ref_result if $ref_result;
+               # we have now stringified $file_name if possible. if it's still 
a ref
+               # then we probably have a file handle
+       }
+
+       my $fh;
+       if (ref($file_name)) {
+               $fh = $file_name;
        }
-
-# set the buffer to either the passed in one or ours and init it to the null
-# string
-
-       my $buf ;
-       my $buf_ref = $opts->{'buf_ref'} || \$buf ;
-       ${$buf_ref} = '' ;
-
-       my( $read_fh, $size_left, $blk_size ) ;
-
-# deal with ref for a file name
-# it could be an open handle or an overloaded object
-
-       if ( ref $file_name ) {
-
-               my $ref_result = _check_ref( $file_name ) ;
-
-               if ( ref $ref_result ) {
-
-# we got an error, deal with it
-
-                       @_ = ( $opts, $ref_result ) ;
-                       goto &_error ;
-               }
-
-               if ( $ref_result ) {
-
-# we got an overloaded object and the result is the stringified value
-# use it as the file name
-
-                       $file_name = $ref_result ;
-               }
-               else {
-
-# here we have just an open handle. set $read_fh so we don't do a sysopen
-
-                       $read_fh = $file_name ;
-                       $blk_size = $opts->{'blk_size'} || 1024 * 1024 ;
-                       $size_left = $blk_size ;
+       else {
+               # to keep with the old ways, read in :raw by default
+               unless (open $fh, "<:raw", $file_name) {
+                       @_ = ($opts, "read_file '$file_name' - open: $!");
+                       goto &_error;
+               }
+               # even though we set raw, let binmode take place here (busted)
+               if (my $bm = $opts->{binmode}) {
+                       binmode $fh, $bm;
                }
        }
 
-# see if we have a path we need to open
-
-       unless ( $read_fh ) {
-
-# a regular file. set the sysopen mode
-
-               my $mode = O_RDONLY ;
-
-#printf "RD: BINARY %x MODE %x\n", O_BINARY, $mode ;
-
-               $read_fh = local( *FH ) ;
-#              $read_fh = gensym ;
-               unless ( sysopen( $read_fh, $file_name, $mode ) ) {
-                       @_ = ( $opts, "read_file '$file_name' - sysopen: $!");
-                       goto &_error ;
-               }
-
-               if ( my $binmode = $opts->{'binmode'} ) {
-                       binmode( $read_fh, $binmode ) ;
-               }
-
-# get the size of the file for use in the read loop
-
-               $size_left = -s $read_fh ;
-
-#print "SIZE $size_left\n" ;
-
-# we need a blk_size if the size is 0 so we can handle pseudofiles like in
-# /proc. these show as 0 size but have data to be slurped.
-
-               unless( $size_left ) {
-
-                       $blk_size = $opts->{'blk_size'} || 1024 * 1024 ;
-                       $size_left = $blk_size ;
-               }
+       # we are now sure to have an open file handle. Let's slurp it in the 
same
+       # way that File::Slurper does.
+       my $buf;
+       my $buf_ref = $opts->{buf_ref} || \$buf;
+       ${$buf_ref} = '';
+       my $blk_size = $opts->{blk_size} || 1024 * 1024;
+       if (my $size = -s $fh) {
+               $blk_size = $size if $size < $blk_size;
+               my ($pos, $read) = 0;
+               do {
+                       unless(defined($read = read $fh, ${$buf_ref}, 
$blk_size, $pos)) {
+                               @_ = ($opts, "read_file '$file_name' - read: 
$!");
+                               goto &_error;
+                       }
+                       $pos += $read;
+               } while ($read && $pos < $size);
        }
-
-# infinite read loop. we exit when we are done slurping
-
-       while( 1 ) {
-
-# do the read and see how much we got
-
-               my $read_cnt = sysread( $read_fh, ${$buf_ref},
-                               $size_left, length ${$buf_ref} ) ;
-
-# since we're using sysread Perl won't automatically restart the call
-# when interrupted by a signal.
-
-               next if $!{EINTR};
-
-               unless ( defined $read_cnt ) {
-
-                       @_ = ( $opts, "read_file '$file_name' - loop sysread: 
$!");
-                       goto &_error ;
-               }
-
-# good read. see if we hit EOF (nothing left to read)
-
-               last if $read_cnt == 0 ;
-
-# loop if we are slurping a handle. we don't track $size_left then.
-
-               next if $blk_size ;
-
-# count down how much we read and loop if we have more to read.
-
-               $size_left -= $read_cnt ;
-               last if $size_left <= 0 ;
+       else {
+               ${$buf_ref} = do { local $/; <$fh> };
        }
+       seek($fh, $opts->{_data_tell}, SEEK_SET) if $opts->{_is_data} && 
$opts->{_data_tell};
 
-# fix up cr/lf to be a newline if this is a windows text file
-
-       ${$buf_ref} =~ s/\015\012/\n/g if $is_win32 && !$opts->{'binmode'} ;
-
-       my $sep = $/ ;
-       $sep = '\n\n+' if defined $sep && $sep eq '' ;
-
-# see if caller wants lines
-
-       if( wantarray || $opts->{'array_ref'} ) {
-
-               use re 'taint' ;
+       # line endings if we're on Windows
+       ${$buf_ref} =~ s/\015\012/\012/g if $is_win32 && !$opts->{binmode};
 
+       # we now have a buffer filled with the file content. Figure out how to
+       # return it to the user
+       my $want_array = wantarray; # let's only ask for this once
+       if ($want_array || $opts->{array_ref}) {
+               use re 'taint';
+               my $sep = $/;
+               $sep = '\n\n+' if defined $sep && $sep eq '';
+               # split the buffered content into lines
                my @lines = length(${$buf_ref}) ?
-                       ${$buf_ref} =~ /(.*?$sep|.+)/sg : () ;
-
-               chomp @lines if $opts->{'chomp'} ;
-
-# caller wants an array ref
-
-               return \@lines if $opts->{'array_ref'} ;
-
-# caller wants list of lines
-
-               return @lines ;
-       }
-
-# caller wants a scalar ref to the slurped text
-
-       return $buf_ref if $opts->{'scalar_ref'} ;
-
-# caller wants a scalar with the slurped text (normal scalar context)
-
-       return ${$buf_ref} if defined wantarray ;
-
-# caller passed in an i/o buffer by reference (normal void context)
-
-       return ;
+                       ${$buf_ref} =~ /(.*?$sep|.+)/sg : ();
+               chomp @lines if $opts->{chomp};
+               return \@lines if $opts->{array_ref};
+               return @lines;
+       }
+       return $buf_ref if $opts->{scalar_ref};
+       # if the function was called in scalar context, return the contents
+       return ${$buf_ref} if defined $want_array;
+       # if we were called in void context, return nothing
+       return;
 }
 
 # errors in this sub are returned as scalar refs
@@ -249,7 +145,7 @@
 
 sub _check_ref {
 
-       my( $handle ) = @_ ;
+       my( $handle, $opts ) = @_ ;
 
 # check if we are reading from a handle (GLOB or IO object)
 
@@ -257,7 +153,7 @@
 
 # we have a handle. deal with seeking to it if it is DATA
 
-               my $err = _seek_data_handle( $handle ) ;
+               my $err = _seek_data_handle( $handle, $opts ) ;
 
 # return the error string if any
 
@@ -282,7 +178,10 @@
 
 sub _seek_data_handle {
 
-       my( $handle ) = @_ ;
+       my( $handle, $opts ) = @_ ;
+       # store some meta-data about the __DATA__ file handle
+       $opts->{_is_data} = 0;
+       $opts->{_data_tell} = 0;
 
 # DEEP DARK MAGIC. this checks the UNTAINT IO flag of a
 # glob/handle. only the DATA handle is untainted (since it is from
@@ -304,11 +203,18 @@
 
        if ( B::svref_2object( $handle )->IO->IoFLAGS & 16 ) {
 
+               # we now know we have the data handle. Let's store its original
+               # location in the file so that we can put it back after the 
read.
+               # this is only done for Bugwards-compatibility in some dists 
such as
+               # CPAN::Index::API that made use of the oddity where sysread 
was in use
+               # before
+               $opts->{_is_data} = 1;
+               $opts->{_data_tell} = tell($handle);
 # set the seek position to the current tell.
 
-               unless( sysseek( $handle, tell( $handle ), SEEK_SET ) ) {
-                       return "read_file '$handle' - sysseek: $!" ;
-               }
+               # unless( sysseek( $handle, tell( $handle ), SEEK_SET ) ) {
+               #       return "read_file '$handle' - sysseek: $!" ;
+               # }
        }
 
 # seek was successful, return no error string
@@ -818,7 +724,7 @@
 =head2 WARNING - PENDING DOOM
 
 Although you technically I<can>, do NOT use this module to work on file 
handles,
-pipes, sockets, standard IO, pseudo-files, or the C<DATA> handle. These are
+pipes, sockets, standard IO, or the C<DATA> handle. These are
 features implemented long ago that just really shouldn't be abused here.
 
 Be warned: this activity will lead to inaccurate encoding/decoding of data.
@@ -937,7 +843,7 @@
        use File::Slurp qw(prepend_file);
        prepend_file('/path/file', $header);
        prepend_file('/path/file', \@lines);
-       prepend_file('/path/file', { binmode => 'raw:'}, $bin_data);
+       prepend_file('/path/file', { binmode => ':raw'}, $bin_data);
 
        # equivalent to:
        use File::Slurp qw(read_file write_file);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/File-Slurp-9999.24/t/data_glob.t 
new/File-Slurp-9999.25/t/data_glob.t
--- old/File-Slurp-9999.24/t/data_glob.t        1970-01-01 01:00:00.000000000 
+0100
+++ new/File-Slurp-9999.25/t/data_glob.t        2018-11-16 15:45:18.000000000 
+0100
@@ -0,0 +1,45 @@
+use strict;
+use warnings;
+
+use File::Basename ();
+use File::Spec ();
+use lib 
File::Spec->catdir(File::Spec->rel2abs(File::Basename::dirname(__FILE__)), 
'lib');
+use FileSlurpTest qw(trap_function);
+use File::Slurp qw(read_file);
+
+# a package with a __DATA__ section
+use FSGlobby ();
+
+use Scalar::Util qw(blessed);
+use Symbol qw(qualify qualify_to_ref);
+use Test::More;
+
+plan tests => 10;
+
+my $obj = FSGlobby->new();
+ok(defined $obj, "Constructor returned defined object");
+isa_ok( $obj, 'FSGlobby');
+
+my $symbolname = qualify("DATA", blessed $obj);
+is($symbolname, 'FSGlobby::DATA', "Symbol::qualify(): Got expected symbol 
name");
+
+my $glob = qualify_to_ref("DATA", blessed $obj);
+is(ref($glob), 'GLOB', "Symbol::qualify_to_ref():  Got a glob");
+
+my @lines = read_file($glob, {chomp => 1});
+my $expected_lines = 8;
+is(scalar @lines, $expected_lines, "Got $expected_lines lines in file");
+is($lines[0], 'File:', "Got expected first line");
+is($lines[$expected_lines - 1], 'Last-Updated:', "Got expected last line");
+my %lines_seen;
+map { $lines_seen{$_}++ } @lines;
+is($lines_seen{$lines[0]}, 1, "First line seen exactly once");
+is($lines_seen{$lines[$expected_lines - 1]}, 1, "Last line seen exactly once");
+
+# read a second time
+# this test exists as yet another regression prevention test because certain
+# modules like CPAN::Index::API make use of what should be considered a bug
+# where sysread was in use, not altering tell and the __DATA__ cursor was good
+# for another read.
+my @second_lines = read_file($glob, {chomp => 1});
+is_deeply(\@second_lines, \@lines, 'multiple reads the same');
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/File-Slurp-9999.24/t/lib/FSGlobby.pm 
new/File-Slurp-9999.25/t/lib/FSGlobby.pm
--- old/File-Slurp-9999.24/t/lib/FSGlobby.pm    1970-01-01 01:00:00.000000000 
+0100
+++ new/File-Slurp-9999.25/t/lib/FSGlobby.pm    2018-11-08 23:54:15.000000000 
+0100
@@ -0,0 +1,18 @@
+package FSGlobby;
+
+sub new {
+    my $class = shift;
+    return bless {}, $class;
+}
+
+1;
+
+__DATA__
+File:
+URL:
+Description:
+Columns:
+Intended-For:
+Written-By:
+Line-Count:
+Last-Updated:


Reply via email to