From 7bb3ddb082eb2d269769c325550cc5d14ba24224 Mon Sep 17 00:00:00 2001 From: ray Date: Fri, 23 Jul 2010 21:46:04 +0000 Subject: [PATCH] Reduce variable/function name and whitespace differences between cvs/rcs. OK xsa zinovik --- usr.bin/cvs/add.c | 20 +++---- usr.bin/cvs/annotate.c | 8 +-- usr.bin/cvs/buf.c | 61 ++++++++++---------- usr.bin/cvs/buf.h | 32 +++++------ usr.bin/cvs/checkout.c | 4 +- usr.bin/cvs/client.c | 12 ++-- usr.bin/cvs/commit.c | 60 ++++++++++---------- usr.bin/cvs/cvs.h | 4 +- usr.bin/cvs/date.y | 10 ++-- usr.bin/cvs/diff.c | 12 ++-- usr.bin/cvs/diff.h | 26 ++++----- usr.bin/cvs/diff3.c | 47 ++++++++-------- usr.bin/cvs/diff_internals.c | 6 +- usr.bin/cvs/file.c | 10 ++-- usr.bin/cvs/getlog.c | 20 +++---- usr.bin/cvs/history.c | 14 ++--- usr.bin/cvs/import.c | 54 +++++++++--------- usr.bin/cvs/init.c | 4 +- usr.bin/cvs/logmsg.c | 12 ++-- usr.bin/cvs/rcs.c | 84 ++++++++++++++-------------- usr.bin/cvs/rcs.h | 16 +++--- usr.bin/cvs/remote.c | 6 +- usr.bin/cvs/server.c | 12 ++-- usr.bin/cvs/trigger.c | 70 +++++++++++------------ usr.bin/cvs/update.c | 20 +++---- usr.bin/cvs/util.c | 12 ++-- usr.bin/cvs/util.h | 14 ++--- usr.bin/rcs/buf.c | 93 +++++++++++++++---------------- usr.bin/rcs/buf.h | 36 ++++++------ usr.bin/rcs/ci.c | 46 ++++++++-------- usr.bin/rcs/co.c | 22 ++++---- usr.bin/rcs/date.y | 10 ++-- usr.bin/rcs/diff.c | 4 +- usr.bin/rcs/diff.h | 9 ++- usr.bin/rcs/diff3.c | 104 ++++++++++++++++++----------------- usr.bin/rcs/ident.c | 22 ++++---- usr.bin/rcs/merge.c | 10 ++-- usr.bin/rcs/rcs.c | 57 +++++++++---------- usr.bin/rcs/rcs.h | 7 +-- usr.bin/rcs/rcsclean.c | 14 ++--- usr.bin/rcs/rcsdiff.c | 28 +++++----- usr.bin/rcs/rcsmerge.c | 10 ++-- usr.bin/rcs/rcsnum.c | 12 ++-- usr.bin/rcs/rcsprog.h | 4 +- usr.bin/rcs/rcsutil.c | 20 +++---- usr.bin/rcs/rlog.c | 20 +++---- 46 files changed, 586 insertions(+), 592 deletions(-) diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c index 06f2630f114..d72df948ce0 100644 --- a/usr.bin/cvs/add.c +++ b/usr.bin/cvs/add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: add.c,v 1.108 2010/04/04 17:11:11 zinovik Exp $ */ +/* $OpenBSD: add.c,v 1.109 2010/07/23 21:46:04 ray Exp $ */ /* * Copyright (c) 2006 Joris Vink * Copyright (c) 2005, 2006 Xavier Santolaria @@ -210,19 +210,19 @@ cvs_add_loginfo(char *repo) if (getcwd(pwd, sizeof(pwd)) == NULL) fatal("Can't get working directory"); - buf = cvs_buf_alloc(1024); + buf = buf_alloc(1024); cvs_trigger_loginfo_header(buf, repo); - cvs_buf_puts(buf, "Log Message:\nDirectory "); - cvs_buf_puts(buf, current_cvsroot->cr_dir); - cvs_buf_putc(buf, '/'); - cvs_buf_puts(buf, repo); - cvs_buf_puts(buf, " added to the repository\n"); + buf_puts(buf, "Log Message:\nDirectory "); + buf_puts(buf, current_cvsroot->cr_dir); + buf_putc(buf, '/'); + buf_puts(buf, repo); + buf_puts(buf, " added to the repository\n"); - cvs_buf_putc(buf, '\0'); + buf_putc(buf, '\0'); - loginfo = cvs_buf_release(buf); + loginfo = buf_release(buf); } void @@ -283,7 +283,7 @@ cvs_add_tobranch(struct cvs_file *cf, char *tag) if ((rdp = rcs_findrev(cf->file_rcs, cf->file_rcs->rf_head)) == NULL) fatal("cvs_add_tobranch: cannot find newly added revision"); - bp = cvs_buf_alloc(1); + bp = buf_alloc(1); if (rcs_deltatext_set(cf->file_rcs, cf->file_rcs->rf_head, bp) == -1) diff --git a/usr.bin/cvs/annotate.c b/usr.bin/cvs/annotate.c index eaaa9bd45af..ac63148c99c 100644 --- a/usr.bin/cvs/annotate.c +++ b/usr.bin/cvs/annotate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: annotate.c,v 1.60 2008/06/14 04:34:08 tobias Exp $ */ +/* $OpenBSD: annotate.c,v 1.61 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2007 Tobias Stoeckmann * Copyright (c) 2006 Xavier Santolaria @@ -69,7 +69,7 @@ cvs_annotate(int argc, char **argv) switch (ch) { case 'D': dateflag = optarg; - cvs_specified_date = cvs_date_parse(dateflag); + cvs_specified_date = date_parse(dateflag); break; case 'f': force_head = 1; @@ -156,8 +156,8 @@ cvs_annotate_local(struct cvs_file *cf) int i; char date[10], rnum[13], *p; RCSNUM *bnum, *rev; - struct cvs_line *line; - struct cvs_line **alines; + struct rcs_line *line; + struct rcs_line **alines; cvs_log(LP_TRACE, "cvs_annotate_local(%s)", cf->file_path); diff --git a/usr.bin/cvs/buf.c b/usr.bin/cvs/buf.c index baf9baa2c6d..85a3ebe0b20 100644 --- a/usr.bin/cvs/buf.c +++ b/usr.bin/cvs/buf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.c,v 1.75 2010/07/23 08:31:19 ray Exp $ */ +/* $OpenBSD: buf.c,v 1.76 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2003 Jean-Francois Brousseau * All rights reserved. @@ -44,18 +44,19 @@ b->cb_size += len; \ } while (0); -struct cvs_buf { +struct buf { u_char *cb_buf; size_t cb_size; size_t cb_len; }; BUF * -cvs_buf_alloc(size_t len) +buf_alloc(size_t len) { BUF *b; b = xmalloc(sizeof(*b)); + /* Postpone creation of zero-sized buffers */ if (len > 0) b->cb_buf = xcalloc(1, len); else @@ -68,44 +69,44 @@ cvs_buf_alloc(size_t len) } BUF * -cvs_buf_load(const char *path) +buf_load(const char *path) { int fd; BUF *bp; if ((fd = open(path, O_RDONLY, 0600)) == -1) - fatal("cvs_buf_load: failed to load '%s' : %s", path, + fatal("buf_load: failed to load '%s' : %s", path, strerror(errno)); - bp = cvs_buf_load_fd(fd); + bp = buf_load_fd(fd); (void)close(fd); return (bp); } BUF * -cvs_buf_load_fd(int fd) +buf_load_fd(int fd) { struct stat st; BUF *buf; if (fstat(fd, &st) == -1) - fatal("cvs_buf_load_fd: fstat: %s", strerror(errno)); + fatal("buf_load_fd: fstat: %s", strerror(errno)); if (lseek(fd, 0, SEEK_SET) == -1) - fatal("cvs_buf_load_fd: lseek: %s", strerror(errno)); + fatal("buf_load_fd: lseek: %s", strerror(errno)); if (st.st_size > SIZE_MAX) - fatal("cvs_buf_load_fd: file size too big"); - buf = cvs_buf_alloc(st.st_size); + fatal("buf_load_fd: file size too big"); + buf = 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)); + fatal("buf_load_fd: read: %s", strerror(errno)); buf->cb_len = buf->cb_size; return (buf); } void -cvs_buf_free(BUF *b) +buf_free(BUF *b) { if (b->cb_buf != NULL) xfree(b->cb_buf); @@ -113,7 +114,7 @@ cvs_buf_free(BUF *b) } u_char * -cvs_buf_release(BUF *b) +buf_release(BUF *b) { u_char *tmp; @@ -123,7 +124,7 @@ cvs_buf_release(BUF *b) } void -cvs_buf_putc(BUF *b, int c) +buf_putc(BUF *b, int c) { u_char *bp; @@ -137,13 +138,13 @@ cvs_buf_putc(BUF *b, int c) } void -cvs_buf_puts(BUF *b, const char *str) +buf_puts(BUF *b, const char *str) { - cvs_buf_append(b, str, strlen(str)); + buf_append(b, str, strlen(str)); } void -cvs_buf_append(BUF *b, const void *data, size_t len) +buf_append(BUF *b, const void *data, size_t len) { size_t left; u_char *bp, *bep; @@ -162,13 +163,13 @@ cvs_buf_append(BUF *b, const void *data, size_t len) } size_t -cvs_buf_len(BUF *b) +buf_len(BUF *b) { return (b->cb_len); } int -cvs_buf_write_fd(BUF *b, int fd) +buf_write_fd(BUF *b, int fd) { if (atomicio(vwrite, fd, b->cb_buf, b->cb_len) != b->cb_len) return (-1); @@ -176,7 +177,7 @@ cvs_buf_write_fd(BUF *b, int fd) } int -cvs_buf_write(BUF *b, const char *path, mode_t mode) +buf_write(BUF *b, const char *path, mode_t mode) { int fd; open: @@ -187,9 +188,9 @@ open: fatal("open: `%s': %s", path, strerror(errno)); } - if (cvs_buf_write_fd(b, fd) == -1) { + if (buf_write_fd(b, fd) == -1) { (void)unlink(path); - fatal("cvs_buf_write: cvs_buf_write_fd: `%s'", path); + fatal("buf_write: buf_write_fd: `%s'", path); } if (fchmod(fd, mode) < 0) @@ -201,39 +202,39 @@ open: } int -cvs_buf_write_stmp(BUF *b, char *template, struct timeval *tv) +buf_write_stmp(BUF *b, char *template, struct timeval *tv) { int fd; if ((fd = mkstemp(template)) == -1) fatal("mkstemp: `%s': %s", template, strerror(errno)); - if (cvs_buf_write_fd(b, fd) == -1) { + if (buf_write_fd(b, fd) == -1) { (void)unlink(template); - fatal("cvs_buf_write_stmp: cvs_buf_write_fd: `%s'", template); + fatal("buf_write_stmp: buf_write_fd: `%s'", template); } if (tv != NULL) { if (futimes(fd, tv) == -1) - fatal("cvs_buf_write_stmp: futimes failed"); + fatal("buf_write_stmp: futimes failed"); } worklist_add(template, &temp_files); if (lseek(fd, 0, SEEK_SET) < 0) - fatal("cvs_buf_write_stmp: lseek: %s", strerror(errno)); + fatal("buf_write_stmp: lseek: %s", strerror(errno)); return (fd); } u_char * -cvs_buf_get(BUF *bp) +buf_get(BUF *bp) { return (bp->cb_buf); } int -cvs_buf_differ(const BUF *b1, const BUF *b2) +buf_differ(const BUF *b1, const BUF *b2) { if (b1->cb_len != b2->cb_len) return (1); diff --git a/usr.bin/cvs/buf.h b/usr.bin/cvs/buf.h index 66fc66e9e76..82c8398e6c4 100644 --- a/usr.bin/cvs/buf.h +++ b/usr.bin/cvs/buf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.h,v 1.26 2009/03/25 21:19:20 joris Exp $ */ +/* $OpenBSD: buf.h,v 1.27 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2003 Jean-Francois Brousseau * All rights reserved. @@ -29,21 +29,21 @@ #include -typedef struct cvs_buf BUF; +typedef struct buf BUF; -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_get(BUF *); -void cvs_buf_append(BUF *, const void *, size_t); -void cvs_buf_putc(BUF *, int); -void cvs_buf_puts(BUF *, const char *); -size_t cvs_buf_len(BUF *); -int cvs_buf_write_fd(BUF *, int); -int cvs_buf_write(BUF *, const char *, mode_t); -int cvs_buf_differ(const BUF *, const BUF *); -int cvs_buf_write_stmp(BUF *, char *, struct timeval *); +BUF *buf_alloc(size_t); +BUF *buf_load(const char *); +BUF *buf_load_fd(int); +void buf_free(BUF *); +u_char *buf_release(BUF *); +u_char *buf_get(BUF *); +void buf_append(BUF *, const void *, size_t); +void buf_putc(BUF *, int); +void buf_puts(BUF *, const char *); +size_t buf_len(BUF *); +int buf_write_fd(BUF *, int); +int buf_write(BUF *, const char *, mode_t); +int buf_differ(const BUF *, const BUF *); +int buf_write_stmp(BUF *, char *, struct timeval *); #endif /* BUF_H */ diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c index 63d2da997a2..1f6d3622270 100644 --- a/usr.bin/cvs/checkout.c +++ b/usr.bin/cvs/checkout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: checkout.c,v 1.165 2009/06/21 20:23:01 sthen Exp $ */ +/* $OpenBSD: checkout.c,v 1.166 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2006 Joris Vink * @@ -95,7 +95,7 @@ cvs_checkout(int argc, char **argv) exit(0); case 'D': dateflag = optarg; - cvs_specified_date = cvs_date_parse(dateflag); + cvs_specified_date = date_parse(dateflag); reset_tag = 0; break; case 'd': diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c index a9f656f0268..b41f101f6cc 100644 --- a/usr.bin/cvs/client.c +++ b/usr.bin/cvs/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.121 2009/04/04 11:29:57 joris Exp $ */ +/* $OpenBSD: client.c,v 1.122 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2006 Joris Vink * @@ -135,20 +135,20 @@ client_get_supported_responses(void) int i, first; first = 0; - bp = cvs_buf_alloc(512); + bp = buf_alloc(512); for (i = 0; cvs_responses[i].supported != -1; i++) { if (cvs_responses[i].hdlr == NULL) continue; if (first != 0) - cvs_buf_putc(bp, ' '); + buf_putc(bp, ' '); else first++; - cvs_buf_puts(bp, cvs_responses[i].name); + buf_puts(bp, cvs_responses[i].name); } - cvs_buf_putc(bp, '\0'); - d = cvs_buf_release(bp); + buf_putc(bp, '\0'); + d = buf_release(bp); return (d); } diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c index 31dc8870b81..f51ea1c3ad1 100644 --- a/usr.bin/cvs/commit.c +++ b/usr.bin/cvs/commit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commit.c,v 1.149 2009/06/07 08:39:13 ray Exp $ */ +/* $OpenBSD: commit.c,v 1.150 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2006 Joris Vink * Copyright (c) 2006 Xavier Santolaria @@ -237,54 +237,54 @@ cvs_commit_loginfo(char *repo) if (getcwd(pwd, sizeof(pwd)) == NULL) fatal("Can't get working directory"); - buf = cvs_buf_alloc(1024); + buf = buf_alloc(1024); cvs_trigger_loginfo_header(buf, repo); if (!RB_EMPTY(&files_added)) { - cvs_buf_puts(buf, "Added Files:"); + buf_puts(buf, "Added Files:"); RB_FOREACH(cf, cvs_flisthead, &files_added) { - cvs_buf_putc(buf, '\n'); - cvs_buf_putc(buf, '\t'); - cvs_buf_puts(buf, cf->file_path); + buf_putc(buf, '\n'); + buf_putc(buf, '\t'); + buf_puts(buf, cf->file_path); } - cvs_buf_putc(buf, '\n'); + buf_putc(buf, '\n'); } if (!RB_EMPTY(&files_modified)) { - cvs_buf_puts(buf, "Modified Files:"); + buf_puts(buf, "Modified Files:"); RB_FOREACH(cf, cvs_flisthead, &files_modified) { - cvs_buf_putc(buf, '\n'); - cvs_buf_putc(buf, '\t'); - cvs_buf_puts(buf, cf->file_path); + buf_putc(buf, '\n'); + buf_putc(buf, '\t'); + buf_puts(buf, cf->file_path); } - cvs_buf_putc(buf, '\n'); + buf_putc(buf, '\n'); } if (!RB_EMPTY(&files_removed)) { - cvs_buf_puts(buf, "Removed Files:"); + buf_puts(buf, "Removed Files:"); RB_FOREACH(cf, cvs_flisthead, &files_removed) { - cvs_buf_putc(buf, '\n'); - cvs_buf_putc(buf, '\t'); - cvs_buf_puts(buf, cf->file_path); + buf_putc(buf, '\n'); + buf_putc(buf, '\t'); + buf_puts(buf, cf->file_path); } - cvs_buf_putc(buf, '\n'); + buf_putc(buf, '\n'); } - cvs_buf_puts(buf, "Log Message:\n"); + buf_puts(buf, "Log Message:\n"); - cvs_buf_puts(buf, logmsg); + buf_puts(buf, logmsg); - cvs_buf_putc(buf, '\n'); - cvs_buf_putc(buf, '\0'); + buf_putc(buf, '\n'); + buf_putc(buf, '\0'); - loginfo = cvs_buf_release(buf); + loginfo = buf_release(buf); } void @@ -610,7 +610,7 @@ cvs_commit_local(struct cvs_file *cf) } else if (onbranch == 1) { b = commit_diff(cf, crev, 1); } else { - b = cvs_buf_load_fd(cf->fd); + b = buf_load_fd(cf->fd); } if (isnew == 0 && onbranch == 0) { @@ -736,9 +736,9 @@ commit_diff(struct cvs_file *cf, RCSNUM *rev, int reverse) if (cf->file_status == FILE_MODIFIED || cf->file_status == FILE_ADDED) { - b = cvs_buf_load_fd(cf->fd); - fd1 = cvs_buf_write_stmp(b, p1, NULL); - cvs_buf_free(b); + b = buf_load_fd(cf->fd); + fd1 = buf_write_stmp(b, p1, NULL); + buf_free(b); } else { fd1 = rcs_rev_write_stmp(cf->file_rcs, rev, p1, 0); } @@ -746,7 +746,7 @@ commit_diff(struct cvs_file *cf, RCSNUM *rev, int reverse) (void)xasprintf(&p2, "%s/diff2.XXXXXXXXXX", cvs_tmpdir); fd2 = rcs_rev_write_stmp(cf->file_rcs, rev, p2, RCS_KWEXP_NONE); - b = cvs_buf_alloc(128); + b = buf_alloc(128); diff_format = D_RCSDIFF; @@ -785,9 +785,9 @@ commit_desc_set(struct cvs_file *cf) if ((fd = open(desc_path, O_RDONLY)) == -1) return; - bp = cvs_buf_load_fd(fd); - cvs_buf_putc(bp, '\0'); - desc = cvs_buf_release(bp); + bp = buf_load_fd(fd); + buf_putc(bp, '\0'); + desc = buf_release(bp); rcs_desc_set(cf->file_rcs, desc); diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h index f0edcf20380..bbb9aa0bf47 100644 --- a/usr.bin/cvs/cvs.h +++ b/usr.bin/cvs/cvs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cvs.h,v 1.177 2010/07/23 08:31:19 ray Exp $ */ +/* $OpenBSD: cvs.h,v 1.178 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. @@ -356,7 +356,7 @@ const char *cvs_var_get(const char *); void cvs_cleanup(void); /* date.y */ -time_t cvs_date_parse(const char *); +time_t date_parse(const char *); /* entries.c */ struct cvs_ent *cvs_ent_parse(const char *); diff --git a/usr.bin/cvs/date.y b/usr.bin/cvs/date.y index 93da8115e54..494af2b3933 100644 --- a/usr.bin/cvs/date.y +++ b/usr.bin/cvs/date.y @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: date.y,v 1.19 2010/07/23 09:11:10 ray Exp $ */ +/* $OpenBSD: date.y,v 1.20 2010/07/23 21:46:05 ray Exp $ */ /* ** Originally written by Steven M. Bellovin while @@ -800,12 +800,12 @@ difftm(struct tm *a, struct tm *b) } /* - * cvs_date_parse() + * date_parse() * * Returns the number of seconds since the Epoch corresponding to the date. */ time_t -cvs_date_parse(const char *p) +date_parse(const char *p) { struct tm gmt, tm; time_t Start, tod, nowtime, tz; @@ -814,7 +814,7 @@ cvs_date_parse(const char *p) if (time(&nowtime) == -1 || !gmtime_r(&nowtime, &gmt) || !localtime_r(&nowtime, &tm)) - fatal("cvs_date_parse failed"); + fatal("date_parse failed"); tz = difftm(&gmt, &tm) / 60; @@ -879,7 +879,7 @@ main(int argc, char **argv) (void)printf("Enter date, or blank line to exit.\n\t> "); (void)fflush(stdout); while (fgets(buff, sizeof(buff), stdin) && buff[0]) { - d = cvs_date_parse(buff); + d = date_parse(buff); if (d == -1) (void)printf("Bad format - couldn't convert.\n"); else diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c index 0fd878d7ad6..4900eda2b32 100644 --- a/usr.bin/cvs/diff.c +++ b/usr.bin/cvs/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.156 2010/07/23 08:31:19 ray Exp $ */ +/* $OpenBSD: diff.c,v 1.157 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2008 Tobias Stoeckmann * Copyright (c) 2006 Joris Vink @@ -97,10 +97,10 @@ cvs_diff(int argc, char **argv) break; case 'D': if (date1 == -1 && rev1 == NULL) { - date1 = cvs_date_parse(optarg); + date1 = date_parse(optarg); dateflag1 = optarg; } else if (date2 == -1 && rev2 == NULL) { - date2 = cvs_date_parse(optarg); + date2 = date_parse(optarg); dateflag2 = optarg; } else { fatal("no more than 2 revisions/dates can" @@ -495,14 +495,14 @@ cvs_diff_local(struct cvs_file *cf) } else { if (fstat(cf->fd, &st) == -1) fatal("fstat failed %s", strerror(errno)); - b1 = cvs_buf_load_fd(cf->fd); + b1 = buf_load_fd(cf->fd); tv2[0].tv_sec = st.st_mtime; tv2[0].tv_usec = 0; tv2[1] = tv2[0]; - fd2 = cvs_buf_write_stmp(b1, p2, tv2); - cvs_buf_free(b1); + fd2 = buf_write_stmp(b1, p2, tv2); + buf_free(b1); } } diff --git a/usr.bin/cvs/diff.h b/usr.bin/cvs/diff.h index 757b272b391..16934ca551d 100644 --- a/usr.bin/cvs/diff.h +++ b/usr.bin/cvs/diff.h @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.h,v 1.20 2009/06/07 08:39:13 ray Exp $ */ +/* $OpenBSD: diff.h,v 1.21 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. @@ -63,8 +63,8 @@ * * @(#)diffreg.c 8.1 (Berkeley) 6/6/93 */ -#ifndef CVS_DIFF_H -#define CVS_DIFF_H +#ifndef DIFF_H +#define DIFF_H #define CVS_DIFF_DEFCTX 3 /* default context length */ /* @@ -80,13 +80,13 @@ /* * Command line flags */ -#define D_FORCEASCII 0x01 /* Treat file as ascii regardless of content */ -#define D_FOLDBLANKS 0x02 /* Treat all white space as equal */ -#define D_MINIMAL 0x04 /* Make diff as small as possible */ -#define D_IGNORECASE 0x08 /* Case-insensitive matching */ -#define D_PROTOTYPE 0x10 /* Display C function prototype */ -#define D_EXPANDTABS 0x20 /* Expand tabs to spaces */ -#define D_IGNOREBLANKS 0x40 /* Ignore white space changes */ +#define D_FORCEASCII 0x01 /* Treat file as ascii regardless of content */ +#define D_FOLDBLANKS 0x02 /* Treat all white space as equal */ +#define D_MINIMAL 0x04 /* Make diff as small as possible */ +#define D_IGNORECASE 0x08 /* Case-insensitive matching */ +#define D_PROTOTYPE 0x10 /* Display C function prototype */ +#define D_EXPANDTABS 0x20 /* Expand tabs to spaces */ +#define D_IGNOREBLANKS 0x40 /* Ignore white space changes */ /* * Status values for diffreg() return values @@ -105,7 +105,7 @@ void cvs_merge_file(struct cvs_file *, int); void diff_output(const char *, ...); int diffreg(const char *, const char *, int, int, BUF *, int); -int ed_patch_lines(struct cvs_lines *, struct cvs_lines *); +int ed_patch_lines(struct rcs_lines *, struct rcs_lines *); extern int diff_format; extern int diff3_conflicts; @@ -116,11 +116,11 @@ extern int diff_iflag; extern int diff_pflag; extern int diff_wflag; extern char *diff_file; -extern char diffargs[128]; +extern char diffargs[512]; /* XXX */ extern BUF *diffbuf; extern RCSNUM *diff_rev1; extern RCSNUM *diff_rev2; extern RCSNUM *d3rev1; extern RCSNUM *d3rev2; -#endif +#endif /* DIFF_H */ diff --git a/usr.bin/cvs/diff3.c b/usr.bin/cvs/diff3.c index 7bbc01da0b2..ec74dcca1f4 100644 --- a/usr.bin/cvs/diff3.c +++ b/usr.bin/cvs/diff3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff3.c,v 1.52 2010/07/23 08:31:19 ray Exp $ */ +/* $OpenBSD: diff3.c,v 1.53 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -104,8 +104,8 @@ struct diff { static size_t szchanges; -static struct diff *d13 = NULL; -static struct diff *d23 = NULL; +static struct diff *d13; +static struct diff *d23; /* * "de" is used to gather editing scripts. These are later spewed out in @@ -114,8 +114,8 @@ static struct diff *d23 = NULL; * look (!?). Array overlap indicates which sections in "de" correspond to * lines that are different in all three files. */ -static struct diff *de = NULL; -static char *overlap = NULL; +static struct diff *de; +static char *overlap; static int overlapcnt = 0; static FILE *fp[3]; static int cline[3]; /* # of the last-read line in each file (0-2) */ @@ -162,8 +162,8 @@ cvs_merge_file(struct cvs_file *cf, int verbose) char *dp13, *dp23, *path1, *path2, *path3; BUF *b1, *b2, *b3, *d1, *d2, *diffb; size_t dlen, plen; - struct cvs_line *lp; - struct cvs_lines *dlines, *plines; + struct rcs_line *lp; + struct rcs_lines *dlines, *plines; overlapcnt = 0; b1 = b2 = b3 = d1 = d2 = diffb = NULL; @@ -171,16 +171,16 @@ cvs_merge_file(struct cvs_file *cf, int verbose) rcsnum_tostr(d3rev1, r1, sizeof(r1)); rcsnum_tostr(d3rev2, r2, sizeof(r2)); - b1 = cvs_buf_load_fd(cf->fd); - d1 = cvs_buf_alloc(128); - d2 = cvs_buf_alloc(128); - diffb = cvs_buf_alloc(128); + b1 = buf_load_fd(cf->fd); + d1 = buf_alloc(128); + d2 = buf_alloc(128); + diffb = buf_alloc(128); (void)xasprintf(&path1, "%s/diff1.XXXXXXXXXX", cvs_tmpdir); (void)xasprintf(&path2, "%s/diff2.XXXXXXXXXX", cvs_tmpdir); (void)xasprintf(&path3, "%s/diff3.XXXXXXXXXX", cvs_tmpdir); - fds[2] = cvs_buf_write_stmp(b1, path1, NULL); + fds[2] = buf_write_stmp(b1, path1, NULL); if (verbose == 1) cvs_printf("Retrieving revision %s\n", r1); fds[3] = rcs_rev_write_stmp(cf->file_rcs, d3rev1, path2, 0); @@ -192,12 +192,12 @@ cvs_merge_file(struct cvs_file *cf, int verbose) diffreg(path2, path3, fds[3], fds[4], d2, D_FORCEASCII); (void)xasprintf(&dp13, "%s/d13.XXXXXXXXXX", cvs_tmpdir); - fds[0] = cvs_buf_write_stmp(d1, dp13, NULL); - cvs_buf_free(d1); + fds[0] = buf_write_stmp(d1, dp13, NULL); + buf_free(d1); (void)xasprintf(&dp23, "%s/d23.XXXXXXXXXX", cvs_tmpdir); - fds[1] = cvs_buf_write_stmp(d2, dp23, NULL); - cvs_buf_free(d2); + fds[1] = buf_write_stmp(d2, dp23, NULL); + buf_free(d2); argc = 0; diffbuf = diffb; @@ -218,10 +218,10 @@ cvs_merge_file(struct cvs_file *cf, int verbose) if (diff3_conflicts < 0) fatal("cvs_merge_file: merging failed for an unknown reason"); - plen = cvs_buf_len(diffb); - patch = cvs_buf_release(diffb); - dlen = cvs_buf_len(b1); - data = cvs_buf_release(b1); + plen = buf_len(diffb); + patch = buf_release(diffb); + dlen = buf_len(b1); + data = buf_release(b1); if (verbose == 1) cvs_printf("Merging differences between %s and %s into `%s'\n", @@ -320,10 +320,10 @@ diff3_internal(int argc, char **argv, const char *fmark, const char *rmark) } int -ed_patch_lines(struct cvs_lines *dlines, struct cvs_lines *plines) +ed_patch_lines(struct rcs_lines *dlines, struct rcs_lines *plines) { char op, *ep; - struct cvs_line *sort, *lp, *dlp, *ndlp, *insert_after; + struct rcs_line *sort, *lp, *dlp, *ndlp, *insert_after; int start, end, i, lineno; u_char tmp; @@ -799,8 +799,7 @@ edscript(int n) (void)fseek(fp[2], (long)de[n].new.from, SEEK_SET); for (k = de[n].new.to-de[n].new.from; k > 0; k-= j) { j = k > BUFSIZ ? BUFSIZ : k; - if (fread(block, (size_t)1, (size_t)j, - fp[2]) != (size_t)j) + if (fread(block, 1, j, fp[2]) != j) return (-1); block[j] = '\0'; diff_output("%s", block); diff --git a/usr.bin/cvs/diff_internals.c b/usr.bin/cvs/diff_internals.c index 40e4d744213..7c83f745865 100644 --- a/usr.bin/cvs/diff_internals.c +++ b/usr.bin/cvs/diff_internals.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff_internals.c,v 1.31 2010/07/16 17:53:20 ray Exp $ */ +/* $OpenBSD: diff_internals.c,v 1.32 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. @@ -204,7 +204,7 @@ const char *diff_file1 = NULL; const char *diff_file2 = NULL; RCSNUM *diff_rev1 = NULL; RCSNUM *diff_rev2 = NULL; -char diffargs[128]; +char diffargs[512]; static struct stat stb1, stb2; static char *ifdefname, *ignore_pats; regex_t ignore_re; @@ -1446,7 +1446,7 @@ diff_output(const char *fmt, ...) if (i == -1) fatal("diff_output: could not allocate memory"); if (diffbuf != NULL) - cvs_buf_puts(diffbuf, str); + buf_puts(diffbuf, str); else cvs_printf("%s", str); xfree(str); diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index 1150d4aec1c..b4109847796 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.259 2010/07/13 20:47:19 nicm Exp $ */ +/* $OpenBSD: file.c,v 1.260 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2006 Joris Vink * Copyright (c) 2004 Jean-Francois Brousseau @@ -808,14 +808,14 @@ cvs_file_classify(struct cvs_file *cf, const char *tag) cf->file_ent != NULL && !RCSNUM_ISBRANCH(cf->file_ent->ce_rev) && cf->file_ent->ce_status != CVS_ENT_ADDED) { b1 = rcs_rev_getbuf(cf->file_rcs, cf->file_ent->ce_rev, 0); - b2 = cvs_buf_load_fd(cf->fd); + b2 = buf_load_fd(cf->fd); - if (cvs_buf_differ(b1, b2)) + if (buf_differ(b1, b2)) ismodified = 1; else ismodified = 0; - cvs_buf_free(b1); - cvs_buf_free(b2); + buf_free(b1); + buf_free(b2); } if (cf->file_rcs != NULL && cf->file_rcsrev != NULL && diff --git a/usr.bin/cvs/getlog.c b/usr.bin/cvs/getlog.c index 2b2028e5413..73917bc02a0 100644 --- a/usr.bin/cvs/getlog.c +++ b/usr.bin/cvs/getlog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getlog.c,v 1.93 2009/03/26 17:30:04 joris Exp $ */ +/* $OpenBSD: getlog.c,v 1.94 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2005, 2006 Xavier Santolaria * Copyright (c) 2006 Joris Vink @@ -452,7 +452,7 @@ date_select(RCSFILE *file, char *date) if (last == NULL) { flags |= LDATE_SINGLE; - firstdate = cvs_date_parse(first); + firstdate = date_parse(first); delim = '\0'; last = "\0"; } else { @@ -462,33 +462,33 @@ date_select(RCSFILE *file, char *date) if (delim == '>' && *last == '\0') { flags |= LDATE_EARLIER; - firstdate = cvs_date_parse(first); + firstdate = date_parse(first); } if (delim == '>' && *first == '\0' && *last != '\0') { flags |= LDATE_LATER; - firstdate = cvs_date_parse(last); + firstdate = date_parse(last); } if (delim == '<' && *last == '\0') { flags |= LDATE_LATER; - firstdate = cvs_date_parse(first); + firstdate = date_parse(first); } if (delim == '<' && *first == '\0' && *last != '\0') { flags |= LDATE_EARLIER; - firstdate = cvs_date_parse(last); + firstdate = date_parse(last); } if (*first != '\0' && *last != '\0') { flags |= LDATE_RANGE; if (delim == '<') { - firstdate = cvs_date_parse(first); - lastdate = cvs_date_parse(last); + firstdate = date_parse(first); + lastdate = date_parse(last); } else { - firstdate = cvs_date_parse(last); - lastdate = cvs_date_parse(first); + firstdate = date_parse(last); + lastdate = date_parse(first); } } diff --git a/usr.bin/cvs/history.c b/usr.bin/cvs/history.c index 05d9e7ecc9b..82b944cecb3 100644 --- a/usr.bin/cvs/history.c +++ b/usr.bin/cvs/history.c @@ -1,4 +1,4 @@ -/* $OpenBSD: history.c,v 1.39 2008/06/19 19:03:25 tobias Exp $ */ +/* $OpenBSD: history.c,v 1.40 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2007 Joris Vink * @@ -130,23 +130,23 @@ cvs_history_add(int type, struct cvs_file *cf, const char *argument) case CVS_HISTORY_CHECKOUT: case CVS_HISTORY_EXPORT: /* - * cvs_buf_alloc uses xcalloc(), so we are safe even + * buf_alloc uses xcalloc(), so we are safe even * if neither cvs_specified_tag nor cvs_specified_date * have been supplied. */ - buf = cvs_buf_alloc(128); + buf = buf_alloc(128); if (cvs_specified_tag != NULL) { - cvs_buf_puts(buf, cvs_specified_tag); + buf_puts(buf, cvs_specified_tag); if (cvs_specified_date != -1) - cvs_buf_putc(buf, ':'); + buf_putc(buf, ':'); } if (cvs_specified_date != -1) { gmtime_r(&cvs_specified_date, &datetm); strftime(timebuf, sizeof(timebuf), "%Y.%m.%d.%H.%M.%S", &datetm); - cvs_buf_puts(buf, timebuf); + buf_puts(buf, timebuf); } - rev = cvs_buf_release(buf); + rev = buf_release(buf); break; case CVS_HISTORY_UPDATE_MERGED: case CVS_HISTORY_UPDATE_MERGED_ERR: diff --git a/usr.bin/cvs/import.c b/usr.bin/cvs/import.c index f07d5d08517..3edd9ce5b65 100644 --- a/usr.bin/cvs/import.c +++ b/usr.bin/cvs/import.c @@ -1,4 +1,4 @@ -/* $OpenBSD: import.c,v 1.101 2009/06/27 16:55:31 martynas Exp $ */ +/* $OpenBSD: import.c,v 1.102 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2006 Joris Vink * @@ -183,7 +183,7 @@ cvs_import(int argc, char **argv) import_printf("\nNo conflicts created by this import.\n\n"); } - loginfo = cvs_buf_release(logbuf); + loginfo = buf_release(logbuf); logbuf = NULL; line_list = cvs_trigger_getlines(CVS_PATH_LOGINFO, import_repository); @@ -209,7 +209,7 @@ import_printf(const char *fmt, ...) va_end(vap); cvs_printf("%s", str); - cvs_buf_puts(logbuf, str); + buf_puts(logbuf, str); xfree(str); } @@ -265,29 +265,29 @@ import_loginfo(char *repo) if (getcwd(pwd, sizeof(pwd)) == NULL) fatal("Can't get working directory"); - logbuf = cvs_buf_alloc(1024); + logbuf = buf_alloc(1024); cvs_trigger_loginfo_header(logbuf, repo); - cvs_buf_puts(logbuf, "Log Message:\n"); - cvs_buf_puts(logbuf, logmsg); + buf_puts(logbuf, "Log Message:\n"); + buf_puts(logbuf, logmsg); if (logmsg[0] != '\0' && logmsg[strlen(logmsg) - 1] != '\n') - cvs_buf_putc(logbuf, '\n'); - cvs_buf_putc(logbuf, '\n'); + buf_putc(logbuf, '\n'); + buf_putc(logbuf, '\n'); - cvs_buf_puts(logbuf, "Status:\n\n"); + buf_puts(logbuf, "Status:\n\n"); - cvs_buf_puts(logbuf, "Vendor Tag:\t"); - cvs_buf_puts(logbuf, vendor_tag); - cvs_buf_putc(logbuf, '\n'); - cvs_buf_puts(logbuf, "Release Tags:\t"); + buf_puts(logbuf, "Vendor Tag:\t"); + buf_puts(logbuf, vendor_tag); + buf_putc(logbuf, '\n'); + buf_puts(logbuf, "Release Tags:\t"); for (i = 0; i < tagcount ; i++) { - cvs_buf_puts(logbuf, "\t\t"); - cvs_buf_puts(logbuf, release_tags[i]); - cvs_buf_putc(logbuf, '\n'); + buf_puts(logbuf, "\t\t"); + buf_puts(logbuf, release_tags[i]); + buf_putc(logbuf, '\n'); } - cvs_buf_putc(logbuf, '\n'); - cvs_buf_putc(logbuf, '\n'); + buf_putc(logbuf, '\n'); + buf_putc(logbuf, '\n'); } static void @@ -322,7 +322,7 @@ import_new(struct cvs_file *cf) if ((branch = rcsnum_parse(import_branch)) == NULL) fatal("import_new: failed to parse branch"); - bp = cvs_buf_load_fd(cf->fd); + bp = buf_load_fd(cf->fd); if ((brev = rcsnum_brtorev(branch)) == NULL) fatal("import_new: failed to get first branch revision"); @@ -397,11 +397,11 @@ import_update(struct cvs_file *cf) fatal("import_update: rcsnum_parse failed"); b1 = rcs_rev_getbuf(cf->file_rcs, rev, RCS_KWEXP_NONE); - b2 = cvs_buf_load_fd(cf->fd); + b2 = buf_load_fd(cf->fd); - ret = cvs_buf_differ(b1, b2); - cvs_buf_free(b1); - cvs_buf_free(b2); + ret = buf_differ(b1, b2); + buf_free(b1); + buf_free(b2); if (ret == 0) { import_tag(cf, brev, rev); rcsnum_free(brev); @@ -463,13 +463,13 @@ import_get_rcsdiff(struct cvs_file *cf, RCSNUM *rev) BUF *b1, *b2; int fd1, fd2; - b2 = cvs_buf_alloc(128); + b2 = buf_alloc(128); - b1 = cvs_buf_load_fd(cf->fd); + b1 = buf_load_fd(cf->fd); (void)xasprintf(&p1, "%s/diff1.XXXXXXXXXX", cvs_tmpdir); - fd1 = cvs_buf_write_stmp(b1, p1, NULL); - cvs_buf_free(b1); + fd1 = buf_write_stmp(b1, p1, NULL); + buf_free(b1); (void)xasprintf(&p2, "%s/diff2.XXXXXXXXXX", cvs_tmpdir); fd2 = rcs_rev_write_stmp(cf->file_rcs, rev, p2, RCS_KWEXP_NONE); diff --git a/usr.bin/cvs/init.c b/usr.bin/cvs/init.c index 338dcf0100a..14694061035 100644 --- a/usr.bin/cvs/init.c +++ b/usr.bin/cvs/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.36 2009/03/25 21:19:20 joris Exp $ */ +/* $OpenBSD: init.c,v 1.37 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * Copyright (c) 2006 Xavier Santolaria @@ -177,7 +177,7 @@ init_mkfile(char *path, const char **content) if ((file = rcs_open(rpath, fd, rcsflags, 0444)) == NULL) fatal("failed to create RCS file for `%s'", path); - b = cvs_buf_load(path); + b = 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 f817f729342..12e667de44f 100644 --- a/usr.bin/cvs/logmsg.c +++ b/usr.bin/cvs/logmsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: logmsg.c,v 1.53 2010/07/23 08:31:19 ray Exp $ */ +/* $OpenBSD: logmsg.c,v 1.54 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2007 Joris Vink * @@ -62,7 +62,7 @@ cvs_logmsg_read(const char *path) fatal("cvs_logmsg_read: %s: file size too big", path); lbuf = NULL; - bp = cvs_buf_alloc(st.st_size); + bp = buf_alloc(st.st_size); while ((buf = fgetln(fp, &len))) { if (buf[len - 1] == '\n') { buf[len - 1] = '\0'; @@ -78,8 +78,8 @@ cvs_logmsg_read(const char *path) sizeof(CVS_LOGMSG_PREFIX) - 1)) continue; - cvs_buf_append(bp, buf, len); - cvs_buf_putc(bp, '\n'); + buf_append(bp, buf, len); + buf_putc(bp, '\n'); } if (lbuf != NULL) @@ -87,8 +87,8 @@ cvs_logmsg_read(const char *path) (void)fclose(fp); - cvs_buf_putc(bp, '\0'); - return (cvs_buf_release(bp)); + buf_putc(bp, '\0'); + return (buf_release(bp)); } char * diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index d14cceed78c..3eac5b26018 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.296 2010/07/23 08:31:19 ray Exp $ */ +/* $OpenBSD: rcs.c,v 1.297 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. @@ -211,8 +211,8 @@ static struct rcs_key { #define RCS_NKEYS (sizeof(rcs_keys)/sizeof(rcs_keys[0])) static RCSNUM *rcs_get_revision(const char *, RCSFILE *); -int rcs_patch_lines(struct cvs_lines *, struct cvs_lines *, - struct cvs_line **, struct rcs_delta *); +int rcs_patch_lines(struct rcs_lines *, struct rcs_lines *, + struct rcs_line **, struct rcs_delta *); static void rcs_parse_init(RCSFILE *); static int rcs_parse_admin(RCSFILE *); static int rcs_parse_delta(RCSFILE *); @@ -232,8 +232,8 @@ static int rcs_pushtok(RCSFILE *, const char *, int); static void rcs_growbuf(RCSFILE *); static void rcs_strprint(const u_char *, size_t, FILE *); -static void rcs_kwexp_line(char *, struct rcs_delta *, struct cvs_lines *, - struct cvs_line *, int mode); +static void rcs_kwexp_line(char *, struct rcs_delta *, struct rcs_lines *, + struct rcs_line *, int mode); static int rcs_ignore_keys = 0; @@ -1025,12 +1025,12 @@ rcs_comment_set(RCSFILE *file, const char *comment) } int -rcs_patch_lines(struct cvs_lines *dlines, struct cvs_lines *plines, - struct cvs_line **alines, struct rcs_delta *rdp) +rcs_patch_lines(struct rcs_lines *dlines, struct rcs_lines *plines, + struct rcs_line **alines, struct rcs_delta *rdp) { u_char op; char *ep; - struct cvs_line *lp, *dlp, *ndlp; + struct rcs_line *lp, *dlp, *ndlp; int i, lineno, nbln; u_char tmp; @@ -1136,8 +1136,8 @@ rcs_patch_lines(struct cvs_lines *dlines, struct cvs_lines *plines, void rcs_delta_stats(struct rcs_delta *rdp, int *ladded, int *lremoved) { - struct cvs_lines *plines; - struct cvs_line *lp; + struct rcs_lines *plines; + struct rcs_line *lp; int added, i, lineno, nbln, removed; char op, *ep; u_char tmp; @@ -1339,7 +1339,7 @@ rcs_rev_remove(RCSFILE *rf, RCSNUM *rev) path_tmp1 = path_tmp2 = NULL; if (prevrdp != NULL && nextrdp != NULL) { - newdiff = cvs_buf_alloc(64); + newdiff = buf_alloc(64); /* calculate new diff */ (void)xasprintf(&path_tmp1, "%s/diff1.XXXXXXXXXX", cvs_tmpdir); @@ -2504,8 +2504,8 @@ rcs_deltatext_set(RCSFILE *rfp, RCSNUM *rev, BUF *bp) if (rdp->rd_text != NULL) xfree(rdp->rd_text); - len = cvs_buf_len(bp); - dtext = cvs_buf_release(bp); + len = buf_len(bp); + dtext = buf_release(bp); bp = NULL; if (len != 0) { @@ -2709,10 +2709,10 @@ rcs_get_revision(const char *revstr, RCSFILE *rfp) * rcs_rev_getlines() * * Get the entire contents of revision from the RCSFILE and - * return it as a pointer to a struct cvs_lines. + * return it as a pointer to a struct rcs_lines. */ -struct cvs_lines * -rcs_rev_getlines(RCSFILE *rfp, RCSNUM *frev, struct cvs_line ***alines) +struct rcs_lines * +rcs_rev_getlines(RCSFILE *rfp, RCSNUM *frev, struct rcs_line ***alines) { size_t plen; int annotate, done, i, nextroot; @@ -2720,8 +2720,8 @@ rcs_rev_getlines(RCSFILE *rfp, RCSNUM *frev, struct cvs_line ***alines) struct rcs_branch *brp; struct rcs_delta *hrdp, *prdp, *rdp, *trdp; u_char *patch; - struct cvs_line *line, *nline; - struct cvs_lines *dlines, *plines; + struct rcs_line *line, *nline; + struct rcs_lines *dlines, *plines; if (rfp->rf_head == NULL || (hrdp = rcs_findrev(rfp, rfp->rf_head)) == NULL) @@ -2759,7 +2759,7 @@ rcs_rev_getlines(RCSFILE *rfp, RCSNUM *frev, struct cvs_line ***alines) i++; } - *alines = xcalloc(i + 1, sizeof(struct cvs_line *)); + *alines = xcalloc(i + 1, sizeof(struct rcs_line *)); (*alines)[i] = NULL; annotate = ANNOTATE_NOW; @@ -2815,7 +2815,7 @@ again: i++; } - *alines = xcalloc(i + 1, sizeof(struct cvs_line *)); + *alines = xcalloc(i + 1, sizeof(struct rcs_line *)); (*alines)[i] = NULL; annotate = ANNOTATE_NOW; @@ -2891,7 +2891,7 @@ done: } void -rcs_annotate_getlines(RCSFILE *rfp, RCSNUM *frev, struct cvs_line ***alines) +rcs_annotate_getlines(RCSFILE *rfp, RCSNUM *frev, struct rcs_line ***alines) { size_t plen; int i, nextroot; @@ -2899,8 +2899,8 @@ rcs_annotate_getlines(RCSFILE *rfp, RCSNUM *frev, struct cvs_line ***alines) struct rcs_branch *brp; struct rcs_delta *rdp, *trdp; u_char *patch; - struct cvs_line *line; - struct cvs_lines *dlines, *plines; + struct rcs_line *line; + struct rcs_lines *dlines, *plines; if (!RCSNUM_ISBRANCHREV(frev)) fatal("rcs_annotate_getlines: branch revision expected"); @@ -2992,7 +2992,7 @@ rcs_annotate_getlines(RCSFILE *rfp, RCSNUM *frev, struct cvs_line ***alines) if (line->l_line != NULL) i++; } - *alines = xcalloc(i + 1, sizeof(struct cvs_line *)); + *alines = xcalloc(i + 1, sizeof(struct rcs_line *)); (*alines)[i] = NULL; i = 0; @@ -3015,13 +3015,13 @@ rcs_rev_getbuf(RCSFILE *rfp, RCSNUM *rev, int mode) { int expmode, expand; struct rcs_delta *rdp; - struct cvs_lines *lines; - struct cvs_line *lp, *nlp; + struct rcs_lines *lines; + struct rcs_line *lp, *nlp; BUF *bp; expand = 0; lines = rcs_rev_getlines(rfp, rev, NULL); - bp = cvs_buf_alloc(1024 * 16); + bp = buf_alloc(1024 * 16); if (!(mode & RCS_KWEXP_NONE)) { if (rfp->rf_expand != NULL) @@ -3048,7 +3048,7 @@ rcs_rev_getbuf(RCSFILE *rfp, RCSNUM *rev, int mode) rcs_kwexp_line(rfp->rf_path, rdp, lines, lp, expmode); do { - cvs_buf_append(bp, lp->l_line, lp->l_len); + buf_append(bp, lp->l_line, lp->l_len); } while ((lp = TAILQ_NEXT(lp, l_list)) != nlp); } @@ -3071,8 +3071,8 @@ rcs_rev_write_fd(RCSFILE *rfp, RCSNUM *rev, int _fd, int mode) size_t ret; int expmode, expand; struct rcs_delta *rdp; - struct cvs_lines *lines; - struct cvs_line *lp, *nlp; + struct rcs_lines *lines; + struct rcs_line *lp, *nlp; extern int print_stdout; expand = 0; @@ -3157,8 +3157,8 @@ rcs_rev_write_stmp(RCSFILE *rfp, RCSNUM *rev, char *template, int mode) } static void -rcs_kwexp_line(char *rcsfile, struct rcs_delta *rdp, struct cvs_lines *lines, - struct cvs_line *line, int mode) +rcs_kwexp_line(char *rcsfile, struct rcs_delta *rdp, struct rcs_lines *lines, + struct rcs_line *line, int mode) { BUF *tmpbuf; int kwtype; @@ -3350,7 +3350,7 @@ rcs_kwexp_line(char *rcsfile, struct rcs_delta *rdp, struct cvs_lines *lines, /* order does not matter anymore below */ if (kwtype & RCS_KW_LOG) { char linebuf[256]; - struct cvs_line *cur, *lp; + struct rcs_line *cur, *lp; char *logp, *l_line, *prefix, *q, *sprefix; size_t i; @@ -3490,28 +3490,28 @@ 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)); + tmpbuf = buf_alloc(len + strlen(expbuf)); /* Append everything before keyword. */ - cvs_buf_append(tmpbuf, line->l_line, + buf_append(tmpbuf, line->l_line, start - line->l_line); /* Append keyword. */ - cvs_buf_puts(tmpbuf, expbuf); + buf_puts(tmpbuf, expbuf); /* Point c to end of keyword. */ - tlen = cvs_buf_len(tmpbuf) - 1; + tlen = buf_len(tmpbuf) - 1; /* Append everything after keyword. */ - cvs_buf_append(tmpbuf, end, + buf_append(tmpbuf, end, line->l_line + line->l_len - end); - c = cvs_buf_get(tmpbuf) + tlen; + c = buf_get(tmpbuf) + tlen; /* Point fin to end of data. */ - fin = cvs_buf_get(tmpbuf) + cvs_buf_len(tmpbuf) - 1; + fin = buf_get(tmpbuf) + buf_len(tmpbuf) - 1; /* Recalculate new length. */ - len = cvs_buf_len(tmpbuf); + len = buf_len(tmpbuf); /* tmpbuf is now ready, convert to string */ if (line->l_needsfree) xfree(line->l_line); line->l_len = len; - line->l_line = cvs_buf_release(tmpbuf); + line->l_line = buf_release(tmpbuf); line->l_needsfree = 1; } } diff --git a/usr.bin/cvs/rcs.h b/usr.bin/cvs/rcs.h index 3935d68e0c3..a5a736d2b06 100644 --- a/usr.bin/cvs/rcs.h +++ b/usr.bin/cvs/rcs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.h,v 1.93 2009/03/25 21:19:20 joris Exp $ */ +/* $OpenBSD: rcs.h,v 1.94 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. @@ -142,12 +142,12 @@ struct rcs_lock { char *rl_name; RCSNUM *rl_num; - TAILQ_ENTRY(rcs_lock) rl_list; + TAILQ_ENTRY(rcs_lock) rl_list; }; struct rcs_branch { RCSNUM *rb_num; - TAILQ_ENTRY(rcs_branch) rb_list; + TAILQ_ENTRY(rcs_branch) rb_list; }; TAILQ_HEAD(rcs_dlist, rcs_delta); @@ -191,8 +191,8 @@ typedef struct rcs_file { void *rf_pdata; } RCSFILE; -struct cvs_line; -struct cvs_lines; +struct rcs_line; +struct rcs_lines; RCSFILE *rcs_open(const char *, int, int, ...); void rcs_close(RCSFILE *); @@ -236,10 +236,10 @@ RCSNUM *rcs_tag_resolve(RCSFILE *, const char *); void rcs_write(RCSFILE *); int rcs_rev_write_stmp(RCSFILE *, RCSNUM *, char *, int); void rcs_rev_write_fd(RCSFILE *, RCSNUM *, int, int); -struct cvs_lines *rcs_rev_getlines(RCSFILE *, RCSNUM *, - struct cvs_line ***); +struct rcs_lines *rcs_rev_getlines(RCSFILE *, RCSNUM *, + struct rcs_line ***); void rcs_annotate_getlines(RCSFILE *, RCSNUM *, - struct cvs_line ***); + struct rcs_line ***); BUF *rcs_rev_getbuf(RCSFILE *, RCSNUM *, int); void rcs_delta_stats(struct rcs_delta *, int *, int *); diff --git a/usr.bin/cvs/remote.c b/usr.bin/cvs/remote.c index 09a828cac57..162fe539282 100644 --- a/usr.bin/cvs/remote.c +++ b/usr.bin/cvs/remote.c @@ -1,4 +1,4 @@ -/* $OpenBSD: remote.c,v 1.28 2009/04/07 21:27:45 joris Exp $ */ +/* $OpenBSD: remote.c,v 1.29 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2006 Joris Vink * @@ -219,8 +219,8 @@ cvs_remote_send_file_buf(char *file, BUF *bp, mode_t mode) if (cvs_server_active != 1) fatal("cvs_remote_send_file_buf is server only"); - len = cvs_buf_len(bp); - data = cvs_buf_release(bp); + len = buf_len(bp); + data = buf_release(bp); cvs_modetostr(mode, buf, sizeof(buf)); cvs_remote_output(buf); diff --git a/usr.bin/cvs/server.c b/usr.bin/cvs/server.c index 5e846b39b6c..2ae21a980be 100644 --- a/usr.bin/cvs/server.c +++ b/usr.bin/cvs/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.99 2009/04/18 16:26:01 joris Exp $ */ +/* $OpenBSD: server.c,v 1.100 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2006 Joris Vink * @@ -219,21 +219,21 @@ cvs_server_validreq(char *data) int i, first; first = 0; - bp = cvs_buf_alloc(512); + bp = buf_alloc(512); for (i = 0; cvs_requests[i].supported != -1; i++) { if (cvs_requests[i].hdlr == NULL) continue; if (first != 0) - cvs_buf_putc(bp, ' '); + buf_putc(bp, ' '); else first++; - cvs_buf_puts(bp, cvs_requests[i].name); + buf_puts(bp, cvs_requests[i].name); } - cvs_buf_putc(bp, '\0'); - d = cvs_buf_release(bp); + buf_putc(bp, '\0'); + d = buf_release(bp); cvs_server_send_response("Valid-requests %s", d); cvs_server_send_response("ok"); diff --git a/usr.bin/cvs/trigger.c b/usr.bin/cvs/trigger.c index 54f64334fb4..f2d3f010b73 100644 --- a/usr.bin/cvs/trigger.c +++ b/usr.bin/cvs/trigger.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trigger.c,v 1.17 2009/03/19 09:55:19 joris Exp $ */ +/* $OpenBSD: trigger.c,v 1.18 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2008 Tobias Stoeckmann * Copyright (c) 2008 Jonathan Armani @@ -71,10 +71,10 @@ expand_args(BUF *buf, struct file_info_list *file_info, const char *repo, } } if (quote) - cvs_buf_putc(buf, '"'); + buf_putc(buf, '"'); if (oldstyle) { - cvs_buf_puts(buf, repo); - cvs_buf_putc(buf, ' '); + buf_puts(buf, repo); + buf_putc(buf, ' '); } if (*format == '\0') @@ -84,16 +84,16 @@ expand_args(BUF *buf, struct file_info_list *file_info, const char *repo, * check like this, add only uses loginfo for directories anyway */ if (cvs_cmdop == CVS_OP_ADD) { - cvs_buf_puts(buf, "- New directory"); + buf_puts(buf, "- New directory"); if (quote) - cvs_buf_putc(buf, '"'); + buf_putc(buf, '"'); return (0); } if (cvs_cmdop == CVS_OP_IMPORT) { - cvs_buf_puts(buf, "- Imported sources"); + buf_puts(buf, "- Imported sources"); if (quote) - cvs_buf_putc(buf, '"'); + buf_putc(buf, '"'); return (0); } @@ -155,10 +155,10 @@ expand_args(BUF *buf, struct file_info_list *file_info, const char *repo, } if (val != NULL) - cvs_buf_puts(buf, val); + buf_puts(buf, val); if (*(++p) != '\0') - cvs_buf_putc(buf, ','); + buf_putc(buf, ','); } if (fi != NULL) @@ -170,11 +170,11 @@ expand_args(BUF *buf, struct file_info_list *file_info, const char *repo, *format == 'p' || *format == 'r' || *format == 't')) break; - cvs_buf_putc(buf, ' '); + buf_putc(buf, ' '); } if (quote) - cvs_buf_putc(buf, '"'); + buf_putc(buf, '"'); return 0; } @@ -190,14 +190,14 @@ expand_var(BUF *buf, const char *var) cvs_log(LP_ERR, "no such user variable ${=%s}", var); return (1); } - cvs_buf_puts(buf, val); + buf_puts(buf, val); } else { if (strcmp(var, "CVSEDITOR") == 0 || strcmp(var, "EDITOR") == 0 || strcmp(var, "VISUAL") == 0) - cvs_buf_puts(buf, cvs_editor); + buf_puts(buf, cvs_editor); else if (strcmp(var, "CVSROOT") == 0) - cvs_buf_puts(buf, current_cvsroot->cr_dir); + buf_puts(buf, current_cvsroot->cr_dir); else if (strcmp(var, "USER") == 0) { pw = getpwuid(geteuid()); if (pw == NULL) { @@ -205,7 +205,7 @@ expand_var(BUF *buf, const char *var) "caller ID"); return (1); } - cvs_buf_puts(buf, pw->pw_name); + buf_puts(buf, pw->pw_name); } else if (strcmp(var, "RCSBIN") == 0) { cvs_log(LP_ERR, "RCSBIN internal variable is no " "longer supported"); @@ -261,13 +261,13 @@ parse_cmd(int type, char *cmd, const char *repo, if (*p == '%') return (NULL); - buf = cvs_buf_alloc(1024); + buf = buf_alloc(1024); p = cmd; again: for (; *p != '\0'; p++) { if ((pos = strcspn(p, "$%")) != 0) { - cvs_buf_append(buf, p, pos); + buf_append(buf, p, pos); p += pos; } @@ -332,14 +332,14 @@ again: goto again; } - cvs_buf_putc(buf, '\0'); - return (cvs_buf_release(buf)); + buf_putc(buf, '\0'); + return (buf_release(buf)); bad: if (q != NULL) xfree(q); cvs_log(LP_NOTICE, "%s contains malformed command '%s'", file, cmd); - cvs_buf_free(buf); + buf_free(buf); return (NULL); } @@ -552,19 +552,19 @@ cvs_trigger_loginfo_header(BUF *buf, char *repo) strerror(errno)); } - cvs_buf_puts(buf, "Update of "); - cvs_buf_puts(buf, current_cvsroot->cr_dir); - cvs_buf_putc(buf, '/'); - cvs_buf_puts(buf, repo); - cvs_buf_putc(buf, '\n'); - - cvs_buf_puts(buf, "In directory "); - cvs_buf_puts(buf, hostname); - cvs_buf_puts(buf, ":"); - cvs_buf_puts(buf, dirname(pwd)); - cvs_buf_putc(buf, '/'); - cvs_buf_puts(buf, repo); - cvs_buf_putc(buf, '\n'); - cvs_buf_putc(buf, '\n'); + buf_puts(buf, "Update of "); + buf_puts(buf, current_cvsroot->cr_dir); + buf_putc(buf, '/'); + buf_puts(buf, repo); + buf_putc(buf, '\n'); + + buf_puts(buf, "In directory "); + buf_puts(buf, hostname); + buf_puts(buf, ":"); + buf_puts(buf, dirname(pwd)); + buf_putc(buf, '/'); + buf_puts(buf, repo); + buf_putc(buf, '\n'); + buf_putc(buf, '\n'); } diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c index 7d51f981a74..5a0b2c78c8d 100644 --- a/usr.bin/cvs/update.c +++ b/usr.bin/cvs/update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: update.c,v 1.161 2010/07/13 21:33:44 nicm Exp $ */ +/* $OpenBSD: update.c,v 1.162 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2006 Joris Vink * @@ -78,7 +78,7 @@ cvs_update(int argc, char **argv) break; case 'D': dateflag = optarg; - cvs_specified_date = cvs_date_parse(dateflag); + cvs_specified_date = date_parse(dateflag); reset_tag = 0; break; case 'd': @@ -529,8 +529,8 @@ update_has_conflict_markers(struct cvs_file *cf) BUF *bp; int conflict; char *content; - struct cvs_line *lp; - struct cvs_lines *lines; + struct rcs_line *lp; + struct rcs_lines *lines; size_t len; cvs_log(LP_TRACE, "update_has_conflict_markers(%s)", cf->file_path); @@ -538,11 +538,11 @@ update_has_conflict_markers(struct cvs_file *cf) if (!(cf->file_flags & FILE_ON_DISK) || cf->file_ent == NULL) return (0); - bp = cvs_buf_load_fd(cf->fd); + bp = buf_load_fd(cf->fd); - cvs_buf_putc(bp, '\0'); - len = cvs_buf_len(bp); - content = cvs_buf_release(bp); + buf_putc(bp, '\0'); + len = buf_len(bp); + content = buf_release(bp); if ((lines = cvs_splitlines(content, len)) == NULL) fatal("update_has_conflict_markers: failed to split lines"); @@ -592,7 +592,7 @@ update_join_file(struct cvs_file *cf) if ((p = strchr(jrev2, ':')) != NULL) { (*p++) = '\0'; - cvs_specified_date = cvs_date_parse(p); + cvs_specified_date = date_parse(p); } rev2 = rcs_translate_tag(jrev2, cf->file_rcs); @@ -601,7 +601,7 @@ update_join_file(struct cvs_file *cf) if (jrev1 != NULL) { if ((p = strchr(jrev1, ':')) != NULL) { (*p++) = '\0'; - cvs_specified_date = cvs_date_parse(p); + cvs_specified_date = date_parse(p); } rev1 = rcs_translate_tag(jrev1, cf->file_rcs); diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c index 458249124fd..f94e920c717 100644 --- a/usr.bin/cvs/util.c +++ b/usr.bin/cvs/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.151 2009/03/24 06:59:19 joris Exp $ */ +/* $OpenBSD: util.c,v 1.152 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * Copyright (c) 2005, 2006 Joris Vink @@ -685,13 +685,13 @@ cvs_mkpath(const char *path, char *tag) /* * Split the contents of a file into a list of lines. */ -struct cvs_lines * +struct rcs_lines * cvs_splitlines(u_char *data, size_t len) { u_char *p, *c; size_t i, tlen; - struct cvs_lines *lines; - struct cvs_line *lp; + struct rcs_lines *lines; + struct rcs_line *lp; lines = xcalloc(1, sizeof(*lines)); TAILQ_INIT(&(lines->l_lines)); @@ -717,9 +717,9 @@ cvs_splitlines(u_char *data, size_t len) } void -cvs_freelines(struct cvs_lines *lines) +cvs_freelines(struct rcs_lines *lines) { - struct cvs_line *lp; + struct rcs_line *lp; while ((lp = TAILQ_FIRST(&(lines->l_lines))) != NULL) { TAILQ_REMOVE(&(lines->l_lines), lp, l_list); diff --git a/usr.bin/cvs/util.h b/usr.bin/cvs/util.h index 2ead529e144..d595c6b4848 100644 --- a/usr.bin/cvs/util.h +++ b/usr.bin/cvs/util.h @@ -1,4 +1,4 @@ -/* $OpenBSD: util.h,v 1.27 2010/07/23 08:31:19 ray Exp $ */ +/* $OpenBSD: util.h,v 1.28 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2006 Niall O'Higgins * All rights reserved. @@ -44,19 +44,19 @@ void cvs_freeargv(char **, int); int cvs_exec(char *, const char *, int); u_int cvs_revision_select(RCSFILE *, char *); -struct cvs_line { +struct rcs_line { struct rcs_delta *l_delta; u_char *l_line; size_t l_len; int l_lineno; int l_lineno_orig; int l_needsfree; - TAILQ_ENTRY(cvs_line) l_list; + TAILQ_ENTRY(rcs_line) l_list; }; -TAILQ_HEAD(tqh, cvs_line); +TAILQ_HEAD(tqh, rcs_line); -struct cvs_lines { +struct rcs_lines { int l_nblines; struct tqh l_lines; }; @@ -66,8 +66,8 @@ struct cvs_argvector { char **argv; }; -struct cvs_lines *cvs_splitlines(u_char *, size_t); -void cvs_freelines(struct cvs_lines *); +struct rcs_lines *cvs_splitlines(u_char *, size_t); +void cvs_freelines(struct rcs_lines *); struct cvs_argvector *cvs_strsplit(char *, const char *); void cvs_argv_destroy(struct cvs_argvector *); int cvs_yesno(void); diff --git a/usr.bin/rcs/buf.c b/usr.bin/rcs/buf.c index 7849f66c1ee..43c67439827 100644 --- a/usr.bin/rcs/buf.c +++ b/usr.bin/rcs/buf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.c,v 1.14 2010/07/23 08:31:19 ray Exp $ */ +/* $OpenBSD: buf.c,v 1.15 2010/07/23 21:46:05 ray Exp $ */ /* * Copyright (c) 2003 Jean-Francois Brousseau * All rights reserved. @@ -41,7 +41,7 @@ #define BUF_INCR 128 -struct rcs_buf { +struct buf { u_int cb_flags; /* buffer handle, buffer size, and data length */ @@ -52,17 +52,17 @@ struct rcs_buf { #define SIZE_LEFT(b) (b->cb_size - b->cb_len) -static void rcs_buf_grow(BUF *, size_t); +static void buf_grow(BUF *, size_t); /* - * rcs_buf_alloc() + * buf_alloc() * * Create a new buffer structure and return a pointer to it. This structure - * uses dynamically-allocated memory and must be freed with rcs_buf_free(), + * uses dynamically-allocated memory and must be freed with buf_free(), * once the buffer is no longer needed. */ BUF * -rcs_buf_alloc(size_t len, u_int flags) +buf_alloc(size_t len, u_int flags) { BUF *b; @@ -81,7 +81,7 @@ rcs_buf_alloc(size_t len, u_int flags) } /* - * rcs_buf_load() + * buf_load() * * Open the file specified by and load all of its contents into a * buffer. @@ -89,7 +89,7 @@ rcs_buf_alloc(size_t len, u_int flags) * Sets errno on error. */ BUF * -rcs_buf_load(const char *path, u_int flags) +buf_load(const char *path, u_int flags) { int fd; ssize_t ret; @@ -110,7 +110,7 @@ rcs_buf_load(const char *path, u_int flags) errno = EFBIG; goto out; } - buf = rcs_buf_alloc(st.st_size, flags); + buf = buf_alloc(st.st_size, flags); for (bp = buf->cb_buf; ; bp += (size_t)ret) { len = SIZE_LEFT(buf); ret = read(fd, bp, len); @@ -118,7 +118,7 @@ rcs_buf_load(const char *path, u_int flags) int saved_errno; saved_errno = errno; - rcs_buf_free(buf); + buf_free(buf); buf = NULL; errno = saved_errno; goto out; @@ -141,13 +141,8 @@ out: return (buf); } -/* - * rcs_buf_free() - * - * Free the buffer and all associated data. - */ void -rcs_buf_free(BUF *b) +buf_free(BUF *b) { if (b->cb_buf != NULL) xfree(b->cb_buf); @@ -155,14 +150,14 @@ rcs_buf_free(BUF *b) } /* - * rcs_buf_release() + * buf_release() * * Free the buffer 's structural information but do not free the contents * of the buffer. Instead, they are returned and should be freed later using * free(). */ void * -rcs_buf_release(BUF *b) +buf_release(BUF *b) { void *tmp; @@ -172,33 +167,33 @@ rcs_buf_release(BUF *b) } /* - * rcs_buf_get() + * buf_get() */ u_char * -rcs_buf_get(BUF *b) +buf_get(BUF *b) { return (b->cb_buf); } /* - * rcs_buf_empty() + * buf_empty() * * Empty the contents of the buffer and reset pointers. */ void -rcs_buf_empty(BUF *b) +buf_empty(BUF *b) { memset(b->cb_buf, 0, b->cb_size); b->cb_len = 0; } /* - * rcs_buf_putc() + * buf_putc() * * Append a single character to the end of the buffer . */ void -rcs_buf_putc(BUF *b, int c) +buf_putc(BUF *b, int c) { u_char *bp; @@ -206,9 +201,9 @@ rcs_buf_putc(BUF *b, int c) if (bp == (b->cb_buf + b->cb_size)) { /* extend */ if (b->cb_flags & BUF_AUTOEXT) - rcs_buf_grow(b, (size_t)BUF_INCR); + buf_grow(b, (size_t)BUF_INCR); else - errx(1, "rcs_buf_putc failed"); + errx(1, "buf_putc failed"); /* the buffer might have been moved */ bp = b->cb_buf + b->cb_len; @@ -218,19 +213,19 @@ rcs_buf_putc(BUF *b, int c) } /* - * rcs_buf_getc() + * buf_getc() * * Return u_char at buffer position . * */ u_char -rcs_buf_getc(BUF *b, size_t pos) +buf_getc(BUF *b, size_t pos) { return (b->cb_buf[pos]); } /* - * rcs_buf_append() + * buf_append() * * Append bytes of data pointed to by to the buffer . If the * buffer is too small to accept all data, it will attempt to append as much @@ -239,7 +234,7 @@ rcs_buf_getc(BUF *b, size_t pos) * Returns the number of bytes successfully appended to the buffer. */ size_t -rcs_buf_append(BUF *b, const void *data, size_t len) +buf_append(BUF *b, const void *data, size_t len) { size_t left, rlen; u_char *bp, *bep; @@ -251,7 +246,7 @@ rcs_buf_append(BUF *b, const void *data, size_t len) if (left < len) { if (b->cb_flags & BUF_AUTOEXT) { - rcs_buf_grow(b, len - left); + buf_grow(b, len - left); bp = b->cb_buf + b->cb_len; } else rlen = bep - bp; @@ -264,11 +259,11 @@ rcs_buf_append(BUF *b, const void *data, size_t len) } /* - * rcs_buf_fappend() + * buf_fappend() * */ size_t -rcs_buf_fappend(BUF *b, const char *fmt, ...) +buf_fappend(BUF *b, const char *fmt, ...) { size_t ret; int n; @@ -280,31 +275,31 @@ rcs_buf_fappend(BUF *b, const char *fmt, ...) va_end(vap); if (n == -1) - errx(1, "rcs_buf_fappend: failed to format data"); + errx(1, "buf_fappend: failed to format data"); - ret = rcs_buf_append(b, str, n); + ret = buf_append(b, str, n); xfree(str); return (ret); } /* - * rcs_buf_len() + * buf_len() * * Returns the size of the buffer that is being used. */ size_t -rcs_buf_len(BUF *b) +buf_len(BUF *b) { return (b->cb_len); } /* - * rcs_buf_write_fd() + * buf_write_fd() * * Write the contents of the buffer to the specified */ int -rcs_buf_write_fd(BUF *b, int fd) +buf_write_fd(BUF *b, int fd) { u_char *bp; size_t len; @@ -329,13 +324,13 @@ rcs_buf_write_fd(BUF *b, int fd) } /* - * rcs_buf_write() + * buf_write() * * Write the contents of the buffer to the file whose path is given in * . If the file does not exist, it is created with mode . */ int -rcs_buf_write(BUF *b, const char *path, mode_t mode) +buf_write(BUF *b, const char *path, mode_t mode) { int fd; open: @@ -346,9 +341,9 @@ rcs_buf_write(BUF *b, const char *path, mode_t mode) err(1, "%s", path); } - if (rcs_buf_write_fd(b, fd) == -1) { + if (buf_write_fd(b, fd) == -1) { (void)unlink(path); - errx(1, "rcs_buf_write: rcs_buf_write_fd: `%s'", path); + errx(1, "buf_write: buf_write_fd: `%s'", path); } if (fchmod(fd, mode) < 0) @@ -360,14 +355,14 @@ rcs_buf_write(BUF *b, const char *path, mode_t mode) } /* - * rcs_buf_write_stmp() + * buf_write_stmp() * * Write the contents of the buffer to a temporary file whose path is * specified using