Skip to content

Commit 6d0174e

Browse files
[libc] allow libc-hdrgen to work on windows files (#87292)
The code does some (overly simple?) checks on file syntax. These checks assume unix line endings and fail on windows. This commit updates the code to strip extra whitespace, making the checks more robust, particularly in the presence of windows line endings. Fixes #86023
1 parent 1079fc4 commit 6d0174e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

libc/utils/HdrGen/Generator.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,19 @@ void Generator::generate(llvm::raw_ostream &OS, llvm::RecordKeeper &Records) {
8484
Line = Line.drop_front(CommandPrefixSize);
8585

8686
P = Line.split("(");
87+
// It's possible that we have windows line endings, so strip off the extra
88+
// CR.
89+
P.second = P.second.trim();
8790
if (P.second.empty() || P.second[P.second.size() - 1] != ')') {
8891
SrcMgr.PrintMessage(llvm::SMLoc::getFromPointer(P.second.data()),
8992
llvm::SourceMgr::DK_Error,
9093
"Command argument list should begin with '(' "
9194
"and end with ')'.");
95+
SrcMgr.PrintMessage(llvm::SMLoc::getFromPointer(P.second.data()),
96+
llvm::SourceMgr::DK_Error, P.second.data());
97+
SrcMgr.PrintMessage(llvm::SMLoc::getFromPointer(P.second.data()),
98+
llvm::SourceMgr::DK_Error,
99+
std::to_string(P.second.size()));
92100
std::exit(1);
93101
}
94102
llvm::StringRef CommandName = P.first;

0 commit comments

Comments
 (0)