From 9a198f83063203c545fb43f1ec28db5eeb36bb07 Mon Sep 17 00:00:00 2001 From: Solderpunk Date: Sat, 8 Dec 2018 16:00:45 +0000 Subject: Enable penlight's strict mode, so that global vars *must* be declared. --- telem.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/telem.lua b/telem.lua index 91916fd..178448e 100755 --- a/telem.lua +++ b/telem.lua @@ -1,6 +1,7 @@ #!/usr/bin/lua5.2 telemver = "0.3 // 2018-05-04" +require("pl.strict") file = require("pl.file") io = require("io") lfs = require("lfs") @@ -12,7 +13,6 @@ table = require("table") _BBS_ROOT = "/var/bbs/" -- Global var declarations --- (Not actually required by Lua, just here to make the design clear/explicit) username = os.getenv("USER") -- TODO: This is, obviously, not secure and will need to be updated boards = {} -- Array of board names, alphaetically sorted @@ -55,8 +55,9 @@ function get_threads(board) if threaddir == "topic" then goto continue end local thread = {} thread.directory = path.join(_BBS_ROOT, "boards", board, threaddir) - _, _, timestamp, thread.author = string.find(threaddir, "(%d+)-(%g+)") + local _, _, timestamp, author = string.find(threaddir, "(%d+)-(%g+)") thread.timestamp = tonumber(timestamp) + thread.author = author io.input(path.join(thread.directory, "subject")) thread.subject = io.read("*line") @@ -84,8 +85,9 @@ function get_posts(thread) if postfile == "subject" then goto continue end local post = {} post.filename = path.join(thread.directory, postfile) - _, _, timestamp, post.author = string.find(postfile, "(%d+)-(%a+)") + local _, _, timestamp, author = string.find(postfile, "(%d+)-(%a+)") post.timestamp = tonumber(timestamp) + post.author = author table.insert(posts, post) ::continue:: end -- cgit v1.2.3