# HG changeset patch # User Matthew Wild # Date 1316557858 -3600 # Node ID 7fbcb7e6a6a010ce3c619a1b207ad313d88ea1bc # Parent 718445c040c44f284e4c9e261e4af34023ae300e tools/ejabberdsql2prosody: Track current line for error reporting diff -r 718445c040c4 -r 7fbcb7e6a6a0 tools/ejabberdsql2prosody.lua --- 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)