Improved filename handling
This commit is contained in:
parent
56f9d3ce85
commit
2eefb9a14b
@ -23,7 +23,7 @@ local function scan_filename()
|
|||||||
tok = token.scan_token()
|
tok = token.scan_token()
|
||||||
cmd = tok.command
|
cmd = tok.command
|
||||||
until cmd ~= spacer_cmd and cmd ~= relax_cmd
|
until cmd ~= spacer_cmd and cmd ~= relax_cmd
|
||||||
while (tok.command <= 12 and tok.index <= token.biggest_char()
|
while (tok.command <= 12 and tok.command > 0 and tok.command ~= 9 and tok.index <= token.biggest_char()
|
||||||
or (token.put_next(tok) and false))
|
or (token.put_next(tok) and false))
|
||||||
and (quoted or tok.index ~= string.byte' ') do
|
and (quoted or tok.index ~= string.byte' ') do
|
||||||
if tok.index == string.byte'"' then
|
if tok.index == string.byte'"' then
|
||||||
@ -36,13 +36,15 @@ local function scan_filename()
|
|||||||
return utf8.char(table.unpack(name))
|
return utf8.char(table.unpack(name))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local l = lpeg or require'lpeg'
|
||||||
|
local add_file_extension = l.Cs((1-('.' * (1-l.S'./\\')^0) * -1)^0 * (l.P(1)^1+l.Cc'.tex'))
|
||||||
local ofiles = {}
|
local ofiles = {}
|
||||||
local function do_openout(p)
|
local function do_openout(p)
|
||||||
if ofiles[p.file] then
|
if ofiles[p.file] then
|
||||||
error[[Existing file]]
|
error[[Existing file]]
|
||||||
else
|
else
|
||||||
local msg
|
local msg
|
||||||
ofiles[p.file], msg = io.open(p.name, 'w')
|
ofiles[p.file], msg = io.open(add_file_extension:match(p.name), 'w')
|
||||||
if not ofiles[p.file] then
|
if not ofiles[p.file] then
|
||||||
error(msg)
|
error(msg)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user