aboutsummaryrefslogtreecommitdiff
path: root/nomsu.lua
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-24 17:36:45 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-24 17:36:50 -0700
commitd7e297844c88022cf10ebeb14759a8df7dd539c4 (patch)
treef6ff3310c6708ef351cea0efcd1791a2eb41a502 /nomsu.lua
parentf7a9d1fc6b2ccd95f2f8df49f99073a6d2be9bb8 (diff)
Fixed stdin handling.
Diffstat (limited to 'nomsu.lua')
-rw-r--r--nomsu.lua30
1 files changed, 19 insertions, 11 deletions
diff --git a/nomsu.lua b/nomsu.lua
index cfb243d..ab04883 100644
--- a/nomsu.lua
+++ b/nomsu.lua
@@ -159,12 +159,24 @@ local run
run = function()
local input_files = { }
for _index_0 = 1, #file_queue do
- local f = file_queue[_index_0]
- if not (Files.exists(f)) then
- error("Could not find: '" .. tostring(f) .. "'")
- end
- for _, filename in Files.walk(f) do
- input_files[filename] = true
+ local _continue_0 = false
+ repeat
+ local f = file_queue[_index_0]
+ if f == 'stdin' then
+ input_files[f] = true
+ _continue_0 = true
+ break
+ end
+ if not (Files.exists(f)) then
+ error("Could not find: '" .. tostring(f) .. "'")
+ end
+ for _, filename in Files.walk(f) do
+ input_files[filename] = true
+ end
+ _continue_0 = true
+ until true
+ if not _continue_0 then
+ break
end
end
nomsu.can_optimize = function(f)
@@ -186,11 +198,7 @@ run = function()
local get_file_and_source
get_file_and_source = function(filename)
local file, source
- if filename == 'stdin' then
- file = io.read("*a")
- Files.spoof('stdin', file)
- source = Source('stdin', 1, #file)
- elseif filename:match("%.nom$") then
+ if filename == 'stdin' or filename:match("%.nom$") then
file = Files.read(filename)
if not file then
error("File does not exist: " .. tostring(filename), 0)