diff options
author | H. Peter Anvin <hpa@zytor.com> | 2007-10-22 19:48:06 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2007-10-22 19:48:06 -0700 |
commit | 50620f4a3f78dc8fb51f76633aeeb962e29093d9 (patch) | |
tree | b508bf3842ecef2c3509f12dec57623a05a98083 /nasmlib.c | |
parent | f41aef273b05a1ed7e2608f019bd8b5d6e561924 (diff) | |
download | nasm-50620f4a3f78dc8fb51f76633aeeb962e29093d9.tar.gz |
Unbreak particularly tricky hex constants
Unbreak hex constants which contain 'b' or 'd' in potentially tricky
places.
Diffstat (limited to 'nasmlib.c')
-rw-r--r-- | nasmlib.c | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -219,7 +219,8 @@ static int radix_letter(char c) int64_t readnum(char *str, bool *error) { char *r = str, *q; - int32_t radix; + int32_t pradix, sradix, radix; + int plen, slen; uint64_t result, checklimit; int digit, last; bool warn = false; @@ -251,14 +252,26 @@ int64_t readnum(char *str, bool *error) * $<string> (hexadecimal) * <string><radix-letter> */ - if (*r == '0' && (radix = radix_letter(r[1]))) - r += 2; + pradix = sradix = 0; + plen = slen = 0; + + if (*r == '0' && (pradix = radix_letter(r[1])) != 0) + plen = 2; else if (*r == '$') - radix = 16, r++; - else if ((radix = radix_letter(q[-1])) != 0) - q--; - else + pradix = 16, plen = 1; + + if ((sradix = radix_letter(q[-1])) != 0) + slen = 1; + + if (pradix && pradix > sradix) { + radix = pradix; + r += plen; + } else if (sradix && sradix > pradix) { + radix = sradix; + q -= slen; + } else { radix = 10; + } /* * If this number has been found for us by something other than |