From cae6c066b736c1b582991e5496a54c9a85b5832d Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Sat, 11 Sep 2010 13:30:49 +0000 Subject: XPath: Minor lang() fix (use ASCII lowercase because language names are ASCII-only anyway) git-svn-id: http://pugixml.googlecode.com/svn/trunk@716 99668b35-9821-0410-8761-19e4c4f06640 --- src/pugixml.cpp | 9 +++++++-- tests/test_xpath_functions.cpp | 12 ++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/pugixml.cpp b/src/pugixml.cpp index a8ed526..0e9b99c 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -21,7 +21,6 @@ #include #ifndef PUGIXML_NO_XPATH -# include # include # include #endif @@ -4903,6 +4902,12 @@ namespace #endif } + // Converts symbol to lower case, if it is an ASCII one + char_t tolower_ascii(char_t ch) + { + return static_cast(ch - 'A') < 26 ? (ch | ' ') : ch; + } + xpath_string string_value(const xpath_node& na) { if (na.attribute()) @@ -7127,7 +7132,7 @@ namespace pugi // strnicmp / strncasecmp is not portable for (const char_t* lit = lang.c_str(); *lit; ++lit) { - if (tolower(*lit) != tolower(*value)) return false; + if (tolower_ascii(*lit) != tolower_ascii(*value)) return false; ++value; } diff --git a/tests/test_xpath_functions.cpp b/tests/test_xpath_functions.cpp index 016c722..7245bee 100644 --- a/tests/test_xpath_functions.cpp +++ b/tests/test_xpath_functions.cpp @@ -216,7 +216,7 @@ TEST(xpath_boolean_false) CHECK_XPATH_FAIL(STR("false(1)")); } -TEST_XML(xpath_boolean_lang, "") +TEST_XML(xpath_boolean_lang, "") { xml_node c; @@ -231,16 +231,16 @@ TEST_XML(xpath_boolean_lang, "