diff options
author | Matthew Wild <mwild1@gmail.com> | 2011-09-20 23:30:58 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2011-09-20 23:30:58 +0100 |
commit | 662e7a289fcc76183346dc072c10c304821f4cf5 (patch) | |
tree | 2af39bee4a4620943500d8f304370e84e2764a04 /tools | |
parent | c372e5d38c0d754f0383e33e28ffab05b299b07f (diff) | |
download | prosody-662e7a289fcc76183346dc072c10c304821f4cf5.tar.gz prosody-662e7a289fcc76183346dc072c10c304821f4cf5.zip |
tools/ejabberdsql2prosody: Track current line for error reporting
Diffstat (limited to 'tools')
-rw-r--r-- | tools/ejabberdsql2prosody.lua | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/ejabberdsql2prosody.lua b/tools/ejabberdsql2prosody.lua index 958cf0e2..576f4436 100644 --- a/tools/ejabberdsql2prosody.lua +++ b/tools/ejabberdsql2prosody.lua @@ -21,12 +21,16 @@ function parseFile(filename) 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) |