diff --git a/moonbuild.lua b/moonbuild.lua index dd64d16..251d6db 100644 --- a/moonbuild.lua +++ b/moonbuild.lua @@ -370,16 +370,26 @@ patsubst = function(str, pattern, replacement) end return _accum_0 end + if str == pattern then + return replacement + end local prefix, suffix = match(pattern, GLOB_PATT) - if not (prefix) then + if not (prefix or suffix) then return str end local reprefix, resuffix = match(replacement, GLOB_PATT) - if not (reprefix) then - return replacement + if not (reprefix or resuffix) then + if (#prefix == 0 or (sub(str, 1, #prefix)) == prefix) and (#suffix == 0 or (sub(str, -#suffix)) == suffix) then + return replacement + else + return str + end + end + if #prefix == 0 or (sub(str, 1, #prefix)) == prefix then + str = reprefix .. (sub(str, #prefix + 1)) end - if (sub(str, 1, #prefix)) == prefix and (sub(str, -#suffix)) == suffix then - return reprefix .. (sub(str, #prefix + 1, -#suffix - 1)) .. resuffix + if #suffix == 0 or (sub(str, -#suffix)) == suffix then + str = (sub(str, 1, -#suffix - 1)) .. resuffix end return str end @@ -513,10 +523,14 @@ flatten = function(tab) for _index_0 = 1, #tab do local e = tab[_index_0] if (type(e)) == 'table' then - local _list_0 = flatten(e) - for _index_1 = 1, #_list_0 do - local v = _list_0[_index_1] - insert(out, v) + if e[1] == nil and (next(e)) ~= nil then + insert(out, e) + else + local _list_0 = flatten(e) + for _index_1 = 1, #_list_0 do + local v = _list_0[_index_1] + insert(out, v) + end end else insert(out, e) diff --git a/rockspecs/moonbuild-1.1.4-1.rockspec b/rockspecs/moonbuild-1.1.4-1.rockspec new file mode 100644 index 0000000..fae7f75 --- /dev/null +++ b/rockspecs/moonbuild-1.1.4-1.rockspec @@ -0,0 +1,23 @@ +build = { + install = { + bin = { + moonbuild = "moonbuild.lua" + } + }, + type = "builtin" +} +dependencies = { + "lua >= 5.3", + "luafilesystem >= 1.7.0" +} +description = { + detailed = "moonbuild is a small build system that simplifies your build definitions by allowing you to use declarative as well as imperative rules. It represents the build as a DAG with explicit ordering, and doesn't give you any default confusing rules (unlike make)\n", + summary = "Small build system in between make and a build.sh" +} +package = "moonbuild" +rockspec_format = "3.0" +source = { + tag = "v1.1.4", + url = "git://github.com/natnat-mc/moonbuild" +} +version = "1.1.4-1"