xmlhandlers: Rearranged a little code.

Sat, 23 Jan 2010 18:41:20 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Sat, 23 Jan 2010 18:41:20 +0500
changeset 2493
ec09d16a51e1
parent 2492
b5e2d1919ec3
child 2494
6a60d67b4bb8

xmlhandlers: Rearranged a little code.

core/xmlhandlers.lua file | annotate | diff | comparison | revisions
--- a/core/xmlhandlers.lua	Sat Jan 23 18:33:39 2010 +0500
+++ b/core/xmlhandlers.lua	Sat Jan 23 18:41:20 2010 +0500
@@ -116,7 +116,24 @@
 		if name == "" then
 			curr_ns, name = "", curr_ns;
 		end
-		if not stanza then
+		if stanza then
+			if #chardata > 0 then
+				-- We have some character data in the buffer
+				stanza:text(t_concat(chardata));
+				chardata = {};
+			end
+			-- Complete stanza
+			if #stanza.last_add == 0 then
+				if tagname ~= stream_error_tag then
+					cb_handlestanza(session, stanza);
+				else
+					cb_error(session, "stream-error", stanza);
+				end
+				stanza = nil;
+			else
+				stanza:up();
+			end
+		else
 			if tagname == stream_tag then
 				if cb_streamclosed then
 					cb_streamclosed(session);
@@ -125,23 +142,6 @@
 				cb_error(session, "parse-error", "unexpected-element-close", name);
 			end
 			stanza, chardata = nil, {};
-			return;
-		end
-		if #chardata > 0 then
-			-- We have some character data in the buffer
-			stanza:text(t_concat(chardata));
-			chardata = {};
-		end
-		-- Complete stanza
-		if #stanza.last_add == 0 then
-			if tagname ~= stream_error_tag then
-				cb_handlestanza(session, stanza);
-			else
-				cb_error(session, "stream-error", stanza);
-			end
-			stanza = nil;
-		else
-			stanza:up();
 		end
 	end
 	return xml_handlers;

mercurial