From 2ba8614d268290d3b18964d83bde1a785b66b2bb Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 23 Jun 2022 16:01:41 +0200 Subject: Handle empty entries in GCC -print-search-dirs --- libbuild2/cc/gcc.cxx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libbuild2/cc/gcc.cxx b/libbuild2/cc/gcc.cxx index 2c844b6..7999c82 100644 --- a/libbuild2/cc/gcc.cxx +++ b/libbuild2/cc/gcc.cxx @@ -370,17 +370,22 @@ namespace build2 { string ds (l, b, (e != string::npos ? e - b : e)); + // Skip empty entries (sometimes found in random MinGW toolchains). + // + if (!ds.empty ()) + { #ifdef _WIN32 - if (path_traits::is_separator (ds[0])) - add_current_drive (ds); + if (path_traits::is_separator (ds[0])) + add_current_drive (ds); #endif - d = dir_path (move (ds)); + d = dir_path (move (ds)); - if (d.relative ()) - throw invalid_path (move (d).string ()); + if (d.relative ()) + throw invalid_path (move (d).string ()); - d.normalize (); + d.normalize (); + } } catch (const invalid_path& e) { @@ -388,7 +393,7 @@ namespace build2 << args[0] << " -print-search-dirs output"; } - if (find (r.begin (), r.end (), d) == r.end ()) + if (!d.empty () && find (r.begin (), r.end (), d) == r.end ()) r.emplace_back (move (d)); if (e == string::npos) -- cgit v1.1