mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-09-22 10:43:39 -04:00
preproc: fix list corruption bug; clean up token handling
expand_one_smacro() would corrupt the end of the list if a macro expanded to another macro with arguments, which was also the last part of the expansion. Instead of doing all that testing with ttail, just scan forward at the end to find the tail pointer; it is O(n) regardless. Clean up the handling of tokens: use inline functions rather than odd macros that sometimes modify their arguments and sometimes don't, and fold some common code into new functions. The tok_is() and tok_isnt() functions always are used with single characters, so make it explicitly so (and remove the local hacks used in some places.) Allow using nasm_malloc() rather than blocked Tokens; this makes tools like valgrind more useful in their reports. For the future, consider making Tokens a separate memory allocation immediately followed by the text, instead of using a pointer; we allocate space for the string in almost every case anyway. Also consider making it a doubly linked list... Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
623
asm/preproc.c
623
asm/preproc.c
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user