summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2009-03-25 21:19:21 +0000
committerJoris Vink <joris@cvs.openbsd.org>2009-03-25 21:19:21 +0000
commit0be2ee121749034bfda448b74a45f397b47b227c (patch)
treeb78d2806044f30291c0efc764c6be0efdc60eb46 /usr.bin
parent632cb1a265894d5f3dccaa8e80410fde4f33c5a5 (diff)
remove unused functions, definitions and outdated comments
from the stone ages.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/buf.c153
-rw-r--r--usr.bin/cvs/buf.h13
-rw-r--r--usr.bin/cvs/cvs.h7
-rw-r--r--usr.bin/cvs/init.c6
-rw-r--r--usr.bin/cvs/rcs.h16
5 files changed, 19 insertions, 176 deletions
diff --git a/usr.bin/cvs/buf.c b/usr.bin/cvs/buf.c
index 2aff95a20b3..1c402c47cca 100644
--- a/usr.bin/cvs/buf.c
+++ b/usr.bin/cvs/buf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf.c,v 1.73 2009/03/23 18:21:23 joris Exp $ */
+/* $OpenBSD: buf.c,v 1.74 2009/03/25 21:19:20 joris Exp $ */
/*
* Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -38,30 +38,24 @@
#include "buf.h"
#define BUF_INCR 128
+#define BUF_GROW(bp, len) \
+ do { \
+ b->cb_buf = xrealloc(b->cb_buf, 1, b->cb_size + len); \
+ b->cb_size += len; \
+ } while (0);
struct cvs_buf {
- /* buffer handle, buffer size, and data length */
u_char *cb_buf;
size_t cb_size;
size_t cb_len;
};
-static void cvs_buf_grow(BUF *, size_t);
-
-/*
- * cvs_buf_alloc()
- *
- * Create a new buffer structure and return a pointer to it. This structure
- * uses dynamically-allocated memory and must be freed with cvs_buf_free(),
- * once the buffer is no longer needed.
- */
BUF *
cvs_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
@@ -110,11 +104,6 @@ cvs_buf_load_fd(int fd)
return (buf);
}
-/*
- * cvs_buf_free()
- *
- * Free the buffer <b> and all associated data.
- */
void
cvs_buf_free(BUF *b)
{
@@ -123,13 +112,6 @@ cvs_buf_free(BUF *b)
xfree(b);
}
-/*
- * cvs_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().
- */
u_char *
cvs_buf_release(BUF *b)
{
@@ -140,23 +122,6 @@ cvs_buf_release(BUF *b)
return (tmp);
}
-/*
- * cvs_buf_empty()
- *
- * Empty the contents of the buffer <b> and reset pointers.
- */
-void
-cvs_buf_empty(BUF *b)
-{
- memset(b->cb_buf, 0, b->cb_size);
- b->cb_len = 0;
-}
-
-/*
- * cvs_buf_putc()
- *
- * Append a single character <c> to the end of the buffer <b>.
- */
void
cvs_buf_putc(BUF *b, int c)
{
@@ -164,48 +129,19 @@ cvs_buf_putc(BUF *b, int c)
bp = b->cb_buf + b->cb_len;
if (bp == (b->cb_buf + b->cb_size)) {
- /* extend */
- cvs_buf_grow(b, (size_t)BUF_INCR);
-
- /* the buffer might have been moved */
+ BUF_GROW(b, BUF_INCR);
bp = b->cb_buf + b->cb_len;
}
*bp = (u_char)c;
b->cb_len++;
}
-/*
- * cvs_buf_puts()
- *
- * Wrapper function for constant strings to cvs_buf_append.
- */
void
cvs_buf_puts(BUF *b, const char *str)
{
cvs_buf_append(b, str, strlen(str));
}
-/*
- * cvs_buf_getc()
- *
- * Return u_char at buffer position <pos>.
- *
- */
-u_char
-cvs_buf_getc(BUF *b, size_t pos)
-{
- return (b->cb_buf[pos]);
-}
-
-/*
- * cvs_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
- * data as possible, or if the BUF_AUTOEXT flag is set for the buffer, it
- * will get resized to an appropriate size to accept all data.
- * Returns the number of bytes successfully appended to the buffer.
- */
void
cvs_buf_append(BUF *b, const void *data, size_t len)
{
@@ -217,7 +153,7 @@ cvs_buf_append(BUF *b, const void *data, size_t len)
left = bep - bp;
if (left < len) {
- cvs_buf_grow(b, len - left);
+ BUF_GROW(b, len - left);
bp = b->cb_buf + b->cb_len;
}
@@ -225,22 +161,12 @@ cvs_buf_append(BUF *b, const void *data, size_t len)
b->cb_len += len;
}
-/*
- * cvs_buf_len()
- *
- * Returns the size of the buffer that is being used.
- */
size_t
cvs_buf_len(BUF *b)
{
return (b->cb_len);
}
-/*
- * cvs_buf_write_fd()
- *
- * Write the contents of the buffer <b> to the specified <fd>
- */
int
cvs_buf_write_fd(BUF *b, int fd)
{
@@ -249,17 +175,11 @@ cvs_buf_write_fd(BUF *b, int fd)
return (0);
}
-/*
- * cvs_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
cvs_buf_write(BUF *b, const char *path, mode_t mode)
{
int fd;
- open:
+open:
if ((fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)) == -1) {
if (errno == EACCES && unlink(path) != -1)
goto open;
@@ -280,13 +200,6 @@ cvs_buf_write(BUF *b, const char *path, mode_t mode)
return (0);
}
-/*
- * cvs_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
- */
int
cvs_buf_write_stmp(BUF *b, char *template, struct timeval *tv)
{
@@ -313,52 +226,10 @@ cvs_buf_write_stmp(BUF *b, char *template, struct timeval *tv)
return (fd);
}
-/*
- * cvs_buf_grow()
- *
- * Grow the buffer <b> by <len> bytes. The contents are unchanged by this
- * operation regardless of the result.
- */
-static void
-cvs_buf_grow(BUF *b, size_t len)
-{
- b->cb_buf = xrealloc(b->cb_buf, 1, b->cb_size + len);
- b->cb_size += len;
-}
-
-/*
- * cvs_buf_copy()
- *
- * Copy the first <len> bytes of data in the buffer <b> starting at offset
- * <off> in the destination buffer <dst>, which can accept up to <len> bytes.
- * Returns the number of bytes successfully copied, or -1 on failure.
- */
-ssize_t
-cvs_buf_copy(BUF *b, size_t off, void *dst, size_t len)
-{
- size_t rc;
-
- if (off > b->cb_len)
- fatal("cvs_buf_copy failed");
-
- rc = MIN(len, (b->cb_len - off));
- memcpy(dst, b->cb_buf + off, rc);
-
- return (ssize_t)rc;
-}
-
-/*
- * cvs_buf_peek()
- *
- * Peek at the contents of the buffer <b> at offset <off>.
- */
-const u_char *
-cvs_buf_peek(BUF *b, size_t off)
+u_char *
+cvs_buf_get(BUF *bp)
{
- if (off >= b->cb_len)
- return (NULL);
-
- return (b->cb_buf + off);
+ return (bp->cb_buf);
}
int
diff --git a/usr.bin/cvs/buf.h b/usr.bin/cvs/buf.h
index 3ff7bbcb024..66fc66e9e76 100644
--- a/usr.bin/cvs/buf.h
+++ b/usr.bin/cvs/buf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf.h,v 1.25 2008/06/10 01:00:34 joris Exp $ */
+/* $OpenBSD: buf.h,v 1.26 2009/03/25 21:19:20 joris Exp $ */
/*
* Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -29,9 +29,6 @@
#include <sys/types.h>
-/* flags */
-#define BUF_AUTOEXT 1 /* autoextend on append */
-
typedef struct cvs_buf BUF;
BUF *cvs_buf_alloc(size_t);
@@ -39,8 +36,7 @@ BUF *cvs_buf_load(const char *);
BUF *cvs_buf_load_fd(int);
void cvs_buf_free(BUF *);
u_char *cvs_buf_release(BUF *);
-u_char cvs_buf_getc(BUF *, size_t);
-void cvs_buf_empty(BUF *);
+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 *);
@@ -50,9 +46,4 @@ 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 *);
-ssize_t cvs_buf_copy(BUF *, size_t, void *, size_t);
-const u_char *cvs_buf_peek(BUF *, size_t);
-
-#define cvs_buf_get(b) cvs_buf_peek(b, 0)
-
#endif /* BUF_H */
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index ecb027deece..b45fd8220a3 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.175 2009/03/19 09:53:16 joris Exp $ */
+/* $OpenBSD: cvs.h,v 1.176 2009/03/25 21:19:20 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -40,9 +40,6 @@
#define CVS_VERSION "OpenCVS 4.5"
-#define CVS_HIST_CACHE 128
-#define CVS_HIST_NBFLD 6
-
#define CVS_CKSUM_LEN MD5_DIGEST_STRING_LENGTH
#define CVS_REV_BUFSZ 32
@@ -80,8 +77,6 @@
#define CVS_OP_WATCH 26
#define CVS_OP_WATCHERS 27
-#define CVS_OP_ANY 64 /* all operations */
-
/* methods */
#define CVS_METHOD_NONE 0
#define CVS_METHOD_LOCAL 1 /* local access */
diff --git a/usr.bin/cvs/init.c b/usr.bin/cvs/init.c
index 33e88816b38..338dcf0100a 100644
--- a/usr.bin/cvs/init.c
+++ b/usr.bin/cvs/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.35 2008/06/23 20:51:08 ragge Exp $ */
+/* $OpenBSD: init.c,v 1.36 2009/03/25 21:19:20 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -147,8 +147,8 @@ init_mkfile(char *path, const char **content)
const char **p;
RCSFILE *file;
- openflags = O_WRONLY|O_CREAT|O_EXCL;
- rcsflags = RCS_RDWR|RCS_CREATE;
+ openflags = O_WRONLY | O_CREAT | O_EXCL;
+ rcsflags = RCS_WRITE | RCS_CREATE;
if ((fd = open(path, openflags, 0444)) == -1)
fatal("init_mkfile: open: `%s': %s", path, strerror(errno));
diff --git a/usr.bin/cvs/rcs.h b/usr.bin/cvs/rcs.h
index 6e1c79c4d88..3935d68e0c3 100644
--- a/usr.bin/cvs/rcs.h
+++ b/usr.bin/cvs/rcs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.h,v 1.92 2008/06/15 04:38:52 tobias Exp $ */
+/* $OpenBSD: rcs.h,v 1.93 2009/03/25 21:19:20 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -28,11 +28,9 @@
#define RCS_H
#include "buf.h"
-#define RCS_DIFF_MAXARG 32
#define RCS_DIFF_DIV \
"==================================================================="
-#define RCSDIR "RCS"
#define RCS_FILE_EXT ",v"
#define RCS_HEAD_BRANCH "HEAD"
@@ -45,7 +43,6 @@
#define RCS_SYM_INVALCHAR "$,.:;@"
-
#define RCS_MAGIC_BRANCH ".0."
#define RCS_STATE_EXP "Exp"
#define RCS_STATE_DEAD "dead"
@@ -55,7 +52,6 @@
#define RCS_LOCK_LOOSE 0
#define RCS_LOCK_STRICT 1
-
/*
* Keyword expansion table
*/
@@ -92,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;
@@ -109,7 +104,6 @@ struct rcs_kw {
/* file flags */
#define RCS_READ (1<<0)
#define RCS_WRITE (1<<1)
-#define RCS_RDWR (RCS_READ|RCS_WRITE)
#define RCS_CREATE (1<<2) /* create the file */
#define RCS_PARSE_FULLY (1<<3) /* fully parse it on open */
@@ -127,18 +121,11 @@ struct rcs_kw {
#define RCS_RD_DEAD 0x01 /* dead */
#define RCS_RD_SELECT 0x02 /* select for operation */
-/* used for rcs_checkout_rev */
-#define CHECKOUT_REV_CREATED 1
-#define CHECKOUT_REV_MERGED 2
-#define CHECKOUT_REV_REMOVED 3
-#define CHECKOUT_REV_UPDATED 4
-
typedef struct rcs_num {
u_int rn_len;
u_int16_t *rn_id;
} RCSNUM;
-
struct rcs_access {
char *ra_name;
uid_t ra_uid;
@@ -158,7 +145,6 @@ struct rcs_lock {
TAILQ_ENTRY(rcs_lock) rl_list;
};
-
struct rcs_branch {
RCSNUM *rb_num;
TAILQ_ENTRY(rcs_branch) rb_list;