summaryrefslogtreecommitdiff
path: root/indra/llxml/llxmlnode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llxml/llxmlnode.cpp')
-rw-r--r--indra/llxml/llxmlnode.cpp65
1 files changed, 40 insertions, 25 deletions
diff --git a/indra/llxml/llxmlnode.cpp b/indra/llxml/llxmlnode.cpp
index 8168f968cd..2ffb0d8503 100644
--- a/indra/llxml/llxmlnode.cpp
+++ b/indra/llxml/llxmlnode.cpp
@@ -631,13 +631,14 @@ bool LLXMLNode::updateNode(
}
//update all of node's children with updateNodes children that match name
- LLXMLNodePtr child;
+ LLXMLNodePtr child = node->getFirstChild();
+ LLXMLNodePtr last_child = child;
LLXMLNodePtr updateChild;
for (updateChild = update_node->getFirstChild(); updateChild.notNull();
updateChild = updateChild->getNextSibling())
{
- for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling())
+ while(child.notNull())
{
std::string nodeName;
std::string updateName;
@@ -656,6 +657,22 @@ bool LLXMLNode::updateNode(
if ((nodeName != "") && (updateName == nodeName))
{
updateNode(child, updateChild);
+ last_child = child;
+ child = child->getNextSibling();
+ if (child.isNull())
+ {
+ child = node->getFirstChild();
+ }
+ break;
+ }
+
+ child = child->getNextSibling();
+ if (child.isNull())
+ {
+ child = node->getFirstChild();
+ }
+ if (child == last_child)
+ {
break;
}
}
@@ -693,7 +710,7 @@ bool LLXMLNode::parseFile(const std::string& filename, LLXMLNodePtr& node, LLXML
LLFILE* fp = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */
if (fp == NULL)
{
- node = new LLXMLNode();
+ node = NULL ;
return false;
}
fseek(fp, 0, SEEK_END);
@@ -746,7 +763,7 @@ bool LLXMLNode::parseBuffer(
{
llwarns << "Parse failure - wrong number of top-level nodes xml."
<< llendl;
- node = new LLXMLNode();
+ node = NULL ;
return false;
}
@@ -784,7 +801,7 @@ bool LLXMLNode::parseStream(
while(str.good())
{
str.read((char*)buffer, BUFSIZE);
- int count = str.gcount();
+ int count = (int)str.gcount();
if (XML_Parse(my_parser, (const char *)buffer, count, !str.good()) != XML_STATUS_OK)
{
@@ -805,7 +822,7 @@ bool LLXMLNode::parseStream(
{
llwarns << "Parse failure - wrong number of top-level nodes xml."
<< llendl;
- node = new LLXMLNode();
+ node = NULL;
return false;
}
@@ -859,23 +876,21 @@ BOOL LLXMLNode::isFullyDefault()
}
// static
-bool LLXMLNode::getLayeredXMLNode(const std::string &xui_filename, LLXMLNodePtr& root,
+bool LLXMLNode::getLayeredXMLNode(LLXMLNodePtr& root,
const std::vector<std::string>& paths)
{
- std::string full_filename = gDirUtilp->findSkinnedFilename(paths.front(), xui_filename);
- if (full_filename.empty())
+ if (paths.empty()) return false;
+
+ std::string filename = paths.front();
+ if (filename.empty())
{
return false;
}
-
- if (!LLXMLNode::parseFile(full_filename, root, NULL))
+
+ if (!LLXMLNode::parseFile(filename, root, NULL))
{
- // try filename as passed in since sometimes we load an xml file from a user-supplied path
- if (!LLXMLNode::parseFile(xui_filename, root, NULL))
- {
- llwarns << "Problem reading UI description file: " << xui_filename << llendl;
- return false;
- }
+ llwarns << "Problem reading UI description file: " << filename << llendl;
+ return false;
}
LLXMLNodePtr updateRoot;
@@ -884,11 +899,8 @@ bool LLXMLNode::getLayeredXMLNode(const std::string &xui_filename, LLXMLNodePtr&
for (itor = paths.begin(), ++itor; itor != paths.end(); ++itor)
{
- std::string nodeName;
- std::string updateName;
-
- std::string layer_filename = gDirUtilp->findSkinnedFilename((*itor), xui_filename);
- if(layer_filename.empty())
+ std::string layer_filename = *itor;
+ if(layer_filename.empty() || layer_filename == filename)
{
// no localized version of this file, that's ok, keep looking
continue;
@@ -896,10 +908,13 @@ bool LLXMLNode::getLayeredXMLNode(const std::string &xui_filename, LLXMLNodePtr&
if (!LLXMLNode::parseFile(layer_filename, updateRoot, NULL))
{
- llwarns << "Problem reading localized UI description file: " << (*itor) + gDirUtilp->getDirDelimiter() + xui_filename << llendl;
+ llwarns << "Problem reading localized UI description file: " << layer_filename << llendl;
return false;
}
+ std::string nodeName;
+ std::string updateName;
+
updateRoot->getAttributeString("name", updateName);
root->getAttributeString("name", nodeName);
@@ -1208,7 +1223,7 @@ bool LLXMLNode::getChild(const LLStringTableEntry* name, LLXMLNodePtr& node, BOO
{
return mDefault->getChild(name, node, FALSE);
}
- node = new LLXMLNode();
+ node = NULL;
return false;
}
@@ -1279,7 +1294,7 @@ bool LLXMLNode::getAttribute(const LLStringTableEntry* name, LLXMLNodePtr& node,
{
return mDefault->getAttribute(name, node, FALSE);
}
- node = new LLXMLNode();
+
return false;
}