diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-01-28 16:04:56 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-01-28 16:04:56 +0000 |
commit | 473fc0b6fa7d2b9626eb63344c55c5c4a0994ba3 (patch) | |
tree | 6d791cc2803da2c78055f7c865d6f2b83f9117bf /lib/getopts.lua | |
parent | 90beddd29cf1977dfc9ca61cc64f2773606038e3 (diff) | |
download | acf-core-473fc0b6fa7d2b9626eb63344c55c5c4a0994ba3.tar.bz2 acf-core-473fc0b6fa7d2b9626eb63344c55c5c4a0994ba3.tar.xz |
Fixed a bug in getopts. Getopts have ben broken for some time... dont know for how long. But now its fixed
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@659 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lib/getopts.lua')
-rw-r--r-- | lib/getopts.lua | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/getopts.lua b/lib/getopts.lua index 9668db2..d5ac795 100644 --- a/lib/getopts.lua +++ b/lib/getopts.lua @@ -1,6 +1,13 @@ module (..., package.seeall) require("fs") +--local conf_file + +function setoptsinfile (file, search, option, value) + local opts = getoptsfromfile(file) + return opts +end + function getoptsfromfile (file, search, filter) local opts = nil if not (fs.is_file(file)) then return nil end @@ -11,7 +18,7 @@ function getoptsfromfile (file, search, filter) local a = string.match ( l, "^%s*(%S*)=" ) if (a) then if not (search) or (search == a) then - local b = string.match ( l, '^%s*%S*%=%"?(.-)%s*%"?%s*$' ) + local b = string.match ( l, '^%s*%S*%s*%=%s*%"?(.-)%s*%"?%s*$' ) local optstable = getopts.opts_to_table(b,filter) if (optstable) or not (filter) then if not (opts) then @@ -20,7 +27,7 @@ function getoptsfromfile (file, search, filter) if (optstable) then opts[a] = optstable ---[[ Next line is DEBUG info. Should be commented out! - opts[a]["debug"] = b + --opts[a]["debug"] = b -- End debug info. --]] else opts[a] = b @@ -35,12 +42,11 @@ end function opts_to_table ( optstring, filter ) local optsparams = nil - local optstr = string.match(optstring, "^\"?(.*)%\"?") -- Filter away leading/trailing " + local optstr = optstring if optstr then - local option = "" - local optvalue = "" + local option = "" for j = 1, string.len(optstr) do - if (string.sub(optstr, j, j) == "-%a%s") then + if (string.find(string.sub(optstr, j, string.len(optstr)), "^-%a%s*")) then option=string.sub(optstr, j, j+1) if not (filter) or (filter == option) then for k = j+1, string.len(optstr) do |