From 960bfaca867c3c7e57a6954d57c3bc7907dfced7 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Fri, 10 Feb 2023 08:15:44 -0800 Subject: [PATCH] fix annotation parsing ref: #2857 --- library/lua/dfhack.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library/lua/dfhack.lua b/library/lua/dfhack.lua index c8b15c191..2ee03dfed 100644 --- a/library/lua/dfhack.lua +++ b/library/lua/dfhack.lua @@ -657,16 +657,18 @@ function Script:get_flags() self.flags_mtime = mtime self._flags = {} local f = io.open(self.path) - local contents = f:read('*all') - f:close() - for line in contents:gmatch('^%-%-@([^\n]+)') do - local chunk = load(line, self.path, 't', self._flags) + for line in f:lines() do + local at_tag = line:match('^%-%-@(.+)') + if not at_tag then goto continue end + local chunk = load(at_tag, self.path, 't', self._flags) if chunk then chunk() else dfhack.printerr('Parse error: ' .. line) end + ::continue:: end + f:close() end return self._flags end