diff options
Diffstat (limited to 'indra/llui/llxuiparser.cpp')
-rw-r--r-- | indra/llui/llxuiparser.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/indra/llui/llxuiparser.cpp b/indra/llui/llxuiparser.cpp index 84507a58b6..f8d4a61721 100644 --- a/indra/llui/llxuiparser.cpp +++ b/indra/llui/llxuiparser.cpp @@ -28,7 +28,6 @@ #include "llxuiparser.h" -#include "lldir.h" #include "llxmlnode.h" #include "llfasttimer.h" #ifdef LL_USESYSTEMLIBS @@ -45,7 +44,6 @@ #include "lluicolor.h" #include "v3math.h" - using namespace BOOST_SPIRIT_CLASSIC_NS; const S32 MAX_STRING_ATTRIBUTE_SIZE = 40; @@ -935,7 +933,7 @@ bool LLXUIParser::readBoolValue(Parser& parser, void* val_ptr) bool value; LLXUIParser& self = static_cast<LLXUIParser&>(parser); bool success = self.mCurReadNode->getBoolValue(1, &value); - *((bool*)val_ptr) = (value != false); + *((bool*)val_ptr) = value; return success; } @@ -1399,17 +1397,36 @@ bool LLSimpleXUIParser::readXUI(const std::string& filename, LLInitParam::BaseBl mCurReadDepth = 0; setParseSilently(silent); - std::string xml = gDirUtilp->getFileContents(filename); - if (xml.empty()) + ScopedFile file(filename, "rb"); + if( !file.isOpen() ) { LL_WARNS("ReadXUI") << "Unable to open file " << filename << LL_ENDL; XML_ParserFree( mParser ); return false; } + S32 bytes_read = 0; + + S32 buffer_size = file.getRemainingBytes(); + void* buffer = XML_GetBuffer(mParser, buffer_size); + if( !buffer ) + { + LL_WARNS("ReadXUI") << "Unable to allocate XML buffer while reading file " << filename << LL_ENDL; + XML_ParserFree( mParser ); + return false; + } + + bytes_read = (S32)fread(buffer, 1, buffer_size, file.mFile); + if( bytes_read <= 0 ) + { + LL_WARNS("ReadXUI") << "Error while reading file " << filename << LL_ENDL; + XML_ParserFree( mParser ); + return false; + } + mEmptyLeafNode.push_back(false); - if (!XML_Parse(mParser, xml.data(), (int)xml.size(), true)) + if( !XML_ParseBuffer(mParser, bytes_read, true ) ) { LL_WARNS("ReadXUI") << "Error while parsing file " << filename << LL_ENDL; XML_ParserFree( mParser ); |