[clangd] Harden test against sed implementations that strip \r.

Also clean up logging and don't print \0.

llvm-svn: 294294
This commit is contained in:
Benjamin Kramer 2017-02-07 11:49:03 +00:00
parent 258d9a528e
commit d588b0f525
2 changed files with 5 additions and 7 deletions

View File

@ -68,18 +68,17 @@ int main(int argc, char *argv[]) {
// Now read the JSON. Insert a trailing null byte as required by the YAML // Now read the JSON. Insert a trailing null byte as required by the YAML
// parser. // parser.
std::vector<char> JSON(Len + 1); std::vector<char> JSON(Len + 1, '\0');
std::cin.read(JSON.data(), Len); std::cin.read(JSON.data(), Len);
if (Len > 0) { if (Len > 0) {
llvm::StringRef JSONRef(JSON.data(), Len);
// Log the message. // Log the message.
Logs << "<-- "; Logs << "<-- " << JSONRef << '\n';
Logs.write(JSON.data(), JSON.size());
Logs << '\n';
Logs.flush(); Logs.flush();
// Finally, execute the action for this JSON message. // Finally, execute the action for this JSON message.
if (!Dispatcher.call(llvm::StringRef(JSON.data(), JSON.size() - 1))) if (!Dispatcher.call(JSONRef))
Logs << "JSON dispatch failed!\n"; Logs << "JSON dispatch failed!\n";
} }
} }

View File

@ -1,5 +1,4 @@
# RUN: sed -e '/^#/d' %s | clangd | FileCheck %s # RUN: sed -e '/^#/d' -e 's/\r*$/\r/' %s | clangd | FileCheck %s
# It is absolutely vital that this file has CRLF line endings.
# #
Content-Length: 125 Content-Length: 125