Filename | C:/tmp64ng/perl/vendor/lib/Portable/FileSpec.pm |
Statements | Executed 1189 statements in 0s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 0s | 0s | BEGIN@5 | Portable::FileSpec::
1 | 1 | 1 | 0s | 0s | BEGIN@6 | Portable::FileSpec::
1 | 1 | 1 | 0s | 0s | BEGIN@7 | Portable::FileSpec::
158 | 9 | 1 | 0s | 0s | CORE:match (opcode) | Portable::FileSpec::
63 | 3 | 1 | 0s | 0s | CORE:regcomp (opcode) | Portable::FileSpec::
470 | 7 | 1 | 0s | 0s | CORE:subst (opcode) | Portable::FileSpec::
66 | 3 | 1 | 0s | 0s | _canon_cat | Portable::FileSpec::
63 | 5 | 5 | 0s | 0s | catdir | Portable::FileSpec::
3 | 2 | 2 | 0s | 0s | catfile | Portable::FileSpec::
6 | 3 | 1 | 0s | 0s | catpath | Portable::FileSpec::
1 | 1 | 1 | 0s | 0s | splitdir | Portable::FileSpec::
1 | 1 | 1 | 0s | 0s | splitpath | Portable::FileSpec::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Portable::FileSpec; | ||||
2 | |||||
3 | ### UGLY HACK: these functions where completely copied from File::Spec::Win32 | ||||
4 | |||||
5 | 2 | 0s | 1 | 0s | # spent 0s within Portable::FileSpec::BEGIN@5 which was called:
# once (0s+0s) by Portable::BEGIN@55 at line 5 # spent 0s making 1 call to Portable::FileSpec::BEGIN@5 |
6 | 2 | 0s | 2 | 0s | # spent 0s within Portable::FileSpec::BEGIN@6 which was called:
# once (0s+0s) by Portable::BEGIN@55 at line 6 # spent 0s making 1 call to Portable::FileSpec::BEGIN@6
# spent 0s making 1 call to strict::import |
7 | 2 | 0s | 2 | 0s | # spent 0s within Portable::FileSpec::BEGIN@7 which was called:
# once (0s+0s) by Portable::BEGIN@55 at line 7 # spent 0s making 1 call to Portable::FileSpec::BEGIN@7
# spent 0s making 1 call to warnings::import |
8 | |||||
9 | 1 | 0s | our $VERSION = '1.22'; | ||
10 | |||||
11 | # Some regexes we use for path splitting | ||||
12 | 1 | 0s | my $DRIVE_RX = '[a-zA-Z]:'; | ||
13 | 1 | 0s | my $UNC_RX = '(?:\\\\\\\\|//)[^\\\\/]+[\\\\/][^\\\\/]+'; | ||
14 | 1 | 0s | my $VOL_RX = "(?:$DRIVE_RX|$UNC_RX)"; | ||
15 | |||||
16 | # spent 0s within Portable::FileSpec::splitpath which was called:
# once (0s+0s) by Portable::default at line 187 of Portable.pm | ||||
17 | 1 | 0s | my ($path, $nofile) = @_; | ||
18 | 1 | 0s | my ($volume,$directory,$file) = ('','',''); | ||
19 | 1 | 0s | if ( $nofile ) { | ||
20 | $path =~ | ||||
21 | m{^ ( $VOL_RX ? ) (.*) }sox; | ||||
22 | $volume = $1; | ||||
23 | $directory = $2; | ||||
24 | } | ||||
25 | else { | ||||
26 | 1 | 0s | 2 | 0s | $path =~ # spent 0s making 1 call to Portable::FileSpec::CORE:match
# spent 0s making 1 call to Portable::FileSpec::CORE:regcomp |
27 | m{^ ( $VOL_RX ? ) | ||||
28 | ( (?:.*[\\/](?:\.\.?\Z(?!\n))?)? ) | ||||
29 | (.*) | ||||
30 | }sox; | ||||
31 | 1 | 0s | $volume = $1; | ||
32 | 1 | 0s | $directory = $2; | ||
33 | 1 | 0s | $file = $3; | ||
34 | } | ||||
35 | |||||
36 | 1 | 0s | return ($volume,$directory,$file); | ||
37 | } | ||||
38 | |||||
39 | # spent 0s within Portable::FileSpec::splitdir which was called:
# once (0s+0s) by Portable::default at line 188 of Portable.pm | ||||
40 | 1 | 0s | my ($directories) = @_ ; | ||
41 | # | ||||
42 | # split() likes to forget about trailing null fields, so here we | ||||
43 | # check to be sure that there will not be any before handling the | ||||
44 | # simple case. | ||||
45 | # | ||||
46 | 1 | 0s | 1 | 0s | if ( $directories !~ m|[\\/]\Z(?!\n)| ) { # spent 0s making 1 call to Portable::FileSpec::CORE:match |
47 | return split( m|[\\/]|, $directories ); | ||||
48 | } | ||||
49 | else { | ||||
50 | # | ||||
51 | # since there was a trailing separator, add a file name to the end, | ||||
52 | # then do the split, then replace it with ''. | ||||
53 | # | ||||
54 | 1 | 0s | my( @directories )= split( m|[\\/]|, "${directories}dummy" ) ; | ||
55 | 1 | 0s | $directories[ $#directories ]= '' ; | ||
56 | 1 | 0s | return @directories ; | ||
57 | } | ||||
58 | } | ||||
59 | |||||
60 | # spent 0s within Portable::FileSpec::catpath which was called 6 times, avg 0s/call:
# 4 times (0s+0s) by Portable::default at line 190 of Portable.pm, avg 0s/call
# once (0s+0s) by Portable::default at line 202 of Portable.pm
# once (0s+0s) by Portable::default at line 203 of Portable.pm | ||||
61 | 6 | 0s | my ($volume,$directory,$file) = @_; | ||
62 | |||||
63 | # If it's UNC, make sure the glue separator is there, reusing | ||||
64 | # whatever separator is first in the $volume | ||||
65 | 6 | 0s | my $v; | ||
66 | 6 | 0s | 6 | 0s | $volume .= $v # spent 0s making 6 calls to Portable::FileSpec::CORE:match, avg 0s/call |
67 | if ( (($v) = $volume =~ m@^([\\/])[\\/][^\\/]+[\\/][^\\/]+\Z(?!\n)@s) && | ||||
68 | $directory =~ m@^[^\\/]@s | ||||
69 | ) ; | ||||
70 | |||||
71 | 6 | 0s | $volume .= $directory ; | ||
72 | |||||
73 | # If the volume is not just A:, make sure the glue separator is | ||||
74 | # there, reusing whatever separator is first in the $volume if possible. | ||||
75 | 6 | 0s | 17 | 0s | if ( $volume !~ m@^[a-zA-Z]:\Z(?!\n)@s && # spent 0s making 17 calls to Portable::FileSpec::CORE:match, avg 0s/call |
76 | $volume =~ m@[^\\/]\Z(?!\n)@ && | ||||
77 | $file =~ m@[^\\/]@ | ||||
78 | ) { | ||||
79 | 4 | 0s | 4 | 0s | $volume =~ m@([\\/])@ ; # spent 0s making 4 calls to Portable::FileSpec::CORE:match, avg 0s/call |
80 | 4 | 0s | my $sep = $1 ? $1 : '\\' ; | ||
81 | 4 | 0s | $volume .= $sep ; | ||
82 | } | ||||
83 | |||||
84 | 6 | 0s | $volume .= $file ; | ||
85 | |||||
86 | 6 | 0s | return $volume ; | ||
87 | } | ||||
88 | |||||
89 | # spent 0s within Portable::FileSpec::catdir which was called 63 times, avg 0s/call:
# 50 times (0s+0s) by Portable::Config::new at line 40 of Portable/Config.pm, avg 0s/call
# 6 times (0s+0s) by Portable::CPAN::new at line 57 of Portable/CPAN.pm, avg 0s/call
# 4 times (0s+0s) by Portable::default at line 194 of Portable.pm, avg 0s/call
# 2 times (0s+0s) by Portable::HomeDir::new at line 37 of Portable/HomeDir.pm, avg 0s/call
# once (0s+0s) by Portable::minicpan::new at line 35 of Portable/minicpan.pm | ||||
90 | # Legacy / compatibility support | ||||
91 | 63 | 0s | return "" unless @_; | ||
92 | 63 | 0s | 4 | 0s | shift, return _canon_cat( "/", @_ ) if $_[0] eq ""; # spent 0s making 4 calls to Portable::FileSpec::_canon_cat, avg 0s/call |
93 | |||||
94 | # Compatibility with File::Spec <= 3.26: | ||||
95 | # catdir('A:', 'foo') should return 'A:\foo'. | ||||
96 | 59 | 0s | 118 | 0s | return _canon_cat( ($_[0].'\\'), @_[1..$#_] ) if $_[0] =~ m{^$DRIVE_RX\z}o; # spent 0s making 59 calls to Portable::FileSpec::CORE:match, avg 0s/call
# spent 0s making 59 calls to Portable::FileSpec::CORE:regcomp, avg 0s/call |
97 | |||||
98 | 59 | 0s | 59 | 0s | return _canon_cat( @_ ); # spent 0s making 59 calls to Portable::FileSpec::_canon_cat, avg 0s/call |
99 | } | ||||
100 | |||||
101 | # spent 0s within Portable::FileSpec::catfile which was called 3 times, avg 0s/call:
# 2 times (0s+0s) by Portable::CPAN::new at line 54 of Portable/CPAN.pm, avg 0s/call
# once (0s+0s) by Portable::Config::new at line 37 of Portable/Config.pm | ||||
102 | # Legacy / compatibility support | ||||
103 | # | ||||
104 | 3 | 0s | shift, return _canon_cat( "/", @_ ) | ||
105 | if $_[0] eq ""; | ||||
106 | |||||
107 | # Compatibility with File::Spec <= 3.26: | ||||
108 | # catfile('A:', 'foo') should return 'A:\foo'. | ||||
109 | 3 | 0s | 6 | 0s | return _canon_cat( ($_[0].'\\'), @_[1..$#_] ) # spent 0s making 3 calls to Portable::FileSpec::CORE:match, avg 0s/call
# spent 0s making 3 calls to Portable::FileSpec::CORE:regcomp, avg 0s/call |
110 | if $_[0] =~ m{^$DRIVE_RX\z}o; | ||||
111 | |||||
112 | 3 | 0s | 3 | 0s | return _canon_cat( @_ ); # spent 0s making 3 calls to Portable::FileSpec::_canon_cat, avg 0s/call |
113 | } | ||||
114 | |||||
115 | # spent 0s within Portable::FileSpec::_canon_cat which was called 66 times, avg 0s/call:
# 59 times (0s+0s) by Portable::FileSpec::catdir at line 98, avg 0s/call
# 4 times (0s+0s) by Portable::FileSpec::catdir at line 92, avg 0s/call
# 3 times (0s+0s) by Portable::FileSpec::catfile at line 112, avg 0s/call | ||||
116 | 66 | 0s | my ($first, @rest) = @_; | ||
117 | |||||
118 | 66 | 0s | 74 | 0s | my $volume = $first =~ s{ \A ([A-Za-z]:) ([\\/]?) }{}x # drive letter # spent 0s making 74 calls to Portable::FileSpec::CORE:subst, avg 0s/call |
119 | ? ucfirst( $1 ).( $2 ? "\\" : "" ) | ||||
120 | : $first =~ s{ \A (?:\\\\|//) ([^\\/]+) | ||||
121 | (?: [\\/] ([^\\/]+) )? | ||||
122 | [\\/]? }{}xs # UNC volume | ||||
123 | ? "\\\\$1".( defined $2 ? "\\$2" : "" )."\\" | ||||
124 | : $first =~ s{ \A [\\/] }{}x # root dir | ||||
125 | ? "\\" | ||||
126 | : ""; | ||||
127 | 66 | 0s | my $path = join "\\", $first, @rest; | ||
128 | |||||
129 | 66 | 0s | $path =~ tr#\\/#\\\\#s; # xx/yy --> xx\yy & xx\\yy --> xx\yy | ||
130 | |||||
131 | # xx/././yy --> xx/yy | ||||
132 | 66 | 0s | 66 | 0s | $path =~ s{(?: # spent 0s making 66 calls to Portable::FileSpec::CORE:subst, avg 0s/call |
133 | (?:\A|\\) # at begin or after a slash | ||||
134 | \. | ||||
135 | (?:\\\.)* # and more | ||||
136 | (?:\\|\z) # at end or followed by slash | ||||
137 | )+ # performance boost -- I do not know why | ||||
138 | }{\\}gx; | ||||
139 | |||||
140 | # XXX I do not know whether more dots are supported by the OS supporting | ||||
141 | # this ... annotation (NetWare or symbian but not MSWin32). | ||||
142 | # Then .... could easily become ../../.. etc: | ||||
143 | # Replace \.\.\. by (\.\.\.+) and substitute with | ||||
144 | # { $1 . ".." . "\\.." x (length($2)-2) }gex | ||||
145 | # ... --> ../.. | ||||
146 | 66 | 0s | 66 | 0s | $path =~ s{ (\A|\\) # at begin or after a slash # spent 0s making 66 calls to Portable::FileSpec::CORE:subst, avg 0s/call |
147 | \.\.\. | ||||
148 | (?=\\|\z) # at end or followed by slash | ||||
149 | }{$1..\\..}gx; | ||||
150 | # xx\yy\..\zz --> xx\zz | ||||
151 | 66 | 0s | 66 | 0s | while ( $path =~ s{(?: # spent 0s making 66 calls to Portable::FileSpec::CORE:subst, avg 0s/call |
152 | (?:\A|\\) # at begin or after a slash | ||||
153 | [^\\]+ # rip this 'yy' off | ||||
154 | \\\.\. | ||||
155 | (?<!\A\.\.\\\.\.) # do *not* replace ^..\.. | ||||
156 | (?<!\\\.\.\\\.\.) # do *not* replace \..\.. | ||||
157 | (?:\\|\z) # at end or followed by slash | ||||
158 | )+ # performance boost -- I do not know why | ||||
159 | }{\\}sx ) {} | ||||
160 | |||||
161 | 66 | 0s | 66 | 0s | $path =~ s#\A\\##; # \xx --> xx NOTE: this is *not* root # spent 0s making 66 calls to Portable::FileSpec::CORE:subst, avg 0s/call |
162 | 66 | 0s | 66 | 0s | $path =~ s#\\\z##; # xx\ --> xx # spent 0s making 66 calls to Portable::FileSpec::CORE:subst, avg 0s/call |
163 | |||||
164 | 66 | 0s | 66 | 0s | if ( $volume =~ m#\\\z# ) # spent 0s making 66 calls to Portable::FileSpec::CORE:match, avg 0s/call |
165 | { # <vol>\.. --> <vol>\ | ||||
166 | 66 | 0s | 66 | 0s | $path =~ s{ \A # at begin # spent 0s making 66 calls to Portable::FileSpec::CORE:subst, avg 0s/call |
167 | \.\. | ||||
168 | (?:\\\.\.)* # and more | ||||
169 | (?:\\|\z) # at end or followed by slash | ||||
170 | }{}x; | ||||
171 | |||||
172 | 66 | 0s | 1 | 0s | return $1 # \\HOST\SHARE\ --> \\HOST\SHARE # spent 0s making 1 call to Portable::FileSpec::CORE:match |
173 | if $path eq "" | ||||
174 | and $volume =~ m#\A(\\\\.*)\\\z#s; | ||||
175 | } | ||||
176 | 66 | 0s | return $path ne "" || $volume ? $volume.$path : "."; | ||
177 | } | ||||
178 | |||||
179 | |||||
180 | 1 | 0s | 1; | ||
# spent 0s within Portable::FileSpec::CORE:match which was called 158 times, avg 0s/call:
# 66 times (0s+0s) by Portable::FileSpec::_canon_cat at line 164, avg 0s/call
# 59 times (0s+0s) by Portable::FileSpec::catdir at line 96, avg 0s/call
# 17 times (0s+0s) by Portable::FileSpec::catpath at line 75, avg 0s/call
# 6 times (0s+0s) by Portable::FileSpec::catpath at line 66, avg 0s/call
# 4 times (0s+0s) by Portable::FileSpec::catpath at line 79, avg 0s/call
# 3 times (0s+0s) by Portable::FileSpec::catfile at line 109, avg 0s/call
# once (0s+0s) by Portable::FileSpec::splitpath at line 26
# once (0s+0s) by Portable::FileSpec::splitdir at line 46
# once (0s+0s) by Portable::FileSpec::_canon_cat at line 172 | |||||
sub Portable::FileSpec::CORE:regcomp; # opcode | |||||
# spent 0s within Portable::FileSpec::CORE:subst which was called 470 times, avg 0s/call:
# 74 times (0s+0s) by Portable::FileSpec::_canon_cat at line 118, avg 0s/call
# 66 times (0s+0s) by Portable::FileSpec::_canon_cat at line 151, avg 0s/call
# 66 times (0s+0s) by Portable::FileSpec::_canon_cat at line 161, avg 0s/call
# 66 times (0s+0s) by Portable::FileSpec::_canon_cat at line 166, avg 0s/call
# 66 times (0s+0s) by Portable::FileSpec::_canon_cat at line 146, avg 0s/call
# 66 times (0s+0s) by Portable::FileSpec::_canon_cat at line 162, avg 0s/call
# 66 times (0s+0s) by Portable::FileSpec::_canon_cat at line 132, avg 0s/call |