From f4c50108da9e4674516112ace7f0097d264fe7e4 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 30 Dec 2017 22:43:47 -0800 Subject: Add raw mode for iterlines --- ninja.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'ninja.lua') diff --git a/ninja.lua b/ninja.lua index 92194d90..e07c574a 100644 --- a/ninja.lua +++ b/ninja.lua @@ -131,20 +131,24 @@ end -- yields non-empty non-comment lines in a file local function linesgen(file) - table.insert(pkg.inputs.gen, '$dir/'..file) - for line in io.lines(pkg.dir..'/'..file) do + for line in io.lines(file) do if #line > 0 and not line:hasprefix('#') then coroutine.yield(line) end end end -function iterlines(file) +function iterlines(file, raw) + table.insert(pkg.inputs.gen, '$dir/'..file) + file = string.format('%s/%s', pkg.dir, file) + if raw then + return io.lines(file) + end return coroutine.wrap(linesgen), file end -function lines(file) - return collect(iterlines(file)) +function lines(file, raw) + return collect(iterlines(file, raw)) end -- -- cgit v1.2.3