From 536b022887980d7914eaaf99f24ccae7e7fb2588 Mon Sep 17 00:00:00 2001 From: hisham Date: Thu, 30 Jul 2009 07:39:33 +0000 Subject: debugging git-svn-id: http://luarocks.org/svn/luarocks/trunk@44 9ca3f7c1-7366-0410-b1a3-b5c78f85698c --- src/luarocks/manif.lua | 14 ++++++-- src/luarocks/search.lua | 4 +-- src/luarocks/util.lua | 94 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index 818f4c57..03512584 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua @@ -76,7 +76,7 @@ local function update_global_lib(repo, manifest) end end else - print("DBG file already in place.") + -- print("File already in place.") end end end @@ -290,7 +290,7 @@ function update_manifest(name, version, repo) return save_manifest(repo, manifest) end ---- Scan a LuaRocks repository and output a manifest file. + --- Scan a LuaRocks repository and output a manifest file. -- A file called 'manifest' will be written in the root of the given -- repository directory. -- @param repo A local repository directory. @@ -309,8 +309,18 @@ function make_manifest(repo) local results = search.disk_search(repo, query) local manifest = { repository = {}, modules = {}, commands = {} } manif_core.manifest_cache[repo] = manifest + + print(util.show_table(results, "results")) + print(util.show_table(manifest, "manifest")) + store_results(results, manifest) + + print(util.show_table(manifest, "manifest after store")) + update_global_lib(repo, manifest) + + print(util.show_table(manifest, "manifest after update")) + return save_manifest(repo, manifest) end diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index e31c0c1b..0ba9ff43 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua @@ -37,7 +37,7 @@ local function query_arch_as_table(query) query.arch = accept elseif format == "string" then local accept = {} - for a in string.gmatch(query.arch, "[%w_]+") do + for a in string.gmatch(query.arch, "[%w_-]+") do accept[a] = true end query.arch = accept @@ -218,7 +218,7 @@ function make_query(name, version) constraints = {} } if version then - table.insert(query.constraints, { op = "~>", version = deps.parse_version(version)}) + table.insert(query.constraints, { op = "==", version = deps.parse_version(version)}) end return query end diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 6e9c3547..f48bfe1f 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua @@ -233,3 +233,97 @@ end function sortedpairs(tbl, sort_function) return coroutine.wrap(function() sortedpairs_iterator(tbl, sort_function) end) end + +--[[ +Author: Julio Manuel Fernandez-Diaz +Date: January 12, 2007 +(For Lua 5.1) + +Formats tables with cycles recursively to any depth. +The output is returned as a string. +References to other tables are shown as values. +Self references are indicated. + +The string returned is "Lua code", which can be procesed +(in the case in which indent is composed by spaces or "--"). +Userdata and function keys and values are shown as strings, +which logically are exactly not equivalent to the original code. + +This routine can serve for pretty formating tables with +proper indentations, apart from printing them: + +print(table.show(t, "t")) -- a typical use + +Heavily based on "Saving tables with cycles", PIL2, p. 113. + +Arguments: +t is the table. +name is the name of the table (optional) +indent is a first indentation (optional). +--]] +function show_table(t, name, indent) + local cart -- a container + local autoref -- for self references + + local function isemptytable(t) return next(t) == nil end + + local function basicSerialize (o) + local so = tostring(o) + if type(o) == "function" then + local info = debug.getinfo(o, "S") + -- info.name is nil because o is not a calling level + if info.what == "C" then + return string.format("%q", so .. ", C function") + else + -- the information is defined through lines + return string.format("%q", so .. ", defined in (" .. info.linedefined .. "-" .. info.lastlinedefined .. ")" .. info.source) + end + elseif type(o) == "number" then + return so + else + return string.format("%q", so) + end + end + + local function addtocart (value, name, indent, saved, field) + indent = indent or "" + saved = saved or {} + field = field or name + + cart = cart .. indent .. field + + if type(value) ~= "table" then + cart = cart .. " = " .. basicSerialize(value) .. ";\n" + else + if saved[value] then + cart = cart .. " = {}; -- " .. saved[value] .. " (self reference)\n" + autoref = autoref .. name .. " = " .. saved[value] .. ";\n" + else + saved[value] = name + --if tablecount(value) == 0 then + if isemptytable(value) then + cart = cart .. " = {};\n" + else + cart = cart .. " = {\n" + for k, v in pairs(value) do + k = basicSerialize(k) + local fname = string.format("%s[%s]", name, k) + field = string.format("[%s]", k) + -- three spaces between levels + addtocart(v, fname, indent .. " ", saved, field) + end + cart = cart .. indent .. "};\n" + end + end + end + end + + name = name or "__unnamed__" + if type(t) ~= "table" then + return name .. " = " .. basicSerialize(t) + end + cart, autoref = "", "" + addtocart(t, name, indent) + return cart .. autoref +end + -- cgit v1.2.3-55-g6feb