XPath: Fixed lang() function

git-svn-id: http://pugixml.googlecode.com/svn/trunk@175 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
arseny.kapoulkine 2009-10-21 20:46:57 +00:00
parent 9233e86055
commit 1b0a27c7f4

View File

@ -1944,9 +1944,7 @@ namespace pugi
std::string lang = m_left->eval_string(c);
xml_node n = c.n.node();
while (n.type() != node_document)
for (xml_node n = c.n.node(); n; n = n.parent())
{
xml_attribute a = n.attribute("xml:lang");
@ -1955,9 +1953,9 @@ namespace pugi
const char* value = a.value();
// strnicmp / strncasecmp is not portable
for (std::string::iterator it = lang.begin(); it != lang.end(); ++it)
for (const char* lit = lang.c_str(); *lit; ++lit)
{
if (tolower(*it) != tolower(*value)) return false;
if (tolower(*lit) != tolower(*value)) return false;
++value;
}