source: for-distributions/trunk/bin/windows/perl/lib/auto/Storable/read_magic.al@ 14489

Last change on this file since 14489 was 14489, checked in by oranfry, 17 years ago

upgrading to perl 5.8

File size: 1.2 KB
Line 
1# NOTE: Derived from ..\..\lib\Storable.pm.
2# Changes made here will be lost when autosplit is run again.
3# See AutoSplit.pm.
4package Storable;
5
6#line 116 "..\..\lib\Storable.pm (autosplit into ..\..\lib\auto\Storable\read_magic.al)"
7sub read_magic {
8 my $header = shift;
9 return unless defined $header and length $header > 11;
10 my $result;
11 if ($header =~ s/^perl-store//) {
12 die "Can't deal with version 0 headers";
13 } elsif ($header =~ s/^pst0//) {
14 $result->{file} = 1;
15 }
16 # Assume it's a string.
17 my ($major, $minor, $bytelen) = unpack "C3", $header;
18
19 my $net_order = $major & 1;
20 $major >>= 1;
21 @$result{qw(major minor netorder)} = ($major, $minor, $net_order);
22
23 return $result if $net_order;
24
25 # I assume that it is rare to find v1 files, so this is an intentionally
26 # inefficient way of doing it, to make the rest of the code constant.
27 if ($major < 2) {
28 delete $result->{minor};
29 $header = '.' . $header;
30 $bytelen = $minor;
31 }
32
33 @$result{qw(byteorder intsize longsize ptrsize)} =
34 unpack "x3 A$bytelen C3", $header;
35
36 if ($major >= 2 and $minor >= 2) {
37 $result->{nvsize} = unpack "x6 x$bytelen C", $header;
38 }
39 $result;
40}
41
42# end of Storable::read_magic
431;
Note: See TracBrowser for help on using the repository browser.