diff options
author | Lauri Aarnio <Lauri.Aarnio@iki.fi> | 2009-02-01 16:37:22 +0200 |
---|---|---|
committer | Lauri Leukkunen <lle@rahina.org> | 2009-02-10 08:38:10 +0200 |
commit | 36506e8e28b3c3bc133dce438e0571e911c044be (patch) | |
tree | 4d65376657b118ea6cc22ef20dd8740c3e182b75 /lua_scripts | |
parent | f09d696f66df2053083a98a1d8442b475f256dbb (diff) |
Path mapping logic: subtrees in rulesets may return without a result
- Previously, a subtree in a ruleset was required to perform a mapping.
- This commit changes the algorithm so that if a match is not found from
the subtree, searching continues in the calling ruleset; i.e. the subtrees
are now called like subroutines are called in programs, not jumped into.
Diffstat (limited to 'lua_scripts')
-rw-r--r-- | lua_scripts/mapping.lua | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/lua_scripts/mapping.lua b/lua_scripts/mapping.lua index 629bbaf..b97e57a 100644 --- a/lua_scripts/mapping.lua +++ b/lua_scripts/mapping.lua @@ -427,26 +427,38 @@ function find_rule(chain, func, full_path) rule.dir, rule.prefix, rule.path) if min_path_len >= 0 then if (rule.chain) then - return find_rule(rule.chain, - func, full_path) - end - - -- Path matches, test if other conditions are - -- also OK: - if ((not rule.func_name - or string.match(func, - rule.func_name))) then + -- if rule can be found from + -- a subtree, return it, + -- otherwise continue looping here. + local s_rule + local s_min_len + s_rule, s_min_len = find_rule( + rule.chain, func, full_path) + if (s_rule ~= nil) then + return s_rule, s_min_len + end if (debug_messages_enabled) then - local rulename = rule.name - if rulename == nil then - rulename = string.format("#%d",i) + sb.log("noise", + "rule not found from subtree") + end + else + -- Path matches, test if other conditions are + -- also OK: + if ((not rule.func_name + or string.match(func, + rule.func_name))) then + if (debug_messages_enabled) then + local rulename = rule.name + if rulename == nil then + rulename = string.format("#%d",i) + end + + sb.log("noise", string.format( + "selected rule '%s'", + rulename)) end - - sb.log("noise", string.format( - "selected rule '%s'", - rulename)) + return rule, min_path_len end - return rule, min_path_len end end end |