|
From: Hans-Bernhard B. <br...@us...> - 2001-03-27 14:09:24
|
Update of /cvsroot/cscope/cscope/src
In directory usw-pr-cvs1:/tmp/cvs-serv11542
Modified Files:
basename.c command.c dir.c display.c edit.c exec.c invlib.c
main.c mypopen.c vpfopen.c global.h library.h vp.h
Log Message:
DOS support and related minor changes
Index: basename.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/basename.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** basename.c 2000/04/27 16:33:47 1.1
--- basename.c 2001/03/27 14:09:19 1.2
***************
*** 40,44 ****
char *
! basename(char *path)
{
char *s, *strrchr();
--- 40,44 ----
char *
! mybasename(char *path)
{
char *s, *strrchr();
Index: command.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/command.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** command.c 2000/05/31 16:54:10 1.10
--- command.c 2001/03/27 14:09:19 1.11
***************
*** 553,557 ****
int c;
! if ((file = myfopen(filename, "r")) == NULL) {
cannotopen(filename);
return(NO);
--- 553,557 ----
int c;
! if ((file = myfopen(filename, "rb")) == NULL) {
cannotopen(filename);
return(NO);
***************
*** 568,572 ****
}
(void) fclose(file);
! (void) freopen(temp1, "r", refsfound);
countrefs();
}
--- 568,572 ----
}
(void) fclose(file);
! (void) freopen(temp1, "rb", refsfound);
countrefs();
}
Index: dir.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/dir.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** dir.c 2001/02/09 19:59:59 1.9
--- dir.c 2001/03/27 14:09:19 1.10
***************
*** 388,394 ****
scan_dir(path, recurse_dir);
}
! else if (entry->d_ino != 0
! && issrcfile(path)
! && infilelist(path) == NO) {
addsrcfile(file, path);
}
--- 388,399 ----
scan_dir(path, recurse_dir);
}
! else if (
! #ifdef __DJGPP__ /* FIXME: should test for feature, not platform */
! 1 /* DJGPP doesn't have this field in dirent */
! #else
! entry->d_ino != 0
! #endif
! && issrcfile(path)
! && infilelist(path) == NO) {
addsrcfile(file, path);
}
Index: display.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/display.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** display.c 2000/05/31 16:54:10 1.12
--- display.c 2001/03/27 14:09:19 1.13
***************
*** 428,432 ****
}
else {
! if ((nonglobalrefs = myfopen(temp2, "w")) == NULL) {
cannotopen(temp2);
return(NO);
--- 428,432 ----
}
else {
! if ((nonglobalrefs = myfopen(temp2, "wb")) == NULL) {
cannotopen(temp2);
return(NO);
***************
*** 440,444 ****
/* append the non-global references */
! (void) freopen(temp2, "r", nonglobalrefs);
while ((c = getc(nonglobalrefs)) != EOF) {
(void) putc(c, refsfound);
--- 440,444 ----
/* append the non-global references */
! (void) freopen(temp2, "rb", nonglobalrefs);
while ((c = getc(nonglobalrefs)) != EOF) {
(void) putc(c, refsfound);
***************
*** 454,458 ****
/* reopen the references found file for reading */
! (void) freopen(temp1, "r", refsfound);
nextline = 1;
totallines = 0;
--- 454,458 ----
/* reopen the references found file for reading */
! (void) freopen(temp1, "rb", refsfound);
nextline = 1;
totallines = 0;
***************
*** 735,744 ****
{
if (refsfound == NULL) {
! if ((refsfound = myfopen(temp1, "w")) == NULL) {
cannotopen(temp1);
return(NO);
}
}
! else if (freopen(temp1, "w", refsfound) == NULL) {
postmsg("Cannot reopen temporary file");
return(NO);
--- 735,744 ----
{
if (refsfound == NULL) {
! if ((refsfound = myfopen(temp1, "wb")) == NULL) {
cannotopen(temp1);
return(NO);
}
}
! else if (freopen(temp1, "wb", refsfound) == NULL) {
postmsg("Cannot reopen temporary file");
return(NO);
Index: edit.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/edit.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** edit.c 2001/02/09 21:07:17 1.4
--- edit.c 2001/03/27 14:09:19 1.5
***************
*** 106,114 ****
file = filepath(file);
! (void) sprintf(msg, "%s +%s %s", basename(editor), linenum, file);
postmsg(msg);
(void) sprintf(plusnum, lineflag, linenum);
/* if this is the more or page commands */
! if (strcmp(s = basename(editor), "more") == 0 || strcmp(s, "page") == 0) {
/* get it to pause after displaying a file smaller than the screen
--- 106,114 ----
file = filepath(file);
! (void) sprintf(msg, "%s +%s %s", mybasename(editor), linenum, file);
postmsg(msg);
(void) sprintf(plusnum, lineflag, linenum);
/* if this is the more or page commands */
! if (strcmp(s = mybasename(editor), "more") == 0 || strcmp(s, "page") == 0) {
/* get it to pause after displaying a file smaller than the screen
Index: exec.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/exec.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** exec.c 2000/05/31 16:54:10 1.3
--- exec.c 2001/03/27 14:09:19 1.4
***************
*** 106,110 ****
/* modify argv[0] to reference the last component of its path name */
! args[0] = basename(args[0]);
/* execute the program or shell script */
--- 106,110 ----
/* modify argv[0] to reference the last component of its path name */
! args[0] = mybasename(args[0]);
/* execute the program or shell script */
***************
*** 130,134 ****
--- 130,136 ----
oldsigquit = signal(SIGQUIT, SIG_IGN);
oldsighup = signal(SIGHUP, SIG_IGN);
+ #ifdef SIGTSTP
oldsigstp = signal(SIGTSTP, SIG_DFL);
+ #endif
}
/* so they can be used to stop the child */
***************
*** 137,141 ****
--- 139,145 ----
(void) signal(SIGQUIT, SIG_DFL);
(void) signal(SIGHUP, SIG_DFL);
+ #ifdef SIGTSTP
(void) signal(SIGTSTP, SIG_DFL);
+ #endif
}
/* check for fork failure */
***************
*** 162,166 ****
--- 166,172 ----
(void) signal(SIGQUIT, oldsigquit);
(void) signal(SIGHUP, oldsighup);
+ #ifdef SIGTSTP
(void) signal(SIGTSTP, oldsigstp);
+ #endif
/* return the child's exit code */
Index: invlib.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/invlib.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** invlib.c 2000/05/18 15:21:21 1.8
--- invlib.c 2001/03/27 14:09:19 1.9
***************
*** 124,128 ****
#endif
/* output file */
! if ((outfile = vpfopen(invname, "w+")) == NULL) {
invcannotopen(invname);
return(0);
--- 124,128 ----
#endif
/* output file */
! if ((outfile = vpfopen(invname, "w+b")) == NULL) {
invcannotopen(invname);
return(0);
***************
*** 132,136 ****
/* posting file */
! if ((fpost = vpfopen(invpost, "w")) == NULL) {
invcannotopen(invpost);
return(0);
--- 132,136 ----
/* posting file */
! if ((fpost = vpfopen(invpost, "wb")) == NULL) {
invcannotopen(invpost);
return(0);
***************
*** 508,512 ****
int read_index;
! if ((invcntl->invfile = vpfopen(invname, ((stat == 0) ? "r" : "r+"))) == NULL) {
invcannotopen(invname);
return(-1);
--- 508,512 ----
int read_index;
! if ((invcntl->invfile = vpfopen(invname, ((stat == 0) ? "rb" : "r+b"))) == NULL) {
invcannotopen(invname);
return(-1);
***************
*** 526,530 ****
goto closeinv;
}
! if ((invcntl->postfile = vpfopen(invpost, ((stat == 0) ? "r" : "r+"))) == NULL) {
invcannotopen(invpost);
goto closeinv;
--- 526,530 ----
goto closeinv;
}
! if ((invcntl->postfile = vpfopen(invpost, ((stat == 0) ? "rb" : "r+b"))) == NULL) {
invcannotopen(invpost);
goto closeinv;
Index: main.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/main.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** main.c 2001/02/09 21:07:17 1.16
--- main.c 2001/03/27 14:09:19 1.17
***************
*** 38,41 ****
--- 38,42 ----
#include "global.h"
+ #include "vp.h"
#include "version.h" /* FILEVERSION and FIXVERSION */
#include <stdlib.h> /* atoi */
***************
*** 255,259 ****
#if !BSD || sun /* suns can access Amdahl databases */
/* System V has a 14 character limit */
! s = basename(path);
if (strlen(s) > 11) {
s[11] = '\0';
--- 256,260 ----
#if !BSD || sun /* suns can access Amdahl databases */
/* System V has a 14 character limit */
! s = mybasename(path);
if (strlen(s) > 11) {
s[11] = '\0';
***************
*** 393,397 ****
/* if the cross-reference is to be considered up-to-date */
if (isuptodate == YES) {
! if ((oldrefs = vpfopen(reffile, "r")) == NULL) {
posterr("cscope: cannot open file %s\n", reffile);
myexit(1);
--- 394,398 ----
/* if the cross-reference is to be considered up-to-date */
if (isuptodate == YES) {
! if ((oldrefs = vpfopen(reffile, "rb")) == NULL) {
posterr("cscope: cannot open file %s\n", reffile);
myexit(1);
***************
*** 542,554 ****
/* create the file name(s) used for a new cross-referene */
(void) strcpy(path, reffile);
! s = basename(path);
*s = '\0';
(void) strcat(path, "n");
++s;
! (void) strcpy(s, basename(reffile));
newreffile = stralloc(path);
! (void) strcpy(s, basename(invname));
newinvname = stralloc(path);
! (void) strcpy(s, basename(invpost));
newinvpost = stralloc(path);
--- 543,555 ----
/* create the file name(s) used for a new cross-referene */
(void) strcpy(path, reffile);
! s = mybasename(path);
*s = '\0';
(void) strcat(path, "n");
++s;
! (void) strcpy(s, mybasename(reffile));
newreffile = stralloc(path);
! (void) strcpy(s, mybasename(invname));
newinvname = stralloc(path);
! (void) strcpy(s, mybasename(invpost));
newinvpost = stralloc(path);
***************
*** 762,766 ****
opendatabase(void)
{
! if ((symrefs = vpopen(reffile, O_RDONLY)) == -1) {
cannotopen(reffile);
myexit(1);
--- 763,767 ----
opendatabase(void)
{
! if ((symrefs = vpopen(reffile, O_BINARY | O_RDONLY)) == -1) {
cannotopen(reffile);
myexit(1);
***************
*** 832,836 ****
/* if there is an old cross-reference and its current directory matches */
/* or this is an unconditional build */
! if ((oldrefs = vpfopen(reffile, "r")) != NULL && unconditional == NO &&
fscanf(oldrefs, "cscope %d %s", &fileversion, olddir) == 2 &&
(strcmp(olddir, currentdir) == 0 || /* remain compatible */
--- 833,837 ----
/* if there is an old cross-reference and its current directory matches */
/* or this is an unconditional build */
! if ((oldrefs = vpfopen(reffile, "rb")) != NULL && unconditional == NO &&
fscanf(oldrefs, "cscope %d %s", &fileversion, olddir) == 2 &&
(strcmp(olddir, currentdir) == 0 || /* remain compatible */
***************
*** 912,916 ****
/* so get the list of included files */
while (i++ < oldnum && fscanf(oldrefs, "%s", oldname) == 1) {
! addsrcfile(basename(oldname), oldname);
}
(void) fclose(oldrefs);
--- 913,917 ----
/* so get the list of included files */
while (i++ < oldnum && fscanf(oldrefs, "%s", oldname) == 1) {
! addsrcfile(mybasename(oldname), oldname);
}
(void) fclose(oldrefs);
***************
*** 924,928 ****
}
/* reopen the old cross-reference file for fast scanning */
! if ((symrefs = vpopen(reffile, O_RDONLY)) == -1) {
(void) fprintf(stderr, "cscope: cannot open file %s\n", reffile);
myexit(1);
--- 925,929 ----
}
/* reopen the old cross-reference file for fast scanning */
! if ((symrefs = vpopen(reffile, O_BINARY | O_RDONLY)) == -1) {
(void) fprintf(stderr, "cscope: cannot open file %s\n", reffile);
myexit(1);
***************
*** 939,947 ****
}
/* open the new cross-reference file */
! if ((newrefs = myfopen(newreffile, "w")) == NULL) {
(void) fprintf(stderr, "cscope: cannot open file %s\n", reffile);
myexit(1);
}
! if (invertedindex == YES && (postings = myfopen(temp1, "w")) == NULL) {
cannotwrite(temp1);
cannotindex();
--- 940,948 ----
}
/* open the new cross-reference file */
! if ((newrefs = myfopen(newreffile, "wb")) == NULL) {
(void) fprintf(stderr, "cscope: cannot open file %s\n", reffile);
myexit(1);
}
! if (invertedindex == YES && (postings = myfopen(temp1, "wb")) == NULL) {
cannotwrite(temp1);
cannotindex();
Index: mypopen.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/mypopen.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** mypopen.c 2001/01/24 16:24:52 1.5
--- mypopen.c 2001/03/27 14:09:19 1.6
***************
*** 37,47 ****
#include <sys/types.h>
#include <sys/wait.h>
! #include "global.h" /* pid_t, RETSIGTYPE, shell, and basename() */
#define tst(a,b) (*mode == 'r'? (b) : (a))
#define RDR 0
#define WTR 1
- #define CLOSE_ON_EXEC 1
static char const rcsid[] = "$Id$";
--- 37,53 ----
#include <sys/types.h>
#include <sys/wait.h>
! #include "global.h" /* pid_t, RETSIGTYPE, shell, and mybasename() */
#define tst(a,b) (*mode == 'r'? (b) : (a))
#define RDR 0
#define WTR 1
+ /* HBB 20010312: make this a bit safer --- don't blindly assume it's 1 */
+ #ifdef FD_CLOEXEC
+ # define CLOSE_ON_EXEC FD_CLOEXEC
+ #else
+ # define CLOSE_ON_EXEC 1
+ #endif
+
static char const rcsid[] = "$Id$";
***************
*** 60,63 ****
--- 66,75 ----
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);
***************
*** 85,89 ****
--- 97,107 ----
fp = fopen(path, mode);
+ #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);
***************
*** 94,97 ****
--- 112,120 ----
mypopen(char *cmd, char *mode)
{
+ #ifdef __DJGPP__
+ /* HBB 20010312: Has its own implementation of popen(), which
+ * is better suited to the platform than cscope's */
+ return (popen)(cmd, mode);
+ #else
int p[2];
pid_t *poptr;
***************
*** 121,125 ****
#endif
(void) close(yourside);
! (void) execlp(shell, basename(shell), "-c", cmd, 0);
_exit(1);
} else if (pid > 0)
--- 144,148 ----
#endif
(void) close(yourside);
! (void) execlp(shell, mybasename(shell), "-c", cmd, 0);
_exit(1);
} else if (pid > 0)
***************
*** 130,135 ****
--- 153,162 ----
(void) close(yourside);
return(fdopen(myside, mode));
+ #endif
}
+ #ifndef __DJGPP__ /* Don't replace that system's pclose() with our own. */
+ /* FIXME: should we really override pclose(), after having left
+ * popen() well alone, and calling our own version mypopen()? */
int
pclose(FILE *ptr)
***************
*** 157,158 ****
--- 184,186 ----
return(status);
}
+ #endif
Index: vpfopen.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/vpfopen.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** vpfopen.c 2000/05/03 22:02:10 1.2
--- vpfopen.c 2001/03/27 14:09:19 1.3
***************
*** 47,52 ****
int i;
! if ((returncode = myfopen(filename, type)) == NULL && filename[0] != '/' &&
! strcmp(type, "r") == 0) {
vpinit(NULL);
for (i = 1; i < vpndirs; i++) {
--- 47,55 ----
int i;
! if ((returncode = myfopen(filename, type)) == NULL
! && filename[0] != '/'
! /* && strcmp(type, "r") == 0 */ /* HBB: this breaks if type=="rb" */
! && type[0] == 'r'
! ) {
vpinit(NULL);
for (i = 1; i < vpndirs; i++) {
Index: global.h
===================================================================
RCS file: /cvsroot/cscope/cscope/src/global.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** global.h 2001/02/09 21:07:17 1.12
--- global.h 2001/03/27 14:09:19 1.13
***************
*** 294,299 ****
int mygetch(void);
int myopen(char *path, int flag, int mode);
- int vpopen(char *path, int oflag);
- int vpaccess(char *path, mode_t amode);
int hash(char *ss);
int execute(char *a, ...);
--- 294,297 ----
Index: library.h
===================================================================
RCS file: /cvsroot/cscope/cscope/src/library.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** library.h 2000/05/18 14:14:57 1.3
--- library.h 2001/03/27 14:09:19 1.4
***************
*** 45,49 ****
/* private library */
! char *basename(char *path);
char *compath(char *pathname);
char *egrepinit(char *egreppat);
--- 45,49 ----
/* private library */
! char *mybasename(char *path);
char *compath(char *pathname);
char *egrepinit(char *egreppat);
Index: vp.h
===================================================================
RCS file: /cvsroot/cscope/cscope/src/vp.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** vp.h 2000/04/27 16:33:47 1.1
--- vp.h 2001/03/27 14:09:19 1.2
***************
*** 42,45 ****
--- 42,59 ----
#define MAXPATH 200 /* max length for entire name */
+ #include <fcntl.h>
+ #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 */
***************
*** 52,53 ****
--- 66,69 ----
void vpinit(char *currentdir);
+ int vpopen(char *path, int oflag);
+ int vpaccess(char *path, mode_t amode);
|