diff options
author | peter <peter@FreeBSD.org> | 1997-08-19 11:21:34 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1997-08-19 11:21:34 +0000 |
commit | 20eb45393a14dc1972e224fd2e93b770d019f529 (patch) | |
tree | cd3decb592803625e31fa3075293770fd78fb5a5 /contrib/cvs | |
parent | f39fffdd46ebe0b8ba2850cd6ec8b7fe3abf4199 (diff) | |
download | FreeBSD-src-20eb45393a14dc1972e224fd2e93b770d019f529.zip FreeBSD-src-20eb45393a14dc1972e224fd2e93b770d019f529.tar.gz |
Redo the $CVSHeader$ support to use code similar to that from David Dawes
but adapted to run within cvs instead of rcs.
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 'contrib/cvs')
-rw-r--r-- | contrib/cvs/src/rcs.c | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/contrib/cvs/src/rcs.c b/contrib/cvs/src/rcs.c index 834acd9..7e80557 100644 --- a/contrib/cvs/src/rcs.c +++ b/contrib/cvs/src/rcs.c @@ -41,7 +41,7 @@ enum rcs_delta_op {RCS_ANNOTATE, RCS_FETCH}; static void RCS_deltas PROTO ((RCSNode *, FILE *, char *, enum rcs_delta_op, char **, size_t *, char **, size_t *)); -static char * getfullCVSname PROTO ((char *)); +static char * getfullCVSname PROTO ((char *, char **)); /* * We don't want to use isspace() from the C library because: @@ -2487,7 +2487,9 @@ expand_keywords (rcs, ver, name, log, loglen, expand, buf, len, retbuf, retlen) char *path; int free_path; char *date; + char *old_path; + old_path = NULL; if (kw == KEYWORD_HEADER || (kw == KEYWORD_LOCALID && keyword_local == KEYWORD_HEADER)) @@ -2495,9 +2497,10 @@ expand_keywords (rcs, ver, name, log, loglen, expand, buf, len, retbuf, retlen) else if (kw == KEYWORD_CVSHEADER || (kw == KEYWORD_LOCALID && keyword_local == KEYWORD_CVSHEADER)) - path = getfullCVSname(rcs->path); + path = getfullCVSname(rcs->path, &old_path); else path = last_component (rcs->path); + printf("path: `%s'\n", path); path = escape_keyword_value (path, &free_path); date = printable_date (ver->date); value = xmalloc (strlen (path) @@ -2515,6 +2518,8 @@ expand_keywords (rcs, ver, name, log, loglen, expand, buf, len, retbuf, retlen) locker != NULL ? locker : ""); if (free_path) free (path); + if (old_path) + free (old_path); free (date); free_value = 1; } @@ -4373,28 +4378,35 @@ RCS_setincexc (arg) return; } +#define ATTIC "/" CVSATTIC static char * -getfullCVSname(CVSname) - char *CVSname; +getfullCVSname(CVSname, pathstore) + char *CVSname, **pathstore; { - int rootlen; - if (CVSroot_directory) { - rootlen = strlen(CVSroot_directory); - /* ignore trailing '/' chars from $CVSROOT */ - while (rootlen > 0) { - if (CVSroot_directory[rootlen - 1] == '/') - rootlen--; - else - break; - } - if (strncmp(CVSname, CVSroot_directory, rootlen) == 0) { - CVSname += rootlen; - /* skip any leading '/' chars */ - while (*CVSname == '/') - CVSname++; - return CVSname; + int rootlen; + char *c = NULL; + int alen = sizeof(ATTIC) - 1; + + *pathstore = xstrdup(CVSname); + if ((c = strrchr(*pathstore, '/')) != NULL) { + if (alen >= *pathstore - c) { + if (!strncmp(c - alen, ATTIC, alen)) { + while (*c != '\0') { + *(c - alen) = *c; + c++; + } + *(c - alen) = '\0'; + } + } } + + rootlen = strlen(CVSroot_directory); + if (!strncmp(*pathstore, CVSroot_directory, rootlen) && + (*pathstore)[rootlen] == '/') + CVSname = (*pathstore + rootlen + 1); + else + CVSname = (*pathstore); } return CVSname; } |