Skip to content

Commit

Permalink
__hxcpp_parse_int now parses hex numbers with wrapping as before (H…
Browse files Browse the repository at this point in the history
…axeFoundation#1053)

* hex numbers now parse as before

* negative hex parsing should be consistent now
  • Loading branch information
SomeoneSom authored Apr 28, 2023
1 parent 8bdd667 commit c3e5ab8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/hx/StdLibs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,16 @@ Dynamic __hxcpp_parse_int(const String &inString)
while (isspace(*str)) ++str;
bool isHex = is_hex_string(str, strlen(str));
char *end = 0;
long result = strtol(str,&end,isHex ? 16 : 10);
long result;
if (isHex)
{
bool neg = str[0] == '-';
if (neg) str++;
result = strtoul(str,&end,16);
if (neg) result = -result;
}
else
result = strtol(str,&end,10);
#ifdef HX_WINDOWS
if (str==end && !isHex)
#else
Expand Down

0 comments on commit c3e5ab8

Please sign in to comment.