mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-09-22 10:43:39 -04:00
BR3392240: preproc: Don't fail on pasting of space expanded rvalue tokens
Reported-by: KO Myung-Hun <komh@chollian.net> Tested-by: KO Myung-Hun <komh@chollian.net> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
29
preproc.c
29
preproc.c
@@ -3640,14 +3640,35 @@ static bool paste_tokens(Token **head, const struct tokseq_match *m,
|
|||||||
if (!pasted)
|
if (!pasted)
|
||||||
pasted = true;
|
pasted = true;
|
||||||
|
|
||||||
/* No ending token */
|
|
||||||
if (!next)
|
|
||||||
error(ERR_FATAL, "No rvalue found on pasting");
|
|
||||||
|
|
||||||
/* Left pasting token is start of line */
|
/* Left pasting token is start of line */
|
||||||
if (!prev_nonspace)
|
if (!prev_nonspace)
|
||||||
error(ERR_FATAL, "No lvalue found on pasting");
|
error(ERR_FATAL, "No lvalue found on pasting");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* No ending token, this might happen in two
|
||||||
|
* cases
|
||||||
|
*
|
||||||
|
* 1) There indeed no right token at all
|
||||||
|
* 2) There is a bare "%define ID" statement,
|
||||||
|
* and @ID does expand to whitespace.
|
||||||
|
*
|
||||||
|
* So technically we need to do a grammar analysis
|
||||||
|
* in another stage of parsing, but for now lets don't
|
||||||
|
* change the behaviour people used to. Simply allow
|
||||||
|
* whitespace after paste token.
|
||||||
|
*/
|
||||||
|
if (!next) {
|
||||||
|
/*
|
||||||
|
* Zap ending space tokens and that's all.
|
||||||
|
*/
|
||||||
|
tok = (*prev_nonspace)->next;
|
||||||
|
while (tok_type_(tok, TOK_WHITESPACE))
|
||||||
|
tok = delete_Token(tok);
|
||||||
|
tok = *prev_nonspace;
|
||||||
|
tok->next = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
tok = *prev_nonspace;
|
tok = *prev_nonspace;
|
||||||
while (tok_type_(tok, TOK_WHITESPACE))
|
while (tok_type_(tok, TOK_WHITESPACE))
|
||||||
tok = delete_Token(tok);
|
tok = delete_Token(tok);
|
||||||
|
Reference in New Issue
Block a user