-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a massive change, but we ran a smoke test against all 646 reverse dependencies on Linux, BSD, and Windows to ensure this change would not break userland. This should get is half way to Perl 5.30 compliance. In general, we've changed the `read_file` function to: * check to see if we're dealing with a glob/file handle * stringify overloadable object if possible * if dealing with string path: * open file handle with `:raw` * run `binmode` if one was supplied * read in content a la File::Slurper (buffered `read`) * normalize how we refer to `$opts` (no quotes) This is more or less as it was before, but now using `read` instead of `sysread`. Using `open '<:raw'` instead of `sysopen`. However, we also have a change for the `__DATA__` handle: We no longer need to do the `sysseek` `tell` trick since we are not using `sysread` anymore. We are only dealing with a buffered `open` and `read`, so we don't have to worry about the unbuffered versions. That old method left a sort of feature that we weren't expecting people to exploit. Since we left the buffered position alone and always set the unbuffered position to the current buffered cursor position, you could read the `__DATA__` handle more than once (the buffered position would remain where it was before we used `sysread` to slurp in the contents). Now that we're using the buffered `read`, we need to work around that for bugwards compatibility. `CPAN::Index::API` is an example of code in the wild making use of this feature bug. BUGWARDS COMPATIBILITY FIX BELOW: Since this isn't a class and we don't have anywhere to store meta data, we'll make use of the `$opts` hash reference. * `$opts->{_is_data}` will be set to true if we're dealing with the `__DATA__` handle. * `$opts->{_data_tell}` will be set to the location of the buffered cursor before we slurp in the contents. After the contents have been read, we'll put the cursor location back where we found it if we're working on the `__DATA__` handle.
- Loading branch information
Showing
1 changed file
with
83 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters