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
This commit is contained in:
vsc 2002-12-10 19:08:25 +00:00
parent 52f4eb1895
commit 696fdc338b
3 changed files with 29 additions and 27 deletions

View File

@ -222,21 +222,14 @@ unix_upd_stream_info (StreamDesc * s)
#endif /* USE_SOCKET */ #endif /* USE_SOCKET */
#if _MSC_VER || defined(__MINGW32__) #if _MSC_VER || defined(__MINGW32__)
{ {
struct _stat buf; if (_isatty(_fileno(s->u.file.file))) {
char *emacs_env = getenv("EMACS"); s->status |= Tty_Stream_f|Reset_Eof_Stream_f|Promptable_Stream_f;
/* make all console descriptors unbuffered */
if (_fstat(YP_fileno(s->u.file.file), &buf) == -1) { setvbuf(s->u.file.file, NULL, _IONBF, 0);
return;
} }
if (buf.st_mode & S_IFCHR) { /* standard error stream should never be buffered */
s->status |= Tty_Stream_f|Reset_Eof_Stream_f|Promptable_Stream_f; if (StdErrStream == s-Stream) {
/* make all console descriptors unbuffered */ setvbuf(s->u.file.file, NULL, _IONBF, 0);
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);
} }
return; return;
} }
@ -773,13 +766,14 @@ static int
ConsolePutc (int sno, int ch) ConsolePutc (int sno, int ch)
{ {
StreamDesc *s = &Stream[sno]; StreamDesc *s = &Stream[sno];
#if MAC || _MSC_VER #if MAC || _MSC_VER || defined(__MINGW32__)
if (ch == 10) if (ch == 10)
{ {
ch = '\n'; putc ('\n', s->u.file.file);
} }
else
#endif #endif
putc (ch, s->u.file.file); putc (ch, s->u.file.file);
console_count_output_char(ch,s); console_count_output_char(ch,s);
return ((int) ch); return ((int) ch);
} }

View File

@ -1343,8 +1343,10 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
if (inpf == NULL) if (inpf == NULL)
inpf = StartUpFile; inpf = StartUpFile;
if (inpf != NULL && (splfild = open_file(inpf, O_RDONLY)) > 0) { 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); return(mode);
}
} }
if (!Yap_dir_separator(inpf[0]) && !Yap_volume_header(inpf)) { 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) { if (YapLibDir != NULL) {
cat_file_name(Yap_FileNameBuf, Yap_LibDir, inpf, YAP_FILENAME_MAX); cat_file_name(Yap_FileNameBuf, Yap_LibDir, inpf, YAP_FILENAME_MAX);
if ((splfild = open_file(Yap_FileNameBuf, O_RDONLY)) > 0) { 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); return(mode);
}
} }
} }
#if HAVE_GETENV #if HAVE_GETENV
@ -1364,8 +1368,10 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
if (yap_env != NULL) { if (yap_env != NULL) {
cat_file_name(Yap_FileNameBuf, yap_env, inpf, YAP_FILENAME_MAX); cat_file_name(Yap_FileNameBuf, yap_env, inpf, YAP_FILENAME_MAX);
if ((splfild = open_file(Yap_FileNameBuf, O_RDONLY)) > 0) { 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); return(mode);
}
} }
} }
} }
@ -1373,8 +1379,10 @@ OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStac
if (LIB_DIR != NULL) { if (LIB_DIR != NULL) {
cat_file_name(Yap_FileNameBuf, LIB_DIR, inpf, YAP_FILENAME_MAX); cat_file_name(Yap_FileNameBuf, LIB_DIR, inpf, YAP_FILENAME_MAX);
if ((splfild = open_file(Yap_FileNameBuf, O_RDONLY)) > 0) { 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); return(mode);
}
} }
} }
} }

View File

@ -225,7 +225,7 @@ Yap_init_socks(char *host, long interface_port)
ling.l_onoff = 1; ling.l_onoff = 1;
ling.l_linger = 0; ling.l_linger = 0;
setsockopt(s, SOL_SOCKET, SO_LINGER, (char *) &ling, setsockopt(s, SOL_SOCKET, SO_LINGER, (void *) &ling,
sizeof(ling)); sizeof(ling));
r = connect ( s, (struct sockaddr *) &soadr, sizeof(soadr)); r = connect ( s, (struct sockaddr *) &soadr, sizeof(soadr));
@ -772,7 +772,7 @@ p_socket_connect(void)
saddr.sin_family = AF_INET; saddr.sin_family = AF_INET;
ling.l_onoff = 1; ling.l_onoff = 1;
ling.l_linger = 0; 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) { sizeof(ling)) < 0) {
#if HAVE_STRERROR #if HAVE_STRERROR
Yap_Error(SYSTEM_ERROR, TermNil, Yap_Error(SYSTEM_ERROR, TermNil,
@ -957,9 +957,9 @@ p_socket_buffering(void)
} }
fd = Yap_GetStreamFd(sno); fd = Yap_GetStreamFd(sno);
if (writing) { if (writing) {
getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bufsize, &len); getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *)&bufsize, &len);
} else { } else {
getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bufsize, &len); getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *)&bufsize, &len);
} }
if (!Yap_unify(ARG3,MkIntegerTerm(bufsize))) if (!Yap_unify(ARG3,MkIntegerTerm(bufsize)))
return(FALSE); return(FALSE);
@ -979,9 +979,9 @@ p_socket_buffering(void)
bufsize = siz; bufsize = siz;
} }
if (writing) { if (writing) {
setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize)); setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *)&bufsize, sizeof(bufsize));
} else { } else {
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof(bufsize)); setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *)&bufsize, sizeof(bufsize));
} }
return(TRUE); return(TRUE);
} }