static int PipePutc (int sno, int ch) { StreamDesc *s = &GLOBAL_Stream[sno]; char c = ch; #if MAC || _MSC_VER if (ch == 10) { ch = '\n'; } #endif { int out = 0; while (!out) { out = write(s->u.pipe.fd, &c, sizeof(c)); if (out <0) { #if HAVE_STRERROR Yap_Error(PERMISSION_ERROR_INPUT_STREAM, TermNil, "error writing stream pipe: %s", strerror(errno)); #else Yap_Error(PERMISSION_ERROR_INPUT_STREAM, TermNil, "error writing stream pipe"); #endif } } } console_count_output_char(ch,s); return ((int) ch); }
/* static */ static int ConsolePutc(int sno, int ch) { StreamDesc *s = &GLOBAL_Stream[sno]; if (ch == 10) { #if MAC || _WIN32 fputs("\n", s->file); #else putc('\n', s->file); #endif LOCAL_newline = true; } else putc(ch, s->file); #if MAC || _WIN32 fflush( NULL ); #endif console_count_output_char(ch, s); return ((int)ch); }
/* check if we read a newline or an EOF */ int console_post_process_read_char(int ch, StreamDesc *s) { /* the character is also going to be output by the console handler */ console_count_output_char(ch, GLOBAL_Stream + StdErrStream); if (ch == '\n') { CACHE_REGS ++s->linecount; ++s->charcount; s->linepos = 0; LOCAL_newline = true; } else { CACHE_REGS ++s->charcount; ++s->linepos; LOCAL_newline = false; } return ch; }