summaryrefslogtreecommitdiff
path: root/lib/libedit/el.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2016-05-20 15:30:18 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2016-05-20 15:30:18 +0000
commitad4992059beb6316e375eb481e84d2ac9718874d (patch)
treeb4418348ce8775fca7ebbdbac9afefe85c228d76 /lib/libedit/el.c
parente0d26c0401fcc02001347d8996fc01d17e5d5291 (diff)
Move the declaration of the function pointer type el_rfunc_t
from the private header "read.h" to the public header <histedit.h>. That's not an interface change, it was already used and documented publicly, merely not properly declared. Improve encapsulation: Make el_read a pointer to an opaque struct in struct editline, such that "read.h" no longer needs to be included from "el.h" but only from the two files using it, read.c and el.c. Only pass the required el_read_t to el_read_{s,g}etfn(), do not pass the full struct editline. OK czarkoff@, also proofread by Christian Heckendorf <mbie at ulmus dot me>.
Diffstat (limited to 'lib/libedit/el.c')
-rw-r--r--lib/libedit/el.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/libedit/el.c b/lib/libedit/el.c
index 846f9b54e96..28d91fad7d4 100644
--- a/lib/libedit/el.c
+++ b/lib/libedit/el.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: el.c,v 1.34 2016/04/11 21:17:29 schwarze Exp $ */
+/* $OpenBSD: el.c,v 1.35 2016/05/20 15:30:17 schwarze Exp $ */
/* $NetBSD: el.c,v 1.61 2011/01/27 23:11:40 christos Exp $ */
/*-
@@ -49,6 +49,7 @@
#include "el.h"
#include "parse.h"
+#include "read.h"
/* el_init():
* Initialize editline and set default parameters.
@@ -100,8 +101,10 @@ el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr)
(void) hist_init(el);
(void) prompt_init(el);
(void) sig_init(el);
- (void) read_init(el);
-
+ if (read_init(el) == -1) {
+ el_end(el);
+ return NULL;
+ }
return el;
}
@@ -281,7 +284,7 @@ el_wset(EditLine *el, int op, ...)
case EL_GETCFN:
{
el_rfunc_t rc = va_arg(ap, el_rfunc_t);
- rv = el_read_setfn(el, rc);
+ rv = el_read_setfn(el->el_read, rc);
break;
}
@@ -429,7 +432,7 @@ el_wget(EditLine *el, int op, ...)
}
case EL_GETCFN:
- *va_arg(ap, el_rfunc_t *) = el_read_getfn(el);
+ *va_arg(ap, el_rfunc_t *) = el_read_getfn(el->el_read);
rv = 0;
break;