mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-12-23 03:55:01 +00:00
Integrate split_shell into worldeditadditions
...it's not used anywhere yet though
This commit is contained in:
parent
b708fec2db
commit
bd1da727a4
2 changed files with 26 additions and 28 deletions
|
@ -1,3 +1,6 @@
|
|||
dofile(worldeditadditions.modpath.."/utils/strings/split.lua")
|
||||
dofile(worldeditadditions.modpath.."/utils/strings/polyfill.lua")
|
||||
dofile(worldeditadditions.modpath.."/utils/strings/tochars.lua")
|
||||
local wea = worldeditadditions
|
||||
|
||||
dofile(wea.modpath.."/utils/strings/split.lua")
|
||||
dofile(wea.modpath.."/utils/strings/polyfill.lua")
|
||||
dofile(wea.modpath.."/utils/strings/tochars.lua")
|
||||
wea.split_shell = dofile(wea.modpath.."/utils/strings/split_shell.lua")
|
||||
|
|
|
@ -1,17 +1,10 @@
|
|||
function is_whitespace(char)
|
||||
return char == " " or char == "\t" or char == "\r" or char == "\n"
|
||||
local table_map = dofile(worldeditadditions.modpath.."/utils/tables/table_map.lua")
|
||||
|
||||
local function is_whitespace(char)
|
||||
return char:match("%s")
|
||||
end
|
||||
|
||||
local function table_map(tbl, func)
|
||||
local result = {}
|
||||
for i,value in ipairs(tbl) do
|
||||
local newval = func(value, i)
|
||||
if newval ~= nil then table.insert(result, newval) end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
function split_shell(text)
|
||||
local function split_shell(text)
|
||||
local text_length = #text
|
||||
local scan_pos = 1
|
||||
local result = { }
|
||||
|
@ -76,17 +69,19 @@ function split_shell(text)
|
|||
end)
|
||||
end
|
||||
|
||||
function test(text)
|
||||
print("Source", text)
|
||||
for i,value in ipairs(split_shell(text)) do
|
||||
print("i", i, "→", value)
|
||||
end
|
||||
print("************")
|
||||
end
|
||||
return split_shell
|
||||
|
||||
test("yay yay yay")
|
||||
test("yay \"yay yay\" yay")
|
||||
test("yay \"yay\\\" yay\" yay")
|
||||
test("yay \"yay 'inside quotes' yay\\\"\" yay")
|
||||
test("yay 'inside quotes' another")
|
||||
test("y\"ay \"yay 'in\\\"side quotes' yay\" y\\\"ay")
|
||||
-- function test(text)
|
||||
-- print("Source", text)
|
||||
-- for i,value in ipairs(split_shell(text)) do
|
||||
-- print("i", i, "→", value)
|
||||
-- end
|
||||
-- print("************")
|
||||
-- end
|
||||
--
|
||||
-- test("yay yay yay")
|
||||
-- test("yay \"yay yay\" yay")
|
||||
-- test("yay \"yay\\\" yay\" yay")
|
||||
-- test("yay \"yay 'inside quotes' yay\\\"\" yay")
|
||||
-- test("yay 'inside quotes' another")
|
||||
-- test("y\"ay \"yay 'in\\\"side quotes' yay\" y\\\"ay")
|
||||
|
|
Loading…
Reference in a new issue