From c3e5ab85b0c19688f7494ae44909ed4bfc63bdb7 Mon Sep 17 00:00:00 2001 From: atpx8 <52360990+SomeoneSom@users.noreply.github.com> Date: Fri, 28 Apr 2023 09:53:01 -0400 Subject: [PATCH] `__hxcpp_parse_int` now parses hex numbers with wrapping as before (#1053) * hex numbers now parse as before * negative hex parsing should be consistent now --- src/hx/StdLibs.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/hx/StdLibs.cpp b/src/hx/StdLibs.cpp index f72e5d42a..e4de722a4 100644 --- a/src/hx/StdLibs.cpp +++ b/src/hx/StdLibs.cpp @@ -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