From ae89fa5728982c328ab0d09f00553fc73f7974e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Sun, 19 Dec 2010 14:10:25 +0000 Subject: [PATCH] make SWIgetc check for EOF and \n --- C/iopreds.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/C/iopreds.c b/C/iopreds.c index c40145f7d..01f17ba6e 100644 --- a/C/iopreds.c +++ b/C/iopreds.c @@ -827,12 +827,16 @@ IOSWIPutc(int sno, int ch) static int IOSWIGetc(int sno) { - int i; + int ch; Yap_StartSlots(); - i = (SWIGetc)(Stream[sno].u.swi_stream.swi_ptr); + ch = (SWIGetc)(Stream[sno].u.swi_stream.swi_ptr); + if (ch == EOF) { + return post_process_eof(Stream+sno); + } + return post_process_read_char(ch, Stream+sno); Yap_CloseSlots(); YENV = ENV; - return i; + return ch; } /* static */ @@ -851,12 +855,16 @@ IOSWIWidePutc(int sno, int ch) static int IOSWIWideGetc(int sno) { - int i; + int ch; Yap_StartSlots(); - i = (SWIWideGetc)(Stream[sno].u.swi_stream.swi_ptr); + ch = (SWIWideGetc)(Stream[sno].u.swi_stream.swi_ptr); + if (ch == EOF) { + return post_process_eof(Stream+sno); + } + return post_process_read_char(ch, Stream+sno); Yap_CloseSlots(); YENV = ENV; - return i; + return ch; } #if USE_SOCKET