* Handle carriage returns. Fixes NIX-53.
This commit is contained in:
parent
bfe19b3c37
commit
2670642733
|
@ -21,6 +21,10 @@ static void adjustLoc(YYLTYPE * loc, const char * s, size_t len)
|
|||
{
|
||||
while (len--) {
|
||||
switch (*s++) {
|
||||
case '\r':
|
||||
if (*s == '\n') /* cr/lf */
|
||||
s++;
|
||||
/* fall through */
|
||||
case '\n':
|
||||
++loc->first_line;
|
||||
loc->first_column = 1;
|
||||
|
@ -85,8 +89,8 @@ inherit { return INHERIT; }
|
|||
{PATH} { yylval->t = toATerm(yytext); return PATH; /* !!! alloc */ }
|
||||
{URI} { yylval->t = toATerm(yytext); return URI; /* !!! alloc */ }
|
||||
|
||||
[ \t\n]+ /* eat up whitespace */
|
||||
\#[^\n]* /* single-line comments */
|
||||
[ \t\r\n]+ /* eat up whitespace */
|
||||
\#[^\r\n]* /* single-line comments */
|
||||
\/\*([^*]|\*[^\/])*\*\/ /* long comments */
|
||||
|
||||
. return yytext[0];
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue