no call func in ref while search

This commit is contained in:
p.kosyh 2010-07-27 07:17:11 +00:00
parent 0a11826b83
commit ff3de03557
2 changed files with 6 additions and 6 deletions

View file

@ -486,18 +486,18 @@ function obj(v)
end end
function ref(n) -- ref object by name function ref(n, nofunc) -- ref object by name
if type(n) == 'string' then if type(n) == 'string' then
local f = loadstring('return '..n); local f = loadstring('return '..n);
if f then if f then
return ref(f()); return ref(f(), nofunc);
end end
return nil; return nil;
end end
if type(n) == 'table' then if type(n) == 'table' then
return n; return n;
end end
if type(n) == 'function' then if type(n) == 'function' and not nofunc then
local r,v = pcall(n); local r,v = pcall(n);
if not r then if not r then
return nil return nil
@ -578,7 +578,7 @@ end
function list_find(self, name) function list_find(self, name)
local n, v, ii local n, v, ii
for n,v,ii in opairs(self) do for n,v,ii in opairs(self) do
if ref(v) == ref(name) then if ref(v) == ref(name, true) then -- do not call func while search
return ii; return ii;
end end
end end

View file

@ -61,7 +61,7 @@ __do_xact = function(str, self)
else else
oo = objs():srch(o) oo = objs():srch(o)
if not oo then if not oo then
oo = ref(o) oo = ref(o, true)
end end
end end
elseif isObject(self) then elseif isObject(self) then
@ -71,7 +71,7 @@ __do_xact = function(str, self)
error("Wrong link: "..s, 3); error("Wrong link: "..s, 3);
end end
d = d:gsub("<&colon;>", ":"); d = d:gsub("<&colon;>", ":");
return xref(d, ref(oo), unpack(aarg)); return xref(d, ref(oo, true), unpack(aarg));
end end
if type(str) ~= 'string' then return end if type(str) ~= 'string' then return end
local s = stead.string.gsub(str,'{[^}]+}', xrefrep); local s = stead.string.gsub(str,'{[^}]+}', xrefrep);