aboutsummaryrefslogtreecommitdiff
path: root/builtin/common
diff options
context:
space:
mode:
authorPierre-Yves Rollo <dev@pyrollo.com>2018-11-01 21:07:01 +0100
committerSmallJoker <SmallJoker@users.noreply.github.com>2018-11-01 21:07:01 +0100
commit0e306c084284aeafb3d5cde0cfec11a85a11cb9c (patch)
tree4f474057ed335f77747c23127819fb94d5e5c47f /builtin/common
parent4d4bfb12515cbd8f260f27951d5247676e0ba1b4 (diff)
downloadminetest-0e306c084284aeafb3d5cde0cfec11a85a11cb9c.tar.gz
minetest-0e306c084284aeafb3d5cde0cfec11a85a11cb9c.tar.bz2
minetest-0e306c084284aeafb3d5cde0cfec11a85a11cb9c.zip
Fix string.split returning an empty table if string starts with sepearator (#7827)
Calling string.split(":A:B:C:D", ":") returns an empty array. This is due to first empty string not making repeat loop decreasing max_split which has a 0 value when reaching until. Changing max_splits default value from -1 to -2 fixes that issue.
Diffstat (limited to 'builtin/common')
-rw-r--r--builtin/common/misc_helpers.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua
index d7f51f072..e250b0ed1 100644
--- a/builtin/common/misc_helpers.lua
+++ b/builtin/common/misc_helpers.lua
@@ -166,7 +166,7 @@ end
--------------------------------------------------------------------------------
function string.split(str, delim, include_empty, max_splits, sep_is_pattern)
delim = delim or ","
- max_splits = max_splits or -1
+ max_splits = max_splits or -2
local items = {}
local pos, len = 1, #str
local plain = not sep_is_pattern