From f6a727beb4e204a42c1d90270773326cc56c8bc0 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Mon, 29 Jun 2015 02:04:55 +0900 Subject: [PATCH] cleanup pic_read --- extlib/benz/read.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/extlib/benz/read.c b/extlib/benz/read.c index d82eebf9..c7abf434 100644 --- a/extlib/benz/read.c +++ b/extlib/benz/read.c @@ -857,23 +857,20 @@ pic_read(pic_state *pic, struct pic_port *port) { size_t ai = pic_gc_arena_preserve(pic); pic_value val; - int c = next(pic, port); + int c; - retry: - c = skip(pic, port, c); + while ((c = skip(pic, port, next(pic, port))) != EOF) { + val = read_nullable(pic, port, c); + if (! pic_invalid_p(val)) { + break; + } + pic_gc_arena_restore(pic, ai); + } if (c == EOF) { return pic_eof_object(); } - val = read_nullable(pic, port, c); - - if (pic_invalid_p(val)) { - c = next(pic, port); - pic_gc_arena_restore(pic, ai); - goto retry; - } - pic_gc_arena_restore(pic, ai); return pic_gc_protect(pic, val); }