mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-25 04:48:22 -08:00
Add check if coroutine lib is accessible
This commit is contained in:
@@ -60,8 +60,12 @@ end
|
|||||||
|
|
||||||
-- like string.sub() but i, j are utf8 strings
|
-- like string.sub() but i, j are utf8 strings
|
||||||
-- a utf8-safe string.sub()
|
-- a utf8-safe string.sub()
|
||||||
function unicode_helpers.sub(string, i, j)
|
function unicode_helpers.sub(str, i, j)
|
||||||
local l = utf8.len(string);
|
if coroutine == nil then
|
||||||
|
return str;
|
||||||
|
end
|
||||||
|
|
||||||
|
local l = utf8.len(str);
|
||||||
|
|
||||||
i = unicode_helpers.relative_position(i, l);
|
i = unicode_helpers.relative_position(i, l);
|
||||||
j = j and unicode_helpers.relative_position(j, l) or l;
|
j = j and unicode_helpers.relative_position(j, l) or l;
|
||||||
@@ -79,7 +83,7 @@ function unicode_helpers.sub(string, i, j)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local diff = j - i;
|
local diff = j - i;
|
||||||
local iterator = unicode_helpers.chars(string, true);
|
local iterator = unicode_helpers.chars(str, true);
|
||||||
|
|
||||||
-- advance up to i
|
-- advance up to i
|
||||||
for _ = 1, i - 1 do
|
for _ = 1, i - 1 do
|
||||||
@@ -90,7 +94,7 @@ function unicode_helpers.sub(string, i, j)
|
|||||||
|
|
||||||
-- i and j are the same, single-charaacter sub
|
-- i and j are the same, single-charaacter sub
|
||||||
if diff == 0 then
|
if diff == 0 then
|
||||||
return string.sub(string, b, b + c - 1);
|
return string.sub(str, b, b + c - 1);
|
||||||
end
|
end
|
||||||
|
|
||||||
i = b;
|
i = b;
|
||||||
@@ -102,7 +106,7 @@ function unicode_helpers.sub(string, i, j)
|
|||||||
|
|
||||||
c, b = select(2, iterator());
|
c, b = select(2, iterator());
|
||||||
|
|
||||||
return string.sub(string, i, b + c - 1);
|
return string.sub(str, i, b + c - 1);
|
||||||
end
|
end
|
||||||
|
|
||||||
function unicode_helpers.init_module()
|
function unicode_helpers.init_module()
|
||||||
|
|||||||
Reference in New Issue
Block a user