aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c>2009-07-30 07:39:33 +0000
committerhisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c>2009-07-30 07:39:33 +0000
commit536b022887980d7914eaaf99f24ccae7e7fb2588 (patch)
tree720fc4fed789c4232465a9f1669a27f58c2914da /src
parentaa229e9942897b26eda8b492e4314ee5a2f23f1c (diff)
downloadluarocks-536b022887980d7914eaaf99f24ccae7e7fb2588.tar.gz
luarocks-536b022887980d7914eaaf99f24ccae7e7fb2588.tar.bz2
luarocks-536b022887980d7914eaaf99f24ccae7e7fb2588.zip
debugging
git-svn-id: http://luarocks.org/svn/luarocks/trunk@44 9ca3f7c1-7366-0410-b1a3-b5c78f85698c
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/manif.lua14
-rw-r--r--src/luarocks/search.lua4
-rw-r--r--src/luarocks/util.lua94
3 files changed, 108 insertions, 4 deletions
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)
76 end 76 end
77 end 77 end
78 else 78 else
79 print("DBG file already in place.") 79 -- print("File already in place.")
80 end 80 end
81 end 81 end
82 end 82 end
@@ -290,7 +290,7 @@ function update_manifest(name, version, repo)
290 return save_manifest(repo, manifest) 290 return save_manifest(repo, manifest)
291end 291end
292 292
293--- Scan a LuaRocks repository and output a manifest file. 293 --- Scan a LuaRocks repository and output a manifest file.
294-- A file called 'manifest' will be written in the root of the given 294-- A file called 'manifest' will be written in the root of the given
295-- repository directory. 295-- repository directory.
296-- @param repo A local repository directory. 296-- @param repo A local repository directory.
@@ -309,8 +309,18 @@ function make_manifest(repo)
309 local results = search.disk_search(repo, query) 309 local results = search.disk_search(repo, query)
310 local manifest = { repository = {}, modules = {}, commands = {} } 310 local manifest = { repository = {}, modules = {}, commands = {} }
311 manif_core.manifest_cache[repo] = manifest 311 manif_core.manifest_cache[repo] = manifest
312
313 print(util.show_table(results, "results"))
314 print(util.show_table(manifest, "manifest"))
315
312 store_results(results, manifest) 316 store_results(results, manifest)
317
318 print(util.show_table(manifest, "manifest after store"))
319
313 update_global_lib(repo, manifest) 320 update_global_lib(repo, manifest)
321
322 print(util.show_table(manifest, "manifest after update"))
323
314 return save_manifest(repo, manifest) 324 return save_manifest(repo, manifest)
315end 325end
316 326
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)
37 query.arch = accept 37 query.arch = accept
38 elseif format == "string" then 38 elseif format == "string" then
39 local accept = {} 39 local accept = {}
40 for a in string.gmatch(query.arch, "[%w_]+") do 40 for a in string.gmatch(query.arch, "[%w_-]+") do
41 accept[a] = true 41 accept[a] = true
42 end 42 end
43 query.arch = accept 43 query.arch = accept
@@ -218,7 +218,7 @@ function make_query(name, version)
218 constraints = {} 218 constraints = {}
219 } 219 }
220 if version then 220 if version then
221 table.insert(query.constraints, { op = "~>", version = deps.parse_version(version)}) 221 table.insert(query.constraints, { op = "==", version = deps.parse_version(version)})
222 end 222 end
223 return query 223 return query
224end 224end
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
233function sortedpairs(tbl, sort_function) 233function sortedpairs(tbl, sort_function)
234 return coroutine.wrap(function() sortedpairs_iterator(tbl, sort_function) end) 234 return coroutine.wrap(function() sortedpairs_iterator(tbl, sort_function) end)
235end 235end
236
237--[[
238Author: Julio Manuel Fernandez-Diaz
239Date: January 12, 2007
240(For Lua 5.1)
241
242Formats tables with cycles recursively to any depth.
243The output is returned as a string.
244References to other tables are shown as values.
245Self references are indicated.
246
247The string returned is "Lua code", which can be procesed
248(in the case in which indent is composed by spaces or "--").
249Userdata and function keys and values are shown as strings,
250which logically are exactly not equivalent to the original code.
251
252This routine can serve for pretty formating tables with
253proper indentations, apart from printing them:
254
255print(table.show(t, "t")) -- a typical use
256
257Heavily based on "Saving tables with cycles", PIL2, p. 113.
258
259Arguments:
260t is the table.
261name is the name of the table (optional)
262indent is a first indentation (optional).
263--]]
264function show_table(t, name, indent)
265 local cart -- a container
266 local autoref -- for self references
267
268 local function isemptytable(t) return next(t) == nil end
269
270 local function basicSerialize (o)
271 local so = tostring(o)
272 if type(o) == "function" then
273 local info = debug.getinfo(o, "S")
274 -- info.name is nil because o is not a calling level
275 if info.what == "C" then
276 return string.format("%q", so .. ", C function")
277 else
278 -- the information is defined through lines
279 return string.format("%q", so .. ", defined in (" .. info.linedefined .. "-" .. info.lastlinedefined .. ")" .. info.source)
280 end
281 elseif type(o) == "number" then
282 return so
283 else
284 return string.format("%q", so)
285 end
286 end
287
288 local function addtocart (value, name, indent, saved, field)
289 indent = indent or ""
290 saved = saved or {}
291 field = field or name
292
293 cart = cart .. indent .. field
294
295 if type(value) ~= "table" then
296 cart = cart .. " = " .. basicSerialize(value) .. ";\n"
297 else
298 if saved[value] then
299 cart = cart .. " = {}; -- " .. saved[value] .. " (self reference)\n"
300 autoref = autoref .. name .. " = " .. saved[value] .. ";\n"
301 else
302 saved[value] = name
303 --if tablecount(value) == 0 then
304 if isemptytable(value) then
305 cart = cart .. " = {};\n"
306 else
307 cart = cart .. " = {\n"
308 for k, v in pairs(value) do
309 k = basicSerialize(k)
310 local fname = string.format("%s[%s]", name, k)
311 field = string.format("[%s]", k)
312 -- three spaces between levels
313 addtocart(v, fname, indent .. " ", saved, field)
314 end
315 cart = cart .. indent .. "};\n"
316 end
317 end
318 end
319 end
320
321 name = name or "__unnamed__"
322 if type(t) ~= "table" then
323 return name .. " = " .. basicSerialize(t)
324 end
325 cart, autoref = "", ""
326 addtocart(t, name, indent)
327 return cart .. autoref
328end
329