diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-10-19 19:30:11 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-10-19 19:30:11 -0700 |
commit | ca544db4b6de0cb994a2eef65cc2e5e47079254b (patch) | |
tree | 9fe5b8798b6f3aa93126268189a4488a2e9fc416 | |
parent | 0ca00860dfde882f384658409a0d14a3b46fc108 (diff) | |
download | nasm-ca544db4b6de0cb994a2eef65cc2e5e47079254b.tar.gz |
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>
-rw-r--r-- | preproc.c | 25 |
1 files changed, 18 insertions, 7 deletions
@@ -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++; } |