From 7198db177768e5978cc4b92d4d5b48d6ec918dca Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 1 Jul 2018 10:19:35 -0700 Subject: [PATCH] Use ChangeStd{in,out}ToBinary --- src/main.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main.cc b/src/main.cc index ebb6b488..8c3ae83c 100644 --- a/src/main.cc +++ b/src/main.cc @@ -9,6 +9,7 @@ using namespace ccls; #include #include +#include #include using namespace llvm; using namespace llvm::cl; @@ -58,15 +59,6 @@ int main(int argc, char** argv) { } pipeline::Init(); - -#ifdef _WIN32 - // We need to write to stdout in binary mode because in Windows, writing - // \n will implicitly write \r\n. Language server API will ignore a - // \r\r\n split request. - _setmode(_fileno(stdout), O_BINARY); - _setmode(_fileno(stdin), O_BINARY); -#endif - IndexInit(); bool language_server = true; @@ -129,6 +121,8 @@ int main(int argc, char** argv) { } } + sys::ChangeStdinToBinary(); + sys::ChangeStdoutToBinary(); // The thread that reads from stdin and dispatchs commands to the main thread. pipeline::LaunchStdin(); // The thread that writes responses from the main thread to stdout.