Skip to content

Commit cad0a7d

Browse files
committed
处理警告,添加打印
1 parent 5a4ca13 commit cad0a7d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

CodeFormatLib/src/CodeFormatLib.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ int range_format(lua_State *L) {
112112
auto startLine = lua_tointeger(L, 3);
113113
auto endLine = lua_tointeger(L, 4);
114114

115-
if(startLine < 0 || endLine < 0){
115+
if (startLine < 0 || endLine < 0) {
116116
lua_pushboolean(L, false);
117117
lua_pushstring(L, "start line or end line < 0");
118118
return 2;
@@ -170,8 +170,14 @@ int type_format(lua_State *L) {
170170
try {
171171
std::string filename = lua_tostring(L, 1);
172172
std::string text = lua_tostring(L, 2);
173-
int line = lua_tointeger(L, 3);
174-
int character = lua_tointeger(L, 4);
173+
auto line = lua_tointeger(L, 3);
174+
auto character = lua_tointeger(L, 4);
175+
176+
if(line < 0 || character < 0){
177+
lua_pushboolean(L, false);
178+
lua_pushstring(L, "line or character param error");
179+
return 2;
180+
}
175181

176182
LuaCodeFormat::ConfigMap configMap;
177183

@@ -204,7 +210,8 @@ int type_format(lua_State *L) {
204210
}
205211
}
206212
auto typeFormatResult = LuaCodeFormat::GetInstance()
207-
.TypeFormat(filename, line, character,
213+
.TypeFormat(filename,
214+
static_cast<std::size_t>(line), static_cast<std::size_t>(character),
208215
std::move(text), configMap, stringTypeOptions);
209216

210217
if (typeFormatResult.empty()) {

Test/src/TestHelper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ void TestHelper::CollectLuaFile(std::filesystem::path directoryPath, std::vector
6262
std::string TestHelper::ReadFile(const std::string &path) {
6363
std::filesystem::path base(ScriptBase);
6464
std::string newPath = (base / path).string();
65+
std::cerr<<"read file from "<< newPath <<std::endl;
6566
#ifdef _WIN32
6667
std::fstream fin(newPath, std::ios::in | std::ios::binary);
6768
#else

0 commit comments

Comments
 (0)