diff options
Diffstat (limited to 'samples')
-rw-r--r-- | samples/lpr.lua | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/samples/lpr.lua b/samples/lpr.lua index c23ebee..d743026 100644 --- a/samples/lpr.lua +++ b/samples/lpr.lua | |||
@@ -27,16 +27,14 @@ if not arg or not arg[1] then | |||
27 | end | 27 | end |
28 | 28 | ||
29 | do | 29 | do |
30 | local s="opt = {" | 30 | local opt = {} |
31 | for i = 2 , table.getn(arg), 1 do | 31 | local pat = "[%s%c%p]*([%w]*)=([\"]?[%w%s_!@#$%%^&*()<>:;]+[\"]\?\.?)" |
32 | s = s .. string.gsub(arg[i],"[%s%c%p]*([%w]*)=([\"]?[%w%s_!@#$%%^&*()<>:;]+[\"]\?\.?)","%1%=\"%2\",\n") | 32 | for i = 2, table.getn(arg), 1 do |
33 | string.gsub(arg[i], pat, function(name, value) opt[name] = value end) | ||
33 | end | 34 | end |
34 | s = s .. "};\n" | ||
35 | assert(loadstring(s))(); | ||
36 | if not arg[2] then | 35 | if not arg[2] then |
37 | return usage() | 36 | return usage() |
38 | end | 37 | end |
39 | |||
40 | if arg[1] ~= "query" then | 38 | if arg[1] ~= "query" then |
41 | r,e=lp.send(arg[1],opt) | 39 | r,e=lp.send(arg[1],opt) |
42 | io.stdout:write(tostring(r or e),'\n') | 40 | io.stdout:write(tostring(r or e),'\n') |