diff options
author | Pixel <pixel@nobis-crew.org> | 2009-02-12 10:27:44 -0800 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2009-02-12 10:27:44 -0800 |
commit | 55cd641affc6d948c30aee1da3436f0b5d25a9f9 (patch) | |
tree | c89385c9a759cb737e828f4de7805f641a02a339 | |
parent | 2a6b51c13e06dd3ded2b419339a6c4f72d8a365c (diff) |
This file parser was stupid. Fixing by loading the whole file in a dynamic buffer.
-rw-r--r-- | lib/LuaXML.cc | 17 |
1 files changed, 5 insertions, 12 deletions
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 <Handle.h> +#include <Buffer.h> #include <BLua.h> 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<const char *>(b.GetBuffer())); lua_newtable(__L); ParseNode(__L, &doc); |