Fix parsing of integers that start with +
This matches the format strtol supports.
This commit is contained in:
parent
b0b84277fa
commit
3229e67712
2 changed files with 19 additions and 2 deletions
|
@ -4440,7 +4440,7 @@ PUGI__NS_BEGIN
|
|||
|
||||
bool negative = (*s == '-');
|
||||
|
||||
s += negative;
|
||||
s += (*s == '+' || *s == '-');
|
||||
|
||||
bool overflow = false;
|
||||
|
||||
|
|
|
@ -1224,4 +1224,21 @@ TEST_XML(dom_as_ullong_hex_overflow, "<node attr1='-0x1' attr2='0x10000000000000
|
|||
CHECK(node.attribute(STR("attr2")).as_ullong() == 18446744073709551615ull);
|
||||
CHECK(node.attribute(STR("attr3")).as_ullong() == 18446744073709551615ull);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
TEST_XML(dom_as_int_plus, "<node attr1='+1' attr2='+0xa' />")
|
||||
{
|
||||
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
|
||||
}
|
Loading…
Add table
Reference in a new issue