diff options
author | Reinhard Kotucha <reinhard.kotucha@web.de> | 2011-06-08 19:26:11 +0000 |
---|---|---|
committer | Reinhard Kotucha <reinhard.kotucha@web.de> | 2011-06-08 19:26:11 +0000 |
commit | 32a92469f9bde065e92eae46f38fedfd0935e5c0 (patch) | |
tree | 372d2e1437233945ddbdc0ab25770162a7ca3884 | |
parent | 0895a4204849575663399a4a569f5145ca07c53a (diff) |
TLUtils.pm: dirname(): support recursive calls.
git-svn-id: svn://tug.org/texlive/trunk@22870 c570f23f-e606-0410-a88d-b1316a301751
-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 "."; } } |