-
Notifications
You must be signed in to change notification settings - Fork 708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MSVC++ 12.0 float hex string parse workaround #362
Conversation
Allow parse_double_hex and parse_float_hex to parse strings without a power.
Is this affecting some new code? I checked to see where |
#if _MSC_VER <= 1800 | ||
float strtof(const char *nptr, char **endptr) { | ||
const char* end = nptr + strlen(nptr); | ||
// review:: should we check for leading whitespaces ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, probably better to match the behavior of strtof
and slip whitespace.
float strtof(const char *nptr, char **endptr) { | ||
const char* end = nptr + strlen(nptr); | ||
// review:: should we check for leading whitespaces ? | ||
if (string_starts_with(nptr, end, "0x")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can start with a leading '+' or '-' too.
It is not affecting new code. Only older MSVC compiler have bad float parsing implementation. I noticed that some recent changes prevent building in VS 2013. Notably the use of |
That seems to be the correct behavior (checked against spec interpreter). Makes sense, I think, since we don't want to make the lexer context-sensitive.
I'm not opposed to supporting VS2013 for now (though I know some others are eager to drop it). If we decide to keep it, we'll have to add an appveyor build so it doesn't regress. |
I will close this PR for now. |
Allow parse_double_hex and parse_float_hex to parse strings without a power.
In MSVC++ 12.0 (and previous versions ?) the float parsing doesn't support hex strings.
Not totally sure if it's a bug or just not supported, but this change is a workaround it for older MSVC compilers.
I tried to minimize changes to not affect modern compilers as
strtof
andstrtod
give the right result.I used
parse_float_hex
andparse_double_hex
to parse hex strings and fallback on normal implementation if not an hex string.