Deprecate wml_utils.trim in favour of stringx.trim and update all use cases
This commit is contained in:
parent
462538bf36
commit
4eb043bb16
3 changed files with 4 additions and 7 deletions
|
@ -25,7 +25,7 @@ function wml_actions.sync_variable(cfg)
|
|||
function()
|
||||
local res = {}
|
||||
for name_raw in utils.split(names) do
|
||||
local name = utils.trim(name_raw)
|
||||
local name = name_raw:trim()
|
||||
local variable_type = string.sub(name, string.len(name)) == "]" and "indexed" or ( wml.variables[name .. ".length"] > 0 and "array" or "attribute")
|
||||
local variable_info = { name = name, type = variable_type }
|
||||
table.insert(res, { "variable", variable_info })
|
||||
|
@ -110,7 +110,7 @@ function wml_actions.clear_variable(cfg, variables)
|
|||
wml.error "[clear_variable] missing required name= attribute."
|
||||
if variables == nil then variables = wml.variables end
|
||||
for w in utils.split(names) do
|
||||
variables[utils.trim(w)] = nil
|
||||
variables[w:trim()] = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
|
||||
local utils = {vwriter = {}}
|
||||
|
||||
function utils.trim(s)
|
||||
-- use (f(a)) to get first argument
|
||||
return (tostring(s):gsub("^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
utils.trim = wesnoth.deprecate_api('wml_utils.trim', 'stringx.trim', 1, nil, stringx.trim)
|
||||
|
||||
function utils.split(s)
|
||||
return tostring(s or ""):gmatch("[^%s,][^,]*")
|
||||
|
|
|
@ -14,7 +14,7 @@ function wesnoth.wml_actions.role(cfg)
|
|||
|
||||
if cfg.type then
|
||||
for value in utils.split(cfg.type) do
|
||||
table.insert(types, utils.trim(value))
|
||||
table.insert(types, value:trim())
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue