[mojosetup] [11/13] Use make_relative() instead of duplicating its code.

Francois Gouget fgouget at codeweavers.com
Mon May 21 14:40:33 EDT 2012


---

This is a cleanup that should not change anything. It may be 
possible to apply it independently from this patchset.

 scripts/mojosetup_mainline.lua |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/scripts/mojosetup_mainline.lua b/scripts/mojosetup_mainline.lua
index da7e18d..a162d56 100644
--- a/scripts/mojosetup_mainline.lua
+++ b/scripts/mojosetup_mainline.lua
@@ -89,10 +89,7 @@ end
 
 local function manifest_add(man, fname, _key, ftype, mode, sums, lndest)
     if (fname ~= nil) and (_key ~= nil) then
-        local destlen = string.len(MojoSetup.destination)
-        if string.sub(fname, 0, destlen) == MojoSetup.destination then
-            fname = string.sub(fname, destlen+2)  -- make it relative.
-        end
+        fname = make_relative(fname, MojoSetup.destination)
 
         if man[fname] ~= nil then
             MojoSetup.logwarning("Overwriting file '" .. fname .. "' in manifest!")
@@ -115,10 +112,7 @@ end
 
 local function manifest_delete(man, fname)
     if fname ~= nil then
-        local destlen = string.len(MojoSetup.destination)
-        if string.sub(fname, 0, destlen) == MojoSetup.destination then
-            fname = string.sub(fname, destlen+2)  -- make it relative.
-        end
+        fname = make_relative(fname, MojoSetup.destination)
 
         if man[fname] == nil then
             MojoSetup.logwarning("Deleting unknown file '" .. fname .. "' from manifest!")
-- 
1.7.10


More information about the mojosetup mailing list