Hemiptera Bugtracker at bugs.linux-forks.de

advtrains

[BUG] bad string.split() function implementation in wagons.lua

Send replies to 160@bugs.linux-forks.de or using the Form below.
avatar From: OP
Sat, 05 Sep 2020 19:14:01 -0000

The string.split() function in wagons.lua line 851 gives wrong results for

non-single-character separators.

Note that this is overriding the minetest builtin split function (see

https://github.com/minetest/minetest/blob/master/builtin/common/misc_helpers.lua#L171)

and thus also affects other mods.

To reproduce: run the following test code. Expected result would be:

1: Demo string, break me on

2: occurrences.

Obtained result is:

1: Demo

2: ing, b

3: eak me on

4: occu

5: ence

6: .

function string:split(sep)

local fields = {}

local pattern = string.format("([^%s]+)", sep)

self:gsub(pattern, function(c) fields[#fields+1] = c end)

return fields

end

local demo = "Demo string, break me on trs occurrences."

local result = demo:split("trs")

for i,v in ipairs(result) do

print(tostring(i) .. ": " .. v)

end

avatar From: Developer
Sat, 05 Sep 2020 19:58:01 -0000

This was fixed by commit 606fc83465d8742550e9f70a13b51bbb9cd6f45e

avatar From: OP
Sat, 05 Sep 2020 20:29:01 -0000

Great, thanks. Wasn't published in the repo yet, that's why i posted the

issue here too...

Il giorno sab 5 set 2020 alle ore 22:00 <160@bugs.linux-forks.de> ha

scritto:

>

> This was fixed by commit 606fc83465d8742550e9f70a13b51bbb9cd6f45e

>

avatar From: Someone else
Mon, 03 Jul 2023 07:39:01 -0000

avatar Status Update
Sat, 05 Sep 2020 20:55:01 -0000
This bug was closed.
Reply