diff options
author | Diego MartÃnez <kaeza@users.noreply.github.com> | 2017-02-11 01:56:54 -0300 |
---|---|---|
committer | Diego MartÃnez <kaeza@users.noreply.github.com> | 2017-02-11 03:42:36 -0300 |
commit | 122d1a83cc380eb3919e28d20531b001c5cf8bac (patch) | |
tree | c15732cd5e198c42c64e81b5ef2a27d4a0a1faa3 /tools/updatetext.lua | |
parent | c667cd0de67e01792072f66ee9f0d539f18f75ad (diff) |
Fix warnings issued by `luacheck`.
Diffstat (limited to 'tools/updatetext.lua')
-rw-r--r-- | tools/updatetext.lua | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/tools/updatetext.lua b/tools/updatetext.lua index 00f9bf6..5d5734b 100644 --- a/tools/updatetext.lua +++ b/tools/updatetext.lua @@ -7,7 +7,7 @@ end if basedir == "" then basedir = "./" end -- Required by load_strings() -function string.trim(s) +function string.trim(s) -- luacheck: ignore return s:gsub("^%s*(.-)%s*$", "%1") end @@ -20,7 +20,7 @@ local function err(fmt, ...) os.exit(1) end -local template +local output, outfile, template local catalogs = { } local function usage() @@ -54,10 +54,7 @@ while i <= #arg do if i > #arg then err("missing required argument to `%s'", a) end - elseif (a == "-c") or (a == "--comment") then - old_msg_mode = "c" - elseif (a == "-d") or (a == "--delete") then - old_msg_mode = "d" + output = arg[i] elseif a:sub(1, 1) ~= "-" then if not template then template = a @@ -81,27 +78,18 @@ if not f then err("error opening template: %s", e) end -local function printf(fmt, ...) - outfile:write(fmt:format(...)) -end - local escapes = { ["\n"] = "\\n", ["="] = "\\=", ["\\"] = "\\\\", } local function escape(s) return s:gsub("[\\\n=]", escapes) end if output then - local e outfile, e = io.open(output, "w") if not outfile then err("error opening file for writing: %s", e) end end -local function printf(fmt, ...) - io.stdout:write(fmt:format(...)) -end - local template_msgs = intllib.load_strings(template) for _, file in ipairs(catalogs) do @@ -120,10 +108,12 @@ for _, file in ipairs(catalogs) do for k, v in pairs(catalog_msgs) do if not template_msgs[k] then print("OLD: "..k) + table.insert(dirty_lines, "OLD: "..escape(k).." = "..escape(v)) end end if #dirty_lines > 0 then - local outf, e = io.open(file, "a+") + local outf + outf, e = io.open(file, "a+") if outf then outf:write("\n") for _, line in ipairs(dirty_lines) do |