From: Hans-Bernhard B. <br...@us...> - 2006-04-21 10:40:46
|
Update of /cvsroot/cscope/cscope/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21961 Modified Files: mypopen.c Log Message: #include <io.h> for setmode() prototype, if platform has it. Index: mypopen.c =================================================================== RCS file: /cvsroot/cscope/cscope/src/mypopen.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** mypopen.c 30 Jan 2005 19:33:28 -0000 1.13 --- mypopen.c 21 Apr 2006 10:40:29 -0000 1.14 *************** *** 49,52 **** --- 49,56 ---- #endif + #ifdef HAVE_IO_H + # include <io.h> /* for setmode() */ + #endif + static char const rcsid[] = "$Id$"; *************** *** 57,95 **** myopen(char *path, int flag, int mode) { ! /* opens a file descriptor and then sets close-on-exec for the file */ ! int fd; ! /* 20020103: if file is not explicitly in Binary mode, make ! * sure we override silly Cygwin behaviour of automatic binary ! * mode for files in "binary mounted" paths */ #if O_BINARY != O_TEXT ! if (! (flag | O_BINARY)) ! flag |= O_TEXT; #endif ! if(mode) ! fd = open(path, flag, mode); ! else ! fd = open(path, flag); #ifdef __DJGPP__ /* FIXME: test feature, not platform */ ! /* HBB 20010312: DOS GCC doesn't have FD_CLOEXEC (yet), so it ! * always fails this call. Have to skip that step */ ! if(fd != -1) ! return(fd); #endif ! if(fd != -1 && (fcntl(fd, F_SETFD, CLOSE_ON_EXEC) != -1)) ! return(fd); ! else { ! /* Ensure that if the fcntl fails and fd is valid, then ! the file is closed properly. In general this should ! not happen. */ ! if (fd != -1) { ! close (fd); } ! return(-1); } } --- 61,99 ---- myopen(char *path, int flag, int mode) { ! /* opens a file descriptor and then sets close-on-exec for the file */ ! int fd; ! /* 20020103: if file is not explicitly in Binary mode, make ! * sure we override silly Cygwin behaviour of automatic binary ! * mode for files in "binary mounted" paths */ #if O_BINARY != O_TEXT ! if (! (flag | O_BINARY)) ! flag |= O_TEXT; #endif ! if(mode) ! fd = open(path, flag, mode); ! else ! fd = open(path, flag); #ifdef __DJGPP__ /* FIXME: test feature, not platform */ ! /* HBB 20010312: DOS GCC doesn't have FD_CLOEXEC (yet), so it ! * always fails this call. Have to skip that step */ ! if(fd != -1) ! return(fd); #endif ! if(fd != -1 && (fcntl(fd, F_SETFD, CLOSE_ON_EXEC) != -1)) ! return(fd); ! else { ! /* Ensure that if the fcntl fails and fd is valid, then ! the file is closed properly. In general this should ! not happen. */ ! if (fd != -1) { ! close (fd); } ! return(-1); } } *************** *** 98,123 **** myfopen(char *path, char *mode) { ! /* opens a file pointer and then sets close-on-exec for the file */ ! FILE *fp; ! fp = fopen(path, mode); #ifdef SETMODE ! if (fp && ! strchr(mode, 'b')) { ! SETMODE(fileno(fp), O_TEXT); ! } #endif /* SETMODE */ #ifdef __DJGPP__ /* FIXME: test feature, not platform */ ! /* HBB 20010312: DOS GCC doesn't have FD_CLOEXEC (yet), so it ! * always fails this call. Have to skip that step */ ! if(fp) #else if(fp && (fcntl(fileno(fp), F_SETFD, CLOSE_ON_EXEC) != -1)) #endif ! return(fp); else ! return(NULL); } --- 102,127 ---- myfopen(char *path, char *mode) { ! /* opens a file pointer and then sets close-on-exec for the file */ ! FILE *fp; ! fp = fopen(path, mode); #ifdef SETMODE ! if (fp && ! strchr(mode, 'b')) { ! SETMODE(fileno(fp), O_TEXT); ! } #endif /* SETMODE */ #ifdef __DJGPP__ /* FIXME: test feature, not platform */ ! /* HBB 20010312: DOS GCC doesn't have FD_CLOEXEC (yet), so it ! * always fails this call. Have to skip that step */ ! if(fp) #else if(fp && (fcntl(fileno(fp), F_SETFD, CLOSE_ON_EXEC) != -1)) #endif ! return(fp); else ! return(NULL); } |