diff options
author | Solderpunk <solderpunk@sdf.org> | 2018-12-08 16:00:45 +0000 |
---|---|---|
committer | Solderpunk <solderpunk@sdf.org> | 2018-12-08 16:00:45 +0000 |
commit | 9a198f83063203c545fb43f1ec28db5eeb36bb07 (patch) | |
tree | e8caeac52f71ef0e6b17da459937fdde7b69b109 /telem.lua | |
parent | Shorten 'cat_file' function using Penlight's file.read. (diff) |
Enable penlight's strict mode, so that global vars *must* be declared.
Diffstat (limited to 'telem.lua')
-rwxr-xr-x | telem.lua | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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 |