From: Petr S. <pe...@us...> - 2001-05-30 19:31:26
|
Update of /cvsroot/cscope/cscope/src In directory usw-pr-cvs1:/tmp/cvs-serv22514/src Modified Files: invlib.c Log Message: Jason Duell fix: The default names for the inverse database files created with the -q option violate the regular cscope naming convention (they get called cscope.in.out and cscope.po.out, whereas if you call "cscope -f cscope", they get called cscope.out.in and cscope.out.po). This causes cscope to fail if you create the database without "-f cscope" but then try to load it with "-f cscope". Since the vim editor plugin for cscope always uses the -f flag, this makes it impossible to use the vim plugin unless you use the -f flag to create the database (and the editor freezes when you try to load the database). This is a needless hassle for new users. While the easiest fix for this problem would be to change to default names for the -q files to match the regular naming convention, this could break user setups that rely on the existing names. So this patch takes a different tack. Whenever "cscope.out" is loaded as the main database, both "cscope.po.out" and "cscope.out.po" are checked (ditto for cscope.in.out & cscope.out.in) before. The two combinations are checked in the appropriate order (i.e., "cscope.po.out" is checked first if the -f flag was not used, and "cscope.out.po" if it was). Only if neither file is present does the database load fail. The patch also contains a rewrite of the documentation for the -q option. I remember being confused by it when I first read the docs, and it now also contains information about the -f flag that is superfluous. Index: invlib.c =================================================================== RCS file: /cvsroot/cscope/cscope/src/invlib.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** invlib.c 2001/03/27 14:09:19 1.9 --- invlib.c 2001/05/30 19:31:23 1.10 *************** *** 509,515 **** --- 509,529 ---- if ((invcntl->invfile = vpfopen(invname, ((stat == 0) ? "rb" : "r+b"))) == NULL) { + /* If db created without '-f', but now invoked with '-f cscope.out', + * 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) ? "r" : "r+")))) + 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) ? "r" : "r+")))) + goto openedinvname; + } invcannotopen(invname); return(-1); } + openedinvname: if (fread(&invcntl->param, sizeof(invcntl->param), 1, invcntl->invfile) == 0) { (void) fprintf(stderr, "%s: empty inverted file\n", argv0); *************** *** 527,533 **** --- 541,556 ---- } 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) ? "r" : "r+")))) + goto openedinvpost; + } else if (!strcmp(invpost, INVPOST)) { + if ((invcntl->postfile = vpfopen("cscope.out.po",((stat == 0)?"r":"r+")))) + goto openedinvpost; + } invcannotopen(invpost); goto closeinv; } + openedinvpost: /* allocate core for a logical block */ if ((invcntl->logblk = malloc((unsigned) invcntl->param.sizeblk)) == NULL) { |