diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-08-28 16:34:59 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-08-28 16:34:59 +0200 |
commit | 762f29a2a9ca7afd66c7cd11598e4d371a117ca7 (patch) | |
tree | 6b3f7b6fe4a5f2be8ed5f8c5bbd1328dc32eb0d9 | |
parent | d18cadf6fcf009b79169c025c8b7a65608e2ee8a (diff) |
Fix locale dependence when extracting GCC library search paths
-rw-r--r-- | build2/cc/gcc.cxx | 21 |
1 files 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 "<name>: =" 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. |