summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2007-01-12 17:25:34 +0000
committerJoris Vink <joris@cvs.openbsd.org>2007-01-12 17:25:34 +0000
commitc50c5ab1efbb56ef86712456147a03d8083d1b12 (patch)
tree9aa390d9a311e9d3ea20404cd053fe39eb67dd95
parent340ed637df4171b6293501027bb6819a0064e2b4 (diff)
complete binary support for opencvs,
adding/importing binary files now works too partially taken from openrcs
-rw-r--r--usr.bin/cvs/commit.c27
-rw-r--r--usr.bin/cvs/diff3.c7
-rw-r--r--usr.bin/cvs/import.c7
-rw-r--r--usr.bin/cvs/rcs.c26
-rw-r--r--usr.bin/cvs/rcs.h4
5 files changed, 30 insertions, 41 deletions
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c
index 7b1db61dadf..da3b640d4c4 100644
--- a/usr.bin/cvs/commit.c
+++ b/usr.bin/cvs/commit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commit.c,v 1.90 2007/01/11 18:06:49 jasper Exp $ */
+/* $OpenBSD: commit.c,v 1.91 2007/01/12 17:25:33 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -26,7 +26,7 @@
void cvs_commit_local(struct cvs_file *);
void cvs_commit_check_files(struct cvs_file *);
-static char *commit_diff_file(struct cvs_file *);
+static BUF *commit_diff_file(struct cvs_file *);
static void commit_desc_set(struct cvs_file *);
struct cvs_flisthead files_affected;
@@ -200,11 +200,10 @@ cvs_commit_check_files(struct cvs_file *cf)
void
cvs_commit_local(struct cvs_file *cf)
{
- BUF *b;
+ BUF *b, *d;
int isnew;
int l, openflags, rcsflags;
- char *f, rbuf[24], nbuf[24];
- char *d = NULL;
+ char rbuf[24], nbuf[24];
CVSENTRIES *entlist;
char *attic, *repo, *rcsfile;
@@ -293,9 +292,6 @@ cvs_commit_local(struct cvs_file *cf)
fatal("cvs_commit_local: failed to load file");
}
- cvs_buf_putc(b, '\0');
- f = cvs_buf_release(b);
-
if (isnew == 0) {
if (rcs_deltatext_set(cf->file_rcs,
cf->file_rcs->rf_head, d) == -1)
@@ -305,14 +301,9 @@ cvs_commit_local(struct cvs_file *cf)
if (rcs_rev_add(cf->file_rcs, RCS_HEAD_REV, logmsg, -1, NULL) == -1)
fatal("cvs_commit_local: failed to add new revision");
- if (rcs_deltatext_set(cf->file_rcs, cf->file_rcs->rf_head, f) == -1)
+ if (rcs_deltatext_set(cf->file_rcs, cf->file_rcs->rf_head, b) == -1)
fatal("cvs_commit_local: failed to set new HEAD delta");
- xfree(f);
-
- if (isnew == 0)
- xfree(d);
-
if (cf->file_status == FILE_REMOVED) {
if (rcs_state_set(cf->file_rcs,
cf->file_rcs->rf_head, RCS_STATE_DEAD) == -1)
@@ -391,10 +382,10 @@ cvs_commit_local(struct cvs_file *cf)
}
}
-static char *
+static BUF *
commit_diff_file(struct cvs_file *cf)
{
- char*delta, *p1, *p2;
+ char *p1, *p2;
BUF *b1, *b2, *b3;
if (cf->file_status == FILE_MODIFIED ||
@@ -428,9 +419,7 @@ commit_diff_file(struct cvs_file *cf)
if (cvs_diffreg(p1, p2, b3) == D_ERROR)
fatal("commit_diff_file: failed to get RCS patch");
- cvs_buf_putc(b3, '\0');
- delta = cvs_buf_release(b3);
- return (delta);
+ return (b3);
}
static void
diff --git a/usr.bin/cvs/diff3.c b/usr.bin/cvs/diff3.c
index 8dc97f1f011..cde14172d0e 100644
--- a/usr.bin/cvs/diff3.c
+++ b/usr.bin/cvs/diff3.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff3.c,v 1.30 2007/01/11 17:44:18 niallo Exp $ */
+/* $OpenBSD: diff3.c,v 1.31 2007/01/12 17:25:33 joris Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@@ -72,7 +72,7 @@ static const char copyright[] =
#ifndef lint
static const char rcsid[] =
- "$OpenBSD: diff3.c,v 1.30 2007/01/11 17:44:18 niallo Exp $";
+ "$OpenBSD: diff3.c,v 1.31 2007/01/12 17:25:33 joris Exp $";
#endif /* not lint */
#include "includes.h"
@@ -228,9 +228,6 @@ cvs_diff3(RCSFILE *rf, char *workfile, int workfd, RCSNUM *rev1,
goto out;
}
- cvs_buf_putc(diffb, '\0');
- cvs_buf_putc(b1, '\0');
-
plen = cvs_buf_len(diffb);
patch = cvs_buf_release(diffb);
dlen = cvs_buf_len(b1);
diff --git a/usr.bin/cvs/import.c b/usr.bin/cvs/import.c
index f877bbdf8dc..552479cd3b1 100644
--- a/usr.bin/cvs/import.c
+++ b/usr.bin/cvs/import.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: import.c,v 1.59 2007/01/11 15:41:42 xsa Exp $ */
+/* $OpenBSD: import.c,v 1.60 2007/01/12 17:25:33 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -169,7 +169,6 @@ static void
import_new(struct cvs_file *cf)
{
BUF *bp;
- char *content;
time_t tstamp;
struct stat st;
struct rcs_branch *brp;
@@ -199,7 +198,6 @@ import_new(struct cvs_file *cf)
fatal("import_new: failed to load %s", cf->file_path);
cvs_buf_putc(bp, '\0');
- content = cvs_buf_release(bp);
if ((brev = rcsnum_brtorev(branch)) == NULL)
fatal("import_new: failed to get first branch revision");
@@ -236,13 +234,12 @@ import_new(struct cvs_file *cf)
TAILQ_INSERT_TAIL(&(rdp->rd_branches), brp, rb_list);
if (rcs_deltatext_set(cf->file_rcs,
- cf->file_rcs->rf_head, content) == -1)
+ cf->file_rcs->rf_head, bp) == -1)
fatal("import_new: failed to set deltatext");
rcs_write(cf->file_rcs);
cvs_printf("N %s/%s\n", import_repository, cf->file_path);
- xfree(content);
rcsnum_free(branch);
rcsnum_free(brev);
}
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c
index 7084d97fd56..a096e829978 100644
--- a/usr.bin/cvs/rcs.c
+++ b/usr.bin/cvs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.193 2007/01/11 17:44:18 niallo Exp $ */
+/* $OpenBSD: rcs.c,v 1.194 2007/01/12 17:25:33 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -1374,9 +1374,9 @@ rcs_rev_add(RCSFILE *rf, RCSNUM *rev, const char *msg, time_t date,
int
rcs_rev_remove(RCSFILE *rf, RCSNUM *rev)
{
- char *newdeltatext, *path_tmp1, *path_tmp2;
+ char *path_tmp1, *path_tmp2;
struct rcs_delta *rdp, *prevrdp, *nextrdp;
- BUF *nextbuf, *prevbuf, *newdiff;
+ BUF *nextbuf, *prevbuf, *newdiff, *newdeltatext;
if (rev == RCS_HEAD_REV)
rev = rf->rf_head;
@@ -1424,9 +1424,9 @@ rcs_rev_remove(RCSFILE *rf, RCSNUM *rev)
if (cvs_diffreg(path_tmp1, path_tmp2, newdiff) == D_ERROR)
fatal("rcs_diffreg failed");
- newdeltatext = cvs_buf_release(newdiff);
+ newdeltatext = newdiff;
} else if (nextrdp == NULL && prevrdp != NULL) {
- newdeltatext = cvs_buf_release(prevbuf);
+ newdeltatext = prevbuf;
}
if (newdeltatext != NULL) {
@@ -2792,9 +2792,10 @@ rcs_expand_keywords(char *rcsfile, struct rcs_delta *rdp, BUF *bp, int mode)
* Returns -1 on error, 0 on success.
*/
int
-rcs_deltatext_set(RCSFILE *rfp, RCSNUM *rev, const char *dtext)
+rcs_deltatext_set(RCSFILE *rfp, RCSNUM *rev, BUF *bp)
{
size_t len;
+ u_char *dtext;
struct rcs_delta *rdp;
/* Write operations require full parsing */
@@ -2806,17 +2807,22 @@ rcs_deltatext_set(RCSFILE *rfp, RCSNUM *rev, const char *dtext)
if (rdp->rd_text != NULL)
xfree(rdp->rd_text);
- len = strlen(dtext);
+ len = cvs_buf_len(bp);
+ dtext = cvs_buf_release(bp);
+ bp = NULL;
+
if (len != 0) {
- /* XXX - use xstrdup() if rd_text changes to char *. */
- rdp->rd_text = xmalloc(len + 1);
+ rdp->rd_text = xmalloc(len);
rdp->rd_tlen = len;
- (void)memcpy(rdp->rd_text, dtext, len + 1);
+ (void)memcpy(rdp->rd_text, dtext, len);
} else {
rdp->rd_text = NULL;
rdp->rd_tlen = 0;
}
+ if (dtext != NULL)
+ xfree(dtext);
+
return (0);
}
diff --git a/usr.bin/cvs/rcs.h b/usr.bin/cvs/rcs.h
index 64aa1875684..c55d089d0de 100644
--- a/usr.bin/cvs/rcs.h
+++ b/usr.bin/cvs/rcs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.h,v 1.69 2006/06/09 14:57:13 xsa Exp $ */
+/* $OpenBSD: rcs.h,v 1.70 2007/01/12 17:25:33 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -238,7 +238,7 @@ int rcs_lock_setmode(RCSFILE *, int);
int rcs_lock_add(RCSFILE *, const char *, RCSNUM *);
int rcs_lock_remove(RCSFILE *, const char *, RCSNUM *);
BUF *rcs_getrev(RCSFILE *, RCSNUM *);
-int rcs_deltatext_set(RCSFILE *, RCSNUM *, const char *);
+int rcs_deltatext_set(RCSFILE *, RCSNUM *, BUF *);
const char *rcs_desc_get(RCSFILE *);
void rcs_desc_set(RCSFILE *, const char *);
const char *rcs_comment_lookup(const char *);