From eaa078b76a6be5417e73b3fc4f5f78642d3ca6c4 Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Sun, 8 Nov 2009 13:01:56 +0000 Subject: XPath: Fixed minor string to number conversion bug git-svn-id: http://pugixml.googlecode.com/svn/trunk@219 99668b35-9821-0410-8761-19e4c4f06640 --- src/pugixpath.cpp | 2 +- tests/test_xpath_functions.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pugixpath.cpp b/src/pugixpath.cpp index 70fe612..4897523 100644 --- a/src/pugixpath.cpp +++ b/src/pugixpath.cpp @@ -387,7 +387,7 @@ namespace if (is_chartype(*string, ct_space)) { while (is_chartype(*string, ct_space)) ++string; - if (*string) return gen_nan(); + return *string ? gen_nan() : r; } if (*string != '.') return gen_nan(); diff --git a/tests/test_xpath_functions.cpp b/tests/test_xpath_functions.cpp index a0c59b8..ed2c47a 100644 --- a/tests/test_xpath_functions.cpp +++ b/tests/test_xpath_functions.cpp @@ -16,11 +16,13 @@ TEST_XML(xpath_number_number, "123") CHECK_XPATH_NUMBER(c, "number(' -123.')", -123); CHECK_XPATH_NUMBER(c, "number('123.')", 123); CHECK_XPATH_NUMBER(c, "number('.56')", 0.56); + CHECK_XPATH_NUMBER(c, "number('123 ')", 123); CHECK_XPATH_NUMBER_NAN(c, "number('foobar')"); CHECK_XPATH_NUMBER_NAN(c, "number('f1')"); CHECK_XPATH_NUMBER_NAN(c, "number('1f')"); CHECK_XPATH_NUMBER_NAN(c, "number('1.f')"); CHECK_XPATH_NUMBER_NAN(c, "number('1.0f')"); + CHECK_XPATH_NUMBER_NAN(c, "number('123 f')"); // number with 1 bool argument CHECK_XPATH_NUMBER(c, "number(true())", 1); -- cgit v1.2.3