Support hex constants in scriptfile_getsymbolvalue()

git-svn-id: https://svn.eduke32.com/eduke32@5822 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2016-08-27 01:40:11 +00:00
parent ae5f941ad0
commit 47edac436b

View file

@ -349,6 +349,20 @@ static char *getsymbtabspace(int32_t reqd)
int32_t scriptfile_getsymbolvalue(char const *name, int32_t *val)
{
if (Bstrlen(name) > 2)
{
if (tolower(name[1]) == 'x') // hex constants
{
int64_t x;
sscanf(name + 2, "%" PRIx64 "", &x);
if (EDUKE32_PREDICT_FALSE(x > UINT32_MAX))
initprintf("warning: number 0x%" PRIx64 " truncated to 32 bits.\n", x);
*val = x;
return 1;
}
}
char *scanner = symbtab;
if (!symbtab) return 0;