Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit Rename key to keymacro to avoid conflicts with t...



details:   https://anonhg.NetBSD.org/src/rev/d90e4c8cda88
branches:  trunk
changeset: 767714:d90e4c8cda88
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Jul 28 01:56:26 2011 +0000

description:
Rename key to keymacro to avoid conflicts with term.h. The renaming of term
to terminal was again to avoid conflicts with term.h. term.h is a moving
namespace violation.

diffstat:

 lib/libedit/Makefile   |    4 +-
 lib/libedit/el.c       |    8 +-
 lib/libedit/el.h       |    6 +-
 lib/libedit/key.c      |  665 -------------------------------------------------
 lib/libedit/key.h      |   80 -----
 lib/libedit/keymacro.c |  665 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/libedit/keymacro.h |   76 +++++
 lib/libedit/map.c      |   46 +-
 lib/libedit/read.c     |    8 +-
 lib/libedit/terminal.c |   81 ++---
 lib/libedit/terminal.h |   10 +-
 lib/libedit/tty.c      |   12 +-
 12 files changed, 827 insertions(+), 834 deletions(-)

diffs (truncated from 2045 to 300 lines):

diff -r ed263378c3b1 -r d90e4c8cda88 lib/libedit/Makefile
--- a/lib/libedit/Makefile      Thu Jul 28 01:44:50 2011 +0000
+++ b/lib/libedit/Makefile      Thu Jul 28 01:56:26 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.43 2011/07/28 01:05:20 christos Exp $
+#      $NetBSD: Makefile,v 1.44 2011/07/28 01:56:26 christos Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/4/93
 
 USE_SHLIBDIR=  yes
@@ -10,7 +10,7 @@
 LIBDPLIBS+=     terminfo ${.CURDIR}/../libterminfo
 
 OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \
-       hist.c key.c map.c chartype.c \
+       hist.c keymacro.c map.c chartype.c \
        parse.c prompt.c read.c refresh.c search.c sig.c terminal.c tty.c vi.c
 
 MAN=   editline.3 editrc.5
diff -r ed263378c3b1 -r d90e4c8cda88 lib/libedit/el.c
--- a/lib/libedit/el.c  Thu Jul 28 01:44:50 2011 +0000
+++ b/lib/libedit/el.c  Thu Jul 28 01:56:26 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: el.c,v 1.65 2011/07/28 01:04:41 christos Exp $ */
+/*     $NetBSD: el.c,v 1.66 2011/07/28 01:56:27 christos Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)el.c       8.2 (Berkeley) 1/3/94";
 #else
-__RCSID("$NetBSD: el.c,v 1.65 2011/07/28 01:04:41 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.66 2011/07/28 01:56:27 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -97,7 +97,7 @@
                el_free(el);
                return NULL;
        }
-       (void) key_init(el);
+       (void) keymacro_init(el);
        (void) map_init(el);
        if (tty_init(el) == -1)
                el->el_flags |= NO_TTY;
@@ -125,7 +125,7 @@
        el_reset(el);
 
        terminal_end(el);
-       key_end(el);
+       keymacro_end(el);
        map_end(el);
        tty_end(el);
        ch_end(el);
diff -r ed263378c3b1 -r d90e4c8cda88 lib/libedit/el.h
--- a/lib/libedit/el.h  Thu Jul 28 01:44:50 2011 +0000
+++ b/lib/libedit/el.h  Thu Jul 28 01:56:26 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: el.h,v 1.23 2011/07/28 01:05:20 christos Exp $ */
+/*     $NetBSD: el.h,v 1.24 2011/07/28 01:56:27 christos Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -100,7 +100,7 @@
 
 #include "tty.h"
 #include "prompt.h"
-#include "key.h"
+#include "keymacro.h"
 #include "terminal.h"
 #include "refresh.h"
 #include "chared.h"
@@ -136,7 +136,7 @@
        el_prompt_t       el_rprompt;   /* Prompt stuff                 */
        el_chared_t       el_chared;    /* Characted editor stuff       */
        el_map_t          el_map;       /* Key mapping stuff            */
-       el_key_t          el_key;       /* Key binding stuff            */
+       el_keymacro_t     el_keymacro;  /* Key binding stuff            */
        el_history_t      el_history;   /* History stuff                */
        el_search_t       el_search;    /* Search stuff                 */
        el_signal_t       el_signal;    /* Signal handling stuff        */
diff -r ed263378c3b1 -r d90e4c8cda88 lib/libedit/key.c
--- a/lib/libedit/key.c Thu Jul 28 01:44:50 2011 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,665 +0,0 @@
-/*     $NetBSD: key.c,v 1.23 2009/12/30 22:37:40 christos Exp $        */
-
-/*-
- * Copyright (c) 1992, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Christos Zoulas of Cornell University.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "config.h"
-#if !defined(lint) && !defined(SCCSID)
-#if 0
-static char sccsid[] = "@(#)key.c      8.1 (Berkeley) 6/4/93";
-#else
-__RCSID("$NetBSD: key.c,v 1.23 2009/12/30 22:37:40 christos Exp $");
-#endif
-#endif /* not lint && not SCCSID */
-
-/*
- * key.c: This module contains the procedures for maintaining
- *       the extended-key map.
- *
- *      An extended-key (key) is a sequence of keystrokes introduced
- *     with a sequence introducer and consisting of an arbitrary
- *     number of characters.  This module maintains a map (the el->el_key.map)
- *     to convert these extended-key sequences into input strs
- *     (XK_STR), editor functions (XK_CMD), or unix commands (XK_EXE).
- *
- *      Warning:
- *       If key is a substr of some other keys, then the longer
- *       keys are lost!!  That is, if the keys "abcd" and "abcef"
- *       are in el->el_key.map, adding the key "abc" will cause the first two
- *       definitions to be lost.
- *
- *      Restrictions:
- *      -------------
- *      1) It is not possible to have one key that is a
- *        substr of another.
- */
-#include <string.h>
-#include <stdlib.h>
-
-#include "el.h"
-
-/*
- * The Nodes of the el->el_key.map.  The el->el_key.map is a linked list
- * of these node elements
- */
-struct key_node_t {
-       Char            ch;             /* single character of key       */
-       int             type;           /* node type                     */
-       key_value_t     val;            /* command code or pointer to str,  */
-                                       /* if this is a leaf             */
-       struct key_node_t *next;        /* ptr to next char of this key  */
-       struct key_node_t *sibling;     /* ptr to another key with same prefix*/
-};
-
-private int             node_trav(EditLine *, key_node_t *, Char *,
-    key_value_t *);
-private int             node__try(EditLine *, key_node_t *, const Char *,
-    key_value_t *, int);
-private key_node_t     *node__get(Int);
-private void            node__free(key_node_t *);
-private void            node__put(EditLine *, key_node_t *);
-private int             node__delete(EditLine *, key_node_t **, const Char *);
-private int             node_lookup(EditLine *, const Char *, key_node_t *,
-    size_t);
-private int             node_enum(EditLine *, key_node_t *, size_t);
-
-#define        KEY_BUFSIZ      EL_BUFSIZ
-
-
-/* key_init():
- *     Initialize the key maps
- */
-protected int
-key_init(EditLine *el)
-{
-
-       el->el_key.buf = el_malloc(KEY_BUFSIZ * sizeof(*el->el_key.buf));
-       if (el->el_key.buf == NULL)
-               return (-1);
-       el->el_key.map = NULL;
-       key_reset(el);
-       return (0);
-}
-
-/* key_end():
- *     Free the key maps
- */
-protected void
-key_end(EditLine *el)
-{
-
-       el_free((ptr_t) el->el_key.buf);
-       el->el_key.buf = NULL;
-       node__free(el->el_key.map);
-}
-
-
-/* key_map_cmd():
- *     Associate cmd with a key value
- */
-protected key_value_t *
-key_map_cmd(EditLine *el, int cmd)
-{
-
-       el->el_key.val.cmd = (el_action_t) cmd;
-       return (&el->el_key.val);
-}
-
-
-/* key_map_str():
- *     Associate str with a key value
- */
-protected key_value_t *
-key_map_str(EditLine *el, Char *str)
-{
-
-       el->el_key.val.str = str;
-       return (&el->el_key.val);
-}
-
-
-/* key_reset():
- *     Takes all nodes on el->el_key.map and puts them on free list.  Then
- *     initializes el->el_key.map with arrow keys
- *     [Always bind the ansi arrow keys?]
- */
-protected void
-key_reset(EditLine *el)
-{
-
-       node__put(el, el->el_key.map);
-       el->el_key.map = NULL;
-       return;
-}
-
-
-/* key_get():
- *     Calls the recursive function with entry point el->el_key.map
- *      Looks up *ch in map and then reads characters until a
- *      complete match is found or a mismatch occurs. Returns the
- *      type of the match found (XK_STR, XK_CMD, or XK_EXE).
- *      Returns NULL in val.str and XK_STR for no match.
- *      The last character read is returned in *ch.
- */
-protected int
-key_get(EditLine *el, Char *ch, key_value_t *val)
-{
-
-       return (node_trav(el, el->el_key.map, ch, val));
-}
-
-
-/* key_add():
- *      Adds key to the el->el_key.map and associates the value in val with it.
- *      If key is already is in el->el_key.map, the new code is applied to the
- *      existing key. Ntype specifies if code is a command, an
- *      out str or a unix command.
- */
-protected void
-key_add(EditLine *el, const Char *key, key_value_t *val, int ntype)
-{
-
-       if (key[0] == '\0') {
-               (void) fprintf(el->el_errfile,
-                   "key_add: Null extended-key not allowed.\n");
-               return;
-       }
-       if (ntype == XK_CMD && val->cmd == ED_SEQUENCE_LEAD_IN) {
-               (void) fprintf(el->el_errfile,
-                   "key_add: sequence-lead-in command not allowed\n");
-               return;
-       }
-       if (el->el_key.map == NULL)
-               /* tree is initially empty.  Set up new node to match key[0] */
-               el->el_key.map = node__get(key[0]);
-                       /* it is properly initialized */
-
-       /* Now recurse through el->el_key.map */
-       (void) node__try(el, el->el_key.map, key, val, ntype);
-       return;
-}
-
-
-/* key_clear():
- *
- */
-protected void



Home | Main Index | Thread Index | Old Index