From ca544db4b6de0cb994a2eef65cc2e5e47079254b Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Sun, 19 Oct 2008 19:30:11 -0700 Subject: [PATCH] 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 --- preproc.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/preproc.c b/preproc.c index e83abbe9..434383b5 100644 --- a/preproc.c +++ b/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++; } -- 2.11.4.GIT