Skip to content
Snippets Groups Projects
Commit 59049d64 authored by Julien Michel's avatar Julien Michel
Browse files

BUG: Fixing bug in the readTextContent. Call to putback was invalidating the input stream

parent b40394f9
No related branches found
No related tags found
No related merge requests found
...@@ -1083,80 +1083,51 @@ bool ossimXmlNode::readTextContent(std::istream& in) ...@@ -1083,80 +1083,51 @@ bool ossimXmlNode::readTextContent(std::istream& in)
theText = ""; theText = "";
theCDataFlag = false; theCDataFlag = false;
char c = in.peek();
do char buf[9];
{ buf[8]='\0';
if(c == '<')
{
in.ignore();
// we will check for comments or CDATA std::streampos initialPos = in.tellg();
if(in.peek()=='!')
{ in.read(buf,9);
char buf1[4]; ossimString ostrBuf(buf);
buf1[3] = '\0';
in.read(buf1, 3);
if(ossimString(buf1) == "!--")
{
// special text read
theText += buf1;
bool done = false;
do
{
if(in.peek() != '-')
{
in.ignore();
}
else
{
in.ignore();
if(in.peek() == '-')
{
in.ignore();
if(in.peek() == '>')
{
in.ignore();
done = true;
c = in.peek();
}
}
}
}while(!done&&!in.fail());
}
else
{
char buf2[6];
buf2[5] = '\0';
in.read(buf2, 5);
if(in.fail())
{
return false;
}
if(ossimString(buf1)+ossimString(buf2) == "![CDATA[")
{
if(readCDataContent(in))
{
theCDataFlag = true;
return true;
}
}
}
}
else
{
in.putback(c);
return true;
}
}
else
{
theText += (char)in.get();
c = in.peek();
}
}while(!in.fail());
if(ostrBuf == "<![CDATA[")
{
if(readCDataContent(in))
{
theCDataFlag = true;
return true;
}
else
{
return false;
}
}
else if(ostrBuf.substr(0,4) == "<!--")
{
in.seekg(initialPos);
char c = in.get();
// Strip comment
while(!in.fail() && c!='>')
{
c = in.get();
}
}
else if(ostrBuf.substr(0,1) == "<")
{
in.seekg(initialPos);
}
else
{
in.seekg(initialPos);
char c = in.peek();
while(!in.fail() && c != '<')
{
theText += (char)in.get();
c = in.peek();
}
}
return !in.fail(); return !in.fail();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment