Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit - add support for home and end keys.



details:   https://anonhg.NetBSD.org/src/rev/19c9a28da462
branches:  trunk
changeset: 499113:19c9a28da462
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Nov 11 22:18:57 2000 +0000

description:
- add support for home and end keys.
- improve debugging support

diffstat:

 lib/libedit/chared.c |   6 +++---
 lib/libedit/el.c     |   8 ++++----
 lib/libedit/el.h     |   8 +++++++-
 lib/libedit/key.c    |  49 ++++++++++++++++++++++++++-----------------------
 lib/libedit/map.c    |  14 +++++++-------
 lib/libedit/read.c   |   6 +++---
 lib/libedit/term.c   |  33 +++++++++++++++++++++++++++++----
 lib/libedit/term.h   |   6 ++++--
 8 files changed, 83 insertions(+), 47 deletions(-)

diffs (truncated from 455 to 300 lines):

diff -r bccd1565894e -r 19c9a28da462 lib/libedit/chared.c
--- a/lib/libedit/chared.c      Sat Nov 11 20:56:46 2000 +0000
+++ b/lib/libedit/chared.c      Sat Nov 11 22:18:57 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chared.c,v 1.9 2000/09/04 22:06:28 lukem Exp $ */
+/*     $NetBSD: chared.c,v 1.10 2000/11/11 22:18:57 christos Exp $     */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)chared.c   8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: chared.c,v 1.9 2000/09/04 22:06:28 lukem Exp $");
+__RCSID("$NetBSD: chared.c,v 1.10 2000/11/11 22:18:57 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -341,7 +341,7 @@
        case NOP:
        case INSERT:
        default:
-               abort();
+               EL_ABORT((el->el_errfile, "Bad oaction %d\n", oaction));
                break;
        }
 
diff -r bccd1565894e -r 19c9a28da462 lib/libedit/el.c
--- a/lib/libedit/el.c  Sat Nov 11 20:56:46 2000 +0000
+++ b/lib/libedit/el.c  Sat Nov 11 22:18:57 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: el.c,v 1.19 2000/09/04 22:06:29 lukem Exp $    */
+/*     $NetBSD: el.c,v 1.20 2000/11/11 22:18:57 christos Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)el.c       8.2 (Berkeley) 1/3/94";
 #else
-__RCSID("$NetBSD: el.c,v 1.19 2000/09/04 22:06:29 lukem Exp $");
+__RCSID("$NetBSD: el.c,v 1.20 2000/11/11 22:18:57 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -223,7 +223,7 @@
 
                default:
                        rv = -1;
-                       abort();
+                       EL_ABORT((el->el_errfile, "Bad op %d\n", op));
                        break;
                }
                break;
@@ -341,7 +341,7 @@
 
                default:
                        rv = -1;
-                       abort();
+                       EL_ABORT((el->errfile, "Bad op %d\n", op));
                        break;
                }
                break;
diff -r bccd1565894e -r 19c9a28da462 lib/libedit/el.h
--- a/lib/libedit/el.h  Sat Nov 11 20:56:46 2000 +0000
+++ b/lib/libedit/el.h  Sat Nov 11 22:18:57 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: el.h,v 1.6 2000/09/04 22:06:29 lukem Exp $     */
+/*     $NetBSD: el.h,v 1.7 2000/11/11 22:18:57 christos Exp $  */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -133,4 +133,10 @@
 
 protected int  el_editmode(EditLine *, int, char **);
 
+#ifdef DEBUG
+#define EL_ABORT(a)    (void) (fprintf(el->el_errfile, "%s, %d: ", \
+                               __FILE__, __LINE__), fprintf a, abort())
+#else
+#define EL_ABORT(a)    abort()
+#endif
 #endif /* _h_el */
diff -r bccd1565894e -r 19c9a28da462 lib/libedit/key.c
--- a/lib/libedit/key.c Sat Nov 11 20:56:46 2000 +0000
+++ b/lib/libedit/key.c Sat Nov 11 22:18:57 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: key.c,v 1.8 2000/10/04 16:21:39 sommerfeld Exp $       */
+/*     $NetBSD: key.c,v 1.9 2000/11/11 22:18:57 christos Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)key.c      8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: key.c,v 1.8 2000/10/04 16:21:39 sommerfeld Exp $");
+__RCSID("$NetBSD: key.c,v 1.9 2000/11/11 22:18:57 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -86,11 +86,12 @@
 };
 
 private int             node_trav(EditLine *, key_node_t *, char *,
-                           key_value_t *);
-private int             node__try(key_node_t *, char *, key_value_t *, int);
+    key_value_t *);
+private int             node__try(EditLine *, key_node_t *, char *,
+    key_value_t *, int);
 private key_node_t     *node__get(int);
-private void            node__put(key_node_t *);
-private int             node__delete(key_node_t **, char *);
+private void            node__put(EditLine *, key_node_t *);
+private int             node__delete(EditLine *, key_node_t **, char *);
 private int             node_lookup(EditLine *, char *, key_node_t *, int);
 private int             node_enum(EditLine *, key_node_t *, int);
 private int             key__decode_char(char *, int, int);
@@ -159,7 +160,7 @@
 key_reset(EditLine *el)
 {
 
-       node__put(el->el_key.map);
+       node__put(el, el->el_key.map);
        el->el_key.map = NULL;
        return;
 }
@@ -207,7 +208,7 @@
                        /* it is properly initialized */
 
        /* Now recurse through el->el_key.map */
-       (void) node__try(el->el_key.map, key, val, ntype);
+       (void) node__try(el, el->el_key.map, key, val, ntype);
        return;
 }
 
@@ -244,7 +245,7 @@
        if (el->el_key.map == NULL)
                return (0);
 
-       (void) node__delete(&el->el_key.map, key);
+       (void) node__delete(el, &el->el_key.map, key);
        return (0);
 }
 
@@ -312,7 +313,7 @@
  *     Find a node that matches *str or allocate a new one
  */
 private int
-node__try(key_node_t *ptr, char *str, key_value_t *val, int ntype)
+node__try(EditLine *el, key_node_t *ptr, char *str, key_value_t *val, int ntype)
 {
 
        if (ptr->ch != *str) {
@@ -328,7 +329,7 @@
        if (*++str == '\0') {
                /* we're there */
                if (ptr->next != NULL) {
-                       node__put(ptr->next);
+                       node__put(el, ptr->next);
                                /* lose longer keys with this prefix */
                        ptr->next = NULL;
                }
@@ -342,7 +343,8 @@
                                el_free((ptr_t) ptr->val.str);
                        break;
                default:
-                       abort();
+                       EL_ABORT((el->el_errfile, "Bad XK_ type %d\n",
+                           ptr->type));
                        break;
                }
 
@@ -355,14 +357,14 @@
                        ptr->val.str = strdup(val->str);
                        break;
                default:
-                       abort();
+                       EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
                        break;
                }
        } else {
                /* still more chars to go */
                if (ptr->next == NULL)
                        ptr->next = node__get(*str);    /* setup new node */
-               (void) node__try(ptr->next, str, val, ntype);
+               (void) node__try(el, ptr->next, str, val, ntype);
        }
        return (0);
 }
@@ -372,7 +374,7 @@
  *     Delete node that matches str
  */
 private int
-node__delete(key_node_t **inptr, char *str)
+node__delete(EditLine *el, key_node_t **inptr, char *str)
 {
        key_node_t *ptr;
        key_node_t *prev_ptr = NULL;
@@ -397,9 +399,10 @@
                else
                        prev_ptr->sibling = ptr->sibling;
                ptr->sibling = NULL;
-               node__put(ptr);
+               node__put(el, ptr);
                return (1);
-       } else if (ptr->next != NULL && node__delete(&ptr->next, str) == 1) {
+       } else if (ptr->next != NULL &&
+           node__delete(el, &ptr->next, str) == 1) {
                if (ptr->next != NULL)
                        return (0);
                if (prev_ptr == NULL)
@@ -407,7 +410,7 @@
                else
                        prev_ptr->sibling = ptr->sibling;
                ptr->sibling = NULL;
-               node__put(ptr);
+               node__put(el, ptr);
                return (1);
        } else {
                return (0);
@@ -419,16 +422,16 @@
  *     Puts a tree of nodes onto free list using free(3).
  */
 private void
-node__put(key_node_t *ptr)
+node__put(EditLine *el, key_node_t *ptr)
 {
        if (ptr == NULL)
                return;
 
        if (ptr->next != NULL) {
-               node__put(ptr->next);
+               node__put(el, ptr->next);
                ptr->next = NULL;
        }
-       node__put(ptr->sibling);
+       node__put(el, ptr->sibling);
 
        switch (ptr->type) {
        case XK_CMD:
@@ -440,7 +443,7 @@
                        el_free((ptr_t) ptr->val.str);
                break;
        default:
-               abort();
+               EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ptr->type));
                break;
        }
        el_free((ptr_t) ptr);
@@ -590,7 +593,7 @@
 
                        break;
                default:
-                       abort();
+                       EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
                        break;
                }
        else
diff -r bccd1565894e -r 19c9a28da462 lib/libedit/map.c
--- a/lib/libedit/map.c Sat Nov 11 20:56:46 2000 +0000
+++ b/lib/libedit/map.c Sat Nov 11 22:18:57 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: map.c,v 1.11 2000/09/04 22:06:30 lukem Exp $   */
+/*     $NetBSD: map.c,v 1.12 2000/11/11 22:18:57 christos Exp $        */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)map.c      8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: map.c,v 1.11 2000/09/04 22:06:30 lukem Exp $");
+__RCSID("$NetBSD: map.c,v 1.12 2000/11/11 22:18:57 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -903,11 +903,11 @@
          */
 #ifdef MAP_DEBUG
        if (sizeof(el_map_emacs) != N_KEYS * sizeof(el_action_t))
-               abort();
+               EL_ABORT((el->errfile, "Emacs map incorrect\n"));
        if (sizeof(el_map_vi_command) != N_KEYS * sizeof(el_action_t))
-               abort();
+               EL_ABORT((el->errfile, "Vi command map incorrect\n"));
        if (sizeof(el_map_vi_insert) != N_KEYS * sizeof(el_action_t))
-               abort();
+               EL_ABORT((el->errfile, "Vi insert map incorrect\n"));
 #endif
 
        el->el_map.alt = (el_action_t *)el_malloc(sizeof(el_action_t) * N_KEYS);
@@ -1189,7 +1189,7 @@
                    first, el->el_map.alt[first]);
        }
 #endif
-       abort();
+       EL_ABORT((el->el_errfile, "Error printing keys\n"));
 }
 



Home | Main Index | Thread Index | Old Index