core :: Text :: escape_to_mk
Unfortunately, some characters are not escapable in Makefile.
These characters are ;
, |
, \
, and the non-printable ones.
They will be rendered as "?{hex}"
.
# Escape to include in a Makefile
#
# Unfortunately, some characters are not escapable in Makefile.
# These characters are `;`, `|`, `\`, and the non-printable ones.
# They will be rendered as `"?{hex}"`.
fun escape_to_mk: String do
var b = new Buffer
for i in [0..length[ do
var c = chars[i]
if c == '$' then
b.append("$$")
else if c == ':' or c == ' ' or c == '#' then
b.add('\\')
b.add(c)
else if c.code_point < 32 or c == ';' or c == '|' or c == '\\' then
b.append("?{c.code_point.to_base(16)}")
else
b.add(c)
end
end
return b.to_s
end
lib/core/text/abstract_text.nit:784,2--805,4