diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-08-16T10·28+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-08-16T10·28+0000 |
commit | 267064273301ee9547589fd5874eee693415352f (patch) | |
tree | 50c50e6e7976ee6136effd9417a7302d519bc5fa /src/libexpr/parser.cc | |
parent | bfe19b3c3728d90cad7575c5d2571d48f0ef0d14 (diff) |
* Handle carriage returns. Fixes NIX-53.
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)); |