Skip to content

Commit 0d3fb9d

Browse files
amadioSFT
authored andcommitted
Simplify query for include directories
- Use only sed instead of awk and grep - Use regex independent of locale settings
1 parent 111fa41 commit 0d3fb9d

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

lib/Interpreter/CIFactory.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,10 @@ namespace {
104104
llvm::SmallVectorImpl<char>& Buf,
105105
AdditionalArgList& Args,
106106
bool Verbose) {
107-
std::string CppInclQuery("LC_ALL=C ");
108-
CppInclQuery.append(Compiler);
109-
CppInclQuery.append(" -xc++ -E -v /dev/null 2>&1 >/dev/null "
110-
"| awk '/^#include </,/^End of search"
111-
"/{if (!/^#include </ && !/^End of search/){ print }}' "
112-
"| GREP_OPTIONS= grep -E \"(c|g)\\+\\+\"");
107+
std::string CppInclQuery(Compiler);
108+
109+
CppInclQuery.append(" -xc++ -E -v /dev/null 2>&1 |"
110+
" sed -n -e '/^.include/,${' -e '/^ \\/.*++/p' -e '}'");
113111

114112
if (Verbose)
115113
cling::log() << "Looking for C++ headers with:\n " << CppInclQuery << "\n";

lib/Interpreter/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,7 @@ if (UNIX)
252252

253253
execute_process(
254254
COMMAND echo ${CLING_CXX_HEADERS}
255-
COMMAND awk "/^#include </,/^End of search/{if (!/^#include </ && !/^End of search/){ print }}"
256-
COMMAND grep -E "(c|g)\\+\\+"
255+
COMMAND sed -n -e /^.include/,\$\{ -e /^\\\ \\\/.*++/p -e \}
257256
OUTPUT_VARIABLE CLING_CXX_HEADERS)
258257

259258
stripNewLine("${CLING_CXX_HEADERS}" CLING_CXX_HEADERS)

0 commit comments

Comments
 (0)