From 3229e677120550a5a40b5b37ec46de6c2cad974c Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Mon, 21 Sep 2015 00:35:57 -0700 Subject: Fix parsing of integers that start with + This matches the format strtol supports. --- src/pugixml.cpp | 2 +- tests/test_dom_traverse.cpp | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/pugixml.cpp b/src/pugixml.cpp index ea6514b..e166142 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -4440,7 +4440,7 @@ PUGI__NS_BEGIN bool negative = (*s == '-'); - s += negative; + s += (*s == '+' || *s == '-'); bool overflow = false; diff --git a/tests/test_dom_traverse.cpp b/tests/test_dom_traverse.cpp index 1fbc317..c7408cb 100644 --- a/tests/test_dom_traverse.cpp +++ b/tests/test_dom_traverse.cpp @@ -1224,4 +1224,21 @@ TEST_XML(dom_as_ullong_hex_overflow, "") +{ + xml_node node = doc.child(STR("node")); + + CHECK(node.attribute(STR("attr1")).as_int() == 1); + CHECK(node.attribute(STR("attr1")).as_uint() == 1); + CHECK(node.attribute(STR("attr2")).as_int() == 10); + CHECK(node.attribute(STR("attr2")).as_uint() == 10); + +#ifdef PUGIXML_HAS_LONG_LONG + CHECK(node.attribute(STR("attr1")).as_llong() == 1); + CHECK(node.attribute(STR("attr1")).as_ullong() == 1); + CHECK(node.attribute(STR("attr2")).as_llong() == 10); + CHECK(node.attribute(STR("attr2")).as_ullong() == 10); +#endif +} \ No newline at end of file -- cgit v1.2.3