From 47edac436bba78e48567f8501379a845b7ba421d Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 27 Aug 2016 01:40:11 +0000 Subject: [PATCH] Support hex constants in scriptfile_getsymbolvalue() git-svn-id: https://svn.eduke32.com/eduke32@5822 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/scriptfile.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/polymer/eduke32/build/src/scriptfile.c b/polymer/eduke32/build/src/scriptfile.c index ebdc2b8a1..e07dbba89 100644 --- a/polymer/eduke32/build/src/scriptfile.c +++ b/polymer/eduke32/build/src/scriptfile.c @@ -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;