]> git.e2factory.org Git - e2factory.git/commitdiff
Remove the collections module
authorTobias Ulmer <tu@emlix.com>
Thu, 9 Aug 2012 08:29:31 +0000 (10:29 +0200)
committerTobias Ulmer <tu@emlix.com>
Mon, 13 Aug 2012 10:22:07 +0000 (12:22 +0200)
The single use of string.explode is replaced by an inline version of the
same functionality.

Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/collection.lua [deleted file]
generic/e2lib.lua
generic/e2option.lua
global/Makefile
local/Makefile
local/e2tool.lua

diff --git a/generic/collection.lua b/generic/collection.lua
deleted file mode 100644 (file)
index e0d30a7..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
---[[
-   e2factory, the emlix embedded build system
-
-   Copyright (C) 2007-2009 Gordon Hecker <gh@emlix.com>, emlix GmbH
-   Copyright (C) 2007-2009 Oskar Schirmer <os@emlix.com>, emlix GmbH
-   Copyright (C) 2007-2008 Felix Winkelmann, emlix GmbH
-
-   For more information have a look at http://www.e2factory.org
-
-   e2factory is a registered trademark by emlix GmbH.
-
-   This file is part of e2factory, the emlix embedded build system.
-
-   e2factory is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.
-]]
-
--- Topological sorting
---
---   table.tsort(DAG) -> ARRAY
---
---     Expects a table of tables as input, where each sub-table contains
---     the node name followed by its dependencies, and returns a topologically
---     sorted array of all entries.
---     When DAG is cyclic, return nil
-
-function table.tsort(dag)
-  local sorted = {}
-  local adjust = {}
-  local colour = {}
-  local function visit(u, path)
-    local p = path
-    if p[u] then sorted = nil end
-    if sorted and not colour[u] then
-      local v = adjust[u]
-      colour[u] = true
-      if v then
-        p[u] = true
-        for i = 1, #v do visit(v[i], p) end
-        p[u] = nil
-      end
-      if sorted then table.insert(sorted, u) end
-    end
-  end
-  for i = 1, #dag do
-    local l = {}
-    for j = 2, #dag[i] do table.insert(l, dag[i][j]) end
-    adjust[dag[i][1]] = l
-  end
-  for i = 1, #dag do visit(dag[i][1], {}) end
-  return sorted
-end
-
-
--- Table operations
---
---   table.reverse(TABLE) -> TABLE'
---
---     Reverse array elements and return new table.
---
---   table.map(TABLE, FUNCTION) -> TABLE'
---
---     Map over table elements creating new table. FUNCTION is called for each
---     table value and the result will be stored under the same key as the original
---     value.
---
---   table.filter(TABLE, FUNCTION) -> TABLE'
---
---     Returns a new table with all elements from TABLE removed that do not
---     satisfy the predicate FUNCTION.
---
---
---   table.grep(TABLE, PATTERN) -> TABLE'
---
---     Filter strings matching a pattern.
---
---   table.print(TABLE, [OUT])
---
---     Prints table contents on OUT, which defaults to io.stdout.
---
---   table.compare(TABLE1, TABLE2, [FUNCTION]) -> BOOL
---
---     Compares tables element by element by passing each pair of elements
---     to FUNCTION (which defaults to "function(x, y) return x == y end").
---
---   table.find(TABLE, VAL, [FUNCTION]) -> KEY, VAL
---
---     Searches TABLE for an entry VAL and returns the key (and value). FUNCTION
---     is the comparison function used to compare the values and defaults to
---     "function(x, y) return x == y end".
-
-function table.reverse(t)
-  local t2 = {}
-  local len = #t
-  local j = 1
-  for i = len, 1, -1 do
-    t2[ j ] = t[ i ]
-    j = j + 1
-  end
-  return t2
-end
-
-function table.map(t, f)
-  local t2 = {}
-  for k, x in pairs(t) do
-    t2[ k ] = f(x)
-  end
-  return t2
-end
-
-function table.filter(t, f)
-  local t2 = {}
-  local i = 1
-  for k, x in pairs(t) do
-    if f(x) then
-      t2[ i ] = x
-      i = i + 1
-    end
-  end
-  return t2
-end
-
-function table.grep(t, p)
-  local function match(x)
-    return string.find(x, p)
-  end
-  return table.filter(t, match)
-end
-
-function table.print(t, out)
-  local out = out or io.stdout
-  out:write(tostring(t), ":\n")
-  for k, v in pairs(t) do
-    print("", k, "->", v)
-  end
-end
-
-function table.compare(t1, t2, p)
-  local p = p or function(x, y) return x == y end
-  if #t1 ~= #t2 then return false
-  else
-    for k, v in pairs(t1) do
-      local x = t2[ k ]
-      if not p(v, x) then return false end
-    end
-    return true
-  end
-end
-
-function table.find(t, x, cmp)
-  cmp = cmp or function(x, y) return x == y end
-  for k, v in pairs(t) do
-    if cmp(v, x) then return k, v end
-  end
-  return nil
-end
-
-
--- String operations
---
---   string.trim(STRING) -> STRING'
---
---     Removes whitespace on both sides from string.
---
---   string.explode(STRING) -> ARRAY
---
---     Convert string into array of characters (one-element strings).
---
---   string.split(STRING, PATTERN) -> ARRAY
---
---     Split string into elements matching PATTERN.
-
-function string.trim(str)
-  return string.match(str, "^%s*(.*%S)%s*$") or ""
-end
-
-function string.explode(str)
-  local t = {}
-  for i = 1, #str do
-    table.insert(t, string.sub(str, i, i))
-  end
-  return t
-end
-
-function string.split(str, pat)
-  local t = {}
-  pat = pat or "%S+"
-  for x in string.gmatch(str, pat) do
-    table.insert(t, x)
-  end
-  return t
-end
index 3b0e9440f63423a814f521daea64d0f049061fe0..b4105f60e67c7cf0ad2232d4f2ca53821ead343b 100644 (file)
@@ -1341,7 +1341,6 @@ function parse_e2versionfile(filename)
                                    filename)
   v.tag = match() or abort("invalid tag name `", l, "' in e2 version file ",
                               filename)
-  --table.print(v)
   log(3, "using e2 branch " .. v.branch .. " tag " .. v.tag)
   return v
 end
index e5af076bf7c3e3d80120a84b36828091996dee02..6be99cc1cd0d5878ccf908d9b2db198f8a1958af 100644 (file)
@@ -28,7 +28,6 @@
 module("e2option", package.seeall)
 require("e2lib")
 require("e2util")
-require("collection")
 local plugin = require("plugin")
 local err = require("err")
 
@@ -322,7 +321,11 @@ function parse(args)
            end
          end
        else
-         local set = string.explode(opt)
+         local set = {}
+         for i = 1, string.len(opt) do
+                 table.insert(set, string.sub(opt, i, i))
+         end
+
          for k, v in pairs(set) do
            if not options[ v ] then
              e2lib.abort(string.format("invalid option: %s\n"..
index 74c7cc70d1830629e6fb80f766cef6c412f3f430..2f13db308ccc13f856c8031c049e7f64dbc781ff 100644 (file)
@@ -36,7 +36,7 @@ GLOBALLUATOOLS = e2-create-project e2-fetch-project e2-install-e2 e2-root
 GLOBALSHTOOLS = e2-locate-project-root e2ssh
 GLOBALTOOLS = $(GLOBALLUATOOLS) $(GLOBALSHTOOLS)
 CLEAN_FILES = *~ $(GLOBALTOOLS) *.lc e2 $(SCRIPTS) *.lua e2-su *.sh e2.conf
-LUA_LIBS = strict.lua collection.lua plugin.lua e2lib.lua
+LUA_LIBS = strict.lua plugin.lua e2lib.lua
 LUA_LIBS += e2option.lua hash.lua tools.lua transport.lua cache.lua url.lua
 LUA_LIBS += generic_git.lua luafile.lua err.lua lock.lua
 LUA_LIBS += buildconfig.lua
index 2759212aab916c015495b1cc7778dae2271a63bb..005f237951c4439b3d331435408af74394afe79b 100644 (file)
@@ -46,7 +46,7 @@ LUA_LIBS = e2option.lua luafile.lua generic_git.lua err.lua
 LUA_LIBS += e2tool.lua scm.lua git.lua svn.lua cvs.lua files.lua
 LUA_LIBS += tools.lua transport.lua cache.lua
 LUA_LIBS += environment.lua plugin.lua url.lua hash.lua lock.lua
-LUA_LIBS += policy.lua strict.lua collection.lua e2build.lua
+LUA_LIBS += policy.lua strict.lua e2build.lua
 LUA_LIBS += e2lib.lua buildconfig.lua
 LOCALTOOLS = $(LOCALSHTOOLS) $(LOCALLUATOOLS)
 
index b2124ecf37f8a93cbc4e1956ee747e00b64e3277..43aaa0869e0aea10cd2d5a558ba4aa3648ce452d 100644 (file)
@@ -32,7 +32,6 @@
 module("e2tool", package.seeall)
 require("e2lib")
 require("strict")
-require("collection")
 local err = require("err")
 require("scm")
 require("files")