From 0e8a7bfb12e6d03ec288cd1fdd0a1453d5e814e1 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 16 Jun 2011 21:05:44 +0200 Subject: Fix bug in LResources: they were unable to handle resources with numbers in names --- src/FbTk/LResourceHelper.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/FbTk/LResourceHelper.lua b/src/FbTk/LResourceHelper.lua index b16e756..e2899f8 100644 --- a/src/FbTk/LResourceHelper.lua +++ b/src/FbTk/LResourceHelper.lua @@ -54,7 +54,7 @@ local function index(table, key) end; local function append_name(str, name) - if type(name) == 'string' and string.match(name, '^%a+$') then + if type(name) == 'string' and string.match(name, '^%a%w*$') then return str .. '.' .. name; elseif type(name) == 'number' then return str .. '[' .. string.format('%g', name) .. ']'; @@ -77,14 +77,14 @@ local function register_resource(root, name, object) local meta = getmetatable(root); meta._state = 1; - local head, tail = string.match(name, '^(%a+)%.?(.*)'); + local head, tail = string.match(name, '^(%a%w*)%.?(.*)'); local t = meta[head]; local mt = getmetatable(t); - if mt ~= nil and mt._magic == cat_magic then - t = mt; - end; if tail == '' then + if mt ~= nil and mt._magic == cat_magic then + t = mt; + end; if getmetatable(object) == res_magic then meta[head] = object; write_resource(object, t); @@ -95,7 +95,7 @@ local function register_resource(root, name, object) return t; end; - if t == nil then + if mt == nil or mt._magic ~= cat_magic then t = new_cat(root, head); end; return register_resource(t, tail, object); -- cgit v0.11.2