Diff

tools/ejabberdsql2prosody.lua @ 1599:308986a3e66a

ejabberdsql2prosody: Added support for all mysql escape sequences
author Waqas Hussain <waqas20@gmail.com>
date Sun, 26 Jul 2009 17:51:36 +0500
parent 1598:d82e13d57821
child 1600:cd9790f42269
line wrap: on
line diff
--- a/tools/ejabberdsql2prosody.lua	Sun Jul 26 17:29:56 2009 +0500
+++ b/tools/ejabberdsql2prosody.lua	Sun Jul 26 17:51:36 2009 +0500
@@ -36,11 +36,21 @@
 	return last;
 end
 
+local escapes = {
+	["\\0"] = "\0";
+	["\\'"] = "'";
+	["\\\""] = "\"";
+	["\\b"] = "\b";
+	["\\n"] = "\n";
+	["\\r"] = "\r";
+	["\\t"] = "\t";
+	["\\Z"] = "\26";
+	["\\\\"] = "\\";
+	["\\%"] = "%";
+	["\\_"] = "_";
+}
 local function unescape(s)
-	if s == "\\'" then return "'"; end
-	if s == "\\n" then return "\n"; end
-	if s == "\\\\" then return "\\"; end
-	error("Unknown escape sequence: "..s);
+	return escapes[s] or error("Unknown escape sequence: "..s);
 end
 local function readString()
 	read("'");