From 56893e9dcd1eeebffb42b227a2151e18d49bc370 Mon Sep 17 00:00:00 2001 From: Gerardo Marset Date: Mon, 25 Feb 2013 20:28:28 -0200 Subject: Use the length operator (#) instead of table.getn. table.getn was deprecated in Lua 5.1 in favor of #, the length operator. See: http://www.lua.org/manual/5.1/manual.html#7.2 --- etc/check-links.lua | 2 +- etc/dispatch.lua | 2 +- etc/forward.lua | 2 +- etc/get.lua | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'etc') 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 -- make sure the user knows how to invoke us arg = arg or {} -if table.getn(arg) < 1 then +if #arg < 1 then print("Usage:\n luasocket check-links.lua [-n] {}") exit() end 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() insert = function(set, value) if not reverse[value] then table.insert(set, value) - reverse[value] = table.getn(set) + reverse[value] = #set end end, 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") local handler = dispatch.newhandler() -- make sure the user knows how to invoke us -if table.getn(arg) < 1 then +if #arg < 1 then print("Usage") print(" lua forward.lua ...") 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 -- main program arg = arg or {} -if table.getn(arg) < 1 then +if #arg < 1 then io.write("Usage:\n lua get.lua []\n") os.exit(1) else get(arg[1], arg[2]) end -- cgit v1.2.3-55-g6feb