From e3fd7f99c00ff34a0425bffe936ce71519f34095 Mon Sep 17 00:00:00 2001 From: hisham Date: Tue, 5 May 2009 13:58:26 +0000 Subject: fixes to build from rockspec and patch feature git-svn-id: http://luarocks.org/svn/luarocks/trunk@17 9ca3f7c1-7366-0410-b1a3-b5c78f85698c --- src/luarocks/fetch.lua | 3 ++- src/luarocks/tools/patch.lua | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index 9d65e6e8..4e17c91d 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua @@ -122,7 +122,8 @@ end -- or nil followed by an error message. function load_local_rockspec(filename) assert(type(filename) == "string") - local rockspec, err = persist.load_into_table(fs.absolute_name(filename)) + filename = fs.absolute_name(filename) + local rockspec, err = persist.load_into_table(filename) if not rockspec then return nil, "Could not load rockspec file "..filename.." ("..err..")" end diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index 4fc5c3b5..6069f389 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua @@ -9,6 +9,8 @@ module("luarocks.tools.patch", package.seeall) +local fs = require("luarocks.fs") + local version = '0.1' local io = io @@ -93,11 +95,12 @@ local function string_as_file(s) eof = false, read = function(self, n) if self.eof then return nil end - local chunk = self.str:sub(at, at+n) + local chunk = self.str:sub(self.at, self.at+n) self.at = self.at + n - if at > self.len then + if self.at > self.len then self.eof = true end + return chunk end, close = function(self) self.eof = true @@ -187,6 +190,7 @@ function read_patch(filename, data) fp = filename == '-' and io.stdin or assert(io.open(filename, "rb")) end local lineno = 0 + for line in file_lines(fp) do lineno = lineno + 1 if state == 'header' then @@ -470,7 +474,6 @@ local function check_patched(file, hunks) error 'nomatch' end lineno = h.starttgt -print() for k,v in pairs(h) do print(k,v) end print() for _, hline in ipairs(h.text) do -- todo: \ No newline at the end of file if not startswith(hline, "-") and not startswith(hline, "\\") then @@ -575,6 +578,7 @@ function apply_patch(patch, strip) local f2patch = filename if not exists(f2patch) then f2patch = strip_dirs(patch.target[fileno], strip) + f2patch = fs.absolute_name(f2patch) if not exists(f2patch) then --FIX:if f2patch nil warning(format("source/target file does not exist\n--- %s\n+++ %s", filename, f2patch)) -- cgit v1.2.3-55-g6feb