mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-09 15:25:56 -04:00
fix string.gmatch for Lua 5.4
This commit is contained in:
parent
711a12bea2
commit
d0d83ed699
@ -3,6 +3,7 @@
|
||||
* [#3533] Added support for observing the contents of fluid container items.
|
||||
* [#3620] Fixed OC 1.8.0+ regression involving API arguments and numbers.
|
||||
* [#3013] Fixed rare server-side deadlock when sending disk activity update packets.
|
||||
* Fixed string.gmatch not supporting the "init" argument on Lua 5.4.
|
||||
* Update GNU Unifont to 15.0.04.
|
||||
|
||||
## OpenOS fixes/improvements
|
||||
|
@ -62,6 +62,9 @@ end
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
local isLuaOver54 = _VERSION:match("5.4")
|
||||
local isLuaOver53 = isLuaOver54 or _VERSION:match("5.3")
|
||||
|
||||
local function checkArg(n, have, ...)
|
||||
have = type(have)
|
||||
local function check(want, ...)
|
||||
@ -548,17 +551,27 @@ do
|
||||
return str_find_aux(s, pattern, init, false, false)
|
||||
end
|
||||
|
||||
local function str_gmatch(s, pattern)
|
||||
local function str_gmatch(s, pattern, init)
|
||||
checkArg(1, s, "string")
|
||||
checkArg(2, pattern, "string")
|
||||
|
||||
if #s < SHORT_STRING then
|
||||
return string_gmatch(s, pattern, repl, n)
|
||||
return string_gmatch(s, pattern, init)
|
||||
end
|
||||
|
||||
local start = 0
|
||||
if isLuaOver54 then
|
||||
checkArg(3, init, "number", "nil")
|
||||
if init ~= nil then
|
||||
start = posrelat(init, #s)
|
||||
if start < 1 then start = 0
|
||||
elseif start > #s + 1 then start = #s + 1
|
||||
else start = start - 1 end
|
||||
end
|
||||
end
|
||||
|
||||
local s = strptr(s)
|
||||
local p = strptr(pattern)
|
||||
local start = 0
|
||||
return function()
|
||||
ms = {
|
||||
src_init = s,
|
||||
|
Loading…
x
Reference in New Issue
Block a user