Commit 28daeaef authored by Pavel Vainerman's avatar Pavel Vainerman

(UniXML): исправил ошибку в предыдущем коммите

(в функции поиска UniXML::iterator:find)
parent c1e3f372
......@@ -3,7 +3,7 @@
Name: libuniset
Version: 1.4
Release: alt8
Release: alt9
Summary: UniSet - library for building distributed industrial control systems
License: GPL
Group: Development/C++
......@@ -211,6 +211,9 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
* Mon Aug 20 2012 Pavel Vainerman <pv@altlinux.ru> 1.4-alt9
- fixed bug in previous commit (bug in UniXML::iterator::find)
* Tue Aug 07 2012 Pavel Vaynerman <pv@server> 1.4-alt8
- fixed bug in UniXML::iterator::find
......
......@@ -120,7 +120,7 @@ string UniXML::getPropUtf8(const xmlNode* node, const string name)
string UniXML::getProp(const xmlNode* node, const string name)
{
const char * text = (const char*)::xmlGetProp((xmlNode*)node, (const xmlChar*)name.c_str());
if( !text )
if (text == NULL)
return "";
return string(text);
......@@ -433,17 +433,30 @@ bool UniXML_iterator::findName( const std::string node, const std::string search
// -------------------------------------------------------------------------
bool UniXML_iterator::find( const std::string searchnode )
{
// Функция ищет "в ширину и в глубь"
xmlNode* rnode = curNode;
while (curNode != NULL)
{
while( curNode->children )
{
curNode=curNode->children;
curNode = curNode->children;
if ( searchnode == (const char*)curNode->name )
return true;
}
curNode=curNode->next;
while( !curNode->next && curNode->parent )
{
// выше исходного узла "подыматься" нельзя
if( curNode == rnode )
break;
curNode = curNode->parent;
}
curNode = curNode->next;
if ( curNode && searchnode == (const char*)curNode->name )
{
......
......@@ -66,6 +66,13 @@ int main()
cout<<"\nCorrect result for algoryhtm 'for_each()':\n"<<"UniSet \n"<<"dlog \n"
<<"ObjectsMap \n"<<"messages \n";
it=xml.begin();
it.find("test");
if( it.find("messages") )
cout << "ERROR! begin=<UniSet> but find <messages>!" << endl;
return 0;
}
......@@ -60,5 +60,7 @@
</ObjectsMap>
<messages name="messages" idfromfile="1" >
<child>
</child>
</messages>
</UNISETPLC>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment