diff options
author | H. Peter Anvin (Intel) <hpa@zytor.com> | 2020-06-14 20:17:57 -0700 |
---|---|---|
committer | H. Peter Anvin (Intel) <hpa@zytor.com> | 2020-06-14 20:17:57 -0700 |
commit | 3957f6f831909f44164012c623b0870911345129 (patch) | |
tree | c3c474f780b59a520e06c0fcc5dc1a03b83b6d41 /asm | |
parent | b292748d9f5fc2ac89a75df4b160a1451a767851 (diff) | |
download | nasm-3957f6f831909f44164012c623b0870911345129.tar.gz |
%line: quote filenames with double spaces, use unsigned char check
Filenames with double spaces need to be quoted; the preprocessor will
otherwise collapse spaces into one.
When comparing for control characters and spaces, use an unsigned
compare.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Diffstat (limited to 'asm')
-rw-r--r-- | asm/nasm.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -446,13 +446,15 @@ static int64_t make_posix_time(const struct tm *tm) * It is considered necessary if any one of these is true: * 1. The filename contains control characters; * 2. The filename starts or ends with a space or quote mark; - * 3. The filename is empty. + * 3. The filename contains more than one space in a row; + * 4. The filename is empty. * * The filename is returned in a newly allocated buffer. */ static char *nasm_quote_filename(const char *fn) { - const char *p = fn; + const unsigned char *p = + (const unsigned char *)fn; if (!p || !*p) return nasm_strdup("\"\""); @@ -460,9 +462,12 @@ static char *nasm_quote_filename(const char *fn) if (*p <= ' ' || nasm_isquote(*p)) { goto quote; } else { + unsigned char cutoff = ' '; + while (*p) { - if (*p < ' ') + if (*p < cutoff) goto quote; + cutoff = ' ' + (*p == ' '); p++; } if (p[-1] <= ' ' || nasm_isquote(p[-1])) |