diff options
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r-- | usr.bin/cvs/buf.c | 61 | ||||
-rw-r--r-- | usr.bin/cvs/buf.h | 12 | ||||
-rw-r--r-- | usr.bin/cvs/client.c | 4 | ||||
-rw-r--r-- | usr.bin/cvs/commit.c | 14 | ||||
-rw-r--r-- | usr.bin/cvs/diff.c | 5 | ||||
-rw-r--r-- | usr.bin/cvs/diff3.c | 12 | ||||
-rw-r--r-- | usr.bin/cvs/file.c | 6 | ||||
-rw-r--r-- | usr.bin/cvs/import.c | 14 | ||||
-rw-r--r-- | usr.bin/cvs/init.c | 10 | ||||
-rw-r--r-- | usr.bin/cvs/logmsg.c | 4 | ||||
-rw-r--r-- | usr.bin/cvs/rcs.c | 8 | ||||
-rw-r--r-- | usr.bin/cvs/server.c | 4 | ||||
-rw-r--r-- | usr.bin/cvs/update.c | 6 |
13 files changed, 54 insertions, 106 deletions
diff --git a/usr.bin/cvs/buf.c b/usr.bin/cvs/buf.c index 12479f8acd7..9a1865db156 100644 --- a/usr.bin/cvs/buf.c +++ b/usr.bin/cvs/buf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.c,v 1.67 2008/02/03 15:08:04 tobias Exp $ */ +/* $OpenBSD: buf.c,v 1.68 2008/02/11 20:33:10 tobias Exp $ */ /* * Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -40,8 +40,6 @@ #define BUF_INCR 128 struct cvs_buf { - u_int cb_flags; - /* buffer handle, buffer size, and data length */ u_char *cb_buf; size_t cb_size; @@ -60,7 +58,7 @@ static void cvs_buf_grow(BUF *, size_t); * once the buffer is no longer needed. */ BUF * -cvs_buf_alloc(size_t len, u_int flags) +cvs_buf_alloc(size_t len) { BUF *b; @@ -71,7 +69,6 @@ cvs_buf_alloc(size_t len, u_int flags) else b->cb_buf = NULL; - b->cb_flags = flags; b->cb_size = len; b->cb_len = 0; @@ -79,7 +76,7 @@ cvs_buf_alloc(size_t len, u_int flags) } BUF * -cvs_buf_load(const char *path, u_int flags) +cvs_buf_load(const char *path) { int fd; BUF *bp; @@ -88,13 +85,13 @@ cvs_buf_load(const char *path, u_int flags) fatal("cvs_buf_load: failed to load '%s' : %s", path, strerror(errno)); - bp = cvs_buf_load_fd(fd, flags); + bp = cvs_buf_load_fd(fd); (void)close(fd); return (bp); } BUF * -cvs_buf_load_fd(int fd, u_int flags) +cvs_buf_load_fd(int fd) { struct stat st; BUF *buf; @@ -105,7 +102,7 @@ cvs_buf_load_fd(int fd, u_int flags) if (lseek(fd, 0, SEEK_SET) == -1) fatal("cvs_buf_load_fd: lseek: %s", strerror(errno)); - buf = cvs_buf_alloc(st.st_size, flags); + buf = cvs_buf_alloc(st.st_size); if (atomicio(read, fd, buf->cb_buf, buf->cb_size) != buf->cb_size) fatal("cvs_buf_load_fd: read: %s", strerror(errno)); buf->cb_len = buf->cb_size; @@ -168,10 +165,7 @@ cvs_buf_putc(BUF *b, int c) bp = b->cb_buf + b->cb_len; if (bp == (b->cb_buf + b->cb_size)) { /* extend */ - if (b->cb_flags & BUF_AUTOEXT) - cvs_buf_grow(b, (size_t)BUF_INCR); - else - fatal("cvs_buf_putc failed"); + cvs_buf_grow(b, (size_t)BUF_INCR); /* the buffer might have been moved */ bp = b->cb_buf + b->cb_len; @@ -201,52 +195,23 @@ cvs_buf_getc(BUF *b, size_t pos) * will get resized to an appropriate size to accept all data. * Returns the number of bytes successfully appended to the buffer. */ -ssize_t +void cvs_buf_append(BUF *b, const void *data, size_t len) { - size_t left, rlen; + size_t left; u_char *bp, *bep; bp = b->cb_buf + b->cb_len; bep = b->cb_buf + b->cb_size; left = bep - bp; - rlen = len; if (left < len) { - if (b->cb_flags & BUF_AUTOEXT) { - cvs_buf_grow(b, len - left); - bp = b->cb_buf + b->cb_len; - } else - rlen = bep - bp; + cvs_buf_grow(b, len - left); + bp = b->cb_buf + b->cb_len; } - memcpy(bp, data, rlen); - b->cb_len += rlen; - - return (rlen); -} - -/* - * cvs_buf_fappend() - * - */ -ssize_t -cvs_buf_fappend(BUF *b, const char *fmt, ...) -{ - ssize_t ret; - char *str; - va_list vap; - - va_start(vap, fmt); - ret = vasprintf(&str, fmt, vap); - va_end(vap); - - if (ret == -1) - fatal("cvs_buf_fappend: failed to format data"); - - ret = cvs_buf_append(b, str, (size_t)ret); - xfree(str); - return (ret); + memcpy(bp, data, len); + b->cb_len += len; } /* diff --git a/usr.bin/cvs/buf.h b/usr.bin/cvs/buf.h index 5a388438fb8..8ed3c774025 100644 --- a/usr.bin/cvs/buf.h +++ b/usr.bin/cvs/buf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.h,v 1.22 2007/02/22 06:42:09 otto Exp $ */ +/* $OpenBSD: buf.h,v 1.23 2008/02/11 20:33:11 tobias Exp $ */ /* * Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -34,16 +34,14 @@ typedef struct cvs_buf BUF; -BUF *cvs_buf_alloc(size_t, u_int); -BUF *cvs_buf_load(const char *, u_int); -BUF *cvs_buf_load_fd(int, u_int); +BUF *cvs_buf_alloc(size_t); +BUF *cvs_buf_load(const char *); +BUF *cvs_buf_load_fd(int); void cvs_buf_free(BUF *); u_char *cvs_buf_release(BUF *); u_char cvs_buf_getc(BUF *, size_t); void cvs_buf_empty(BUF *); -ssize_t cvs_buf_append(BUF *, const void *, size_t); -ssize_t cvs_buf_fappend(BUF *, const char *, ...) - __attribute__((format(printf, 2, 3))); +void cvs_buf_append(BUF *, const void *, size_t); void cvs_buf_putc(BUF *, int); size_t cvs_buf_len(BUF *); int cvs_buf_write_fd(BUF *, int); diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c index 6bdfe380fc3..5cee868bb23 100644 --- a/usr.bin/cvs/client.c +++ b/usr.bin/cvs/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.104 2008/02/10 14:08:52 xsa Exp $ */ +/* $OpenBSD: client.c,v 1.105 2008/02/11 20:33:11 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -134,7 +134,7 @@ client_get_supported_responses(void) int i, first; first = 0; - bp = cvs_buf_alloc(512, BUF_AUTOEXT); + bp = cvs_buf_alloc(512); for (i = 0; cvs_responses[i].supported != -1; i++) { if (cvs_responses[i].hdlr == NULL) continue; diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c index b8a181bc80d..b3e84f1306b 100644 --- a/usr.bin/cvs/commit.c +++ b/usr.bin/cvs/commit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commit.c,v 1.128 2008/02/10 13:07:58 joris Exp $ */ +/* $OpenBSD: commit.c,v 1.129 2008/02/11 20:33:11 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> @@ -446,8 +446,7 @@ cvs_commit_local(struct cvs_file *cf) } else if (onbranch == 1) { b = commit_diff(cf, crev, 1); } else { - if ((b = cvs_buf_load_fd(cf->fd, BUF_AUTOEXT)) == NULL) - fatal("cvs_commit_local: failed to load file"); + b = cvs_buf_load_fd(cf->fd); } if (isnew == 0 && onbranch == 0) { @@ -557,9 +556,7 @@ commit_diff(struct cvs_file *cf, RCSNUM *rev, int reverse) if (cf->file_status == FILE_MODIFIED || cf->file_status == FILE_ADDED) { - if ((b = cvs_buf_load_fd(cf->fd, BUF_AUTOEXT)) == NULL) - fatal("commit_diff: failed to load '%s'", - cf->file_path); + b = cvs_buf_load_fd(cf->fd); cvs_buf_write_stmp(b, p1, NULL); cvs_buf_free(b); } else { @@ -569,8 +566,7 @@ commit_diff(struct cvs_file *cf, RCSNUM *rev, int reverse) (void)xasprintf(&p2, "%s/diff2.XXXXXXXXXX", cvs_tmpdir); rcs_rev_write_stmp(cf->file_rcs, rev, p2, RCS_KWEXP_NONE); - if ((b = cvs_buf_alloc(128, BUF_AUTOEXT)) == NULL) - fatal("commit_diff: failed to create diff buf"); + b = cvs_buf_alloc(128); diff_format = D_RCSDIFF; @@ -602,7 +598,7 @@ commit_desc_set(struct cvs_file *cf) if ((fd = open(desc_path, O_RDONLY)) == -1) return; - bp = cvs_buf_load_fd(fd, BUF_AUTOEXT); + bp = cvs_buf_load_fd(fd); cvs_buf_putc(bp, '\0'); desc = cvs_buf_release(bp); diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c index 2e3b196bf10..02d73ebf55b 100644 --- a/usr.bin/cvs/diff.c +++ b/usr.bin/cvs/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.128 2008/02/09 12:27:31 tobias Exp $ */ +/* $OpenBSD: diff.c,v 1.129 2008/02/11 20:33:11 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -367,8 +367,7 @@ cvs_diff_local(struct cvs_file *cf) } else { if (fstat(cf->fd, &st) == -1) fatal("fstat failed %s", strerror(errno)); - if ((b1 = cvs_buf_load_fd(cf->fd, BUF_AUTOEXT)) == NULL) - fatal("failed to load %s", cf->file_path); + b1 = cvs_buf_load_fd(cf->fd); tv2[0].tv_sec = st.st_mtime; tv2[0].tv_usec = 0; diff --git a/usr.bin/cvs/diff3.c b/usr.bin/cvs/diff3.c index 9c811594429..fa6a440fc45 100644 --- a/usr.bin/cvs/diff3.c +++ b/usr.bin/cvs/diff3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff3.c,v 1.39 2007/09/17 10:07:21 tobias Exp $ */ +/* $OpenBSD: diff3.c,v 1.40 2008/02/11 20:33:11 tobias 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.39 2007/09/17 10:07:21 tobias Exp $"; + "$OpenBSD: diff3.c,v 1.40 2008/02/11 20:33:11 tobias Exp $"; #endif /* not lint */ #include <ctype.h> @@ -176,10 +176,10 @@ cvs_merge_file(struct cvs_file *cf, int verbose) rcsnum_tostr(cf->file_ent->ce_rev, r1, sizeof(r1)); rcsnum_tostr(cf->file_rcsrev, r2, sizeof(r2)); - b1 = cvs_buf_load_fd(cf->fd, BUF_AUTOEXT); - d1 = cvs_buf_alloc((size_t)128, BUF_AUTOEXT); - d2 = cvs_buf_alloc((size_t)128, BUF_AUTOEXT); - diffb = cvs_buf_alloc((size_t)128, BUF_AUTOEXT); + b1 = cvs_buf_load_fd(cf->fd); + d1 = cvs_buf_alloc(128); + d2 = cvs_buf_alloc(128); + diffb = cvs_buf_alloc(128); (void)close(cf->fd); cf->fd = open(cf->file_path, O_WRONLY | O_TRUNC); diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index 556b6dca588..0c26a98f7f0 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.221 2008/02/10 14:00:41 joris Exp $ */ +/* $OpenBSD: file.c,v 1.222 2008/02/11 20:33:11 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -754,9 +754,7 @@ cvs_file_classify(struct cvs_file *cf, const char *tag) if (b1 == NULL) fatal("failed to get HEAD revision for comparison"); - b2 = cvs_buf_load_fd(cf->fd, BUF_AUTOEXT); - if (b2 == NULL) - fatal("failed to get file content for comparison"); + b2 = cvs_buf_load_fd(cf->fd); if (cvs_buf_differ(b1, b2)) ismodified = 1; diff --git a/usr.bin/cvs/import.c b/usr.bin/cvs/import.c index fe17c4dd71f..93059218fd4 100644 --- a/usr.bin/cvs/import.c +++ b/usr.bin/cvs/import.c @@ -1,4 +1,4 @@ -/* $OpenBSD: import.c,v 1.82 2008/02/04 15:07:33 tobias Exp $ */ +/* $OpenBSD: import.c,v 1.83 2008/02/11 20:33:11 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -230,8 +230,7 @@ import_new(struct cvs_file *cf) if ((branch = rcsnum_parse(import_branch)) == NULL) fatal("import_new: failed to parse branch"); - if ((bp = cvs_buf_load_fd(cf->fd, BUF_AUTOEXT)) == NULL) - fatal("import_new: failed to load %s", cf->file_path); + bp = cvs_buf_load_fd(cf->fd); if ((brev = rcsnum_brtorev(branch)) == NULL) fatal("import_new: failed to get first branch revision"); @@ -301,8 +300,7 @@ import_update(struct cvs_file *cf) if ((b1 = rcs_rev_getbuf(cf->file_rcs, rev, RCS_KWEXP_NONE)) == NULL) fatal("import_update: failed to grab revision"); - if ((b2 = cvs_buf_load_fd(cf->fd, BUF_AUTOEXT)) == NULL) - fatal("import_update: failed to load %s", cf->file_path); + b2 = cvs_buf_load_fd(cf->fd); ret = cvs_buf_differ(b1, b2); cvs_buf_free(b1); @@ -363,12 +361,10 @@ import_get_rcsdiff(struct cvs_file *cf, RCSNUM *rev) char *p1, *p2; BUF *b1, *b2; - b2 = cvs_buf_alloc(128, BUF_AUTOEXT); + b2 = cvs_buf_alloc(128); if (cvs_noexec != 1) { - if ((b1 = cvs_buf_load_fd(cf->fd, BUF_AUTOEXT)) == NULL) - fatal("import_get_rcsdiff: failed loading %s", - cf->file_path); + b1 = cvs_buf_load_fd(cf->fd); (void)xasprintf(&p1, "%s/diff1.XXXXXXXXXX", cvs_tmpdir); cvs_buf_write_stmp(b1, p1, NULL); diff --git a/usr.bin/cvs/init.c b/usr.bin/cvs/init.c index 716ee394abb..bfaf96ac830 100644 --- a/usr.bin/cvs/init.c +++ b/usr.bin/cvs/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.32 2007/02/22 06:42:09 otto Exp $ */ +/* $OpenBSD: init.c,v 1.33 2008/02/11 20:33:11 tobias Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> @@ -157,10 +157,9 @@ init_mkfile(char *path, const char *const *content) if (content != NULL) { for (p = content; *p != NULL; ++p) { len = strlen(*p); - b = cvs_buf_alloc(len, BUF_AUTOEXT); + b = cvs_buf_alloc(len); - if (cvs_buf_append(b, *p, strlen(*p)) < 0) - fatal("init_mkfile: cvs_buf_append"); + cvs_buf_append(b, *p, strlen(*p)); if (cvs_buf_write_fd(b, fd) < 0) fatal("init_mkfile: cvs_buf_write_fd"); @@ -184,8 +183,7 @@ init_mkfile(char *path, const char *const *content) if ((file = rcs_open(rpath, fd, rcsflags, 0444)) == NULL) fatal("failed to create RCS file for `%s'", path); - if ((b = cvs_buf_load(path, BUF_AUTOEXT)) == NULL) - fatal("init_mkfile: failed to load %s", path); + b = cvs_buf_load(path); if (rcs_rev_add(file, RCS_HEAD_REV, "initial checkin", -1, NULL) == -1) fatal("init_mkfile: failed to add new revision"); diff --git a/usr.bin/cvs/logmsg.c b/usr.bin/cvs/logmsg.c index b76e56e3972..fa2fd795a61 100644 --- a/usr.bin/cvs/logmsg.c +++ b/usr.bin/cvs/logmsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: logmsg.c,v 1.45 2007/09/25 10:04:47 chl Exp $ */ +/* $OpenBSD: logmsg.c,v 1.46 2008/02/11 20:33:11 tobias Exp $ */ /* * Copyright (c) 2007 Joris Vink <joris@openbsd.org> * @@ -58,7 +58,7 @@ cvs_logmsg_read(const char *path) fatal("cvs_logmsg_read: fdopen %s", strerror(errno)); lbuf = NULL; - bp = cvs_buf_alloc(st.st_size, BUF_AUTOEXT); + bp = cvs_buf_alloc(st.st_size); while ((buf = fgetln(fp, &len))) { if (buf[len - 1] == '\n') { buf[len - 1] = '\0'; diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index efc2482fae4..c7d5114ef54 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.248 2008/02/10 10:21:42 joris Exp $ */ +/* $OpenBSD: rcs.c,v 1.249 2008/02/11 20:33:11 tobias Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -1319,7 +1319,7 @@ rcs_rev_remove(RCSFILE *rf, RCSNUM *rev) prevbuf = NULL; if (prevrdp != NULL && nextrdp != NULL) { - newdiff = cvs_buf_alloc(64, BUF_AUTOEXT); + newdiff = cvs_buf_alloc(64); /* calculate new diff */ (void)xasprintf(&path_tmp1, "%s/diff1.XXXXXXXXXX", cvs_tmpdir); @@ -3032,7 +3032,7 @@ rcs_rev_getbuf(RCSFILE *rfp, RCSNUM *rev, int mode) expand = 0; lines = rcs_rev_getlines(rfp, rev, NULL); - bp = cvs_buf_alloc(1024, BUF_AUTOEXT); + bp = cvs_buf_alloc(1024); if (!(mode & RCS_KWEXP_NONE)) { if (rfp->rf_expand != NULL) @@ -3494,7 +3494,7 @@ rcs_kwexp_line(char *rcsfile, struct rcs_delta *rdp, struct cvs_lines *lines, fatal("rcs_kwexp_line: truncated"); /* Concatenate everything together. */ - tmpbuf = cvs_buf_alloc(len + strlen(expbuf), BUF_AUTOEXT); + tmpbuf = cvs_buf_alloc(len + strlen(expbuf)); /* Append everything before keyword. */ cvs_buf_append(tmpbuf, line->l_line, start - line->l_line); diff --git a/usr.bin/cvs/server.c b/usr.bin/cvs/server.c index ef3aae2f03d..6293237abb8 100644 --- a/usr.bin/cvs/server.c +++ b/usr.bin/cvs/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.83 2008/02/09 20:04:00 xsa Exp $ */ +/* $OpenBSD: server.c,v 1.84 2008/02/11 20:33:11 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -212,7 +212,7 @@ cvs_server_validreq(char *data) int i, first; first = 0; - bp = cvs_buf_alloc(512, BUF_AUTOEXT); + bp = cvs_buf_alloc(512); for (i = 0; cvs_requests[i].supported != -1; i++) { if (cvs_requests[i].hdlr == NULL) continue; diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c index 1d111081b73..da52a82a3ca 100644 --- a/usr.bin/cvs/update.c +++ b/usr.bin/cvs/update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: update.c,v 1.131 2008/02/10 10:21:42 joris Exp $ */ +/* $OpenBSD: update.c,v 1.132 2008/02/11 20:33:11 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -509,9 +509,7 @@ update_has_conflict_markers(struct cvs_file *cf) if (cf->fd == -1) return (0); - if ((bp = cvs_buf_load_fd(cf->fd, BUF_AUTOEXT)) == NULL) - fatal("update_has_conflict_markers: failed to load %s", - cf->file_path); + bp = cvs_buf_load_fd(cf->fd); cvs_buf_putc(bp, '\0'); len = cvs_buf_len(bp); |