diff options
author | Hans Hagen <pragma@wxs.nl> | 2010-11-01 12:14:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2010-11-01 12:14:00 +0100 |
commit | 5af44dc9b7791e82d01b0cc817a128ad0332b07d (patch) | |
tree | 4ae5cc93fdb03d7170a6ddcaf26bb4cccd0964df /tex/context/base/l-io.lua | |
parent | d3c8eee372dd3ce5c180cefce270b9b0d4e8c77a (diff) | |
download | context-5af44dc9b7791e82d01b0cc817a128ad0332b07d.tar.gz |
beta 2010.11.01 12:14
Diffstat (limited to 'tex/context/base/l-io.lua')
-rw-r--r-- | tex/context/base/l-io.lua | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/tex/context/base/l-io.lua b/tex/context/base/l-io.lua index f9a663519..88816648d 100644 --- a/tex/context/base/l-io.lua +++ b/tex/context/base/l-io.lua @@ -9,6 +9,7 @@ if not modules then modules = { } end modules ['l-io'] = { local io = io local byte, find, gsub, format = string.byte, string.find, string.gsub, string.format local concat = table.concat +local type = type if string.find(os.getenv("PATH"),";") then io.fileseparator, io.pathseparator = "\\", ";" @@ -67,12 +68,19 @@ function io.size(filename) end function io.noflines(f) - local n = 0 - for _ in f:lines() do - n = n + 1 + if type(f) == "string" then + local f = io.open(filename) + local n = f and io.noflines(f) or 0 + assert(f:close()) + return n + else + local n = 0 + for _ in f:lines() do + n = n + 1 + end + f:seek('set',0) + return n end - f:seek('set',0) - return n end local nextchar = { @@ -164,6 +172,7 @@ function io.ask(question,default,options) io.write(format(" [%s]",default)) end io.write(format(" ")) + io.flush() local answer = io.read() answer = gsub(answer,"^%s*(.*)%s*$","%1") if answer == "" and default then |