From 83a85292b6e247b2c710cd6e32615ed78c771057 Mon Sep 17 00:00:00 2001 From: stefanf Date: Tue, 4 Oct 2005 21:59:29 +0000 Subject: Merge makelist rev 1.10 and map.c rev 1.22 from NetBSD. They just patch the bug fixed in the last commit to map.c in a different way. Follow NetBSD to facilitate future merges. --- lib/libedit/makelist | 3 +-- lib/libedit/map.c | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/libedit/makelist b/lib/libedit/makelist index 75faa41..e44a0e7 100644 --- a/lib/libedit/makelist +++ b/lib/libedit/makelist @@ -1,5 +1,5 @@ #!/bin/sh - -# $NetBSD: makelist,v 1.9 2005/05/16 13:14:43 lukem Exp $ +# $NetBSD: makelist,v 1.10 2005/08/08 14:04:49 christos Exp $ # $FreeBSD$ # # Copyright (c) 1992, 1993 @@ -119,7 +119,6 @@ case $FLAG in } } END { - printf(" { NULL, 0, NULL }\n"); printf("};\n"); printf("\nprotected const el_bindings_t* help__get()"); printf("{ return el_func_help; }\n"); diff --git a/lib/libedit/map.c b/lib/libedit/map.c index 6714248..76c9e4d 100644 --- a/lib/libedit/map.c +++ b/lib/libedit/map.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $NetBSD: map.c,v 1.20 2004/08/13 12:10:39 mycroft Exp $ + * $NetBSD: map.c,v 1.22 2005/08/09 13:58:44 christos Exp $ */ #if !defined(lint) && !defined(SCCSID) @@ -913,11 +913,11 @@ map_init(EditLine *el) el->el_map.vic = el_map_vi_command; el->el_map.vii = el_map_vi_insert; el->el_map.help = (el_bindings_t *) el_malloc(sizeof(el_bindings_t) * - (EL_NUM_FCNS + 1)); + EL_NUM_FCNS); if (el->el_map.help == NULL) return (-1); (void) memcpy(el->el_map.help, help__get(), - sizeof(el_bindings_t) * (EL_NUM_FCNS + 1)); + sizeof(el_bindings_t) * EL_NUM_FCNS); el->el_map.func = (el_func_t *)el_malloc(sizeof(el_func_t) * EL_NUM_FCNS); if (el->el_map.func == NULL) @@ -1123,11 +1123,12 @@ private void map_print_key(EditLine *el, el_action_t *map, const char *in) { char outbuf[EL_BUFSIZ]; - el_bindings_t *bp; + el_bindings_t *bp, *ep; if (in[0] == '\0' || in[1] == '\0') { (void) key__decode_str(in, outbuf, ""); - for (bp = el->el_map.help; bp->name != NULL; bp++) + ep = &el->el_map.help[el->el_map.nfunc]; + for (bp = el->el_map.help; bp < ep; bp++) if (bp->func == map[(unsigned char) *in]) { (void) fprintf(el->el_outfile, "%s\t->\t%s\n", outbuf, bp->name); @@ -1144,7 +1145,7 @@ map_print_key(EditLine *el, el_action_t *map, const char *in) private void map_print_some_keys(EditLine *el, el_action_t *map, int first, int last) { - el_bindings_t *bp; + el_bindings_t *bp, *ep; char firstbuf[2], lastbuf[2]; char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ]; @@ -1159,7 +1160,8 @@ map_print_some_keys(EditLine *el, el_action_t *map, int first, int last) key__decode_str(firstbuf, unparsbuf, STRQQ)); return; } - for (bp = el->el_map.help; bp->name != NULL; bp++) { + ep = &el->el_map.help[el->el_map.nfunc]; + for (bp = el->el_map.help; bp < ep; bp++) { if (bp->func == map[first]) { if (first == last) { (void) fprintf(el->el_outfile, "%-15s-> %s\n", @@ -1242,7 +1244,7 @@ map_bind(EditLine *el, int argc, const char **argv) char outbuf[EL_BUFSIZ]; const char *in = NULL; char *out = NULL; - el_bindings_t *bp; + el_bindings_t *bp, *ep; int cmd; int key; @@ -1284,8 +1286,8 @@ map_bind(EditLine *el, int argc, const char **argv) return (0); case 'l': - for (bp = el->el_map.help; bp->name != NULL; - bp++) + ep = &el->el_map.help[el->el_map.nfunc]; + for (bp = el->el_map.help; bp < ep; bp++) (void) fprintf(el->el_outfile, "%s\n\t%s\n", bp->name, bp->description); @@ -1386,7 +1388,7 @@ protected int map_addfunc(EditLine *el, const char *name, const char *help, el_func_t func) { void *p; - int nf = el->el_map.nfunc + 2; + int nf = el->el_map.nfunc + 1; if (name == NULL || help == NULL || func == NULL) return (-1); @@ -1405,7 +1407,6 @@ map_addfunc(EditLine *el, const char *name, const char *help, el_func_t func) el->el_map.help[nf].name = name; el->el_map.help[nf].func = nf; el->el_map.help[nf].description = help; - el->el_map.help[++nf].name = NULL; el->el_map.nfunc++; return (0); -- cgit v1.1