summaryrefslogtreecommitdiff
path: root/usr.bin/cvs/rcs.c
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2005-10-10 13:41:26 +0000
committerJoris Vink <joris@cvs.openbsd.org>2005-10-10 13:41:26 +0000
commit048cdec9b9dbd5bce2c83565ba43ebb9ba717a08 (patch)
tree997d58e39646e1c836ed89bf8a1e9da5dd5419bf /usr.bin/cvs/rcs.c
parent194308a440da0af87759a7870e9aa70f776caf4c (diff)
correctly fill in the rd_next field in rcs_rev_add();
ok niallo@
Diffstat (limited to 'usr.bin/cvs/rcs.c')
-rw-r--r--usr.bin/cvs/rcs.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c
index 4d711559e8d..ebbf57fa13a 100644
--- a/usr.bin/cvs/rcs.c
+++ b/usr.bin/cvs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.82 2005/10/09 16:14:23 joris Exp $ */
+/* $OpenBSD: rcs.c,v 1.83 2005/10/10 13:41:25 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -1451,13 +1451,27 @@ rcs_rev_add(RCSFILE *rf, RCSNUM *rev, const char *msg, time_t date)
{
time_t now;
struct passwd *pw;
- struct rcs_delta *rdp;
+ struct rcs_delta *ordp, *rdp;
+ RCSNUM *old;
+
+ if ((old = rcsnum_alloc()) == NULL)
+ return (-1);
if (rev == RCS_HEAD_REV) {
+ rcsnum_cpy(rf->rf_head, old, 0);
rev = rcsnum_inc(rf->rf_head);
- } else if ((rdp = rcs_findrev(rf, rev)) != NULL) {
- rcs_errno = RCS_ERR_DUPENT;
- return (-1);
+ } else {
+ if ((rdp = rcs_findrev(rf, rev)) != NULL) {
+ rcs_errno = RCS_ERR_DUPENT;
+ return (-1);
+ }
+
+ ordp = NULL;
+ rcsnum_cpy(rev, old, 0);
+ while (ordp == NULL) {
+ old = rcsnum_dec(old);
+ ordp = rcs_findrev(rf, old);
+ }
}
if ((pw = getpwuid(getuid())) == NULL) {
@@ -1480,6 +1494,13 @@ rcs_rev_add(RCSFILE *rf, RCSNUM *rev, const char *msg, time_t date)
}
rcsnum_cpy(rev, rdp->rd_num, 0);
+ if ((rdp->rd_next = rcsnum_alloc()) == NULL) {
+ rcs_freedelta(rdp);
+ return (-1);
+ }
+ rcsnum_cpy(old, rdp->rd_next, 0);
+ rcsnum_free(old);
+
if ((rdp->rd_author = cvs_strdup(pw->pw_name)) == NULL) {
rcs_freedelta(rdp);
return (-1);