writeEscapedMakePath

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

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.

void
writeEscapedMakePath
(,
const(char)* fname
)

Parameters

buf OutBuffer

Buffer to write the escaped path to

fname const(char)*

Path to escape

Examples

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

OutBuffer buf;
buf.writeEscapedMakePath(input);
assert(buf[] == expected);

Meta