Quantcast

WoWAPI: Add strsplit to string module and fix for "." in delimiter string.

Johnny C. Lam [07-13-14 - 11:30]
WoWAPI: Add strsplit to string module and fix for "." in delimiter string.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1533 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
WoWAPI.lua
diff --git a/WoWAPI.lua b/WoWAPI.lua
index 64498ed..ff84af1 100644
--- a/WoWAPI.lua
+++ b/WoWAPI.lua
@@ -379,6 +379,8 @@ end
 		http://lua-users.org/wiki/SplitJoin
 --]]--------------------------------------------------------------------
 WoWAPI.strsplit = function(delim, str, maxNb)
+	-- Fix up '.' character class.
+	delim = string.gsub(delim, "%.", "%%.")
 	-- Eliminate bad cases...
 	if string.find(str, delim) == nil then
 		return str
@@ -513,6 +515,8 @@ function WoWAPI:ExportSymbols(namespace)
 			namespace[k] = namespace[k] or v
 		end
 	end
+	-- Special handling for strsplit() to add to "string" module.
+	string.split = string.split or WoWAPI.strsplit
 	-- Special handling for wipe() to add to "table" module.
 	table.wipe = table.wipe or WoWAPI.wipe
 end