summaryrefslogtreecommitdiffstats
path: root/lib/libedit/map.c
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2005-10-04 21:59:29 +0000
committerstefanf <stefanf@FreeBSD.org>2005-10-04 21:59:29 +0000
commit83a85292b6e247b2c710cd6e32615ed78c771057 (patch)
treedb8cfa28832271abea07cc685706294fda158c22 /lib/libedit/map.c
parent476cfba9225e972007bed7311b00879f18d63883 (diff)
downloadFreeBSD-src-83a85292b6e247b2c710cd6e32615ed78c771057.zip
FreeBSD-src-83a85292b6e247b2c710cd6e32615ed78c771057.tar.gz
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.
Diffstat (limited to 'lib/libedit/map.c')
-rw-r--r--lib/libedit/map.c25
1 files changed, 13 insertions, 12 deletions
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);
OpenPOWER on IntegriCloud