directiv.c: $-hex requires nasm_isnumstart, not just nasm_isnumchar

For identifier-escapes beginning with $a-f to work, the $ hexadecimal
prefix cannot be used, nor could it ever be used, with A-F immediately
after the $. This is the main reason the $-hex has been deprecated.

When adding the non-dollarhex mode, this got accidentally promoted to
nasm_isnumchar() instead of nasm_isnumstart(), which broke using
$-escaped identifiers in directives.

To fix this properly, it would be a good thing to add a central
identifier-skipping function.

Fixes: https://github.com/netwide-assembler/nasm/issues/223
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel) 2026-06-25 14:52:33 -07:00
parent 19125b6d46
commit 1fc631a173
2 changed files with 3 additions and 1 deletions

View file

@ -395,7 +395,7 @@ bool process_directives(char *directive)
value++; /* skip escaping $ if present */
validid = nasm_isidchar(*value);
if (globl.dollarhex)
validid &= !nasm_isnumchar(*value);
validid &= !nasm_isnumstart(value[1]);
} else {
validid = nasm_isidstart(*value);
}

View file

@ -11,3 +11,5 @@ global_after:
extern_after:
nop
extern extern_after
extern $foo
jmp foo