summaryrefslogtreecommitdiff
path: root/indra/llui/llxuiparser.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-05-22 09:30:04 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-05-22 09:30:04 -0400
commiteb81d5f23fc725f53857d7a62923e273a057c455 (patch)
tree5c1ba76e722d9630fa597023a1e6c196a04f758c /indra/llui/llxuiparser.cpp
parentf8ccb39b8d944f9d2bf4308f909273cd5a35cbe7 (diff)
parent47985e5822ce9fdebb7443e13b3c1a781a842ecd (diff)
Merge remote-tracking branch 'DRTVWR-600-maint-A' into nat/kwds
Diffstat (limited to 'indra/llui/llxuiparser.cpp')
-rw-r--r--indra/llui/llxuiparser.cpp29
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 );