Normalize file paths in find_file_in_path()

This renders script file names more nicely, for example when printed by the
reporter. It also avoids redundant prefixing of "./" to local scripts. I'm not
adding unit tests since normalize_path() already has them. A btest follows in
the next commit.
This commit is contained in:
Christian Kreibich 2023-10-03 21:05:29 -07:00
parent e22bf8ebb6
commit 6108b18a3b

View file

@ -2010,7 +2010,7 @@ static string find_file_in_path(const string& filename, const string& path,
if ( filepath.is_absolute() )
{
if ( can_read(filename) )
return filename;
return detail::normalize_path(filename);
else
return {};
}
@ -2024,12 +2024,12 @@ static string find_file_in_path(const string& filename, const string& path,
string with_ext = abs_path + ext;
if ( can_read(with_ext) )
return with_ext;
return detail::normalize_path(with_ext);
}
}
if ( can_read(abs_path) )
return abs_path;
return detail::normalize_path(abs_path);
return {};
}