Fix #18263: ImportC fails when DMD is installed in path with spaces (#21263)

Fixes https://github.com/dlang/dmd/issues/18263

Command to invoke the preprocessor wasn't quoting paths.

This isn't bulletproof and really the interface should be taking an
array of strings or use a command-builder type pattern, but this
resolves the common issue of paths with spaces in them.
This commit is contained in:
drpriver 2025-04-18 12:35:39 -07:00 committed by GitHub
parent 011c27165e
commit 0845912f27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -993,7 +993,7 @@ public int runPreprocessor(Loc loc, const(char)[] cpp, const(char)[] filename, c
*/
OutBuffer buf;
buf.writestring(cpp);
buf.printf(" /P /Zc:preprocessor /PD /nologo /utf-8 %.*s /FI%s /Fi%.*s",
buf.printf(" /P /Zc:preprocessor /PD /nologo /utf-8 \"%.*s\" \"/FI%s\" \"/Fi%.*s\"",
cast(int)filename.length, filename.ptr, importc_h, cast(int)output.length, output.ptr);
/* Append preprocessor switches to command line