[nasm:nasm-2.15.xx] %line: quote filenames with double spaces, use unsigned char check
nasm-bot for H. Peter Anvin (Intel)
hpa at zytor.com
Sun Jun 14 20:21:04 PDT 2020
Commit-ID: 3957f6f831909f44164012c623b0870911345129
Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=3957f6f831909f44164012c623b0870911345129
Author: H. Peter Anvin (Intel) <hpa at zytor.com>
AuthorDate: Sun, 14 Jun 2020 20:17:57 -0700
Committer: H. Peter Anvin (Intel) <hpa at zytor.com>
CommitDate: Sun, 14 Jun 2020 20:17:57 -0700
%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 at zytor.com>
---
asm/nasm.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/asm/nasm.c b/asm/nasm.c
index a9793a20..333ba70c 100644
--- a/asm/nasm.c
+++ b/asm/nasm.c
@@ -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]))
More information about the Nasm-commits
mailing list