Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- -*- coding: raw-text -*- -- makefile.lua - tools for generating makefiles. -- This is part of blogme3. -- Author: Eduardo Ochs <[email protected]> -- Version: 2007apr16 -- <http://anggtwu.net/blogme3/makefile.lua> -- <http://anggtwu.net/blogme3/makefile.lua.html> -- License: GPL. -- (find-angg "TH/Files.tcl") --------[ expandguillemets ]-------- -- Example: -- FOO = {"foo", "bar", "plic"} -- BLETCH = {"bletch", "blotch"} -- print(expandguillemets("deps: «FOO| _.html» «BLETCH| _.html»")) -- --> "deps: foo.html bar.html plic.html bletch.html blotch.html" expandunderlines = function (guillemetbody) return function (underlineexpansion) return (string.gsub(guillemetbody, "_", underlineexpansion)) end end expandguillemet = function (arrayname, body) if type(_G[arrayname]) ~= "table" then error("expandguillemet: not a global table: "..arrayname) end return table.concat(map(expandunderlines(body), _G[arrayname])) end expandguillemets = function (str) return (string.gsub(str, "«([A-Za-z_0-9]+)%s*|([^«»]*)»", expandguillemet)) end --------[ handle lists of files ]-------- toset = function (array) local set = {} for _,v in ipairs(array) do set[v]=v end return set end toarray = function (set) local array = {} for k,v in pairs(set) do tinsert(array, v) end table.sort(array) return array end minus = function (set1, set2) for k,v in pairs(set2) do set1[k] = nil end return set1 end without = function (str1, str2) local set1 = toset(split(str1)) local set2 = toset(split(str2)) return toarray(minus(set1, set2)) end splitandsort = function (str) local items = split(str) table.sort(items) return items end