summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pugixpath.cpp9
-rw-r--r--tests/test_xpath_parse.cpp6
-rw-r--r--tests/test_xpath_xalan_5.cpp6
3 files changed, 11 insertions, 10 deletions
diff --git a/src/pugixpath.cpp b/src/pugixpath.cpp
index 00cb56d..a22943b 100644
--- a/src/pugixpath.cpp
+++ b/src/pugixpath.cpp
@@ -861,7 +861,8 @@ namespace pugi
lex_axis_attribute,
lex_dot,
lex_double_dot,
- lex_double_colon
+ lex_double_colon,
+ lex_eof
};
struct xpath_lexer_string
@@ -926,7 +927,7 @@ namespace pugi
switch (*m_cur)
{
case 0:
- m_cur_lexeme = lex_none;
+ m_cur_lexeme = lex_eof;
break;
case '>':
@@ -1118,7 +1119,7 @@ namespace pugi
while (IS_CHARTYPEX(*m_cur, ctx_digit)) m_cur++;
- if (*m_cur == '.' && IS_CHARTYPEX(*(m_cur+1), ctx_digit))
+ if (*m_cur == '.')
{
m_cur++;
@@ -3558,7 +3559,7 @@ namespace pugi
{
xpath_ast_node* result = parse_expression();
- if (m_lexer.current() != lex_none)
+ if (m_lexer.current() != lex_eof)
{
// there are still unparsed tokens left, error
throw xpath_exception("Incorrect query");
diff --git a/tests/test_xpath_parse.cpp b/tests/test_xpath_parse.cpp
index bedb3e9..0caf104 100644
--- a/tests/test_xpath_parse.cpp
+++ b/tests/test_xpath_parse.cpp
@@ -29,6 +29,7 @@ TEST(xpath_number_parse)
CHECK_XPATH_NUMBER(c, STR("123.456"), 123.456);
CHECK_XPATH_NUMBER(c, STR(".123"), 0.123);
CHECK_XPATH_NUMBER(c, STR("123.4567890123456789012345"), 123.4567890123456789012345);
+ CHECK_XPATH_NUMBER(c, STR("123."), 123);
}
TEST(xpath_number_error)
@@ -225,12 +226,11 @@ TEST(xpath_parse_jaxen_invalid)
STR("///triple slash"), STR("/numbers numbers"), STR("/a/b[c > d]efg"), STR("/inv/child::"), STR("/invoice/@test[abcd"),
STR("/invoice/@test[abcd > x"), STR("string-length('a"), STR("/descendant::()"), STR("(1 + 1"), STR("!false()"),
STR("$author"), STR("10 + $foo"), STR("$foo:bar"), STR("$varname[@a='1']"), STR("foo/$variable/foo"),
- STR(".[1]"), STR("chyld::foo"), STR("foo/tacos()"), STR("foo/tacos()"), STR("/foo/bar[baz"), STR("//"), // STR("*:foo"), $$ should not compile
+ STR(".[1]"), STR("chyld::foo"), STR("foo/tacos()"), STR("foo/tacos()"), STR("/foo/bar[baz"), STR("//"), STR("*:foo"),
STR("/cracker/cheese[(mold > 1) and (sense/taste"),
// From xpath-as3 tests
- STR("a b"), STR("//self::node())"), STR("/x/y[contains(self::node())"), STR("/x/y[contains(self::node()]"), STR("///"),
- STR("text::a"), // STR("***"), $$ should not compile
+ STR("a b"), STR("//self::node())"), STR("/x/y[contains(self::node())"), STR("/x/y[contains(self::node()]"), STR("///"), STR("text::a"),
// From haXe-xpath tests
STR("|/gjs"), STR("+3"), STR("/html/body/p != ---'div'/a"), STR(""), STR("@"), STR("#akf"), STR(",")
diff --git a/tests/test_xpath_xalan_5.cpp b/tests/test_xpath_xalan_5.cpp
index c1e7b18..3a71bc2 100644
--- a/tests/test_xpath_xalan_5.cpp
+++ b/tests/test_xpath_xalan_5.cpp
@@ -68,8 +68,8 @@ TEST_XML(xpath_xalan_select_6, "<div div='20' div-5='12'>9</div>")
CHECK_XPATH_NUMBER(doc, STR("(* - 4) div 2"), 2.5);
CHECK_XPATH_NUMBER(doc, STR("' 6 ' div 2"), 3);
CHECK_XPATH_NUMBER(doc, STR("' 6 '*div"), 54);
- // CHECK_XPATH_NUMBER(doc, STR("5.*."), 45); $$ should work
- // CHECK_XPATH_NUMBER(doc, STR("5.+."), 14); $$ should work
+ CHECK_XPATH_NUMBER(doc, STR("5.*."), 45);
+ CHECK_XPATH_NUMBER(doc, STR("5.+."), 14);
}
TEST_XML(xpath_xalan_select_7, "<doc div='20'><div>9</div><attribute>8</attribute></doc>")
@@ -235,7 +235,7 @@ TEST(xpath_xalan_error_namespace)
CHECK_XPATH_FAIL(STR("namespace-uri(baz2:b,..)"));
CHECK_XPATH_FAIL(STR("name(a,b)"));
CHECK_XPATH_FAIL(STR(":foo"));
- // CHECK_XPATH_FAIL(STR("*:foo")); $$ should not compile
+ CHECK_XPATH_FAIL(STR("*:foo"));
}
TEST(xpath_xalan_error_position)