summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/sqdb-build.lua22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/sqdb-build.lua b/src/sqdb-build.lua
index 2806bb2..2e9af22 100755
--- a/src/sqdb-build.lua
+++ b/src/sqdb-build.lua
@@ -76,7 +76,7 @@ local function get_domain(domain, locked)
end
entry = child
end
- return child
+ return entry
end
local function get_path(domain_entry, path, locked)
@@ -217,21 +217,22 @@ local function enum_all(cb)
end
end
-local function prune_paths(paths, category)
- local path, pdata, cat
+local function prune_paths(paths, category, locked)
+ local path, pdata, cat, lock
local num_paths = 0
for path, pdata in pairs(paths) do
local sub_paths = 0
cat = pdata.category or category
+ lock = pdata.locked or locked
if pdata.paths ~= nil then
- sub_paths = prune_paths(pdata.paths, cat)
+ sub_paths = prune_paths(pdata.paths, cat, lock)
if sub_paths == 0 then
pdata.paths = nil
end
end
- if cat == category and sub_paths == 0 then
+ if cat == category and lock == locked and sub_paths == 0 then
paths[path] = nil
else
num_paths = num_paths + 1
@@ -241,15 +242,16 @@ local function prune_paths(paths, category)
return num_paths
end
-local function prune_tree(d, pcategory)
+local function prune_tree(d, pcategory, plocked)
local num_childs = 0
local num_paths = 0
- local cat
+ local cat, locked
cat = d.category or pcategory
+ locked = d.locked or plocked
if d.children ~= nil then
for n, child in pairs(d.children) do
- if prune_tree(child, cat, n) then
+ if prune_tree(child, cat, locked) then
d.children[n] = nil
else
num_childs = num_childs + 1
@@ -262,12 +264,12 @@ local function prune_tree(d, pcategory)
end
--print(name, d.category, category, d.num_paths, num_childs)
if d.paths ~= nil then
- num_paths = prune_paths(d.paths, cat)
+ num_paths = prune_paths(d.paths, cat, locked)
if num_paths == 0 then
d.paths = nil
end
end
- if d.category == pcategory and num_paths == 0 and num_childs == 0 then
+ if d.category == pcategory and d.locked == plocked and num_paths == 0 and num_childs == 0 then
--num_pruned_leafs = num_pruned_leafs + 1
return true
end