Software /
code /
prosody
Diff
tools/ejabberdsql2prosody.lua @ 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 |
parent | 3541:a72b88953bf2 |
child | 4496:11983a1e92c0 |
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)