summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-05-26 23:30:44 +0800
committerruki <[email protected]>2021-05-26 23:30:44 +0800
commit9177f156bb1b70fb7adea5c10b6db22012048769 (patch)
treeeef35bde44f533987e18666886f8b47a7bca9684
parent7d1291b310e771c903922ebf4502372c7339c72e (diff)
remove more ifelse again
-rw-r--r--xmake/modules/core/tools/clang_cl.lua4
-rw-r--r--xmake/modules/core/tools/nvcc.lua2
-rw-r--r--xmake/modules/detect/tools/link/has_flags.lua2
-rw-r--r--xmake/modules/lib/detect/features.lua2
4 files changed, 5 insertions, 5 deletions
diff --git a/xmake/modules/core/tools/clang_cl.lua b/xmake/modules/core/tools/clang_cl.lua
index 22a28f20c..4e0046fe8 100644
--- a/xmake/modules/core/tools/clang_cl.lua
+++ b/xmake/modules/core/tools/clang_cl.lua
@@ -205,7 +205,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags)
-- get 16 lines of errors
if start > 0 then
- lines = table.slice(lines, start, start + ifelse(#lines - start > 16, 16, #lines - start))
+ lines = table.slice(lines, start, start + ((#lines - start > 16) and 16 or (#lines - start)))
end
end
@@ -220,7 +220,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags)
if ok and errdata and #errdata > 0 and (option.get("diagnosis") or option.get("warning")) then
local lines = errdata:split('\n', {plain = true})
if #lines > 0 then
- local warnings = table.concat(table.slice(lines, 1, ifelse(#lines > 8, 8, #lines)), "\n")
+ local warnings = table.concat(table.slice(lines, 1, (#lines > 8 and 8 or #lines)), "\n")
cprint("${color.warning}%s", warnings)
end
end
diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua
index f4df5c866..784b606c5 100644
--- a/xmake/modules/core/tools/nvcc.lua
+++ b/xmake/modules/core/tools/nvcc.lua
@@ -349,7 +349,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags)
-- get 16 lines of errors
if start > 0 or not option.get("verbose") then
if start == 0 then start = 1 end
- errors = table.concat(table.slice(lines, start, start + ifelse(#lines - start > 16, 16, #lines - start)), "\n")
+ errors = table.concat(table.slice(lines, start, start + ((#lines - start > 16) and 16 or (#lines - start))), "\n")
end
-- raise compiling errors
diff --git a/xmake/modules/detect/tools/link/has_flags.lua b/xmake/modules/detect/tools/link/has_flags.lua
index 819a84279..e0e2d8292 100644
--- a/xmake/modules/detect/tools/link/has_flags.lua
+++ b/xmake/modules/detect/tools/link/has_flags.lua
@@ -76,7 +76,7 @@ function _check_try_running(flags, opt)
-- make an stub source file
local flags_str = table.concat(flags, " "):lower()
local winmain = flags_str:find("subsystem:windows")
- local sourcefile = path.join(os.tmpdir(), "detect", ifelse(winmain, "winmain_", "") .. "link_has_flags.c")
+ local sourcefile = path.join(os.tmpdir(), "detect", (winmain and "winmain_" or "") .. "link_has_flags.c")
if not os.isfile(sourcefile) then
if winmain then
io.writefile(sourcefile, "int WinMain(void* instance, void* previnst, char** argv, int argc)\n{return 0;}")
diff --git a/xmake/modules/lib/detect/features.lua b/xmake/modules/lib/detect/features.lua
index 19b6067cc..614d8c592 100644
--- a/xmake/modules/lib/detect/features.lua
+++ b/xmake/modules/lib/detect/features.lua
@@ -72,7 +72,7 @@ function main(name, opt)
end
-- detect.tools.xxx.features(opt)?
- _g._checking = ifelse(coroutine_running, key, nil)
+ _g._checking = coroutine_running and key or nil
local features = import("detect.tools." .. tool.name .. ".features", {try = true})
if features then
result = features(opt)