From a625fe26e46fa0c61c1fbab82013589813ebf4c4 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Mon, 20 Jul 2015 15:41:34 +0200 Subject: fixed bad reference to main LuaRocks install path, should fix AppVeyor failures --- src/luarocks/cfg.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 31b3211a..70c1bd04 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -374,7 +374,7 @@ local defaults = { } if cfg.platforms.windows then - local full_prefix = (site_config.LUAROCKS_PREFIX or (os.getenv("PROGRAMFILES")..[[\LuaRocks]])).."\\"..cfg.major_version + local full_prefix = (site_config.LUAROCKS_PREFIX or (os.getenv("PROGRAMFILES")..[[\LuaRocks]])) extra_luarocks_module_dir = full_prefix.."\\lua\\?.lua" home_config_file = home_config_file and home_config_file:gsub("\\","/") -- cgit v1.2.3-55-g6feb From cfc253ffb580bd30cb004ad3bf4e72b3314791e0 Mon Sep 17 00:00:00 2001 From: mpeterv Date: Sat, 17 Oct 2015 11:41:26 +0300 Subject: Fix empty line handling in patch.lua Interpret empty lines in hunk bodies as empty context lines, that is, add a space to them. This is consistent with command-line patch tool behaviour. Fixes #434. --- src/luarocks/tools/patch.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index b53bad61..9e5074ad 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua @@ -200,8 +200,13 @@ function patch.read_patch(filename, data) if state == 'hunkbody' then -- skip hunkskip and hunkbody code until definition of hunkhead read + if line:match"^[\r\n]*$" then + -- prepend space to empty lines to interpret them as context properly + line = " " .. line + end + -- process line first - if line:match"^[- +\\]" or line:match"^[\r\n]*$" then + if line:match"^[- +\\]" then -- gather stats about line endings local he = files.hunkends[nextfileno] if endswith(line, "\r\n") then -- cgit v1.2.3-55-g6feb From 7886cffec0721ecfb733384946d7a4399c43b897 Mon Sep 17 00:00:00 2001 From: mpeterv Date: Sat, 17 Oct 2015 10:46:44 +0300 Subject: Fix patch error message when source is different check_patched() relies on throwing and catching string 'nomatch'. Pass 0 as the second argument for error() when throwing to avoid location info being added to the message. Fixes lack of error when patch should fail with "source is different" error. --- src/luarocks/tools/patch.lua | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index b53bad61..c4715cd6 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua @@ -455,16 +455,15 @@ local function find_hunks(file, hunks) end local function check_patched(file, hunks) - local matched = true local lineno = 1 local ok, err = pcall(function() if #file == 0 then - error 'nomatch' + error('nomatch', 0) end for hno, h in ipairs(hunks) do -- skip to line just before hunk starts if #file < h.starttgt then - error 'nomatch' + error('nomatch', 0) end lineno = h.starttgt for _, hline in ipairs(h.text) do @@ -473,22 +472,18 @@ local function check_patched(file, hunks) local line = file[lineno] lineno = lineno + 1 if #line == 0 then - error 'nomatch' + error('nomatch', 0) end if endlstrip(line) ~= endlstrip(hline:sub(2)) then warning(format("file is not patched - failed hunk: %d", hno)) - error 'nomatch' + error('nomatch', 0) end end end end end) - if err == 'nomatch' then - matched = false - end - -- todo: display failed hunk, i.e. expected/found - - return matched + -- todo: display failed hunk, i.e. expected/found + return err ~= 'nomatch' end local function patch_hunks(srcname, tgtname, hunks) -- cgit v1.2.3-55-g6feb From cb3e2aff5c1665db48bdd274bd696a0d465cbd3a Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Tue, 27 Oct 2015 09:26:52 +0100 Subject: explicit warn when enviornment variable given filename doesn't exist --- src/luarocks/cfg.lua | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 70c1bd04..66d3d25a 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -228,17 +228,33 @@ end if not site_config.LUAROCKS_FORCE_CONFIG then home_config_file_default = home_config_dir.."/config-"..cfg.lua_version..".lua" - local list = { - os.getenv("LUAROCKS_CONFIG_" .. version_suffix) or os.getenv("LUAROCKS_CONFIG"), - home_config_file_default, - home_config_dir.."/config.lua", - } - -- first entry might be a silent nil, check and remove if so - if not list[1] then table.remove(list, 1) end - home_config_file = load_config_file(list) - home_config_ok = (home_config_file ~= nil) + local config_env_var = "LUAROCKS_CONFIG_" .. version_suffix + local config_env_value = os.getenv(config_env_var) + if not config_env_value then + config_env_var = "LUAROCKS_CONFIG" + config_env_value = os.getenv(config_env_var) + end + + -- first try environment provided file, so we can explicitly warn when it is missing + if config_env_value then + local list = { config_env_value } + home_config_file = load_config_file(list) + home_config_ok = (home_config_file ~= nil) + if not home_config_ok then + io.stderr:write("Warning: could not load configuration file `"..config_env_value.."` given in environment variable "..config_env_var.."\n") + end + end + -- try the alternative defaults if there was no environment specified file or it didn't work + if not home_config_ok then + local list = { + home_config_file_default, + home_config_dir.."/config.lua", + } + home_config_file = load_config_file(list) + home_config_ok = (home_config_file ~= nil) + end end -- cgit v1.2.3-55-g6feb