mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-04-12 18:40:23 +08:00
preproc: correctly handle quoted strings inside %[...] constructs
We need to skip quoted strings when determining the ending point of %[...] constructs. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
0ca00860df
commit
ca544db4b6
25
preproc.c
25
preproc.c
@ -779,7 +779,7 @@ static char *read_line(void)
|
||||
*/
|
||||
static Token *tokenize(char *line)
|
||||
{
|
||||
char *p = line;
|
||||
char c, *p = line;
|
||||
enum pp_token_type type;
|
||||
Token *list = NULL;
|
||||
Token *t, **tail = &list;
|
||||
@ -810,12 +810,23 @@ static Token *tokenize(char *line)
|
||||
int lvl = 1;
|
||||
line += 2; /* Skip the leading %[ */
|
||||
p++;
|
||||
while (*p) {
|
||||
if (*p == ']') {
|
||||
if (!--lvl)
|
||||
break;
|
||||
} else if (*p == '%' && p[1] == '[') {
|
||||
lvl++;
|
||||
while (lvl && (c = *p)) {
|
||||
switch (c) {
|
||||
case ']':
|
||||
lvl--;
|
||||
break;
|
||||
case '%':
|
||||
p++;
|
||||
if (*p == '[')
|
||||
lvl++;
|
||||
break;
|
||||
case '\'':
|
||||
case '\"':
|
||||
case '`':
|
||||
p = nasm_skip_string(p);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user