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>
This commit is contained in:
H. Peter Anvin 2017-08-16 22:15:39 -07:00
parent f05034fd58
commit 427b9cae8b
2 changed files with 25 additions and 1 deletions

View file

@ -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;

View file

@ -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}