summaryrefslogtreecommitdiff
path: root/usr.bin/mg
diff options
context:
space:
mode:
authorVincent Labrecque <vincent@cvs.openbsd.org>2002-02-13 03:21:13 +0000
committerVincent Labrecque <vincent@cvs.openbsd.org>2002-02-13 03:21:13 +0000
commit84ef7ef9ac906bce95e3bacb548ee251781f97c2 (patch)
tree0e23f45f7bebcdbbb4880313f89a1d2123870322 /usr.bin/mg
parent41a92edea7577287da7309a859cc4d3b325475b2 (diff)
simplify the define_key() code to use sane functions in two separate buffer
instead of hardcoding sizes. ok art@,deraadt@
Diffstat (limited to 'usr.bin/mg')
-rw-r--r--usr.bin/mg/extend.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/usr.bin/mg/extend.c b/usr.bin/mg/extend.c
index ffbc0395a76..440a26b1c26 100644
--- a/usr.bin/mg/extend.c
+++ b/usr.bin/mg/extend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: extend.c,v 1.18 2001/07/05 17:36:05 matthieu Exp $ */
+/* $OpenBSD: extend.c,v 1.19 2002/02/13 03:21:12 vincent Exp $ */
/*
* Extended (M-X) commands, rebinding, and startup file processing.
@@ -495,20 +495,22 @@ localbind(f, n)
*/
/* ARGSUSED */
int
-define_key(f, n)
- int f, n;
+define_key(int f, int n)
{
- static char buf[48] = "Define key map: ";
- KEYMAP *mp;
+ static char buf[48];
+ char tmp[32];
+ KEYMAP *mp;
- buf[16] = '\0';
- if (eread(buf, &buf[16], 48 - 16, EFNEW) != TRUE)
+ strlcpy(buf, "Define key map: ", sizeof buf);
+ if (eread(buf, tmp, sizeof tmp, EFNEW) != TRUE)
return FALSE;
- if ((mp = name_map(&buf[16])) == NULL) {
- ewprintf("Unknown map %s", &buf[16]);
+ strlcat(buf, tmp, sizeof buf);
+ if ((mp = name_map(tmp)) == NULL) {
+ ewprintf("Unknown map %s", tmp);
return FALSE;
}
- (void)strncat(&buf[16], " key: ", 48 - 16 - 1);
+ strlcat(buf, "key: ", sizeof buf);
+
return dobind(mp, buf, FALSE);
}