Software /
code /
prosody
Changeset
4384:7fbcb7e6a6a0
tools/ejabberdsql2prosody: Track current line for error reporting
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 20 Sep 2011 23:30:58 +0100 |
parents | 4383:718445c040c4 |
children | 4385:c94167139f27 |
files | tools/ejabberdsql2prosody.lua |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/ejabberdsql2prosody.lua Wed Sep 21 03:25:34 2011 +0500 +++ b/tools/ejabberdsql2prosody.lua Tue Sep 20 23:30:58 2011 +0100 @@ -21,12 +21,16 @@ local file = nil; local last = nil; +local line = 1; local function read(expected) local ch; if last then ch = last; last = nil; - else ch = file:read(1); end - if expected and ch ~= expected then error("expected: "..expected.."; got: "..(ch or "nil")); end + else + ch = file:read(1); + if ch == "\n" then line = line + 1; end + end + if expected and ch ~= expected then error("expected: "..expected.."; got: "..(ch or "nil").." on line "..line); end return ch; end local function pushback(ch)