From 370c898db13a7768888f27a5d378cd4081aaa8b7 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 3 Oct 2012 17:53:06 -0300 Subject: Comment format consistency. --- src/luarocks/util.lua | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 1a1cccf9..512644c6 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua @@ -342,33 +342,23 @@ function remove_path_dupes(list, sep) return table.concat(final, sep) 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: - -io.write(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). ---]] +--- +-- Formats tables with cycles recursively to any depth. +-- 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: +-- io.write(table.show(t, "t")) -- a typical use +-- Written by Julio Manuel Fernandez-Diaz, +-- Heavily based on "Saving tables with cycles", PIL2, p. 113. +-- @param t table: is the table. +-- @param name string: is the name of the table (optional) +-- @param indent string: is a first indentation (optional). +-- @return string: the pretty-printed table function show_table(t, name, indent) local cart -- a container local autoref -- for self references -- cgit v1.2.3-55-g6feb From 93185e7a5d602635c278c8e218dd6b7ad29fade1 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 3 Oct 2012 17:53:23 -0300 Subject: Remove unused third argument. --- src/luarocks/search.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index 4e0318c7..ec0fa69c 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua @@ -287,9 +287,7 @@ end -- @param results table: A table where keys are package names and versions -- are tables matching version strings to an array of rocks servers. -- @param show_repo boolean or nil: Whether to show repository --- @param long boolean or nil: Whether to show module files --- information or not. Default is true. -function print_results(results, show_repo, long) +function print_results(results, show_repo) assert(type(results) == "table") assert(type(show_repo) == "boolean" or not show_repo) -- Force display of repo location for the time being -- cgit v1.2.3-55-g6feb From e457e70e65f7d1d19af6a6717601fc57175648b8 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 3 Oct 2012 17:53:56 -0300 Subject: Remove dead code. --- src/luarocks/command_line.lua | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'src') diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 8fa9073c..d08ffdfe 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua @@ -21,18 +21,6 @@ local function die(message) os.exit(1) end -local function is_writable(tree) - if type(tree) == "string" then - return fs.make_dir(tree) and fs.is_writable(tree) - else - writable = true - for k, v in pairs(tree) do - writable = writable and fs.make_dir(v) and fs.is_writable(v) - end - return writable - end -end - --- Main command-line processor. -- Parses input arguments and calls the appropriate driver function -- to execute the action requested on the command-line, forwarding -- cgit v1.2.3-55-g6feb From dde3ca9493dedbb950d5c1dfdf32a1bd1b152fca Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 8 Oct 2012 20:19:50 -0300 Subject: Check root parent only if root does not exist (useful for ~/.luarocks, avoids breakage with /usr/local). Closes #100. --- src/luarocks/fs/lua.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index c413ccb3..24b05a59 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -669,13 +669,18 @@ function check_command_permissions(flags) local root_dir = path.root_dir(cfg.rocks_dir) local ok = true local err = "" - for _, dir in ipairs { cfg.rocks_dir, root_dir, dir.dir_name(root_dir) } do + for _, dir in ipairs { cfg.rocks_dir, root_dir } do if fs.exists(dir) and not fs.is_writable(dir) then ok = false err = "Your user does not have write permissions in " .. dir break end end + local root_parent = dir.dir_name(root_dir) + if ok and not fs.exists(root_dir) and not fs.is_writable(root_parent) then + ok = false + err = root_dir.." does not exist and your user does not have write permissions in " .. root_parent + end if ok then return true else -- cgit v1.2.3-55-g6feb