too many line count in nextc()

This commit is contained in:
Yukihiro Matsumoto
2012-05-17 19:09:29 +09:00
parent 490fa45298
commit 89e31b5838
+21 -19
View File
@@ -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;
}