Don't add an extra { NULL, 0, NULL } element to the help array. Instead keep

it always the same size as the function array for consistency. Reported in
FreeBSD PR 82381, but fixed differently.
This commit is contained in:
christos 2005-08-08 14:04:49 +00:00
parent c0065dc0df
commit d8f117745d
2 changed files with 7 additions and 8 deletions

View File

@ -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 $
#
# Copyright (c) 1992, 1993
# The Regents of the University of California. All rights reserved.
@ -118,7 +118,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");

View File

@ -1,4 +1,4 @@
/* $NetBSD: map.c,v 1.20 2004/08/13 12:10:39 mycroft Exp $ */
/* $NetBSD: map.c,v 1.21 2005/08/08 14:04:49 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: map.c,v 1.20 2004/08/13 12:10:39 mycroft Exp $");
__RCSID("$NetBSD: map.c,v 1.21 2005/08/08 14:04:49 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@ -1125,11 +1125,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);
@ -1388,7 +1389,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);
@ -1407,7 +1408,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);