Redo the $CVSHeader$ support to use code from David Dawes as in XFree86.

The stuff I hacked together didn't strip out "/Attic/" for files
on branches when the HEAD version was cvs rm'ed.
This commit is contained in:
Peter Wemm 1997-08-19 11:17:37 +00:00
parent 04b8783cda
commit 0b5711950f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=28407

View File

@ -177,7 +177,7 @@ Report problems and direct all questions to:
#include "rcsbase.h"
libId(fnmsId, "$Id: rcsfnms.c,v 1.6 1997/02/22 15:47:36 peter Exp $")
libId(fnmsId, "$Id: rcsfnms.c,v 1.7 1997/05/11 05:33:06 peter Exp $")
static char const *bindex P((char const*,int));
static int fin2open P((char const*, size_t, char const*, size_t, char const*, size_t, RILE*(*)P((struct buf*,struct stat*,int)), int));
@ -867,37 +867,45 @@ getfullRCSname()
}
}
/* Derived from code from the XFree86 project */
char const *
getfullCVSname()
/*
* Return a pointer to the fill pathname of the RCS file, but trim $CVSROOT.
/* Function: returns a pointer to the path name of the RCS file with the
* CVSROOT part stripped off, and with 'Attic/' stripped off (if present).
*/
{
char const *CVSname;
char const *cvsroot;
int rootlen;
CVSname = getfullRCSname();
cvsroot = getenv("CVSROOT");
#define ATTICDIR "/Attic"
if (cvsroot) {
rootlen = strlen(cvsroot);
/* ignore trailing '/' chars from $CVSROOT */
while (rootlen > 0) {
if (cvsroot[rootlen - 1] == '/')
rootlen--;
else
break;
}
if (strncmp(CVSname, cvsroot, rootlen) == 0) {
CVSname += rootlen;
/* skip any leading '/' chars */
while (*CVSname == '/')
CVSname++;
return CVSname;
char const *namebuf = getfullRCSname();
char *cvsroot = cgetenv("CVSROOT");
int cvsrootlen;
char *c = NULL;
int alen = strlen(ATTICDIR);
if ((c = strrchr(namebuf, '/')) != NULL) {
if (alen >= namebuf - c) {
if (!strncmp(c - alen, ATTICDIR, alen)) {
while(*c != '\0') {
*(c - alen) = *c;
c++;
}
*(c - alen) = '\0';
}
}
}
if (!cvsroot)
return(namebuf);
else
{
cvsrootlen = strlen(cvsroot);
if (!strncmp(namebuf, cvsroot, cvsrootlen) &&
namebuf[cvsrootlen] == '/')
return(namebuf + cvsrootlen + 1);
else
return(namebuf);
}
return CVSname;
}
static size_t