diff options
author | Marius <mariausol@gmail.com> | 2010-11-01 14:00:14 +0200 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2010-11-01 14:00:14 +0200 |
commit | e19e21294c4450e292a48ee5a3cec8a90daf91ed (patch) | |
tree | a0c53a86c5692bd2d07b9c96a51a9d8325f57c52 /tex/context/base/l-io.lua | |
parent | b8fc800cde67f29f4724b642d87278f864ec2d58 (diff) | |
download | context-e19e21294c4450e292a48ee5a3cec8a90daf91ed.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 |