summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@cvs.openbsd.org>2008-01-31 16:36:12 +0000
committerTobias Stoeckmann <tobias@cvs.openbsd.org>2008-01-31 16:36:12 +0000
commit733fc74bc2023ea50e6e6879d17302025c57af96 (patch)
tree09a612d47ce38b49c8e676f2893ed89abb594f2c /usr.bin
parent3c90b54126879ef2830d45dda517b5b1304b2ab2 (diff)
Revert last patch and add this magic branch number only during
output, this way we don't have to hassle in our internal brach handling. OK joris@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/rcs/rcs.c4
-rw-r--r--usr.bin/rcs/rcs.h3
-rw-r--r--usr.bin/rcs/rcsnum.c55
3 files changed, 52 insertions, 10 deletions
diff --git a/usr.bin/rcs/rcs.c b/usr.bin/rcs/rcs.c
index 57d8d049267..c7e2814262d 100644
--- a/usr.bin/rcs/rcs.c
+++ b/usr.bin/rcs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.44 2008/01/06 14:45:50 tobias Exp $ */
+/* $OpenBSD: rcs.c,v 1.45 2008/01/31 16:36:11 tobias Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -423,6 +423,8 @@ rcs_write(RCSFILE *rfp)
fprintf(fp, "symbols");
TAILQ_FOREACH(symp, &(rfp->rf_symbols), rs_list) {
+ if (RCSNUM_ISBRANCH(symp->rs_num))
+ rcsnum_addmagic(symp->rs_num);
rcsnum_tostr(symp->rs_num, numbuf, sizeof(numbuf));
fprintf(fp, "\n\t%s:%s", symp->rs_name, numbuf);
}
diff --git a/usr.bin/rcs/rcs.h b/usr.bin/rcs/rcs.h
index 12daf5aabd6..9f279ea8764 100644
--- a/usr.bin/rcs/rcs.h
+++ b/usr.bin/rcs/rcs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.h,v 1.6 2007/02/27 07:59:13 xsa Exp $ */
+/* $OpenBSD: rcs.h,v 1.7 2008/01/31 16:36:11 tobias Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -265,6 +265,7 @@ RCSNUM *rcsnum_revtobr(const RCSNUM *);
RCSNUM *rcsnum_inc(RCSNUM *);
RCSNUM *rcsnum_dec(RCSNUM *);
void rcsnum_free(RCSNUM *);
+int rcsnum_addmagic(RCSNUM *);
int rcsnum_aton(const char *, char **, RCSNUM *);
char *rcsnum_tostr(const RCSNUM *, char *, size_t);
void rcsnum_cpy(const RCSNUM *, RCSNUM *, u_int);
diff --git a/usr.bin/rcs/rcsnum.c b/usr.bin/rcs/rcsnum.c
index 61327ad36b1..4103882a456 100644
--- a/usr.bin/rcs/rcsnum.c
+++ b/usr.bin/rcs/rcsnum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsnum.c,v 1.9 2008/01/22 08:31:18 tobias Exp $ */
+/* $OpenBSD: rcsnum.c,v 1.10 2008/01/31 16:36:11 tobias Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -56,6 +56,24 @@ rcsnum_alloc(void)
}
/*
+ * rcsnum_addmagic()
+ *
+ * Adds a magic branch number to an RCS number.
+ * Returns 0 on success, or -1 on failure.
+ */
+int
+rcsnum_addmagic(RCSNUM *rn)
+{
+ if (!rn->rn_len || rn->rn_len > RCSNUM_MAXLEN - 1)
+ return -1;
+ rcsnum_setsize(rn, rn->rn_len + 1);
+ rn->rn_id[rn->rn_len - 1] = rn->rn_id[rn->rn_len - 2];
+ rn->rn_id[rn->rn_len - 2] = 0;
+
+ return 0;
+}
+
+/*
* rcsnum_parse()
*
* Parse a string specifying an RCS number and return the corresponding RCSNUM.
@@ -214,6 +232,7 @@ rcsnum_aton(const char *str, char **ep, RCSNUM *nump)
{
u_int32_t val;
const char *sp;
+ char *s;
if (nump->rn_id == NULL)
nump->rn_id = xmalloc(sizeof(*(nump->rn_id)));
@@ -261,15 +280,35 @@ rcsnum_aton(const char *str, char **ep, RCSNUM *nump)
* about this, cvs does this for "efficiency reasons", i'd like
* to hear one.
*
+ * We just make sure we remove the .0. from in the branch number.
+ *
* XXX - for compatibility reasons with GNU cvs we _need_
- * to add these magic branch numbers.
+ * to skip this part for the 'log' command, apparently it does
+ * show the magic branches for an unknown and probably
+ * completely insane and not understandable reason in that output.
+ *
*/
- if (nump->rn_len > 1 && !(nump->rn_len % 2)) {
- nump->rn_len++;
- nump->rn_id = xrealloc(nump->rn_id, nump->rn_len + 1,
- sizeof(*(nump->rn_id)));
- nump->rn_id[nump->rn_len] = nump->rn_id[nump->rn_len - 1];
- nump->rn_id[nump->rn_len - 1] = 0;
+ if (nump->rn_len > 2 && nump->rn_id[nump->rn_len - 1] == 0
+ && !(rcsnum_flags & RCSNUM_NO_MAGIC)) {
+ /*
+ * Look for ".0.x" at the end of the branch number.
+ */
+ if ((s = strrchr(str, '.')) != NULL) {
+ s--;
+ while (*s != '.')
+ s--;
+
+ /*
+ * If we have a "magic" branch, adjust it
+ * so the .0. is removed.
+ */
+ if (!strncmp(s, RCS_MAGIC_BRANCH,
+ strlen(RCS_MAGIC_BRANCH))) {
+ nump->rn_id[nump->rn_len - 1] =
+ nump->rn_id[nump->rn_len];
+ nump->rn_len--;
+ }
+ }
}
/* We can't have a single-digit rcs number. */