diff options
author | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2010-02-14 13:55:48 +0000 |
---|---|---|
committer | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2010-02-14 13:55:48 +0000 |
commit | 9f6d562076285029ab523101e266a38e4f5c065b (patch) | |
tree | c68a1b3fd1dfc13008e98f93eb46de27f216c878 /Master/texmf | |
parent | 5b86f37c365be0bdbbafd145fb1d294549001027 (diff) |
Lua tlpdb reader: improve error messages.
git-svn-id: svn://tug.org/texlive/trunk@17010 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf')
-rw-r--r-- | Master/texmf/scripts/texlive/lua/texlive/tlpdb.tlu | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/Master/texmf/scripts/texlive/lua/texlive/tlpdb.tlu b/Master/texmf/scripts/texlive/lua/texlive/tlpdb.tlu index 9722c078704..ee0c4547dd8 100644 --- a/Master/texmf/scripts/texlive/lua/texlive/tlpdb.tlu +++ b/Master/texmf/scripts/texlive/lua/texlive/tlpdb.tlu @@ -42,15 +42,25 @@ function read_tlpdb(root) local fn = root..'/tlpkg/texlive.tlpdb' if (lfs.isfile(fn)) then -- tlpdb exists + local lineno = 0 -- current line number + local errline = '' -- current line + local function die(msg) + io.stderr:write(msg..' in '..fn..' at line '..tostring(lineno) + ..'\n>>'..errline..'<<\n') + -- for now, exit, but this is bad behaviour if we want to be used + -- as a library. FIXME. + os.exit(1) + end local started = false local lastcmd = "" local arch local size - local line local tlpobj = {} local name local tlpdb = {} for line in io.lines(fn) do + lineno = lineno + 1 + errline = line if string.match(line, '^%s*$') then if started then -- we have encountered an empty line while creating a tlpobj, so @@ -71,8 +81,7 @@ function read_tlpdb(root) lastcmd == 'depend' then line = string.gsub(line, '^ ', lastcmd.."continued ") else - io.stderr:write('Error reading tlpdb: continuation of '..lastcmd..' not allowed in line\n>>'..line..'<<\n') - os.exit(1) + die('Continuation of '..lastcmd..' not allowed') end end local first @@ -119,8 +128,7 @@ function read_tlpdb(root) tlpobj.runsize = rsize else if #rest > 0 then - io.stderr:write('Unknown tag in line\n>>'..line.."<<\n") - os.exit(1) + die('Unknown tag') end end elseif first == "docfiles" then @@ -129,8 +137,7 @@ function read_tlpdb(root) tlpobj.docsize = dsize else if #rest > 0 then - io.stderr:write('Unknown tag in line\n>>'..line.."<<\n") - os.exit(1) + die('Unknown tag') end end elseif first == "srcfiles" then @@ -139,8 +146,7 @@ function read_tlpdb(root) tlpobj.srcsize = ssize else if #rest > 0 then - io.stderr:write('Unknown tag in line\n>>'..line.."<<\n") - os.exit(1) + die('Unknown tag') end end elseif first == "binfiles" then @@ -153,8 +159,7 @@ function read_tlpdb(root) elseif string.match(aaa,'^size=(%S*)$') then bsize = string.match(aaa,'^size=(%S*)$') else - io.stderr:write('Unknown tag in line\n>>'..line.."<<\n") - os.exit(1) + die('Unknown tag') end end if barch and bsize then @@ -164,8 +169,7 @@ function read_tlpdb(root) tlpobj.binsize[barch] = bsize arch = barch else - io.stderr:write('Incomplete binfile tags in line\n>>'..line.."<<\n") - os.exit(1) + die('Incomplete binfile tags ') end elseif first == "runfilescontinued" then if not(tlpobj.runfiles) then @@ -189,8 +193,7 @@ function read_tlpdb(root) end tlpobj.docfiledata[dfile][aaa] = bbb else - io.stderr:write('Error reading tlpdb: unknown docfile tag in line\n>>'..line.."<<\n") - os.exit(1) + die('Unknown docfile tag') end end lastcmd = "docfiles" @@ -226,13 +229,10 @@ function read_tlpdb(root) end table.insert(tlpobj.execute,rest) else - print("first = "..first) - io.stderr:write('Error reading tlpdb: unknown directive in line\n>>'..line.."<<\n") - os.exit(1) + die('Unknown directive') end if not(first) then - io.stderr:write('Error reading tlpdb: missing directive in line\n>>'..line.."<<\n") - os.exit(1) + die('Missing directive') end end end @@ -248,4 +248,4 @@ end -- tab-width: 2 -- indent-tabs-mode: nil -- End: --- vim:set tabstop=2 expandtab: # +-- vim:set tabstop=2 shiftwidth=2 expandtab: # |