aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/check-links.lua2
-rw-r--r--etc/dispatch.lua2
-rw-r--r--etc/forward.lua2
-rw-r--r--etc/get.lua2
-rw-r--r--samples/lpr.lua2
-rw-r--r--samples/tinyirc.lua2
-rw-r--r--src/mbox.lua4
-rw-r--r--src/url.lua4
-rw-r--r--test/httptest.lua2
-rw-r--r--test/smtptest.lua14
-rw-r--r--test/urltest.lua2
11 files changed, 19 insertions, 19 deletions
diff --git a/etc/check-links.lua b/etc/check-links.lua
index d2e4266..283f3ac 100644
--- a/etc/check-links.lua
+++ b/etc/check-links.lua
@@ -11,7 +11,7 @@ dispatch.TIMEOUT = 10
11 11
12-- make sure the user knows how to invoke us 12-- make sure the user knows how to invoke us
13arg = arg or {} 13arg = arg or {}
14if table.getn(arg) < 1 then 14if #arg < 1 then
15 print("Usage:\n luasocket check-links.lua [-n] {<url>}") 15 print("Usage:\n luasocket check-links.lua [-n] {<url>}")
16 exit() 16 exit()
17end 17end
diff --git a/etc/dispatch.lua b/etc/dispatch.lua
index cc8cb23..31a1290 100644
--- a/etc/dispatch.lua
+++ b/etc/dispatch.lua
@@ -76,7 +76,7 @@ local function newset()
76 insert = function(set, value) 76 insert = function(set, value)
77 if not reverse[value] then 77 if not reverse[value] then
78 table.insert(set, value) 78 table.insert(set, value)
79 reverse[value] = table.getn(set) 79 reverse[value] = #set
80 end 80 end
81 end, 81 end,
82 remove = function(set, value) 82 remove = function(set, value)
diff --git a/etc/forward.lua b/etc/forward.lua
index 9073ac4..05ced1a 100644
--- a/etc/forward.lua
+++ b/etc/forward.lua
@@ -3,7 +3,7 @@ local dispatch = require("dispatch")
3local handler = dispatch.newhandler() 3local handler = dispatch.newhandler()
4 4
5-- make sure the user knows how to invoke us 5-- make sure the user knows how to invoke us
6if table.getn(arg) < 1 then 6if #arg < 1 then
7 print("Usage") 7 print("Usage")
8 print(" lua forward.lua <iport:ohost:oport> ...") 8 print(" lua forward.lua <iport:ohost:oport> ...")
9 os.exit(1) 9 os.exit(1)
diff --git a/etc/get.lua b/etc/get.lua
index 4196f00..9edc235 100644
--- a/etc/get.lua
+++ b/etc/get.lua
@@ -135,7 +135,7 @@ end
135 135
136-- main program 136-- main program
137arg = arg or {} 137arg = arg or {}
138if table.getn(arg) < 1 then 138if #arg < 1 then
139 io.write("Usage:\n lua get.lua <remote-url> [<local-file>]\n") 139 io.write("Usage:\n lua get.lua <remote-url> [<local-file>]\n")
140 os.exit(1) 140 os.exit(1)
141else get(arg[1], arg[2]) end 141else get(arg[1], arg[2]) end
diff --git a/samples/lpr.lua b/samples/lpr.lua
index 2b059b1..3d5e2f8 100644
--- a/samples/lpr.lua
+++ b/samples/lpr.lua
@@ -29,7 +29,7 @@ end
29do 29do
30 local opt = {} 30 local opt = {}
31 local pat = "[%s%c%p]*([%w]*)=([\"]?[%w%s_!@#$%%^&*()<>:;]+[\"]\?\.?)" 31 local pat = "[%s%c%p]*([%w]*)=([\"]?[%w%s_!@#$%%^&*()<>:;]+[\"]\?\.?)"
32 for i = 2, table.getn(arg), 1 do 32 for i = 2, #arg, 1 do
33 string.gsub(arg[i], pat, function(name, value) opt[name] = value end) 33 string.gsub(arg[i], pat, function(name, value) opt[name] = value end)
34 end 34 end
35 if not arg[2] then 35 if not arg[2] then
diff --git a/samples/tinyirc.lua b/samples/tinyirc.lua
index e75851f..5babb7e 100644
--- a/samples/tinyirc.lua
+++ b/samples/tinyirc.lua
@@ -31,7 +31,7 @@ function newset()
31 insert = function(set, value) 31 insert = function(set, value)
32 if not reverse[value] then 32 if not reverse[value] then
33 table.insert(set, value) 33 table.insert(set, value)
34 reverse[value] = table.getn(set) 34 reverse[value] = #set
35 end 35 end
36 end, 36 end,
37 remove = function(set, value) 37 remove = function(set, value)
diff --git a/src/mbox.lua b/src/mbox.lua
index b7d4a2a..35adf4e 100644
--- a/src/mbox.lua
+++ b/src/mbox.lua
@@ -34,7 +34,7 @@ end
34function Public.parse_headers(headers_s) 34function Public.parse_headers(headers_s)
35 local headers_t = Public.split_headers(headers_s) 35 local headers_t = Public.split_headers(headers_s)
36 local headers = {} 36 local headers = {}
37 for i = 1, table.getn(headers_t) do 37 for i = 1, #headers_t do
38 local name, value = Public.parse_header(headers_t[i]) 38 local name, value = Public.parse_header(headers_t[i])
39 if name then 39 if name then
40 name = string.lower(name) 40 name = string.lower(name)
@@ -74,7 +74,7 @@ end
74 74
75function Public.parse(mbox_s) 75function Public.parse(mbox_s)
76 local mbox = Public.split_mbox(mbox_s) 76 local mbox = Public.split_mbox(mbox_s)
77 for i = 1, table.getn(mbox) do 77 for i = 1, #mbox do
78 mbox[i] = Public.parse_message(mbox[i]) 78 mbox[i] = Public.parse_message(mbox[i])
79 end 79 end
80 return mbox 80 return mbox
diff --git a/src/url.lua b/src/url.lua
index 1bfecad..6ca6d68 100644
--- a/src/url.lua
+++ b/src/url.lua
@@ -259,7 +259,7 @@ function parse_path(path)
259 path = path or "" 259 path = path or ""
260 --path = string.gsub(path, "%s", "") 260 --path = string.gsub(path, "%s", "")
261 string.gsub(path, "([^/]+)", function (s) table.insert(parsed, s) end) 261 string.gsub(path, "([^/]+)", function (s) table.insert(parsed, s) end)
262 for i = 1, table.getn(parsed) do 262 for i = 1, #parsed do
263 parsed[i] = unescape(parsed[i]) 263 parsed[i] = unescape(parsed[i])
264 end 264 end
265 if string.sub(path, 1, 1) == "/" then parsed.is_absolute = 1 end 265 if string.sub(path, 1, 1) == "/" then parsed.is_absolute = 1 end
@@ -277,7 +277,7 @@ end
277----------------------------------------------------------------------------- 277-----------------------------------------------------------------------------
278function build_path(parsed, unsafe) 278function build_path(parsed, unsafe)
279 local path = "" 279 local path = ""
280 local n = table.getn(parsed) 280 local n = #parsed
281 if unsafe then 281 if unsafe then
282 for i = 1, n-1 do 282 for i = 1, n-1 do
283 path = path .. parsed[i] 283 path = path .. parsed[i]
diff --git a/test/httptest.lua b/test/httptest.lua
index 614acf3..d5fbb37 100644
--- a/test/httptest.lua
+++ b/test/httptest.lua
@@ -66,7 +66,7 @@ local check_request = function(request, expect, ignore)
66 local response = {} 66 local response = {}
67 response.code, response.headers, response.status = 67 response.code, response.headers, response.status =
68 socket.skip(1, http.request(request)) 68 socket.skip(1, http.request(request))
69 if t and table.getn(t) > 0 then response.body = table.concat(t) end 69 if t and #t > 0 then response.body = table.concat(t) end
70 check_result(response, expect, ignore) 70 check_result(response, expect, ignore)
71end 71end
72 72
diff --git a/test/smtptest.lua b/test/smtptest.lua
index 5f0e0e5..b5380ff 100644
--- a/test/smtptest.lua
+++ b/test/smtptest.lua
@@ -20,7 +20,7 @@ dofile("testsupport.lua")
20 20
21local total = function() 21local total = function()
22 local t = 0 22 local t = 0
23 for i = 1, table.getn(sent) do 23 for i = 1, #sent do
24 t = t + sent[i].count 24 t = t + sent[i].count
25 end 25 end
26 return t 26 return t
@@ -83,7 +83,7 @@ end
83 83
84local check = function(sent, m) 84local check = function(sent, m)
85 io.write("checking ", m.headers.title, ": ") 85 io.write("checking ", m.headers.title, ": ")
86 for i = 1, table.getn(sent) do 86 for i = 1, #sent do
87 local s = sent[i] 87 local s = sent[i]
88 if s.title == m.headers.title and s.count > 0 then 88 if s.title == m.headers.title and s.count > 0 then
89 check_headers(s.headers, m.headers) 89 check_headers(s.headers, m.headers)
@@ -98,7 +98,7 @@ end
98 98
99local insert = function(sent, message) 99local insert = function(sent, message)
100 if type(message.rcpt) == "table" then 100 if type(message.rcpt) == "table" then
101 message.count = table.getn(message.rcpt) 101 message.count = #message.rcpt
102 else message.count = 1 end 102 else message.count = 1 end
103 message.headers = message.headers or {} 103 message.headers = message.headers or {}
104 message.headers.title = message.title 104 message.headers.title = message.title
@@ -115,7 +115,7 @@ local wait = function(sentinel, n)
115 io.write("waiting for ", n, " messages: ") 115 io.write("waiting for ", n, " messages: ")
116 while 1 do 116 while 1 do
117 local mbox = parse(get()) 117 local mbox = parse(get())
118 if n == table.getn(mbox) then break end 118 if n == #mbox then break end
119 if socket.time() - sentinel.time > 50 then 119 if socket.time() - sentinel.time > 50 then
120 to = 1 120 to = 1
121 break 121 break
@@ -237,7 +237,7 @@ empty()
237print("ok") 237print("ok")
238 238
239io.write("sending messages: ") 239io.write("sending messages: ")
240for i = 1, table.getn(sent) do 240for i = 1, #sent do
241 ret, err = socket.smtp.mail(sent[i]) 241 ret, err = socket.smtp.mail(sent[i])
242 if not ret then fail(err) end 242 if not ret then fail(err) end
243 io.write("+") 243 io.write("+")
@@ -249,9 +249,9 @@ wait(mark(), total())
249 249
250io.write("parsing mailbox: ") 250io.write("parsing mailbox: ")
251local mbox = parse(get()) 251local mbox = parse(get())
252print(table.getn(mbox) .. " messages found!") 252print(#mbox .. " messages found!")
253 253
254for i = 1, table.getn(mbox) do 254for i = 1, #mbox do
255 check(sent, mbox[i]) 255 check(sent, mbox[i])
256end 256end
257 257
diff --git a/test/urltest.lua b/test/urltest.lua
index 71e4428..32cb348 100644
--- a/test/urltest.lua
+++ b/test/urltest.lua
@@ -34,7 +34,7 @@ end
34 34
35local check_parse_path = function(path, expect) 35local check_parse_path = function(path, expect)
36 local parsed = socket.url.parse_path(path) 36 local parsed = socket.url.parse_path(path)
37 for i = 1, math.max(table.getn(parsed), table.getn(expect)) do 37 for i = 1, math.max(#parsed, #expect) do
38 if parsed[i] ~= expect[i] then 38 if parsed[i] ~= expect[i] then
39 print(path) 39 print(path)
40 os.exit() 40 os.exit()