From 55cd641affc6d948c30aee1da3436f0b5d25a9f9 Mon Sep 17 00:00:00 2001 From: Pixel Date: Thu, 12 Feb 2009 10:27:44 -0800 Subject: This file parser was stupid. Fixing by loading the whole file in a dynamic buffer. --- lib/LuaXML.cc | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/LuaXML.cc b/lib/LuaXML.cc index 8dc98cc..62cb57e 100644 --- a/lib/LuaXML.cc +++ b/lib/LuaXML.cc @@ -20,6 +20,7 @@ #include "tinyxml.h" #include +#include #include class LuaXML : public Base { @@ -98,22 +99,14 @@ static int ParseString(lua_State *L) { return 1; } -#define XMLBUFSIZ 81920 - static int ParseHandle(lua_State *__L) { Lua * L = Lua::find(__L); Handle * h = (Handle *) LuaObject::getme(L, 1); TiXmlDocument doc; - char buffer[XMLBUFSIZ + 1]; - int l; - - while (!h->IsClosed()) { - l = h->read(buffer, XMLBUFSIZ); - if (l) { - buffer[l] = 0; - doc.Parse(buffer); - } - } + Buffer b(true); + + b.copyfrom(h); + doc.Parse(reinterpret_cast(b.GetBuffer())); lua_newtable(__L); ParseNode(__L, &doc); -- cgit v1.2.3