summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/cvs/add.c32
-rw-r--r--usr.bin/cvs/checkout.c14
-rw-r--r--usr.bin/cvs/client.c34
-rw-r--r--usr.bin/cvs/cvs.h4
-rw-r--r--usr.bin/cvs/entries.c21
-rw-r--r--usr.bin/cvs/remove.c8
-rw-r--r--usr.bin/cvs/server.c11
-rw-r--r--usr.bin/cvs/update.c8
-rw-r--r--usr.bin/cvs/util.c12
9 files changed, 98 insertions, 46 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c
index 8508d064d0a..bcf73266f72 100644
--- a/usr.bin/cvs/add.c
+++ b/usr.bin/cvs/add.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: add.c,v 1.93 2008/02/06 18:12:28 tobias Exp $ */
+/* $OpenBSD: add.c,v 1.94 2008/02/09 20:04:00 xsa Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -122,16 +122,19 @@ cvs_add(int argc, char **argv)
void
cvs_add_entry(struct cvs_file *cf)
{
- char entry[CVS_ENT_MAXLINELEN];
+ char *entry;
CVSENTRIES *entlist;
if (cf->file_type == CVS_DIR) {
- (void)xsnprintf(entry, CVS_ENT_MAXLINELEN,
- "D/%s////", cf->file_name);
+ entry = xmalloc(CVS_ENT_MAXLINELEN);
+ cvs_ent_line_str(cf->file_name, NULL, NULL, NULL, NULL, 1, 0,
+ entry, CVS_ENT_MAXLINELEN);
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_add(entlist, entry);
cvs_ent_close(entlist, ENT_SYNC);
+
+ xfree(entry);
} else {
add_entry(cf);
}
@@ -241,8 +244,9 @@ add_directory(struct cvs_file *cf)
entry, tag, date);
p = xmalloc(CVS_ENT_MAXLINELEN);
- (void)xsnprintf(p, CVS_ENT_MAXLINELEN,
- "D/%s////", cf->file_name);
+ cvs_ent_line_str(cf->file_name, NULL, NULL, NULL,
+ NULL, 1, 0, p, CVS_ENT_MAXLINELEN);
+
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_add(entlist, p);
cvs_ent_close(entlist, ENT_SYNC);
@@ -376,7 +380,7 @@ static void
add_entry(struct cvs_file *cf)
{
FILE *fp;
- char entry[CVS_ENT_MAXLINELEN], path[MAXPATHLEN];
+ char *entry, path[MAXPATHLEN];
char revbuf[CVS_REV_BUFSZ], tbuf[CVS_TIME_BUFSZ];
char sticky[CVS_ENT_MAXLINELEN];
CVSENTRIES *entlist;
@@ -385,6 +389,7 @@ add_entry(struct cvs_file *cf)
return;
sticky[0] = '\0';
+ entry = xmalloc(CVS_ENT_MAXLINELEN);
if (cf->file_status == FILE_REMOVED) {
rcsnum_tostr(cf->file_ent->ce_rev, revbuf, sizeof(revbuf));
@@ -397,9 +402,9 @@ add_entry(struct cvs_file *cf)
cf->file_ent->ce_tag);
/* Remove the '-' prefixing the version number. */
- (void)xsnprintf(entry, CVS_ENT_MAXLINELEN,
- "/%s/%s/%s/%s/%s", cf->file_name, revbuf, tbuf,
- cf->file_ent->ce_opts ? cf->file_ent->ce_opts : "", sticky);
+ cvs_ent_line_str(cf->file_name, revbuf, tbuf,
+ cf->file_ent->ce_opts ? cf->file_ent->ce_opts : "", sticky,
+ 0, 0, entry, CVS_ENT_MAXLINELEN);
} else {
if (logmsg != NULL) {
(void)xsnprintf(path, MAXPATHLEN, "%s/%s%s",
@@ -426,9 +431,9 @@ add_entry(struct cvs_file *cf)
(void)xsnprintf(tbuf, sizeof(tbuf), "Initial %s",
cf->file_name);
- (void)xsnprintf(entry, CVS_ENT_MAXLINELEN,
- "/%s/0/%s/%s/%s", cf->file_name, tbuf, kflag ? kbuf : "",
- sticky);
+
+ cvs_ent_line_str(cf->file_name, "0", tbuf, kflag ? kbuf : "",
+ sticky, 0, 0, entry, CVS_ENT_MAXLINELEN);
}
if (cvs_server_active) {
@@ -440,4 +445,5 @@ add_entry(struct cvs_file *cf)
cvs_ent_add(entlist, entry);
cvs_ent_close(entlist, ENT_SYNC);
}
+ xfree(entry);
}
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c
index 6697a34b400..1467acdab92 100644
--- a/usr.bin/cvs/checkout.c
+++ b/usr.bin/cvs/checkout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: checkout.c,v 1.134 2008/02/09 17:01:43 tobias Exp $ */
+/* $OpenBSD: checkout.c,v 1.135 2008/02/09 20:04:00 xsa Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -425,7 +425,7 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags)
struct timeval tv[2];
struct tm *datetm;
char *tosend;
- char template[MAXPATHLEN], entry[CVS_ENT_MAXLINELEN];
+ char template[MAXPATHLEN], *entry;
char kbuf[8], sticky[CVS_REV_BUFSZ], rev[CVS_REV_BUFSZ];
char timebuf[CVS_TIME_BUFSZ], tbuf[CVS_TIME_BUFSZ];
@@ -520,14 +520,16 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags)
strlcpy(kbuf, cf->file_ent->ce_opts, sizeof(kbuf));
}
- (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s/%s/%s",
- cf->file_name, rev, timebuf, kbuf, sticky);
+ entry = xmalloc(CVS_ENT_MAXLINELEN);
+ cvs_ent_line_str(cf->file_name, rev, timebuf, kbuf, sticky, 0, 0,
+ entry, CVS_ENT_MAXLINELEN);
if (cvs_server_active == 0) {
if (!(co_flags & CO_REMOVE) && cvs_cmdop != CVS_OP_EXPORT) {
ent = cvs_ent_open(cf->file_wd);
cvs_ent_add(ent, entry);
cvs_ent_close(ent, ENT_SYNC);
+ xfree(entry);
}
} else {
if (co_flags & CO_MERGE) {
@@ -544,8 +546,10 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags)
else
cvs_server_update_entry("Updated", cf);
- if (!(co_flags & CO_REMOVE))
+ if (!(co_flags & CO_REMOVE)) {
cvs_remote_output(entry);
+ xfree(entry);
+ }
if (!(co_flags & CO_COMMIT) && !(co_flags & CO_REMOVE)) {
if (!(co_flags & CO_MERGE)) {
diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c
index 1f0abd88cf4..d00fc43bd45 100644
--- a/usr.bin/cvs/client.c
+++ b/usr.bin/cvs/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.101 2008/02/09 12:48:23 joris Exp $ */
+/* $OpenBSD: client.c,v 1.102 2008/02/09 20:04:00 xsa Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -156,7 +156,7 @@ static void
client_check_directory(char *data, char *repository)
{
CVSENTRIES *entlist;
- char entry[CVS_ENT_MAXLINELEN], *parent, *base, *p;
+ char *entry, *parent, *base, *p;
STRIP_SLASH(data);
@@ -183,11 +183,15 @@ client_check_directory(char *data, char *repository)
if (!strcmp(parent, "."))
return;
- (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "D/%s////", base);
+ entry = xmalloc(CVS_ENT_MAXLINELEN);
+ cvs_ent_line_str(base, NULL, NULL, NULL, NULL, 1, 0, entry,
+ CVS_ENT_MAXLINELEN);
entlist = cvs_ent_open(parent);
cvs_ent_add(entlist, entry);
cvs_ent_close(entlist, ENT_SYNC);
+
+ xfree(entry);
}
void
@@ -603,7 +607,7 @@ cvs_client_checkedin(char *data)
CVSENTRIES *entlist;
struct cvs_ent *ent, *newent;
size_t len;
- char *dir, *e, entry[CVS_ENT_MAXLINELEN], rev[CVS_REV_BUFSZ];
+ char *dir, *e, *entry, rev[CVS_REV_BUFSZ];
char sticky[CVS_ENT_MAXLINELEN], timebuf[CVS_TIME_BUFSZ];
if (data == NULL)
@@ -644,13 +648,17 @@ cvs_client_checkedin(char *data)
cvs_ent_free(ent);
}
- (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s%s/%s/%s/%s",
- newent->ce_name, (newent->ce_status == CVS_ENT_REMOVED) ? "-" : "",
- rev, timebuf, newent->ce_opts ? newent->ce_opts : "", sticky);
+ entry = xmalloc(CVS_ENT_MAXLINELEN);
+ cvs_ent_line_str(newent->ce_name, rev, timebuf,
+ newent->ce_opts ? newent->ce_opts : "", sticky, 0,
+ newent->ce_status == CVS_ENT_REMOVED ? 1 : 0,
+ entry, CVS_ENT_MAXLINELEN);
cvs_ent_free(newent);
cvs_ent_add(entlist, entry);
cvs_ent_close(entlist, ENT_SYNC);
+
+ xfree(entry);
}
void
@@ -664,7 +672,7 @@ cvs_client_updated(char *data)
struct cvs_ent *e;
const char *errstr;
struct timeval tv[2];
- char repo[MAXPATHLEN], entry[CVS_ENT_MAXLINELEN];
+ char repo[MAXPATHLEN], *entry;
char timebuf[CVS_TIME_BUFSZ], revbuf[CVS_REV_BUFSZ];
char *en, *mode, *len, *rpath;
char sticky[CVS_ENT_MAXLINELEN], fpath[MAXPATHLEN];
@@ -711,9 +719,11 @@ cvs_client_updated(char *data)
(void)xsnprintf(sticky, sizeof(sticky), "T%s", e->ce_tag);
rcsnum_tostr(e->ce_rev, revbuf, sizeof(revbuf));
- (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s/%s/%s",
- e->ce_name, revbuf, timebuf,
- e->ce_opts ? e->ce_opts : "", sticky);
+
+ entry = xmalloc(CVS_ENT_MAXLINELEN);
+ cvs_ent_line_str(e->ce_name, revbuf, timebuf,
+ e->ce_opts ? e->ce_opts : "", sticky, 0, 0,
+ entry, CVS_ENT_MAXLINELEN);
cvs_ent_free(e);
@@ -723,6 +733,8 @@ cvs_client_updated(char *data)
cvs_ent_close(ent, ENT_SYNC);
}
+ xfree(entry);
+
if ((fd = open(fpath, O_CREAT | O_WRONLY | O_TRUNC)) == -1)
fatal("cvs_client_updated: open: %s: %s",
fpath, strerror(errno));
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index 762de0fd4be..cc601ecad4c 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.157 2008/02/09 12:48:23 joris Exp $ */
+/* $OpenBSD: cvs.h,v 1.158 2008/02/09 20:04:00 xsa Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -376,6 +376,8 @@ void cvs_ent_add(CVSENTRIES *, const char *);
void cvs_ent_remove(CVSENTRIES *, const char *);
void cvs_ent_close(CVSENTRIES *, int);
void cvs_ent_free(struct cvs_ent *);
+void cvs_ent_line_str(const char *, char *, char *, char *, char *,
+ int, int, char *, size_t);
void cvs_parse_tagfile(char *, char **, char **, int *);
void cvs_write_tagfile(const char *, char *, char *);
diff --git a/usr.bin/cvs/entries.c b/usr.bin/cvs/entries.c
index 1b6153a9d63..27f6af771cc 100644
--- a/usr.bin/cvs/entries.c
+++ b/usr.bin/cvs/entries.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: entries.c,v 1.89 2008/02/09 17:01:43 tobias Exp $ */
+/* $OpenBSD: entries.c,v 1.90 2008/02/09 20:04:00 xsa Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -317,6 +317,25 @@ cvs_ent_remove(CVSENTRIES *ep, const char *name)
xfree(l);
}
+/*
+ * cvs_ent_line_str()
+ *
+ * Build CVS/Entries line.
+ *
+ */
+void
+cvs_ent_line_str(const char *name, char *rev, char *tstamp, char *opts,
+ char *sticky, int isdir, int isremoved, char *buf, size_t len)
+{
+ if (isdir == 1) {
+ (void)xsnprintf(buf, len, "D/%s////", name);
+ return;
+ }
+
+ (void)xsnprintf(buf, len, "/%s/%s%s/%s/%s/%s",
+ name, isremoved == 1 ? "-" : "", rev, tstamp, opts, sticky);
+}
+
void
cvs_ent_free(struct cvs_ent *ent)
{
diff --git a/usr.bin/cvs/remove.c b/usr.bin/cvs/remove.c
index dd4bb4fd5ac..3f4afeaa6e4 100644
--- a/usr.bin/cvs/remove.c
+++ b/usr.bin/cvs/remove.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remove.c,v 1.71 2008/02/06 12:42:46 tobias Exp $ */
+/* $OpenBSD: remove.c,v 1.72 2008/02/09 20:04:00 xsa Exp $ */
/*
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
*
@@ -198,9 +198,9 @@ cvs_remove_local(struct cvs_file *cf)
cf->file_ent->ce_tag);
entry = xmalloc(CVS_ENT_MAXLINELEN);
- (void)xsnprintf(entry, CVS_ENT_MAXLINELEN,
- "/%s/-%s/%s/%s/%s", cf->file_name, rbuf, tbuf,
- cf->file_ent->ce_opts ? : "", sticky);
+ cvs_ent_line_str(cf->file_name, rbuf, tbuf,
+ cf->file_ent->ce_opts ? : "", sticky, 0, 1,
+ entry, CVS_ENT_MAXLINELEN);
if (cvs_server_active == 1) {
cvs_server_update_entry("Checked-in", cf);
diff --git a/usr.bin/cvs/server.c b/usr.bin/cvs/server.c
index d5518305a60..ef3aae2f03d 100644
--- a/usr.bin/cvs/server.c
+++ b/usr.bin/cvs/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.82 2008/02/03 18:18:44 tobias Exp $ */
+/* $OpenBSD: server.c,v 1.83 2008/02/09 20:04:00 xsa Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -317,7 +317,7 @@ void
cvs_server_directory(char *data)
{
CVSENTRIES *entlist;
- char *dir, *repo, *parent, entry[CVS_ENT_MAXLINELEN], *dirn, *p;
+ char *dir, *repo, *parent, *entry, *dirn, *p;
if (current_cvsroot == NULL)
fatal("No Root specified for Directory");
@@ -351,11 +351,14 @@ cvs_server_directory(char *data)
fatal("cvs_server_directory: %s", strerror(errno));
if (strcmp(parent, ".")) {
- entlist = cvs_ent_open(parent);
- (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "D/%s////", dirn);
+ entry = xmalloc(CVS_ENT_MAXLINELEN);
+ cvs_ent_line_str(dirn, NULL, NULL, NULL, NULL, 1, 0,
+ entry, CVS_ENT_MAXLINELEN);
+ entlist = cvs_ent_open(parent);
cvs_ent_add(entlist, entry);
cvs_ent_close(entlist, ENT_SYNC);
+ xfree(entry);
}
if (server_currentdir != NULL)
diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c
index 02a2f6d1eb5..d24bac354af 100644
--- a/usr.bin/cvs/update.c
+++ b/usr.bin/cvs/update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: update.c,v 1.128 2008/02/09 17:52:32 joris Exp $ */
+/* $OpenBSD: update.c,v 1.129 2008/02/09 20:04:00 xsa Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -473,9 +473,9 @@ update_clear_conflict(struct cvs_file *cf)
cf->file_ent->ce_tag);
entry = xmalloc(CVS_ENT_MAXLINELEN);
- (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s/%s/%s",
- cf->file_name, revbuf, timebuf, cf->file_ent->ce_opts ? : "",
- sticky);
+ cvs_ent_line_str(cf->file_name, revbuf, timebuf,
+ cf->file_ent->ce_opts ? : "", sticky, 0, 0,
+ entry, CVS_ENT_MAXLINELEN);
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_add(entlist, entry);
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c
index e8e55bfbe37..dac31a9c9c2 100644
--- a/usr.bin/cvs/util.c
+++ b/usr.bin/cvs/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.134 2008/02/09 16:56:58 joris Exp $ */
+/* $OpenBSD: util.c,v 1.135 2008/02/09 20:04:00 xsa Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
@@ -554,7 +554,7 @@ cvs_mkpath(const char *path, char *tag)
CVSENTRIES *ent;
FILE *fp;
size_t len;
- char entry[CVS_ENT_MAXLINELEN], sticky[CVS_REV_BUFSZ];
+ char *entry, sticky[CVS_REV_BUFSZ];
char *sp, *dp, *dir, *p, rpath[MAXPATHLEN], repo[MAXPATHLEN];
dir = xstrdup(path);
@@ -619,10 +619,16 @@ cvs_mkpath(const char *path, char *tag)
if (dp != NULL) {
if ((p = strchr(dp, '/')) != NULL)
*p = '\0';
+
+ entry = xmalloc(CVS_ENT_MAXLINELEN);
+ cvs_ent_line_str(dp, NULL, NULL, NULL, NULL, 1, 0,
+ entry, CVS_ENT_MAXLINELEN);
+
ent = cvs_ent_open(rpath);
- xsnprintf(entry, sizeof(entry), "D/%s////", dp);
cvs_ent_add(ent, entry);
cvs_ent_close(ent, ENT_SYNC);
+ xfree(entry);
+
if (p != NULL)
*p = '/';
}