From 696fdc338b3eb67ab77585df5e6bf95e742d2723 Mon Sep 17 00:00:00 2001 From: vsc Date: Tue, 10 Dec 2002 19:08:25 +0000 Subject: [PATCH] start working on configure support for vc WIN should always disable buffering on stderr fix some warnings in ypsocks do some cleanups in save.c git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@722 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/iopreds.c | 28 +++++++++++----------------- C/save.c | 16 ++++++++++++---- C/ypsocks.c | 12 ++++++------ 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/C/iopreds.c b/C/iopreds.c index 64b1665c9..52ce28a4a 100644 --- a/C/iopreds.c +++ b/C/iopreds.c @@ -222,21 +222,14 @@ unix_upd_stream_info (StreamDesc * s) #endif /* USE_SOCKET */ #if _MSC_VER || defined(__MINGW32__) { - struct _stat buf; - char *emacs_env = getenv("EMACS"); - - if (_fstat(YP_fileno(s->u.file.file), &buf) == -1) { - return; + if (_isatty(_fileno(s->u.file.file))) { + s->status |= Tty_Stream_f|Reset_Eof_Stream_f|Promptable_Stream_f; + /* make all console descriptors unbuffered */ + setvbuf(s->u.file.file, NULL, _IONBF, 0); } - if (buf.st_mode & S_IFCHR) { - s->status |= Tty_Stream_f|Reset_Eof_Stream_f|Promptable_Stream_f; - /* make all console descriptors unbuffered */ - setvbuf(s->u.file.file, NULL, _IONBF, 0); - } else if (emacs_env != NULL && strcmp(emacs_env,"t") == 0) { - /* emacs communicates with sub-processes via a pipe */ - s->status |= Tty_Stream_f|Reset_Eof_Stream_f|Promptable_Stream_f; - /* make all console descriptors unbuffered */ - setvbuf(s->u.file.file, NULL, _IONBF, 0); + /* standard error stream should never be buffered */ + if (StdErrStream == s-Stream) { + setvbuf(s->u.file.file, NULL, _IONBF, 0); } return; } @@ -773,13 +766,14 @@ static int ConsolePutc (int sno, int ch) { StreamDesc *s = &Stream[sno]; -#if MAC || _MSC_VER +#if MAC || _MSC_VER || defined(__MINGW32__) if (ch == 10) { - ch = '\n'; + putc ('\n', s->u.file.file); } + else #endif - putc (ch, s->u.file.file); + putc (ch, s->u.file.file); console_count_output_char(ch,s); return ((int) ch); } diff --git a/C/save.c b/C/save.c index fff7a259c..2047681fd 100644 --- a/C/save.c +++ b/C/save.c @@ -1343,8 +1343,10 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac if (inpf == NULL) inpf = StartUpFile; if (inpf != NULL && (splfild = open_file(inpf, O_RDONLY)) > 0) { - if ((mode = commit_to_saved_state(inpf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE) + if ((mode = commit_to_saved_state(inpf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE) { + Yap_ErrorMessage = NULL; return(mode); + } } if (!Yap_dir_separator(inpf[0]) && !Yap_volume_header(inpf)) { /* @@ -1354,8 +1356,10 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac if (YapLibDir != NULL) { cat_file_name(Yap_FileNameBuf, Yap_LibDir, inpf, YAP_FILENAME_MAX); if ((splfild = open_file(Yap_FileNameBuf, O_RDONLY)) > 0) { - if ((mode = commit_to_saved_state(Yap_FileNameBuf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE) + if ((mode = commit_to_saved_state(Yap_FileNameBuf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE) { + Yap_ErrorMessage = NULL; return(mode); + } } } #if HAVE_GETENV @@ -1364,8 +1368,10 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac if (yap_env != NULL) { cat_file_name(Yap_FileNameBuf, yap_env, inpf, YAP_FILENAME_MAX); if ((splfild = open_file(Yap_FileNameBuf, O_RDONLY)) > 0) { - if ((mode = commit_to_saved_state(Yap_FileNameBuf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE) + if ((mode = commit_to_saved_state(Yap_FileNameBuf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE) { + Yap_ErrorMessage = NULL; return(mode); + } } } } @@ -1373,8 +1379,10 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac if (LIB_DIR != NULL) { cat_file_name(Yap_FileNameBuf, LIB_DIR, inpf, YAP_FILENAME_MAX); if ((splfild = open_file(Yap_FileNameBuf, O_RDONLY)) > 0) { - if ((mode = commit_to_saved_state(Yap_FileNameBuf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE) + if ((mode = commit_to_saved_state(Yap_FileNameBuf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE) { + Yap_ErrorMessage = NULL; return(mode); + } } } } diff --git a/C/ypsocks.c b/C/ypsocks.c index 3041a9aa7..9a1a19542 100644 --- a/C/ypsocks.c +++ b/C/ypsocks.c @@ -225,7 +225,7 @@ Yap_init_socks(char *host, long interface_port) ling.l_onoff = 1; ling.l_linger = 0; - setsockopt(s, SOL_SOCKET, SO_LINGER, (char *) &ling, + setsockopt(s, SOL_SOCKET, SO_LINGER, (void *) &ling, sizeof(ling)); r = connect ( s, (struct sockaddr *) &soadr, sizeof(soadr)); @@ -772,7 +772,7 @@ p_socket_connect(void) saddr.sin_family = AF_INET; ling.l_onoff = 1; ling.l_linger = 0; - if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (char *) &ling, + if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (void *) &ling, sizeof(ling)) < 0) { #if HAVE_STRERROR Yap_Error(SYSTEM_ERROR, TermNil, @@ -957,9 +957,9 @@ p_socket_buffering(void) } fd = Yap_GetStreamFd(sno); if (writing) { - getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bufsize, &len); + getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *)&bufsize, &len); } else { - getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bufsize, &len); + getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *)&bufsize, &len); } if (!Yap_unify(ARG3,MkIntegerTerm(bufsize))) return(FALSE); @@ -979,9 +979,9 @@ p_socket_buffering(void) bufsize = siz; } if (writing) { - setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize)); + setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *)&bufsize, sizeof(bufsize)); } else { - setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof(bufsize)); + setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *)&bufsize, sizeof(bufsize)); } return(TRUE); }