diff options
Diffstat (limited to 'Master')
-rw-r--r-- | Master/tlpkg/TeXLive/TLUtils.pm | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index 40f47ac6950..0051bc91ff6 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -526,13 +526,23 @@ Return C<$path> with its trailing C</component> removed. sub dirname { my $path=shift; - if (win32) { + my $drive=''; + if (&win32) { $path=~s!\\!/!g; } - if ($path=~m!/!) { # dirname("foo/bar/baz") -> "foo/bar" - $path=~m!(.*)/.*!; # works because of greedy matching - return $1; - } else { # dirname("ignore") -> "." + if ($path=~m!^[A-Za-z]\:!) { + $path=~ s/^(.\:)(.*)/$1,$2/; + ($drive, $path)=($1,$2); + } + if ($path=~m!/!) { + $path=~m!(.*)/.*!; # works because of greedy matching + my $dir=$1; + if (length($dir)) { # dirname("foo/bar/baz") -> "foo/bar" + return "$drive$dir"; + } else { # dirname("/baz") -> "/" + return "$drive/"; + } + } else { # dirname("ignore") -> "." return "."; } } |