From bd822fa4c6c918b89dd1f23fbd31dca181f8460c Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Wed, 25 Jun 2014 21:40:18 +0900 Subject: [PATCH] fix EOF handling --- src/read.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/read.c b/src/read.c index 62c456b2..15416251 100644 --- a/src/read.c +++ b/src/read.c @@ -530,6 +530,23 @@ read(pic_state *pic, struct pic_port *port, char c) { pic_value val; + retry: + val = read_nullable(pic, port, c); + + if (pic_undef_p(val)) { + c = next(port); + goto retry; + } + + return val; +} + +pic_value +pic_read(pic_state *pic, struct pic_port *port) +{ + pic_value val; + char c = next(port); + retry: c = skip(port, c); @@ -547,16 +564,6 @@ read(pic_state *pic, struct pic_port *port, char c) return val; } -pic_value -pic_read(pic_state *pic, struct pic_port *port) -{ - char c; - - c = next(port); - - return read(pic, port, c); -} - pic_value pic_read_cstr(pic_state *pic, const char *str) {