From 762f29a2a9ca7afd66c7cd11598e4d371a117ca7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 28 Aug 2016 16:34:59 +0200 Subject: Fix locale dependence when extracting GCC library search paths --- build2/cc/gcc.cxx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/build2/cc/gcc.cxx b/build2/cc/gcc.cxx index a6c7448..4c115b4 100644 --- a/build2/cc/gcc.cxx +++ b/build2/cc/gcc.cxx @@ -56,14 +56,23 @@ namespace build2 { ifdstream is (pr.in_ofd, fdstream_mode::skip, ifdstream::badbit); + // The output of -print-search-dirs are a bunch of lines that start + // with ": =" where name can be "install", "programs", or + // "libraries". If you have English locale, that is. If you set your + // LC_ALL="tr_TR", then it becomes "kurulum", "programlar", and + // "kitapl?klar". Also, Clang omits "install" while GCC and Intel + // icc print all three. The "libraries" seem to be alwasy last, + // however. + // string s; - while (getline (is, s)) + for (bool found (false); !found && getline (is, s); ) { - if (s.compare (0, 12, "libraries: =") == 0) - { - l.assign (s, 12, string::npos); - break; - } + found = (s.compare (0, 12, "libraries: =") == 0); + + size_t p (found ? 9 : s.find (": =")); + + if (p != string::npos) + l.assign (s, p + 3, string::npos); } is.close (); // Don't block. -- cgit v1.1