Comparison

util/stanza.lua @ 2956:15a145a67044

util.stanza: Fixed some more nil global accesses.
author Waqas Hussain <waqas20@gmail.com>
date Thu, 01 Apr 2010 19:12:08 +0500
parent 2955:f807dc244a5b
child 2961:db3c0ecce3f4
comparison
equal deleted inserted replaced
2955:f807dc244a5b 2956:15a145a67044
223 if stanza then 223 if stanza then
224 local attr = stanza.attr; 224 local attr = stanza.attr;
225 for i=1,#attr do attr[i] = nil; end 225 for i=1,#attr do attr[i] = nil; end
226 local attrx = {}; 226 local attrx = {};
227 for att in pairs(attr) do 227 for att in pairs(attr) do
228 if s_find(att, "|", 1, true) and not s_find(k, "\1", 1, true) then 228 if s_find(att, "|", 1, true) and not s_find(att, "\1", 1, true) then
229 local ns,na = s_match(k, "^([^|]+)|(.+)$"); 229 local ns,na = s_match(att, "^([^|]+)|(.+)$");
230 attrx[ns.."\1"..na] = attr[att]; 230 attrx[ns.."\1"..na] = attr[att];
231 attr[att] = nil; 231 attr[att] = nil;
232 end 232 end
233 end 233 end
234 for a,v in pairs(attrx) do 234 for a,v in pairs(attrx) do
235 attr[x] = v; 235 attr[a] = v;
236 end 236 end
237 setmetatable(stanza, stanza_mt); 237 setmetatable(stanza, stanza_mt);
238 for _, child in ipairs(stanza) do 238 for _, child in ipairs(stanza) do
239 if type(child) == "table" then 239 if type(child) == "table" then
240 deserialize(child); 240 deserialize(child);