make SWIgetc check for EOF and \n

This commit is contained in:
Vítor Santos Costa 2010-12-19 14:10:25 +00:00
parent cede94f6d2
commit ae89fa5728
1 changed files with 14 additions and 6 deletions

View File

@ -827,12 +827,16 @@ IOSWIPutc(int sno, int ch)
static int static int
IOSWIGetc(int sno) IOSWIGetc(int sno)
{ {
int i; int ch;
Yap_StartSlots(); 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(); Yap_CloseSlots();
YENV = ENV; YENV = ENV;
return i; return ch;
} }
/* static */ /* static */
@ -851,12 +855,16 @@ IOSWIWidePutc(int sno, int ch)
static int static int
IOSWIWideGetc(int sno) IOSWIWideGetc(int sno)
{ {
int i; int ch;
Yap_StartSlots(); 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(); Yap_CloseSlots();
YENV = ENV; YENV = ENV;
return i; return ch;
} }
#if USE_SOCKET #if USE_SOCKET