summaryrefslogtreecommitdiff
path: root/usr.bin/rcs
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/rcs')
-rw-r--r--usr.bin/rcs/buf.c93
-rw-r--r--usr.bin/rcs/buf.h36
-rw-r--r--usr.bin/rcs/ci.c46
-rw-r--r--usr.bin/rcs/co.c22
-rw-r--r--usr.bin/rcs/date.y10
-rw-r--r--usr.bin/rcs/diff.c4
-rw-r--r--usr.bin/rcs/diff.h9
-rw-r--r--usr.bin/rcs/diff3.c104
-rw-r--r--usr.bin/rcs/ident.c22
-rw-r--r--usr.bin/rcs/merge.c10
-rw-r--r--usr.bin/rcs/rcs.c57
-rw-r--r--usr.bin/rcs/rcs.h7
-rw-r--r--usr.bin/rcs/rcsclean.c14
-rw-r--r--usr.bin/rcs/rcsdiff.c28
-rw-r--r--usr.bin/rcs/rcsmerge.c10
-rw-r--r--usr.bin/rcs/rcsnum.c12
-rw-r--r--usr.bin/rcs/rcsprog.h4
-rw-r--r--usr.bin/rcs/rcsutil.c20
-rw-r--r--usr.bin/rcs/rlog.c20
19 files changed, 261 insertions, 267 deletions
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 <jfb@openbsd.org>
* 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 <path> 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 <b> 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 <b>'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 <b> 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 <c> to the end of the buffer <b>.
*/
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 <pos>.
*
*/
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 <len> bytes of data pointed to by <data> to the buffer <b>. 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 <b> to the specified <fd>
*/
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 <b> to the file whose path is given in
* <path>. If the file does not exist, it is created with mode <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 <b> to a temporary file whose path is
* specified using <template> (see mkstemp.3). NB. This function will modify
* <template>, as per mkstemp
*/
void
-rcs_buf_write_stmp(BUF *b, char *template)
+buf_write_stmp(BUF *b, char *template)
{
int fd;
@@ -376,22 +371,22 @@ rcs_buf_write_stmp(BUF *b, char *template)
worklist_add(template, &temp_files);
- if (rcs_buf_write_fd(b, fd) == -1) {
+ if (buf_write_fd(b, fd) == -1) {
(void)unlink(template);
- errx(1, "rcs_buf_write_stmp: rcs_buf_write_fd: `%s'", template);
+ errx(1, "buf_write_stmp: buf_write_fd: `%s'", template);
}
(void)close(fd);
}
/*
- * rcs_buf_grow()
+ * buf_grow()
*
* Grow the buffer <b> by <len> bytes. The contents are unchanged by this
* operation regardless of the result.
*/
static void
-rcs_buf_grow(BUF *b, size_t len)
+buf_grow(BUF *b, size_t len)
{
b->cb_buf = xrealloc(b->cb_buf, 1, b->cb_size + len);
b->cb_size += len;
diff --git a/usr.bin/rcs/buf.h b/usr.bin/rcs/buf.h
index 16ded552b25..990a4b8195f 100644
--- a/usr.bin/rcs/buf.h
+++ b/usr.bin/rcs/buf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf.h,v 1.9 2007/02/27 07:59:13 xsa Exp $ */
+/* $OpenBSD: buf.h,v 1.10 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -27,11 +27,11 @@
* -----------------
*
* This code provides an API to generic memory buffer management. All
- * operations are performed on a rcs_buf structure, which is kept opaque to the
+ * operations are performed on a buf structure, which is kept opaque to the
* API user in order to avoid corruption of the fields and make sure that only
* the internals can modify the fields.
*
- * The first step is to allocate a new buffer using the rcs_buf_alloc()
+ * The first step is to allocate a new buffer using the buf_alloc()
* function, which returns a pointer to a new buffer.
*/
@@ -43,21 +43,21 @@
/* flags */
#define BUF_AUTOEXT 1 /* autoextend on append */
-typedef struct rcs_buf BUF;
+typedef struct buf BUF;
-BUF *rcs_buf_alloc(size_t, u_int);
-BUF *rcs_buf_load(const char *, u_int);
-void rcs_buf_free(BUF *);
-void *rcs_buf_release(BUF *);
-u_char rcs_buf_getc(BUF *, size_t);
-void rcs_buf_empty(BUF *);
-size_t rcs_buf_append(BUF *, const void *, size_t);
-size_t rcs_buf_fappend(BUF *, const char *, ...)
+BUF *buf_alloc(size_t, u_int);
+BUF *buf_load(const char *, u_int);
+void buf_free(BUF *);
+void *buf_release(BUF *);
+u_char buf_getc(BUF *, size_t);
+void buf_empty(BUF *);
+size_t buf_append(BUF *, const void *, size_t);
+size_t buf_fappend(BUF *, const char *, ...)
__attribute__((format(printf, 2, 3)));
-void rcs_buf_putc(BUF *, int);
-size_t rcs_buf_len(BUF *);
-int rcs_buf_write_fd(BUF *, int);
-int rcs_buf_write(BUF *, const char *, mode_t);
-void rcs_buf_write_stmp(BUF *, char *);
-u_char *rcs_buf_get(BUF *b);
+void buf_putc(BUF *, int);
+size_t buf_len(BUF *);
+int buf_write_fd(BUF *, int);
+int buf_write(BUF *, const char *, mode_t);
+void buf_write_stmp(BUF *, char *);
+u_char *buf_get(BUF *b);
#endif /* BUF_H */
diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c
index 72aa4f3e116..f53697e95cd 100644
--- a/usr.bin/rcs/ci.c
+++ b/usr.bin/rcs/ci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ci.c,v 1.206 2010/07/22 17:49:18 millert Exp $ */
+/* $OpenBSD: ci.c,v 1.207 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (c) 2005, 2006 Niall O'Higgins <niallo@openbsd.org>
* All rights reserved.
@@ -136,7 +136,7 @@ checkin_main(int argc, char **argv)
case 'd':
if (rcs_optarg == NULL)
pb.date = DATE_MTIME;
- else if ((pb.date = rcs_date_parse(rcs_optarg)) <= 0)
+ else if ((pb.date = date_parse(rcs_optarg)) <= 0)
errx(1, "invalid date");
break;
case 'f':
@@ -348,7 +348,7 @@ checkin_diff_file(struct checkin_params *pb)
b1 = b2 = b3 = NULL;
path1 = path2 = NULL;
- if ((b1 = rcs_buf_load(pb->filename, BUF_AUTOEXT)) == NULL) {
+ if ((b1 = buf_load(pb->filename, BUF_AUTOEXT)) == NULL) {
warnx("failed to load file: `%s'", pb->filename);
goto out;
}
@@ -359,21 +359,21 @@ checkin_diff_file(struct checkin_params *pb)
}
b2 = rcs_kwexp_buf(b2, pb->file, pb->frev);
- if ((b3 = rcs_buf_alloc(128, BUF_AUTOEXT)) == NULL) {
+ if ((b3 = buf_alloc(128, BUF_AUTOEXT)) == NULL) {
warnx("failed to allocated buffer for diff");
goto out;
}
(void)xasprintf(&path1, "%s/diff1.XXXXXXXXXX", rcs_tmpdir);
- rcs_buf_write_stmp(b1, path1);
+ buf_write_stmp(b1, path1);
- rcs_buf_free(b1);
+ buf_free(b1);
b1 = NULL;
(void)xasprintf(&path2, "%s/diff2.XXXXXXXXXX", rcs_tmpdir);
- rcs_buf_write_stmp(b2, path2);
+ buf_write_stmp(b2, path2);
- rcs_buf_free(b2);
+ buf_free(b2);
b2 = NULL;
diff_format = D_RCSDIFF;
@@ -383,11 +383,11 @@ checkin_diff_file(struct checkin_params *pb)
return (b3);
out:
if (b1 != NULL)
- rcs_buf_free(b1);
+ buf_free(b1);
if (b2 != NULL)
- rcs_buf_free(b2);
+ buf_free(b2);
if (b3 != NULL)
- rcs_buf_free(b3);
+ buf_free(b3);
if (path1 != NULL)
xfree(path1);
if (path2 != NULL)
@@ -451,7 +451,7 @@ checkin_update(struct checkin_params *pb)
pb->frev = pb->file->rf_head;
/* Load file contents */
- if ((bp = rcs_buf_load(pb->filename, BUF_AUTOEXT)) == NULL)
+ if ((bp = buf_load(pb->filename, BUF_AUTOEXT)) == NULL)
return (-1);
/* If this is a zero-ending RCSNUM eg 4.0, increment it (eg to 4.1) */
@@ -511,7 +511,7 @@ checkin_update(struct checkin_params *pb)
* If -f is not specified and there are no differences, tell
* the user and revert to latest version.
*/
- if (!(pb->flags & FORCE) && (rcs_buf_len(pb->deltatext) < 1)) {
+ if (!(pb->flags & FORCE) && (buf_len(pb->deltatext) < 1)) {
if (checkin_revert(pb) == -1)
return (-1);
else
@@ -627,7 +627,7 @@ checkin_init(struct checkin_params *pb)
}
/* Load file contents */
- if ((bp = rcs_buf_load(pb->filename, BUF_AUTOEXT)) == NULL)
+ if ((bp = buf_load(pb->filename, BUF_AUTOEXT)) == NULL)
return (-1);
/* Get default values from working copy if -k specified */
@@ -867,11 +867,11 @@ checkin_keywordscan(BUF *data, RCSNUM **rev, time_t *date, char **author,
char *kwstr;
unsigned char *c, *end, *start;
- end = rcs_buf_get(data) + rcs_buf_len(data) - 1;
+ end = buf_get(data) + buf_len(data) - 1;
kwstr = NULL;
- left = rcs_buf_len(data);
- for (c = rcs_buf_get(data);
+ left = buf_len(data);
+ for (c = buf_get(data);
c <= end && (c = memchr(c, '$', left)) != NULL;
left = end - c + 1) {
size_t len;
@@ -918,12 +918,12 @@ checkin_keywordscan(BUF *data, RCSNUM **rev, time_t *date, char **author,
}
len = c - start + 1;
- buf = rcs_buf_alloc(len + 1, 0);
- rcs_buf_append(buf, start, len);
+ buf = buf_alloc(len + 1, 0);
+ buf_append(buf, start, len);
/* XXX - Not binary safe. */
- rcs_buf_putc(buf, '\0');
- checkin_parsekeyword(rcs_buf_get(buf), rev, date, author, state);
+ buf_putc(buf, '\0');
+ checkin_parsekeyword(buf_get(buf), rev, date, author, state);
loopend:;
}
if (kwstr == NULL)
@@ -997,7 +997,7 @@ checkin_parsekeyword(char *keystring, RCSNUM **rev, time_t *date,
if (i < 5)
break;
(void)xasprintf(&datestring, "%s %s", tokens[3], tokens[4]);
- if ((*date = rcs_date_parse(datestring)) <= 0)
+ if ((*date = date_parse(datestring)) <= 0)
errx(1, "could not parse date");
xfree(datestring);
@@ -1024,7 +1024,7 @@ checkin_parsekeyword(char *keystring, RCSNUM **rev, time_t *date,
if (i < 3)
break;
(void)xasprintf(&datestring, "%s %s", tokens[1], tokens[2]);
- if ((*date = rcs_date_parse(datestring)) <= 0)
+ if ((*date = date_parse(datestring)) <= 0)
errx(1, "could not parse date");
xfree(datestring);
break;
diff --git a/usr.bin/rcs/co.c b/usr.bin/rcs/co.c
index 3619d149de7..5268c15abd9 100644
--- a/usr.bin/rcs/co.c
+++ b/usr.bin/rcs/co.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: co.c,v 1.110 2009/02/25 23:16:20 ray Exp $ */
+/* $OpenBSD: co.c,v 1.111 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -262,7 +262,7 @@ checkout_rev(RCSFILE *file, RCSNUM *frev, const char *dst, int flags,
rcsdate = givendate = -1;
if (date != NULL)
- givendate = rcs_date_parse(date);
+ givendate = date_parse(date);
if (file->rf_ndelta == 0 && !(flags & QUIET))
(void)fprintf(stderr,
@@ -303,7 +303,7 @@ checkout_rev(RCSFILE *file, RCSNUM *frev, const char *dst, int flags,
TAILQ_FOREACH(rdp, &file->rf_delta, rd_list) {
if (date != NULL) {
fdate = asctime(&rdp->rd_date);
- rcsdate = rcs_date_parse(fdate);
+ rcsdate = date_parse(fdate);
if (givendate <= rcsdate)
continue;
}
@@ -354,7 +354,7 @@ checkout_rev(RCSFILE *file, RCSNUM *frev, const char *dst, int flags,
return (-1);
}
} else {
- bp = rcs_buf_alloc(1, 0);
+ bp = buf_alloc(1, 0);
}
/*
@@ -463,16 +463,16 @@ checkout_rev(RCSFILE *file, RCSNUM *frev, const char *dst, int flags,
}
if (flags & PIPEOUT)
- rcs_buf_write_fd(bp, STDOUT_FILENO);
+ buf_write_fd(bp, STDOUT_FILENO);
else {
(void)unlink(dst);
if ((fd = open(dst, O_WRONLY|O_CREAT|O_TRUNC, mode)) < 0)
err(1, "%s", dst);
- if (rcs_buf_write_fd(bp, fd) < 0) {
+ if (buf_write_fd(bp, fd) < 0) {
warnx("failed to write revision to file");
- rcs_buf_free(bp);
+ buf_free(bp);
(void)close(fd);
return (-1);
}
@@ -492,7 +492,7 @@ checkout_rev(RCSFILE *file, RCSNUM *frev, const char *dst, int flags,
(void)close(fd);
}
- rcs_buf_free(bp);
+ buf_free(bp);
return (0);
}
@@ -546,13 +546,13 @@ checkout_file_has_diffs(RCSFILE *rfp, RCSNUM *frev, const char *dst)
}
(void)xasprintf(&tempfile, "%s/diff.XXXXXXXXXX", rcs_tmpdir);
- rcs_buf_write_stmp(bp, tempfile);
- rcs_buf_empty(bp);
+ buf_write_stmp(bp, tempfile);
+ buf_empty(bp);
diff_format = D_RCSDIFF;
ret = diffreg(dst, tempfile, bp, D_FORCEASCII);
- rcs_buf_free(bp);
+ buf_free(bp);
unlink(tempfile);
xfree(tempfile);
diff --git a/usr.bin/rcs/date.y b/usr.bin/rcs/date.y
index 3e0aa290717..424a0835f7f 100644
--- a/usr.bin/rcs/date.y
+++ b/usr.bin/rcs/date.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: date.y,v 1.7 2010/07/23 09:14:58 ray Exp $ */
+/* $OpenBSD: date.y,v 1.8 2010/07/23 21:46:05 ray Exp $ */
/*
** Originally written by Steven M. Bellovin <smb@research.att.com> while
@@ -805,12 +805,12 @@ difftm(struct tm *a, struct tm *b)
}
/*
- * rcs_date_parse()
+ * date_parse()
*
* Returns the number of seconds since the Epoch corresponding to the date.
*/
time_t
-rcs_date_parse(const char *p)
+date_parse(const char *p)
{
struct tm gmt, tm;
time_t Start, tod, nowtime, tz;
@@ -819,7 +819,7 @@ rcs_date_parse(const char *p)
if (time(&nowtime) == -1 || !gmtime_r(&nowtime, &gmt) ||
!localtime_r(&nowtime, &tm))
- errx(1, "cvs_date_parse failed");
+ errx(1, "date_parse failed");
tz = difftm(&gmt, &tm) / 60;
@@ -884,7 +884,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 = rcs_date_parse(buff);
+ d = date_parse(buff);
if (d == -1)
(void)printf("Bad format - couldn't convert.\n");
else
diff --git a/usr.bin/rcs/diff.c b/usr.bin/rcs/diff.c
index c3f9f27cb91..087210aaf45 100644
--- a/usr.bin/rcs/diff.c
+++ b/usr.bin/rcs/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.30 2010/07/16 17:53:20 ray Exp $ */
+/* $OpenBSD: diff.c,v 1.31 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -1377,7 +1377,7 @@ diff_output(const char *fmt, ...)
if (i == -1)
err(1, "diff_output");
if (diffbuf != NULL)
- rcs_buf_append(diffbuf, str, strlen(str));
+ buf_append(diffbuf, str, strlen(str));
else
printf("%s", str);
xfree(str);
diff --git a/usr.bin/rcs/diff.h b/usr.bin/rcs/diff.h
index 32fd0ed2eda..1dbfc659f0b 100644
--- a/usr.bin/rcs/diff.h
+++ b/usr.bin/rcs/diff.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.h,v 1.8 2009/07/14 14:09:46 jsg Exp $ */
+/* $OpenBSD: diff.h,v 1.9 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -63,9 +63,8 @@
*
* @(#)diffreg.c 8.1 (Berkeley) 6/6/93
*/
-
-#ifndef RCS_DIFF_H
-#define RCS_DIFF_H
+#ifndef DIFF_H
+#define DIFF_H
#include <sys/queue.h>
@@ -125,4 +124,4 @@ extern RCSNUM *diff_rev1;
extern RCSNUM *diff_rev2;
extern regex_t *diff_ignore_re;
-#endif /* RCS_DIFF_H */
+#endif /* DIFF_H */
diff --git a/usr.bin/rcs/diff3.c b/usr.bin/rcs/diff3.c
index 0cd51a12583..faa995bdfa3 100644
--- a/usr.bin/rcs/diff3.c
+++ b/usr.bin/rcs/diff3.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff3.c,v 1.29 2010/07/23 08:31:19 ray Exp $ */
+/* $OpenBSD: diff3.c,v 1.30 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@@ -126,7 +126,7 @@ static int last[4];
static int eflag = 3; /* default -E for compatibility with former RCS */
static int oflag = 1; /* default -E for compatibility with former RCS */
static int debug = 0;
-static char f1mark[256], f3mark[256]; /* markers for -E and -X */
+static char f1mark[MAXPATHLEN], f3mark[MAXPATHLEN]; /* markers for -E and -X */
static int duplicate(struct range *, struct range *);
static int edit(struct diff *, int, int);
@@ -166,45 +166,45 @@ merge_diff3(char **av, int flags)
if ((flags & MERGE_EFLAG) && !(flags & MERGE_OFLAG))
oflag = 0;
- if ((b1 = rcs_buf_load(av[0], BUF_AUTOEXT)) == NULL)
+ if ((b1 = buf_load(av[0], BUF_AUTOEXT)) == NULL)
goto out;
- if ((b2 = rcs_buf_load(av[1], BUF_AUTOEXT)) == NULL)
+ if ((b2 = buf_load(av[1], BUF_AUTOEXT)) == NULL)
goto out;
- if ((b3 = rcs_buf_load(av[2], BUF_AUTOEXT)) == NULL)
+ if ((b3 = buf_load(av[2], BUF_AUTOEXT)) == NULL)
goto out;
- d1 = rcs_buf_alloc(128, BUF_AUTOEXT);
- d2 = rcs_buf_alloc(128, BUF_AUTOEXT);
- diffb = rcs_buf_alloc(128, BUF_AUTOEXT);
+ d1 = buf_alloc(128, BUF_AUTOEXT);
+ d2 = buf_alloc(128, BUF_AUTOEXT);
+ diffb = buf_alloc(128, BUF_AUTOEXT);
(void)xasprintf(&path1, "%s/diff1.XXXXXXXXXX", rcs_tmpdir);
(void)xasprintf(&path2, "%s/diff2.XXXXXXXXXX", rcs_tmpdir);
(void)xasprintf(&path3, "%s/diff3.XXXXXXXXXX", rcs_tmpdir);
- rcs_buf_write_stmp(b1, path1);
- rcs_buf_write_stmp(b2, path2);
- rcs_buf_write_stmp(b3, path3);
+ buf_write_stmp(b1, path1);
+ buf_write_stmp(b2, path2);
+ buf_write_stmp(b3, path3);
- rcs_buf_free(b2);
+ buf_free(b2);
b2 = NULL;
if ((diffreg(path1, path3, d1, D_FORCEASCII) == D_ERROR) ||
(diffreg(path2, path3, d2, D_FORCEASCII) == D_ERROR)) {
- rcs_buf_free(diffb);
+ buf_free(diffb);
diffb = NULL;
goto out;
}
(void)xasprintf(&dp13, "%s/d13.XXXXXXXXXX", rcs_tmpdir);
- rcs_buf_write_stmp(d1, dp13);
+ buf_write_stmp(d1, dp13);
- rcs_buf_free(d1);
+ buf_free(d1);
d1 = NULL;
(void)xasprintf(&dp23, "%s/d23.XXXXXXXXXX", rcs_tmpdir);
- rcs_buf_write_stmp(d2, dp23);
+ buf_write_stmp(d2, dp23);
- rcs_buf_free(d2);
+ buf_free(d2);
d2 = NULL;
argc = 0;
@@ -217,15 +217,15 @@ merge_diff3(char **av, int flags)
diff3_conflicts = diff3_internal(argc, argv, av[0], av[2]);
if (diff3_conflicts < 0) {
- rcs_buf_free(diffb);
+ buf_free(diffb);
diffb = NULL;
goto out;
}
- plen = rcs_buf_len(diffb);
- patch = rcs_buf_release(diffb);
- dlen = rcs_buf_len(b1);
- data = rcs_buf_release(b1);
+ plen = buf_len(diffb);
+ patch = buf_release(diffb);
+ dlen = buf_len(b1);
+ data = buf_release(b1);
if ((diffb = rcs_patchfile(data, dlen, patch, plen, ed_patch_lines)) == NULL)
goto out;
@@ -235,13 +235,13 @@ merge_diff3(char **av, int flags)
out:
if (b2 != NULL)
- rcs_buf_free(b2);
+ buf_free(b2);
if (b3 != NULL)
- rcs_buf_free(b3);
+ buf_free(b3);
if (d1 != NULL)
- rcs_buf_free(d1);
+ buf_free(d1);
if (d2 != NULL)
- rcs_buf_free(d2);
+ buf_free(d2);
(void)unlink(path1);
(void)unlink(path2);
@@ -287,7 +287,7 @@ rcs_diff3(RCSFILE *rf, char *workfile, RCSNUM *rev1, RCSNUM *rev2, int flags)
rcsnum_tostr(rev1, r1, sizeof(r1));
rcsnum_tostr(rev2, r2, sizeof(r2));
- if ((b1 = rcs_buf_load(workfile, BUF_AUTOEXT)) == NULL)
+ if ((b1 = buf_load(workfile, BUF_AUTOEXT)) == NULL)
goto out;
if (!(flags & QUIET))
@@ -300,38 +300,38 @@ rcs_diff3(RCSFILE *rf, char *workfile, RCSNUM *rev1, RCSNUM *rev2, int flags)
if ((b3 = rcs_getrev(rf, rev2)) == NULL)
goto out;
- d1 = rcs_buf_alloc(128, BUF_AUTOEXT);
- d2 = rcs_buf_alloc(128, BUF_AUTOEXT);
- diffb = rcs_buf_alloc(128, BUF_AUTOEXT);
+ d1 = buf_alloc(128, BUF_AUTOEXT);
+ d2 = buf_alloc(128, BUF_AUTOEXT);
+ diffb = buf_alloc(128, BUF_AUTOEXT);
(void)xasprintf(&path1, "%s/diff1.XXXXXXXXXX", rcs_tmpdir);
(void)xasprintf(&path2, "%s/diff2.XXXXXXXXXX", rcs_tmpdir);
(void)xasprintf(&path3, "%s/diff3.XXXXXXXXXX", rcs_tmpdir);
- rcs_buf_write_stmp(b1, path1);
- rcs_buf_write_stmp(b2, path2);
- rcs_buf_write_stmp(b3, path3);
+ buf_write_stmp(b1, path1);
+ buf_write_stmp(b2, path2);
+ buf_write_stmp(b3, path3);
- rcs_buf_free(b2);
+ buf_free(b2);
b2 = NULL;
if ((diffreg(path1, path3, d1, D_FORCEASCII) == D_ERROR) ||
(diffreg(path2, path3, d2, D_FORCEASCII) == D_ERROR)) {
- rcs_buf_free(diffb);
+ buf_free(diffb);
diffb = NULL;
goto out;
}
(void)xasprintf(&dp13, "%s/d13.XXXXXXXXXX", rcs_tmpdir);
- rcs_buf_write_stmp(d1, dp13);
+ buf_write_stmp(d1, dp13);
- rcs_buf_free(d1);
+ buf_free(d1);
d1 = NULL;
(void)xasprintf(&dp23, "%s/d23.XXXXXXXXXX", rcs_tmpdir);
- rcs_buf_write_stmp(d2, dp23);
+ buf_write_stmp(d2, dp23);
- rcs_buf_free(d2);
+ buf_free(d2);
d2 = NULL;
argc = 0;
@@ -344,15 +344,15 @@ rcs_diff3(RCSFILE *rf, char *workfile, RCSNUM *rev1, RCSNUM *rev2, int flags)
diff3_conflicts = diff3_internal(argc, argv, workfile, r2);
if (diff3_conflicts < 0) {
- rcs_buf_free(diffb);
+ buf_free(diffb);
diffb = NULL;
goto out;
}
- plen = rcs_buf_len(diffb);
- patch = rcs_buf_release(diffb);
- dlen = rcs_buf_len(b1);
- data = rcs_buf_release(b1);
+ plen = buf_len(diffb);
+ patch = buf_release(diffb);
+ dlen = buf_len(b1);
+ data = buf_release(b1);
if ((diffb = rcs_patchfile(data, dlen, patch, plen, ed_patch_lines)) == NULL)
goto out;
@@ -362,13 +362,13 @@ rcs_diff3(RCSFILE *rf, char *workfile, RCSNUM *rev1, RCSNUM *rev2, int flags)
out:
if (b2 != NULL)
- rcs_buf_free(b2);
+ buf_free(b2);
if (b3 != NULL)
- rcs_buf_free(b3);
+ buf_free(b3);
if (d1 != NULL)
- rcs_buf_free(d1);
+ buf_free(d1);
if (d2 != NULL)
- rcs_buf_free(d2);
+ buf_free(d2);
(void)unlink(path1);
(void)unlink(path2);
@@ -449,14 +449,18 @@ ed_patch_lines(struct rcs_lines *dlines, struct rcs_lines *plines)
/* Skip blank lines */
if (lp->l_len < 2)
continue;
+
/* NUL-terminate line buffer for strtol() safety. */
tmp = lp->l_line[lp->l_len - 1];
lp->l_line[lp->l_len - 1] = '\0';
+
/* len - 1 is NUL terminator so we use len - 2 for 'op' */
op = lp->l_line[lp->l_len - 2];
start = (int)strtol(lp->l_line, &ep, 10);
+
/* Restore the last byte of the buffer */
lp->l_line[lp->l_len - 1] = tmp;
+
if (op == 'a') {
if (start > dlines->l_nblines ||
start < 0 || *ep != 'a')
@@ -585,6 +589,7 @@ readin(char *name, struct diff **dd)
(*dd)[i].old.from = (*dd)[i-1].old.to;
(*dd)[i].new.from = (*dd)[i-1].new.to;
}
+
(void)fclose(fp[0]);
return (i);
@@ -903,8 +908,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, 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/rcs/ident.c b/usr.bin/rcs/ident.c
index 6f9db86ec1f..be68267fbc4 100644
--- a/usr.bin/rcs/ident.c
+++ b/usr.bin/rcs/ident.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ident.c,v 1.26 2009/10/15 10:08:43 sobrado Exp $ */
+/* $OpenBSD: ident.c,v 1.27 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (c) 2005 Xavier Santolaria <xsa@openbsd.org>
* All rights reserved.
@@ -119,19 +119,19 @@ ident_line(FILE *fp)
BUF *bp;
size_t len;
- bp = rcs_buf_alloc(512, BUF_AUTOEXT);
+ bp = buf_alloc(512, BUF_AUTOEXT);
while ((c = getc(fp)) != VALDELIM) {
if (c == EOF)
goto out;
if (isalpha(c))
- rcs_buf_putc(bp, c);
+ buf_putc(bp, c);
else
goto out;
}
- rcs_buf_putc(bp, VALDELIM);
+ buf_putc(bp, VALDELIM);
while ((c = getc(fp)) != KEYDELIM) {
if (c == EOF)
@@ -140,26 +140,26 @@ ident_line(FILE *fp)
if (c == '\n')
goto out;
- rcs_buf_putc(bp, c);
+ buf_putc(bp, c);
}
- len = rcs_buf_len(bp);
- if (rcs_buf_getc(bp, len - 1) != ' ')
+ len = buf_len(bp);
+ if (buf_getc(bp, len - 1) != ' ')
goto out;
/* append trailing KEYDELIM */
- rcs_buf_putc(bp, c);
+ buf_putc(bp, c);
/* Append newline for printing. */
- rcs_buf_putc(bp, '\n');
+ buf_putc(bp, '\n');
printf(" %c", KEYDELIM);
fflush(stdout);
- rcs_buf_write_fd(bp, STDOUT_FILENO);
+ buf_write_fd(bp, STDOUT_FILENO);
found++;
out:
if (bp != NULL)
- rcs_buf_free(bp);
+ buf_free(bp);
}
void
diff --git a/usr.bin/rcs/merge.c b/usr.bin/rcs/merge.c
index 2aad5a25d9d..aa74f4a034e 100644
--- a/usr.bin/rcs/merge.c
+++ b/usr.bin/rcs/merge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: merge.c,v 1.6 2007/04/26 21:49:33 sobrado Exp $ */
+/* $OpenBSD: merge.c,v 1.7 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
* All rights reserved.
@@ -102,13 +102,13 @@ merge_main(int argc, char **argv)
status = 0;
if (flags & PIPEOUT)
- rcs_buf_write_fd(bp, STDOUT_FILENO);
+ buf_write_fd(bp, STDOUT_FILENO);
else {
/* XXX */
- if (rcs_buf_write(bp, argv[0], 0644) < 0)
- warnx("rcs_buf_write failed");
+ if (buf_write(bp, argv[0], 0644) < 0)
+ warnx("buf_write failed");
}
- rcs_buf_free(bp);
+ buf_free(bp);
return (status);
}
diff --git a/usr.bin/rcs/rcs.c b/usr.bin/rcs/rcs.c
index e8d034972ac..94870dffc19 100644
--- a/usr.bin/rcs/rcs.c
+++ b/usr.bin/rcs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.58 2010/07/23 08:31:19 ray Exp $ */
+/* $OpenBSD: rcs.c,v 1.59 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -1145,7 +1145,7 @@ rcs_patch_lines(struct rcs_lines *dlines, struct rcs_lines *plines)
*
* Get the whole contents of revision <rev> from the RCSFILE <rfp>. The
* returned buffer is dynamically allocated and should be released using
- * rcs_buf_free() once the caller is done using it.
+ * buf_free() once the caller is done using it.
*/
BUF*
rcs_getrev(RCSFILE *rfp, RCSNUM *frev)
@@ -1190,13 +1190,13 @@ rcs_getrev(RCSFILE *rfp, RCSNUM *frev)
len = rdp->rd_tlen;
if (len == 0) {
- rbuf = rcs_buf_alloc(1, 0);
- rcs_buf_empty(rbuf);
+ rbuf = buf_alloc(1, 0);
+ buf_empty(rbuf);
return (rbuf);
}
- rbuf = rcs_buf_alloc(len, BUF_AUTOEXT);
- rcs_buf_append(rbuf, rdp->rd_text, len);
+ rbuf = buf_alloc(len, BUF_AUTOEXT);
+ buf_append(rbuf, rdp->rd_text, len);
isbranch = 0;
brev = NULL;
@@ -1261,14 +1261,14 @@ rcs_getrev(RCSFILE *rfp, RCSNUM *frev)
rdp = rcs_findrev(rfp, crev);
if (rdp == NULL) {
- rcs_buf_free(rbuf);
+ buf_free(rbuf);
return (NULL);
}
plen = rdp->rd_tlen;
- dlen = rcs_buf_len(rbuf);
+ dlen = buf_len(rbuf);
patch = rdp->rd_text;
- data = rcs_buf_release(rbuf);
+ data = buf_release(rbuf);
/* check if we have parsed this rev's deltatext */
if (rdp->rd_tlen == 0)
rcs_parse_deltatexts(rfp, rdp->rd_num);
@@ -1455,16 +1455,16 @@ rcs_rev_remove(RCSFILE *rf, RCSNUM *rev)
if ((nextbuf = rcs_getrev(rf, nextrdp->rd_num)) == NULL)
errx(1, "error getting revision");
- newdiff = rcs_buf_alloc(64, BUF_AUTOEXT);
+ newdiff = buf_alloc(64, BUF_AUTOEXT);
/* calculate new diff */
(void)xasprintf(&path_tmp1, "%s/diff1.XXXXXXXXXX", rcs_tmpdir);
- rcs_buf_write_stmp(nextbuf, path_tmp1);
- rcs_buf_free(nextbuf);
+ buf_write_stmp(nextbuf, path_tmp1);
+ buf_free(nextbuf);
(void)xasprintf(&path_tmp2, "%s/diff2.XXXXXXXXXX", rcs_tmpdir);
- rcs_buf_write_stmp(prevbuf, path_tmp2);
- rcs_buf_free(prevbuf);
+ buf_write_stmp(prevbuf, path_tmp2);
+ buf_free(prevbuf);
diff_format = D_RCSDIFF;
if (diffreg(path_tmp1, path_tmp2, newdiff, D_FORCEASCII) == D_ERROR)
@@ -2662,9 +2662,9 @@ rcs_expand_keywords(char *rcsfile, struct rcs_delta *rdp, BUF *bp, int mode)
if (timezone_flag != NULL)
rcs_set_tz(timezone_flag, rdp, &tb);
- len = rcs_buf_len(bp);
+ len = buf_len(bp);
- c = rcs_buf_get(bp);
+ c = buf_get(bp);
found = 0;
/* Final character in buffer. */
fin = c + len - 1;
@@ -2832,25 +2832,25 @@ rcs_expand_keywords(char *rcsfile, struct rcs_delta *rdp, BUF *bp, int mode)
errx(1, "rcs_expand_keywords: string truncated");
/* Concatenate everything together. */
- tmpbuf = rcs_buf_alloc(len + strlen(expbuf), BUF_AUTOEXT);
+ tmpbuf = buf_alloc(len + strlen(expbuf), BUF_AUTOEXT);
/* Append everything before keyword. */
- rcs_buf_append(tmpbuf, rcs_buf_get(newbuf),
- start - (unsigned char *)rcs_buf_get(newbuf));
+ buf_append(tmpbuf, buf_get(newbuf),
+ start - (unsigned char *)buf_get(newbuf));
/* Append keyword. */
- rcs_buf_append(tmpbuf, expbuf, strlen(expbuf));
+ buf_append(tmpbuf, expbuf, strlen(expbuf));
/* Point c to end of keyword. */
- c = rcs_buf_get(tmpbuf) + rcs_buf_len(tmpbuf) - 1;
+ c = buf_get(tmpbuf) + buf_len(tmpbuf) - 1;
/* Append everything after keyword. */
- rcs_buf_append(tmpbuf, end,
- ((unsigned char *)rcs_buf_get(newbuf) + rcs_buf_len(newbuf)) - end);
+ buf_append(tmpbuf, end,
+ ((unsigned char *)buf_get(newbuf) + buf_len(newbuf)) - end);
/* Point fin to end of data. */
- fin = rcs_buf_get(tmpbuf) + rcs_buf_len(tmpbuf) - 1;
+ fin = buf_get(tmpbuf) + buf_len(tmpbuf) - 1;
/* Recalculate new length. */
- len = rcs_buf_len(tmpbuf);
+ len = buf_len(tmpbuf);
/* tmpbuf is now ready, free old newbuf if allocated here. */
if (newbuf != bp)
- rcs_buf_free(newbuf);
+ buf_free(newbuf);
newbuf = tmpbuf;
}
}
@@ -2880,9 +2880,10 @@ rcs_deltatext_set(RCSFILE *rfp, RCSNUM *rev, BUF *bp)
if (rdp->rd_text != NULL)
xfree(rdp->rd_text);
- len = rcs_buf_len(bp);
- dtext = rcs_buf_release(bp);
+ len = buf_len(bp);
+ dtext = buf_release(bp);
bp = NULL;
+
if (len != 0) {
rdp->rd_text = xmalloc(len);
rdp->rd_tlen = len;
diff --git a/usr.bin/rcs/rcs.h b/usr.bin/rcs/rcs.h
index 6e82ae5ed66..2401f5fb004 100644
--- a/usr.bin/rcs/rcs.h
+++ b/usr.bin/rcs/rcs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.h,v 1.8 2008/02/02 16:21:38 xsa Exp $ */
+/* $OpenBSD: rcs.h,v 1.9 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -45,7 +45,6 @@
#define RCS_SYM_INVALCHAR "$,.:;@"
-
#define RCS_MAGIC_BRANCH ".0."
#define RCS_STATE_EXP "Exp"
#define RCS_STATE_DEAD "dead"
@@ -55,7 +54,6 @@
#define RCS_LOCK_LOOSE 0
#define RCS_LOCK_STRICT 1
-
/*
* Keyword expansion table
*/
@@ -90,7 +88,6 @@
((k & RCS_KWEXP_ERR) || \
((k & RCS_KWEXP_OLD) && (k & ~RCS_KWEXP_OLD)))
-
struct rcs_kw {
char kw_str[16];
int kw_type;
@@ -146,7 +143,6 @@ typedef struct rcs_num {
u_int16_t *rn_id;
} RCSNUM;
-
struct rcs_access {
char *ra_name;
uid_t ra_uid;
@@ -166,7 +162,6 @@ struct rcs_lock {
TAILQ_ENTRY(rcs_lock) rl_list;
};
-
struct rcs_branch {
RCSNUM *rb_num;
TAILQ_ENTRY(rcs_branch) rb_list;
diff --git a/usr.bin/rcs/rcsclean.c b/usr.bin/rcs/rcsclean.c
index b0168ab1e51..f4cd973b739 100644
--- a/usr.bin/rcs/rcsclean.c
+++ b/usr.bin/rcs/rcsclean.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsclean.c,v 1.50 2007/06/30 08:23:49 xsa Exp $ */
+/* $OpenBSD: rcsclean.c,v 1.51 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -165,22 +165,22 @@ rcsclean_file(char *fname, const char *rev_str)
warnx("failed to get needed revision");
goto out;
}
- if ((b2 = rcs_buf_load(fname, 0)) == NULL) {
+ if ((b2 = buf_load(fname, 0)) == NULL) {
warnx("failed to load `%s'", fname);
goto out;
}
/* If buffer lengths are the same, compare contents as well. */
- if (rcs_buf_len(b1) != rcs_buf_len(b2))
+ if (buf_len(b1) != buf_len(b2))
match = 0;
else {
size_t len, n;
- len = rcs_buf_len(b1);
+ len = buf_len(b1);
match = 1;
for (n = 0; n < len; ++n)
- if (rcs_buf_getc(b1, n) != rcs_buf_getc(b2, n)) {
+ if (buf_getc(b1, n) != buf_getc(b2, n)) {
match = 0;
break;
}
@@ -211,9 +211,9 @@ rcsclean_file(char *fname, const char *rev_str)
out:
if (b1 != NULL)
- rcs_buf_free(b1);
+ buf_free(b1);
if (b2 != NULL)
- rcs_buf_free(b2);
+ buf_free(b2);
if (file != NULL)
rcs_close(file);
}
diff --git a/usr.bin/rcs/rcsdiff.c b/usr.bin/rcs/rcsdiff.c
index 78239f8f336..1ba7a00678b 100644
--- a/usr.bin/rcs/rcsdiff.c
+++ b/usr.bin/rcs/rcsdiff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsdiff.c,v 1.75 2007/07/03 00:56:23 ray Exp $ */
+/* $OpenBSD: rcsdiff.c,v 1.76 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -316,7 +316,7 @@ rcsdiff_file(RCSFILE *file, RCSNUM *rev, const char *filename, int dflags)
tv[0].tv_sec = (long)rcs_rev_getdate(file, rev);
tv[1].tv_sec = tv[0].tv_sec;
- if ((b2 = rcs_buf_load(filename, BUF_AUTOEXT)) == NULL) {
+ if ((b2 = buf_load(filename, BUF_AUTOEXT)) == NULL) {
warnx("failed to load file: `%s'", filename);
goto out;
}
@@ -332,18 +332,18 @@ rcsdiff_file(RCSFILE *file, RCSNUM *rev, const char *filename, int dflags)
tv2[1].tv_sec = t;
(void)xasprintf(&path1, "%s/diff1.XXXXXXXXXX", rcs_tmpdir);
- rcs_buf_write_stmp(b1, path1);
+ buf_write_stmp(b1, path1);
- rcs_buf_free(b1);
+ buf_free(b1);
b1 = NULL;
if (utimes(path1, (const struct timeval *)&tv) < 0)
warn("utimes");
(void)xasprintf(&path2, "%s/diff2.XXXXXXXXXX", rcs_tmpdir);
- rcs_buf_write_stmp(b2, path2);
+ buf_write_stmp(b2, path2);
- rcs_buf_free(b2);
+ buf_free(b2);
b2 = NULL;
if (utimes(path2, (const struct timeval *)&tv2) < 0)
@@ -355,9 +355,9 @@ out:
if (fd != -1)
(void)close(fd);
if (b1 != NULL)
- rcs_buf_free(b1);
+ buf_free(b1);
if (b2 != NULL)
- rcs_buf_free(b2);
+ buf_free(b2);
if (path1 != NULL)
xfree(path1);
if (path2 != NULL)
@@ -413,18 +413,18 @@ rcsdiff_rev(RCSFILE *file, RCSNUM *rev1, RCSNUM *rev2, int dflags)
fprintf(stderr, "%s -r%s -r%s\n", diffargs, rbuf1, rbuf2);
(void)xasprintf(&path1, "%s/diff1.XXXXXXXXXX", rcs_tmpdir);
- rcs_buf_write_stmp(b1, path1);
+ buf_write_stmp(b1, path1);
- rcs_buf_free(b1);
+ buf_free(b1);
b1 = NULL;
if (utimes(path1, (const struct timeval *)&tv) < 0)
warn("utimes");
(void)xasprintf(&path2, "%s/diff2.XXXXXXXXXX", rcs_tmpdir);
- rcs_buf_write_stmp(b2, path2);
+ buf_write_stmp(b2, path2);
- rcs_buf_free(b2);
+ buf_free(b2);
b2 = NULL;
if (utimes(path2, (const struct timeval *)&tv2) < 0)
@@ -434,9 +434,9 @@ rcsdiff_rev(RCSFILE *file, RCSNUM *rev1, RCSNUM *rev2, int dflags)
out:
if (b1 != NULL)
- rcs_buf_free(b1);
+ buf_free(b1);
if (b2 != NULL)
- rcs_buf_free(b2);
+ buf_free(b2);
if (path1 != NULL)
xfree(path1);
if (path2 != NULL)
diff --git a/usr.bin/rcs/rcsmerge.c b/usr.bin/rcs/rcsmerge.c
index 9b57b23be80..280e351557a 100644
--- a/usr.bin/rcs/rcsmerge.c
+++ b/usr.bin/rcs/rcsmerge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsmerge.c,v 1.51 2007/06/30 08:23:49 xsa Exp $ */
+/* $OpenBSD: rcsmerge.c,v 1.52 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
* All rights reserved.
@@ -166,15 +166,15 @@ rcsmerge_main(int argc, char **argv)
status = 0;
if (flags & PIPEOUT)
- rcs_buf_write_fd(bp, STDOUT_FILENO);
+ buf_write_fd(bp, STDOUT_FILENO);
else {
/* XXX mode */
- if (rcs_buf_write(bp, argv[0], 0644) < 0)
- warnx("rcs_buf_write failed");
+ if (buf_write(bp, argv[0], 0644) < 0)
+ warnx("buf_write failed");
}
- rcs_buf_free(bp);
+ buf_free(bp);
out:
rcs_close(file);
diff --git a/usr.bin/rcs/rcsnum.c b/usr.bin/rcs/rcsnum.c
index 176de241de8..dc44ca2a769 100644
--- a/usr.bin/rcs/rcsnum.c
+++ b/usr.bin/rcs/rcsnum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsnum.c,v 1.11 2008/05/22 07:03:02 joris Exp $ */
+/* $OpenBSD: rcsnum.c,v 1.12 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -282,8 +282,8 @@ rcsnum_aton(const char *str, char **ep, RCSNUM *nump)
* rightside of the branch number, so instead of having an odd
* number of dot-separated decimals, it will have an even number.
*
- * Now, according to all the documentation i've found on the net
- * about this, cvs does this for "efficiency reasons", i'd like
+ * Now, according to all the documentation I've found on the net
+ * about this, cvs does this for "efficiency reasons", I'd like
* to hear one.
*
* We just make sure we remove the .0. from in the branch number.
@@ -305,9 +305,9 @@ rcsnum_aton(const char *str, char **ep, RCSNUM *nump)
s--;
/*
- * If we have a "magic" branch, adjust it
- * so the .0. is removed.
- */
+ * If we have a "magic" branch, adjust it
+ * so the .0. is removed.
+ */
if (!strncmp(s, RCS_MAGIC_BRANCH,
strlen(RCS_MAGIC_BRANCH))) {
nump->rn_id[nump->rn_len - 1] =
diff --git a/usr.bin/rcs/rcsprog.h b/usr.bin/rcs/rcsprog.h
index dc9b720d40c..66db98cda81 100644
--- a/usr.bin/rcs/rcsprog.h
+++ b/usr.bin/rcs/rcsprog.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsprog.h,v 1.62 2010/07/23 08:31:19 ray Exp $ */
+/* $OpenBSD: rcsprog.h,v 1.63 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -83,7 +83,7 @@ extern char *rcs_tmpdir;
extern struct wklhead temp_files;
/* date.y */
-time_t rcs_date_parse(const char *);
+time_t date_parse(const char *);
/* ci.c */
int checkin_main(int, char **);
diff --git a/usr.bin/rcs/rcsutil.c b/usr.bin/rcs/rcsutil.c
index 83a9638379c..a4fa4928387 100644
--- a/usr.bin/rcs/rcsutil.c
+++ b/usr.bin/rcs/rcsutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsutil.c,v 1.33 2008/05/10 20:23:24 joris Exp $ */
+/* $OpenBSD: rcsutil.c,v 1.34 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -337,7 +337,7 @@ rcs_prompt(const char *prompt)
size_t len;
char *buf;
- bp = rcs_buf_alloc(0, BUF_AUTOEXT);
+ bp = buf_alloc(0, BUF_AUTOEXT);
if (isatty(STDIN_FILENO))
(void)fprintf(stderr, "%s", prompt);
if (isatty(STDIN_FILENO))
@@ -348,14 +348,14 @@ rcs_prompt(const char *prompt)
if (buf[0] == '.' && (len == 1 || buf[1] == '\n'))
break;
else
- rcs_buf_append(bp, buf, len);
+ buf_append(bp, buf, len);
if (isatty(STDIN_FILENO))
(void)fprintf(stderr, ">> ");
}
- rcs_buf_putc(bp, '\0');
+ buf_putc(bp, '\0');
- return (rcs_buf_release(bp));
+ return (buf_release(bp));
}
u_int
@@ -451,10 +451,10 @@ rcs_set_description(RCSFILE *file, const char *in)
/* Description is in file <in>. */
if (in != NULL && *in != '-') {
- if ((bp = rcs_buf_load(in, BUF_AUTOEXT)) == NULL)
+ if ((bp = buf_load(in, BUF_AUTOEXT)) == NULL)
return (-1);
- rcs_buf_putc(bp, '\0');
- content = rcs_buf_release(bp);
+ buf_putc(bp, '\0');
+ content = buf_release(bp);
/* Description is in <in>. */
} else if (in != NULL)
/* Skip leading `-'. */
@@ -535,11 +535,11 @@ rcs_patchfile(u_char *data, size_t dlen, u_char *patch, size_t plen,
return (NULL);
}
- res = rcs_buf_alloc(1024, BUF_AUTOEXT);
+ res = buf_alloc(1024, BUF_AUTOEXT);
TAILQ_FOREACH(lp, &dlines->l_lines, l_list) {
if (lp->l_line == NULL)
continue;
- rcs_buf_append(res, lp->l_line, lp->l_len);
+ buf_append(res, lp->l_line, lp->l_len);
}
rcs_freelines(dlines);
diff --git a/usr.bin/rcs/rlog.c b/usr.bin/rcs/rlog.c
index 696c23b9cd8..43d451450e0 100644
--- a/usr.bin/rcs/rlog.c
+++ b/usr.bin/rcs/rlog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rlog.c,v 1.62 2009/02/15 12:55:18 joris Exp $ */
+/* $OpenBSD: rlog.c,v 1.63 2010/07/23 21:46:05 ray Exp $ */
/*
* Copyright (c) 2005, 2009 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -227,7 +227,7 @@ rlog_select_daterev(RCSFILE *rcsfile, char *date)
if (last == NULL) {
flags |= RLOG_DATE_SINGLE;
- firstdate = rcs_date_parse(first);
+ firstdate = date_parse(first);
delim = '\0';
last = "\0";
} else {
@@ -237,33 +237,33 @@ rlog_select_daterev(RCSFILE *rcsfile, char *date)
if (delim == '>' && *last == '\0') {
flags |= RLOG_DATE_EARLIER;
- firstdate = rcs_date_parse(first);
+ firstdate = date_parse(first);
}
if (delim == '>' && *first == '\0' && *last != '\0') {
flags |= RLOG_DATE_LATER;
- firstdate = rcs_date_parse(last);
+ firstdate = date_parse(last);
}
if (delim == '<' && *last == '\0') {
flags |= RLOG_DATE_LATER;
- firstdate = rcs_date_parse(first);
+ firstdate = date_parse(first);
}
if (delim == '<' && *first == '\0' && *last != '\0') {
flags |= RLOG_DATE_EARLIER;
- firstdate = rcs_date_parse(last);
+ firstdate = date_parse(last);
}
if (*first != '\0' && *last != '\0') {
flags |= RLOG_DATE_RANGE;
if (delim == '<') {
- firstdate = rcs_date_parse(first);
- lastdate = rcs_date_parse(last);
+ firstdate = date_parse(first);
+ lastdate = date_parse(last);
} else {
- firstdate = rcs_date_parse(last);
- lastdate = rcs_date_parse(first);
+ firstdate = date_parse(last);
+ lastdate = date_parse(first);
}
}