handle CR before LF; close #1781

parent 3b339ed4
......@@ -3327,6 +3327,7 @@ backref_error(parser_state *p, node *n)
}
}
static void pushback(parser_state *p, int c);
static mrb_bool peeks(parser_state *p, const char *s);
static mrb_bool skips(parser_state *p, const char *s);
......@@ -3360,6 +3361,14 @@ nextc(parser_state *p)
}
}
p->column++;
if (c == '\r') {
c = nextc(p);
if (c != '\n') {
pushback(p, c);
return '\r';
}
return c;
}
return c;
eof:
......@@ -3814,44 +3823,27 @@ parse_string(parser_state *p)
if (c == end || c == beg) {
tokadd(p, c);
}
else if ((c == '\n') && (type & STR_FUNC_ARRAY)) {
else if (c == '\n') {
p->lineno++;
p->column = 0;
if (type & STR_FUNC_ARRAY) {
tokadd(p, '\n');
}
else {
if (type & STR_FUNC_REGEXP) {
if (c == 'u') {
pushback(p, c);
tokadd(p, read_escape(p));
}
else {
tokadd(p, '\\');
if (c >= 0)
tokadd(p, c);
}
}
else {
pushback(p, c);
tokadd(p, read_escape(p));
}
if (hinf)
hinf->line_head = FALSE;
}
}
else {
if (c != beg && c != end) {
switch (c) {
case '\n':
if (c == '\n') {
p->lineno++;
p->column = 0;
break;
case '\\':
break;
default:
if (! ISSPACE(c))
}
if (!(c == '\\' || ((type & STR_FUNC_ARRAY) && ISSPACE(c)))) {
tokadd(p, '\\');
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment