Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit Don't add an extra { NULL, 0, NULL } element to ...



details:   https://anonhg.NetBSD.org/src/rev/8c40a0cca167
branches:  trunk
changeset: 583480:8c40a0cca167
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Aug 08 14:04:49 2005 +0000

description:
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.

diffstat:

 lib/libedit/makelist |   3 +--
 lib/libedit/map.c    |  12 ++++++------
 2 files changed, 7 insertions(+), 8 deletions(-)

diffs (68 lines):

diff -r a5332787a918 -r 8c40a0cca167 lib/libedit/makelist
--- a/lib/libedit/makelist      Mon Aug 08 12:12:30 2005 +0000
+++ b/lib/libedit/makelist      Mon Aug 08 14:04:49 2005 +0000
@@ -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 @@
            }
        }
        END {
-           printf("    { NULL, 0, NULL }\n");
            printf("};\n");
            printf("\nprotected const el_bindings_t* help__get()");
            printf("{ return el_func_help; }\n");
diff -r a5332787a918 -r 8c40a0cca167 lib/libedit/map.c
--- a/lib/libedit/map.c Mon Aug 08 12:12:30 2005 +0000
+++ b/lib/libedit/map.c Mon Aug 08 14:04:49 2005 +0000
@@ -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 @@
 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 @@
 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 @@
        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);



Home | Main Index | Thread Index | Old Index