diff options
Diffstat (limited to 'src/libexpr/parser.cc')
-rw-r--r-- | src/libexpr/parser.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/libexpr/parser.cc b/src/libexpr/parser.cc index 9b3e9041dfc1..fa6c4e2f3225 100644 --- a/src/libexpr/parser.cc +++ b/src/libexpr/parser.cc @@ -79,11 +79,16 @@ Expr unescapeStr(const char * s) if (c == '\\') { assert(*s); c = *s++; - if (c == 'n') t += "\n"; - else if (c == 'r') t += "\r"; - else if (c == 't') t += "\t"; + if (c == 'n') t += '\n'; + else if (c == 'r') t += '\r'; + else if (c == 't') t += '\t'; else t += c; } + else if (c == '\r') { + /* Normalise CR and CR/LF into LF. */ + t += '\n'; + if (*s == '\n') s++; /* cr/lf */ + } else t += c; } return makeStr(toATerm(t)); |