summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-06-08 00:51:01 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-06-08 01:38:44 +0900
commitd75b84016cc152b7efcffaa3d50fd339419aaf6a (patch)
treeb8c24b17a88696024afb1d375e8623dc1c043d7a
parenta13e8f5ee1bd4db95ef678fde66542703fb8ebe2 (diff)
downloadmruby-d75b84016cc152b7efcffaa3d50fd339419aaf6a.tar.gz
mruby-d75b84016cc152b7efcffaa3d50fd339419aaf6a.zip
do not ignore negative characters (e.g. EOF and partial EOF); fix #2361 fix #2369
-rw-r--r--src/parse.y11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/parse.y b/src/parse.y
index ba295b7e0..9841351ea 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -3373,7 +3373,9 @@ nextc(parser_state *p)
c = (unsigned char)*p->s++;
}
}
- p->column++;
+ if (c >= 0) {
+ p->column++;
+ }
if (c == '\r') {
c = nextc(p);
if (c != '\n') {
@@ -3396,8 +3398,9 @@ nextc(parser_state *p)
static void
pushback(parser_state *p, int c)
{
- if (c < 0) return;
- p->column--;
+ if (c >= 0) {
+ p->column--;
+ }
p->pb = cons((node*)(intptr_t)c, p->pb);
}
@@ -3421,7 +3424,7 @@ peekc_n(parser_state *p, int n)
do {
c0 = nextc(p);
- if (c0 < 0) return c0;
+ if (c0 == -1) return c0; /* do not skip partial EOF */
list = push(list, (node*)(intptr_t)c0);
} while(n--);
if (p->pb) {