diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-09-24 15:20:52 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-09-24 15:20:52 +0000 |
commit | 42b3d348e8794e9b0754034c7b958d2de62e414a (patch) | |
tree | ca0db89f39b92400b66865fe5ac2d7c3ee730bb5 /lib/format.lua | |
parent | ca81c0892c5f2cbb175bf38d43bb466934919b38 (diff) | |
download | acf-core-42b3d348e8794e9b0754034c7b958d2de62e414a.tar.bz2 acf-core-42b3d348e8794e9b0754034c7b958d2de62e414a.tar.xz |
Added parse_configfile function to format.lua library.
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1488 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lib/format.lua')
-rw-r--r-- | lib/format.lua | 12 |
1 files changed, 12 insertions, 0 deletions
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) |