From 6108b18a3b1411fa544bf12a5b9e7ddb69e135cd Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Tue, 3 Oct 2023 21:05:29 -0700 Subject: [PATCH] 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. --- src/util.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util.cc b/src/util.cc index ce45b1c5c8..9d38ea69ca 100644 --- a/src/util.cc +++ b/src/util.cc @@ -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 {}; }