summaryrefslogtreecommitdiff
path: root/usr.bin/vi/common/key.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-01-16 06:40:24 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-01-16 06:40:24 +0000
commit315054f4737a39489e0a14f3a92bff61f1592832 (patch)
tree62bf010653374ce09b6beb4dfa0414a91457233b /usr.bin/vi/common/key.c
parent79e3d817585ca08a91e30ad14abe43e2ab70295f (diff)
Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where sensible to avoid pulling in the pollution. These are the files confirmed through binary verification. ok guenther, millert, doug (helped with the verification protocol)
Diffstat (limited to 'usr.bin/vi/common/key.c')
-rw-r--r--usr.bin/vi/common/key.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/vi/common/key.c b/usr.bin/vi/common/key.c
index dd3101c9bd1..63421dd75d1 100644
--- a/usr.bin/vi/common/key.c
+++ b/usr.bin/vi/common/key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key.c,v 1.13 2014/11/12 04:28:41 bentley Exp $ */
+/* $OpenBSD: key.c,v 1.14 2015/01/16 06:40:14 deraadt Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -11,7 +11,6 @@
#include "config.h"
-#include <sys/param.h>
#include <sys/queue.h>
#include <sys/time.h>
@@ -28,6 +27,8 @@
#include "common.h"
#include "../vi/vi.h"
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+
static int v_event_append(SCR *, EVENT *);
static int v_event_grow(SCR *, int);
static int v_key_cmp(const void *, const void *);
@@ -344,7 +345,7 @@ v_event_push(SCR *sp, EVENT *p_evp, CHAR_T *p_s, size_t nitems, u_int flags)
*/
#define TERM_PUSH_SHIFT 30
total = gp->i_cnt + gp->i_next + nitems + TERM_PUSH_SHIFT;
- if (total >= gp->i_nelem && v_event_grow(sp, MAX(total, 64)))
+ if (total >= gp->i_nelem && v_event_grow(sp, MAXIMUM(total, 64)))
return (1);
if (gp->i_cnt)
MEMMOVE(gp->i_event + TERM_PUSH_SHIFT + nitems,
@@ -383,7 +384,7 @@ v_event_append(SCR *sp, EVENT *argp)
gp = sp->gp;
if (gp->i_event == NULL ||
nevents > gp->i_nelem - (gp->i_next + gp->i_cnt))
- v_event_grow(sp, MAX(nevents, 64));
+ v_event_grow(sp, MAXIMUM(nevents, 64));
evp = gp->i_event + gp->i_next + gp->i_cnt;
gp->i_cnt += nevents;