mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
too many line count in nextc()
This commit is contained in:
+21
-19
@@ -3003,29 +3003,31 @@ nextc(parser_state *p)
|
||||
p->pb = p->pb->cdr;
|
||||
cons_free(tmp);
|
||||
}
|
||||
else if (p->f) {
|
||||
if (feof(p->f)) return -1;
|
||||
c = fgetc(p->f);
|
||||
if (c == EOF) return -1;
|
||||
}
|
||||
else if (!p->s || p->s >= p->send) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
c = *p->s++;
|
||||
}
|
||||
if (c == '\n') {
|
||||
if (p->column < 0) {
|
||||
p->column++; // pushback caused an underflow
|
||||
if (p->f) {
|
||||
if (feof(p->f)) return -1;
|
||||
c = fgetc(p->f);
|
||||
if (c == EOF) return -1;
|
||||
}
|
||||
else if (!p->s || p->s >= p->send) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
p->lineno++;
|
||||
p->column = 0;
|
||||
c = *p->s++;
|
||||
}
|
||||
if (c == '\n') {
|
||||
if (p->column < 0) {
|
||||
p->column++; // pushback caused an underflow
|
||||
}
|
||||
else {
|
||||
p->lineno++;
|
||||
p->column = 0;
|
||||
}
|
||||
// must understand heredoc
|
||||
}
|
||||
else {
|
||||
p->column++;
|
||||
}
|
||||
// must understand heredoc
|
||||
}
|
||||
else {
|
||||
p->column++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user