diff options
author | peter <peter@FreeBSD.org> | 1997-08-19 11:17:37 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1997-08-19 11:17:37 +0000 |
commit | d0361cec9cb6a37d87ca0f68885b45a6b14bc44c (patch) | |
tree | c4f53d796856832e922bab33e7032ee333a1f1f0 /gnu/usr.bin | |
parent | 3197c9d2cb7b87f573bd4a5f56ebbcc9ad994429 (diff) | |
download | FreeBSD-src-d0361cec9cb6a37d87ca0f68885b45a6b14bc44c.zip FreeBSD-src-d0361cec9cb6a37d87ca0f68885b45a6b14bc44c.tar.gz |
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.
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r-- | gnu/usr.bin/rcs/lib/rcsfnms.c | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/gnu/usr.bin/rcs/lib/rcsfnms.c b/gnu/usr.bin/rcs/lib/rcsfnms.c index c44d114..8154cdf 100644 --- a/gnu/usr.bin/rcs/lib/rcsfnms.c +++ b/gnu/usr.bin/rcs/lib/rcsfnms.c @@ -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"); - - 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; + +#define ATTICDIR "/Attic" + + 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 |