optimized hex digit verification a little

This commit is contained in:
unknown 2015-04-20 16:52:48 -04:00
parent ec9afe9c33
commit 3ef067f6d1
1 changed files with 9 additions and 5 deletions

View File

@ -1917,11 +1917,15 @@ stdstr CCheats::ReadOptionsString(HWND hDlg, bool &/*validcodes*/, bool &validop
int is_valid_hex_digit(char symbol)
{
if (
((symbol >= 'a') && (symbol <= 'f'))
|| ((symbol >= 'A') && (symbol <= 'F'))
|| ((symbol >= '0') && (symbol <= '9'))
)
if (symbol < '0')
return 0; /* no valid hex figures before '0' */
if (symbol <= '9')
return 1;
symbol &= ~0x20; /* in ASCII, forces lowercase to uppercase */
if (symbol < 'A')
return 0;
if (symbol <= 'Z')
return 1;
return 0;
}