diff options
| author | Opportunity <[email protected]> | 2020-01-20 20:26:08 +0800 |
|---|---|---|
| committer | Opportunity <[email protected]> | 2020-01-20 22:21:47 +0800 |
| commit | 929d2d1e48456e45118754ded06dd0dd420415f1 (patch) | |
| tree | 52599db7bfe57b76e02802253d88cd7177b88985 /xmake/core/base/string.lua | |
| parent | ab317d02fb8442204813b5b66457406498e48c1c (diff) | |
fix string.split
Diffstat (limited to 'xmake/core/base/string.lua')
| -rw-r--r-- | xmake/core/base/string.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/xmake/core/base/string.lua b/xmake/core/base/string.lua index e1b96fb75..8cdca335f 100644 --- a/xmake/core/base/string.lua +++ b/xmake/core/base/string.lua @@ -74,7 +74,7 @@ end function string:split(delimiter, opt) local result = {} local start = 1 - local pos, epos = self:find(delimiter, start, opt and opt.plain) + local pos, epos = self:find(delimiter, start, opt and opt.plain) while pos do local substr = self:sub(start, pos - 1) if (#substr > 0) or (opt and opt.strict) then @@ -88,6 +88,10 @@ function string:split(delimiter, opt) end if start <= #self then table.insert(result, self:sub(start)) + elseif opt and opt.strict and (not opt.limit or #result < opt.limit) then + if start == #self + 1 then + table.insert(result, "") + end end return result end |
