diff options
author | Steven Barth <steven@midlink.org> | 2008-08-28 17:10:35 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-08-28 17:10:35 +0000 |
commit | 8b28f46eeab80c7a5ec6f454780a338302eaa0da (patch) | |
tree | da81fdaca4fd014d2d4c3ff6b55cee6d9975684a /libs | |
parent | af2cce3839386dd545fb4d9d80809716972560b9 (diff) |
Added maxdepth to luci.util.dumptable
Diffstat (limited to 'libs')
-rw-r--r-- | libs/core/luasrc/util.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua index 39784f592..233bfcc33 100644 --- a/libs/core/luasrc/util.lua +++ b/libs/core/luasrc/util.lua @@ -183,18 +183,18 @@ end --- Recursively dumps a table to stdout, useful for testing and debugging. -- @param t Table value to dump --- @param i Number of tabs to prepend to each line +-- @param maxdepth Maximum depth -- @return Always nil -function dumptable(t, i, seen) +function dumptable(t, maxdepth, i, seen) i = i or 0 seen = seen or setmetatable({}, {__mode="k"}) for k,v in pairs(t) do perror(string.rep("\t", i) .. tostring(k) .. "\t" .. tostring(v)) - if type(v) == "table" then + if type(v) == "table" and i < maxdepth then if not seen[v] then seen[v] = true - dumptable(v, i+1, seen) + dumptable(v, maxdepth, i+1, seen) else perror(string.rep("\t", i) .. "*** RECURSION ***") end |