summaryrefslogtreecommitdiff
path: root/stdscan.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-10-22 16:53:48 -0700
committerH. Peter Anvin <hpa@zytor.com>2007-10-22 16:53:48 -0700
commitbea0bbb62c9947421bc0fddcd2b58a40435e2181 (patch)
tree21623213cc08b04a9eb771b2a46bb1e057a1948c /stdscan.c
parent3b2ad1bc370653e90d6b2fa9cfc587a7aea405f3 (diff)
downloadnasm-bea0bbb62c9947421bc0fddcd2b58a40435e2181.tar.gz
More consistent handling of radix letters
Allow any radix letter from the set [bydtoqhx] to be used either "Intel-style" (0...x) or "C-style" (0x...). In Intel style, the leading 0 remains optional as long as the first digit is in the range 0-9. As a consequence, allow the prefix "0h" for hexadecimal floating point.
Diffstat (limited to 'stdscan.c')
-rw-r--r--stdscan.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/stdscan.c b/stdscan.c
index 9235b08f..dda4e0a3 100644
--- a/stdscan.c
+++ b/stdscan.c
@@ -119,13 +119,14 @@ int stdscan(void *private_data, struct tokenval *tv)
bool is_hex = false;
bool is_float = false;
bool has_e = false;
- bool has_h = false;
char c;
- r = stdscan_bufptr++;
+ r = stdscan_bufptr;
- if (r[0] == '$' || (r[0] == '0' || (r[1] == 'x' || r[1] == 'X')))
+ if (*stdscan_bufptr == '$') {
+ stdscan_bufptr++;
is_hex = true;
+ }
for (;;) {
c = *stdscan_bufptr++;
@@ -138,9 +139,9 @@ int stdscan(void *private_data, struct tokenval *tv)
is_float = true;
stdscan_bufptr++;
}
- } else if (c == 'H' || c == 'h') {
- has_h = true;
- } else if (is_hex & (c == 'P' || c == 'p')) {
+ } else if (c == 'H' || c == 'h' || c == 'X' || c == 'x') {
+ is_hex = true;
+ } else if (is_hex && (c == 'P' || c == 'p')) {
is_float = true;
if (*stdscan_bufptr == '+' || *stdscan_bufptr == '-')
stdscan_bufptr++;
@@ -153,7 +154,7 @@ int stdscan(void *private_data, struct tokenval *tv)
}
stdscan_bufptr--; /* Point to first character beyond number */
- if (has_e && !has_h) {
+ if (has_e && !is_hex) {
/* 1e13 is floating-point, but 1e13h is not */
is_float = true;
}