summaryrefslogtreecommitdiff
path: root/xmake/core/base/string.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2019-06-05 22:51:26 +0800
committerruki <[email protected]>2019-06-05 11:08:41 +0800
commit06dba0daf4968b9632ebc00a9018c6af044422df (patch)
tree511cb7366de4cfb613e327998f6520a80dffa638 /xmake/core/base/string.lua
parentab59ae06a2b2560912446d20fe4eef1e49e3ed55 (diff)
add string.split test
Diffstat (limited to 'xmake/core/base/string.lua')
-rw-r--r--xmake/core/base/string.lua10
1 files changed, 4 insertions, 6 deletions
diff --git a/xmake/core/base/string.lua b/xmake/core/base/string.lua
index d031a228f..13ca6c1fb 100644
--- a/xmake/core/base/string.lua
+++ b/xmake/core/base/string.lua
@@ -172,13 +172,11 @@ function string:split(delimiter, opt)
local start = 1
local pos, epos = self:find(delimiter, start, opt and opt.plain)
while pos do
- if opt and opt.limit and opt.limit > 0 and #result + 1 >= opt.limit then
- break
- end
local substr = self:sub(start, pos - 1)
- if #substr > 0 then
- table.insert(result, substr)
- elseif opt and opt.strict then
+ if (#substr > 0) or (opt and opt.strict) then
+ if opt and opt.limit and opt.limit > 0 and #result + 1 >= opt.limit then
+ break
+ end
table.insert(result, substr)
end
start = epos + 1