Hi list,
I started using Lua 5.3 for some things and I noticed that the
function "splitlines" in my LUA_INIT file doesn't work in 5.3. Here
its definition (warning: I wrote these functions 15+ years ago!
Ugly!):
split = function (str, pat)
local arr = {}
string.gsub(str, pat or "([^%s]+)", function (word)
table.insert(arr, word)
end)
return arr
end
splitlines = function (bigstr)
local arr = split(bigstr, "([^\n]*)\n?")
table.remove(arr)
return arr
end
It seems that the behavior of string.gsub changed from 5.2 to 5.3. In
5.1 and 5.2 the
arr = split(bigstr, "([^\n]*)\n?")
would always generate an sequence with an empty string at its end, and
table.remove would delete it.
I remember ___veeeery___ vaguely a discussion here in the list about a
change in string.gsub that made it stop substituting the empty sting
at the end, but I'm not being able to find it now... anyone has a
pointer to it? I don't know how to fix my code in an elegant way to
make it work in 5.2 and 5.3 and I would like to take a look at the
discussion...
Thanks in advance,
Eduardo Ochs
http://angg.twu.net/dednat6.html