summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2017-08-16 22:15:39 -0700
committerH. Peter Anvin <hpa@zytor.com>2017-08-16 22:17:51 -0700
commit427b9cae8b0f195cfc4f28151c6d0565980a9ad2 (patch)
treeaa0ad2900100db15476e475d5b5f6d850592c40e
parentf05034fd5809c88d0a27cd2698e8cccca40f13a8 (diff)
downloadnasm-427b9cae8b0f195cfc4f28151c6d0565980a9ad2.tar.gz
nasm: when using -MW, enclose whitespace in double quotes
When using the -MW option, enclose whitespace-containing filenames in double quotes. There are probably quite a few other things we ought to know how to do... Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--asm/nasm.c23
-rw-r--r--doc/nasmdoc.src3
2 files changed, 25 insertions, 1 deletions
diff --git a/asm/nasm.c b/asm/nasm.c
index 213cfffb..8b5699bb 100644
--- a/asm/nasm.c
+++ b/asm/nasm.c
@@ -637,6 +637,7 @@ static char *quote_for_wmake(const char *str)
{
const char *p;
char *os, *q;
+ bool quote = false;
size_t n = 1; /* Terminating zero */
@@ -645,6 +646,15 @@ static char *quote_for_wmake(const char *str)
for (p = str; *p; p++) {
switch (*p) {
+ case ' ':
+ case '\t':
+ quote = true;
+ n++;
+ break;
+ case '\"':
+ quote = true;
+ n += 2;
+ break;
case '$':
case '#':
n += 2;
@@ -655,8 +665,14 @@ static char *quote_for_wmake(const char *str)
}
}
+ if (quote)
+ n += 2;
+
os = q = nasm_malloc(n);
+ if (quote)
+ *q++ = '\"';
+
for (p = str; *p; p++) {
switch (*p) {
case '$':
@@ -664,12 +680,19 @@ static char *quote_for_wmake(const char *str)
*q++ = '$';
*q++ = *p;
break;
+ case '\"':
+ *q++ = *p;
+ *q++ = *p;
+ break;
default:
*q++ = *p;
break;
}
}
+ if (quote)
+ *q++ = '\"';
+
*q = '\0';
return os;
diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src
index 243fb145..57a9bf0f 100644
--- a/doc/nasmdoc.src
+++ b/doc/nasmdoc.src
@@ -524,7 +524,8 @@ file has been removed.
This option causes NASM to attempt to quote dependencies according to
Watcom Make conventions rather than POSIX Make conventions (also used
by most other Make variants.) This quotes \c{#} as \c{$#} rather than
-\c{\\#}, and uses \c{&} rather than \c{\\} for continuation lines.
+\c{\\#}, uses \c{&} rather than \c{\\} for continuation lines, and
+encloses filenames containing whitespace in double quotes.
\S{opt-F} The \i\c{-F} Option: Selecting a \i{Debug Information Format}