From 06dba0daf4968b9632ebc00a9018c6af044422df Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 5 Jun 2019 22:51:26 +0800 Subject: add string.split test --- xmake/core/base/string.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'xmake/core/base/string.lua') 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 -- cgit v1.3.1