From: Hans-Bernhard B. <br...@us...> - 2002-01-04 12:11:53
|
Update of /cvsroot/cscope/cscope/src In directory usw-pr-cvs1:/tmp/cvs-serv8110/src Modified Files: global.h mypopen.c vp.h Log Message: Fix against Cygwin binmode mounts of source files Index: global.h =================================================================== RCS file: /cvsroot/cscope/cscope/src/global.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** global.h 2001/10/10 16:49:22 1.19 --- global.h 2002/01/04 12:11:50 1.20 *************** *** 107,110 **** --- 107,129 ---- #endif + /* HBB 20020103: Need to force text or binary mode opens on Cygwins, + * because of their "binary/text mode mount" silliness :-( */ + #ifndef O_TEXT + # ifdef _O_TEXT + # define O_TEXT _O_TEXT + # else + # define O_TEXT 0x00 + # endif + #endif + /* Same for binary mode --- moved here from vp.h */ + #ifndef O_BINARY + # ifdef _O_BINARY + # define O_BINARY _O_BINARY + # else + # define O_BINARY 0x00 + # endif + #endif + + typedef enum { /* boolean data type */ NO, Index: mypopen.c =================================================================== RCS file: /cvsroot/cscope/cscope/src/mypopen.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** mypopen.c 2001/07/05 15:08:21 1.7 --- mypopen.c 2002/01/04 12:11:50 1.8 *************** *** 43,46 **** --- 43,50 ---- #define WTR 1 + #if !defined(HAVE_SETMODE) && defined(HAVE__SETMODE) + # define setmode _setmode + #endif + /* HBB 20010312: make this a bit safer --- don't blindly assume it's 1 */ #ifdef FD_CLOEXEC *************** *** 61,64 **** --- 65,75 ---- 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); *************** *** 97,100 **** --- 108,117 ---- fp = fopen(path, mode); + #if HAVE_SETMODE + if (! strchr(mode, 'b')) { + setmode(fileno(fp), O_TEXT); + } + #endif /* HAVE_SETMODE */ + #ifdef __DJGPP__ /* FIXME: test feature, not platform */ /* HBB 20010312: DOS GCC doesn't have FD_CLOEXEC (yet), so it *************** *** 106,110 **** return(fp); ! else return(NULL); } --- 123,128 ---- return(fp); ! else ! return(NULL); } Index: vp.h =================================================================== RCS file: /cvsroot/cscope/cscope/src/vp.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** vp.h 2001/07/05 14:31:00 1.3 --- vp.h 2002/01/04 12:11:50 1.4 *************** *** 48,62 **** #include <sys/stat.h> - /* In view of DOS portability, we may need the vale of the O_BINARY - * bit mask. On Unix platforms, it's not defined, nor is it needed --> - * set it to a no-op value */ - #ifndef O_BINARY - # ifdef _O_BINARY - # define O_BINARY _O_BINARY - # else - # define O_BINARY 0x00 - # endif - #endif - #if !NOMALLOC extern char **vpdirs; /* directories (including current) in view path */ --- 48,51 ---- |