Skip to content

Commit

Permalink
preproc: fix pasting of TOKEN_HERE, TOKEN_BASE and TOKEN_QMARK
Browse files Browse the repository at this point in the history
Make the pasting behavior of TOKEN_QMARK, TOKEN_HERE and TOKEN_BASE
match the NASM 2.15 behavior: ? is a keyword and pastes as an ID, $
and $$ are treated as operators (which doesn't seem to make much
sense, but it is the current legacy behavior.)

Reported-by: C. Masloch <[email protected]>
Bugzilla: https://bugzilla.nasm.us/show_bug.cgi?id=3392733
Signed-off-by: H. Peter Anvin (Intel) <[email protected]>
  • Loading branch information
H. Peter Anvin (Intel) committed Mar 24, 2021
1 parent 6d95cc8 commit 5368e45
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions asm/preproc.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 1996-2020 The NASM Authors - All Rights Reserved
* Copyright 1996-2021 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
Expand Down Expand Up @@ -1478,7 +1478,7 @@ static Token *tokenize(const char *line)
p++;
} else if (nasm_isidstart(*p) || (*p == '$' && nasm_isidstart(p[1]))) {
/*
* A regular identifier. This includes keywords, which are not
* A regular identifier. This includes keywords which are not
* special to the preprocessor.
*/
type = TOKEN_ID;
Expand Down Expand Up @@ -4907,7 +4907,8 @@ static inline bool pp_concat_match(const Token *t, enum concat_flags mask)

switch (t->type) {
case TOKEN_ID:
ctype = CONCAT_ID; /* Ought this include $ and $$? */
case TOKEN_QMARK: /* Keyword, treated as ID for pasting */
ctype = CONCAT_ID;
break;
case TOKEN_LOCAL_MACRO:
ctype = CONCAT_LOCAL_MACRO;
Expand All @@ -4922,6 +4923,11 @@ static inline bool pp_concat_match(const Token *t, enum concat_flags mask)
case TOKEN_FLOAT:
ctype = CONCAT_NUM;
break;
case TOKEN_HERE:
case TOKEN_BASE:
/* NASM 2.15 treats these as operators, but is that sane? */
ctype = CONCAT_OP;
break;
case TOKEN_OTHER:
ctype = CONCAT_OP; /* For historical reasons */
break;
Expand Down

0 comments on commit 5368e45

Please sign in to comment.