From c75586cf32a9de21341150148e8363e91d096abd Mon Sep 17 00:00:00 2001 From: freesource Date: Fri, 14 Sep 2001 05:13:22 +0000 Subject: [PATCH] Hopefully, this properly fixes the relativing of dirs/files from make_link_relative when it makes "absolutely" no sense. --- BootRoot/Yard.pm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/BootRoot/Yard.pm b/BootRoot/Yard.pm index 2853b3d..d9669f8 100644 --- a/BootRoot/Yard.pm +++ b/BootRoot/Yard.pm @@ -196,6 +196,7 @@ sub read_contents_file { my($abs_file) = find_file_in_path($link); $Included{$abs_file} = 1 if $abs_file; + #### Have to be careful here. Record the rel link for use #### in setting up the root fs, but use the abs_link in @files #### so next loop gets any actual files. @@ -1331,13 +1332,27 @@ sub make_link_relative { # It's absolute -- we have to relativize it # The abs_file guaranteed not to have any funny # stuff like "/./" or "/foo/../../bar" already in it. - $newlink = ("../" x path_length($abs_file)) . $1; + + ## This is an experimental solution to an annoying tendency + ## for this to happen ../../../../ for files/dirs .. basically + ## this occurs when called from include_file() called from + ## extra_links() .. the reason for relativing links like this + ## doesn't make sense. + if (!-f $link && !-d $link) { + $newlink = ("../" x path_length($abs_file)) . $1; + } } else { # Already relative $newlink = $link; } - cleanup_link($newlink); + if ($newlink) { + cleanup_link($newlink) + } + else { + return $link; + } + } }