From Wang Rui, "I've fixed the problem that osgx format doesn't read the Font property and wrapped string correctly. The first problem happened because the matchString() made a mistake in comparing two strings with the same start but different size. The second just needs complete rewriting of writeWrappedString() and readWrappedString() in src/osgPlugins/osg/XmlStreamOperator.h

I also fixed a possible bug in osgDB::XmlParser that doesn't handle control characters (like " to ") when reading node attributes, because the writeWrappedString() and readWrappedString() now depend heavily on control characters. An additional improvement is that osgx now supports comments."
This commit is contained in:
Robert Osfield
2010-09-30 09:34:41 +00:00
parent 47af827648
commit ab1920c427
3 changed files with 103 additions and 54 deletions

View File

@@ -258,8 +258,13 @@ bool XmlNode::read(Input& input)
++input;
while((c=input[0])>=0 && c!='"')
{
value.push_back(c);
++input;
if (c=='&')
readAndReplaceControl(value, input);
else
{
value.push_back(c);
++input;
}
}
++input;
}
@@ -268,8 +273,13 @@ bool XmlNode::read(Input& input)
++input;
while((c=input[0])>=0 && c!='\'')
{
value.push_back(c);
++input;
if (c=='&')
readAndReplaceControl(value, input);
else
{
value.push_back(c);
++input;
}
}
++input;
}
@@ -335,20 +345,7 @@ bool XmlNode::read(Input& input)
if (c=='&')
{
std::string value;
while(input && (c=input.get())!=';') { value.push_back(c); }
value.push_back(c);
if (input._controlToCharacterMap.count(value)!=0)
{
c = input._controlToCharacterMap[value];
OSG_INFO<<"Read control character "<<value<<" converted to "<<char(c)<<std::endl;
contents.push_back(c);
}
else
{
OSG_NOTICE<<"Warning: read control character "<<value<<", but have no mapping to convert it to."<<std::endl;
}
readAndReplaceControl(contents, input);
}
else
{
@@ -459,3 +456,24 @@ bool XmlNode::writeProperties(const ControlMap& controlMap, std::ostream& fout)
return true;
}
bool XmlNode::readAndReplaceControl(std::string& contents, XmlNode::Input& input)
{
int c = 0;
std::string value;
while(input && (c=input.get())!=';') { value.push_back(c); }
value.push_back(c);
if (input._controlToCharacterMap.count(value)!=0)
{
c = input._controlToCharacterMap[value];
OSG_INFO<<"Read control character "<<value<<" converted to "<<char(c)<<std::endl;
contents.push_back(c);
return true;
}
else
{
OSG_NOTICE<<"Warning: read control character "<<value<<", but have no mapping to convert it to."<<std::endl;
return false;
}
}