From 42b3d348e8794e9b0754034c7b958d2de62e414a Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Wed, 24 Sep 2008 15:20:52 +0000 Subject: Added parse_configfile function to format.lua library. git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1488 ab2d0c66-481e-0410-8bed-d214d4d58bed --- lib/format.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/format.lua') diff --git a/lib/format.lua b/lib/format.lua index f012c3b..e19899f 100644 --- a/lib/format.lua +++ b/lib/format.lua @@ -82,6 +82,18 @@ function parse_linesandwords ( input ) return lines end +-- returns a table with label value pairs + +function parse_configfile( input ) + local config = {} + local lines = parse_linesandwords(input) + + for i,linetable in ipairs(lines) do + config[linetable[1]] = table.concat(linetable, " ", 2) or "" + end + return config +end + -- search and replace through a table -- string is easy string.gsub(string, find, replace) -- cgit v1.2.3