Skip to content

Commit 6c54895

Browse files
committed
修改声明
1 parent adbd915 commit 6c54895

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

CodeFormat/src/CodeFormat.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
#include "CodeService/LuaFormatter.h"
77
#include "Util/CommandLine.h"
88

9+
// https://stackoverflow.com/questions/1598985/c-read-binary-stdin
10+
#ifdef _WIN32
11+
# include <io.h>
12+
# include <fcntl.h>
13+
# define SET_BINARY_MODE() _setmode(_fileno(stdin), _O_BINARY);\
14+
_setmode(_fileno(stdout), _O_BINARY)
15+
#else
16+
# define SET_BINARY_MODE() ((void)0)
17+
#endif
18+
19+
920
int main(int argc, char** argv)
1021
{
1122
CommandLine cmd;
@@ -32,6 +43,7 @@ int main(int argc, char** argv)
3243
}
3344
else if (cmd.Get<int>("stdin") != 0)
3445
{
46+
SET_BINARY_MODE();
3547
std::size_t size = cmd.Get<int>("stdin");
3648

3749
std::string buffer;
@@ -42,15 +54,15 @@ int main(int argc, char** argv)
4254
parser = LuaParser::LoadFromBuffer(std::move(buffer));
4355
}
4456

45-
LuaCodeStyleOptions options;
57+
std::shared_ptr<LuaCodeStyleOptions> options;
4658
if (!cmd.Get<std::string>("config").empty())
4759
{
4860
options = LuaCodeStyleOptions::ParseFromEditorConfig(cmd.Get<std::string>("config"));
4961
}
5062

5163
parser->BuildAstWithComment();
5264

53-
LuaFormatter formatter(parser, options);
65+
LuaFormatter formatter(parser, *options);
5466
formatter.BuildFormattedElement();
5567

5668
if (cmd.GetTarget() == "format")

CodeFormatServer/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ target_sources(CodeFormatServer
4343

4444
target_link_libraries(CodeFormatServer PUBLIC CodeService)
4545

46-
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
46+
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
47+
target_compile_definitions(CodeFormatServer PUBLIC -D_WIN32_WINNT=0x0601)
48+
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
4749
target_link_libraries(CodeFormatServer PUBLIC pthread)
4850
endif()
4951

0 commit comments

Comments
 (0)