diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-11-08 17:22:59 -0800 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-11-08 17:22:59 -0800 |
| commit | ec0a94dae6c08b427af2df3434704cf30b6f1edb (patch) | |
| tree | c899e6c53c634752b2aa386502e3925149d3d7d2 /src | |
| parent | f80401de6c9b7dd9e0676c4414aae7a6e033ac5f (diff) | |
| parent | fa71403bc5578cff9dfa8a9de36026bd9b6b0220 (diff) | |
| download | mruby-ec0a94dae6c08b427af2df3434704cf30b6f1edb.tar.gz mruby-ec0a94dae6c08b427af2df3434704cf30b6f1edb.zip | |
Merge pull request #1565 from Fleurer/fix1564
nextc(): always return an '\n' at end of input
Diffstat (limited to 'src')
| -rw-r--r-- | src/parse.y | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/parse.y b/src/parse.y index 168850bcc..b60316cee 100644 --- a/src/parse.y +++ b/src/parse.y @@ -3316,14 +3316,14 @@ nextc(parser_state *p) else { #ifdef ENABLE_STDIO if (p->f) { - if (feof(p->f)) goto end_retry; + if (feof(p->f)) goto eof; c = fgetc(p->f); - if (c == EOF) goto end_retry; + if (c == EOF) goto eof; } else #endif if (!p->s || p->s >= p->send) { - goto end_retry; + goto eof; } else { c = (unsigned char)*p->s++; @@ -3332,14 +3332,20 @@ nextc(parser_state *p) p->column++; return c; - end_retry: + eof: + if (!p->eof) { + p->eof = TRUE; + return '\n'; + } + if (!p->cxt) return -1; else { mrbc_context *cxt = p->cxt; if (cxt->partial_hook(p) < 0) return -1; - c = '\n'; - p->lineno = 1; + p->eof = FALSE; + p->cxt = NULL; + c = nextc(p); p->cxt = cxt; return c; } |
