View source code
Display the source code in dmd/utils.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Function dmd.utils.writeEscapedMakePath

Takes a path, and make it compatible with GNU Makefile format.

void writeEscapedMakePath (
  ref OutBuffer buf,
  const(char)* fname

GNU make uses a weird quoting scheme for white space. A space or tab preceded by 2N+1 backslashes represents N backslashes followed by space; a space or tab preceded by 2N backslashes represents N backslashes at the end of a file name; and backslashes in other contexts should not be doubled.


buf Buffer to write the escaped path to
fname Path to escape


version (Windows)
    enum input = `C:\My Project\file#4$.ext`;
    enum expected = `C:\My\ Project\file\#4$$.ext`;
    enum input = `/foo\bar/weird$.:name#\ with spaces.ext`;
    enum expected = `/foo\bar/weird$$.\:name\#\\\ with\ spaces.ext`;

OutBuffer buf;
writeln(buf[]); // expected


Walter Bright


Boost License 1.0