Update of /cvsroot/cscope/cscope/src
In directory usw-pr-cvs1:/tmp/cvs-serv18214/src
Modified Files:
constants.h invlib.c
Log Message:
Jason Duell's latest revision of the invname patch
Index: constants.h
===================================================================
RCS file: /cvsroot/cscope/cscope/src/constants.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** constants.h 2001/07/09 14:00:25 1.10
--- constants.h 2001/08/13 15:31:22 1.11
***************
*** 73,76 ****
--- 73,79 ----
#define INVNAME "cscope.in.out" /* inverted index to the database */
#define INVPOST "cscope.po.out" /* inverted index postings */
+ #define INVNAME2 "cscope.out.in"/* follows correct naming convention */
+ #define INVPOST2 "cscope.out.po"/* follows correct naming convention */
+
#define STMTMAX 10000 /* maximum source statement length */
#define READ 4 /* access(2) parameter */
Index: invlib.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/invlib.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** invlib.c 2001/07/05 16:47:04 1.14
--- invlib.c 2001/08/13 15:31:22 1.15
***************
*** 504,507 ****
--- 504,530 ----
}
+ /*
+ * If 'invname' ends with the 'from' substring, it is replaced inline with the
+ * 'to' substring (which must be of the exact same length), and the function
+ * returns 0. Otherwise, returns -1.
+ */
+
+ static int
+ invflipname(char * invname, const char *from, const char *to)
+ {
+ char *temp, *i = NULL;
+
+ assert(strlen(from) == strlen(to));
+
+ temp = invname - 1;
+ while( (temp = strstr(temp + 1, from)))
+ i = temp;
+ if (!i || i[strlen(from)] != '\0')
+ return -1;
+ while(*to)
+ *i++ = *to++;
+ return 0;
+ }
+
int
invopen(INVCONTROL *invcntl, char *invname, char *invpost, int stat)
***************
*** 513,525 ****
* we need to check for 'cscope.in.out', rather than 'cscope.out.in':
* I.e, hack around our own violation of the inverse db naming convention */
! if (!strcmp(invname, "cscope.out.in")) {
! if ((invcntl->invfile = vpfopen(INVNAME, ((stat == 0) ? "rb" : "r+b"))))
goto openedinvname;
/* more silliness: if you create the db with '-f cscope', then try to open
* it without '-f cscope', you'll fail unless we check for 'cscope.out.in'
* here. */
! } else if (!strcmp(invname, INVNAME)) {
! if ((invcntl->invfile = vpfopen("cscope.out.in", ((stat == 0) ? "rb" : "r+b"))))
goto openedinvname;
}
invcannotopen(invname);
--- 536,551 ----
* we need to check for 'cscope.in.out', rather than 'cscope.out.in':
* I.e, hack around our own violation of the inverse db naming convention */
! if (!invflipname(invname, INVNAME2, INVNAME)) {
! if ((invcntl->invfile = vpfopen(invname, ((stat == 0) ? "rb" : "r+b"))))
goto openedinvname;
+ invflipname(invname, INVNAME, INVNAME2); /* change back for err msg */
+ }
/* more silliness: if you create the db with '-f cscope', then try to open
* it without '-f cscope', you'll fail unless we check for 'cscope.out.in'
* here. */
! else if (!invflipname(invname, INVNAME, INVNAME2)) {
! if ((invcntl->invfile = vpfopen(invname, ((stat == 0) ? "rb" : "r+b"))))
goto openedinvname;
+ invflipname(invname, INVNAME2, INVNAME); /* change back for err msg */
}
invcannotopen(invname);
***************
*** 543,552 ****
if ((invcntl->postfile = vpfopen(invpost, ((stat == 0) ? "rb" : "r+b"))) == NULL) {
/* exact same naming convention hacks as above for invname */
! if (!strcmp(invpost, "cscope.out.po")) {
! if ((invcntl->postfile = vpfopen(INVPOST, ((stat == 0) ? "rb" : "r+b"))))
goto openedinvpost;
! } else if (!strcmp(invpost, INVPOST)) {
! if ((invcntl->postfile = vpfopen("cscope.out.po",((stat == 0)?"rb":"r+b"))))
goto openedinvpost;
}
invcannotopen(invpost);
--- 569,580 ----
if ((invcntl->postfile = vpfopen(invpost, ((stat == 0) ? "rb" : "r+b"))) == NULL) {
/* exact same naming convention hacks as above for invname */
! if (!invflipname(invpost, INVPOST2, INVPOST)) {
! if ((invcntl->postfile = vpfopen(invpost, ((stat == 0) ? "rb" : "r+b"))))
goto openedinvpost;
! invflipname(invpost, INVPOST, INVPOST2); /* change back for err msg */
! } else if (!invflipname(invpost, INVPOST, INVPOST2)) {
! if ((invcntl->postfile = vpfopen(invpost,((stat == 0)?"rb":"r+b"))))
goto openedinvpost;
+ invflipname(invpost, INVPOST2, INVPOST); /* change back for err msg */
}
invcannotopen(invpost);
|