Lua API: Allow WML tags with leading underscore (#3877)

@gfgtdf said that it's more consistent to allow them across the board,
which IMHO is a strong enough argument for the API change in master.
This commit is contained in:
Jyrki Vesterinen 2019-01-19 15:02:10 +02:00
parent 7d2e9383a3
commit 81d0d2214a
3 changed files with 10 additions and 3 deletions

View file

@ -50,6 +50,7 @@
* wml.tostring() now outputs a string that can be parsed back to WML without loss of data.
* Add wml.clone() function that performs a deep copy of a config or vconfig.
* Organize API functions into several new (sub)modules: gui, wesnoth.units, wesnoth.interface
* Allow WML tag names injected with wml.tag to start with underscores.
### User Interface
* Don't show in the sidebar the time of day schedule of a shrouded hex. (issue #3638)
### Packaging

View file

@ -56,12 +56,18 @@
wml.tostring(table)
end))
-- Tag names can't start with underscores.
assert_equal(false, pcall(function()
-- Tag names can start with underscores.
assert_equal(true, pcall(function()
local table = {T._reserved {}}
wml.tostring(table)
end))
-- An underscore by itself isn't allowed.
assert_equal(false, pcall(function()
local table = {T._ {}}
wml.tostring(table)
end))
-- Commit 13a4822d made the WML parser accept dollar signs in tag names.
-- However, they are supposed to be rejected, and this test enforces
-- that at least the Lua API rejects them.

View file

@ -757,7 +757,7 @@ bool luaW_toconfig(lua_State *L, int index, config &cfg)
if (!lua_istable(L, -1)) return_misformed();
lua_rawgeti(L, -1, 1);
char const *m = lua_tostring(L, -1);
if (!m || !config::valid_tag(m) || m[0] == '_') return_misformed();
if (!m || !config::valid_tag(m)) return_misformed();
lua_rawgeti(L, -2, 2);
if (!luaW_toconfig(L, -1, cfg.add_child(m)))
return_misformed();