Skip to content

Commit

Permalink
Debugger: Allow setting regs to inf/nan.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Apr 15, 2018
1 parent 5b37e13 commit 6a3c12a
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions Core/Debugger/WebSocket/WebSocketUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,27 @@ static bool U32FromString(const char *str, uint32_t *out, bool allowFloat) {
return true;
}

// We have to try float last because we use float bits.
union {
uint32_t u;
float f;
} bits;
if (allowFloat && TryParse(str, &bits.f)) {
*out = bits.u;
return true;
// We have to try float last because we use float bits, so 1.0 != 1.
if (allowFloat) {
union {
uint32_t u;
float f;
} bits;
if (TryParse(str, &bits.f)) {
*out = bits.u;
return true;
}

if (!strcasecmp(str, "nan")) {
*out = 0x7FC00000;
return true;
} else if (!strcasecmp(str, "infinity") || !strcasecmp(str, "inf")) {
*out = 0x7F800000;
return true;
} else if (!strcasecmp(str, "-infinity") || !strcasecmp(str, "-inf")) {
*out = 0xFF800000;
return true;
}
}

return false;
Expand Down

0 comments on commit 6a3c12a

Please sign in to comment.