diff options
Diffstat (limited to 'cmd-line-utils/libedit/chared.c')
-rw-r--r-- | cmd-line-utils/libedit/chared.c | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/cmd-line-utils/libedit/chared.c b/cmd-line-utils/libedit/chared.c index 62a407e66a8..21fc8bc2c1d 100644 --- a/cmd-line-utils/libedit/chared.c +++ b/cmd-line-utils/libedit/chared.c @@ -1,4 +1,4 @@ -/* $NetBSD: chared.c,v 1.18 2002/11/20 16:50:08 christos Exp $ */ +/* $NetBSD: chared.c,v 1.22 2004/08/13 12:10:38 mycroft Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -15,11 +15,7 @@ * 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 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. * @@ -36,14 +32,7 @@ * SUCH DAMAGE. */ -#include "config.h" -#if !defined(lint) && !defined(SCCSID) -#if 0 -static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: chared.c,v 1.18 2002/11/20 16:50:08 christos Exp $"); -#endif -#endif /* not lint && not SCCSID */ +#include <config.h> /* * chared.c: Character editor utilities @@ -62,13 +51,13 @@ cv_undo(EditLine *el) { c_undo_t *vu = &el->el_chared.c_undo; c_redo_t *r = &el->el_chared.c_redo; - int size; + uint size; /* Save entire line for undo */ size = el->el_line.lastchar - el->el_line.buffer; vu->len = size; vu->cursor = el->el_line.cursor - el->el_line.buffer; - memcpy(vu->buf, el->el_line.buffer, (size_t)size); + memcpy(vu->buf, el->el_line.buffer, size); /* save command info for redo */ r->count = el->el_state.doingarg ? el->el_state.argument : 0; @@ -139,6 +128,21 @@ c_delafter(EditLine *el, int num) } +/* c_delafter1(): + * Delete the character after the cursor, do not yank + */ +protected void +c_delafter1(EditLine *el) +{ + char *cp; + + for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++) + *cp = cp[1]; + + el->el_line.lastchar--; +} + + /* c_delbefore(): * Delete num characters before the cursor */ @@ -167,6 +171,21 @@ c_delbefore(EditLine *el, int num) } +/* c_delbefore1(): + * Delete the character before the cursor, do not yank + */ +protected void +c_delbefore1(EditLine *el) +{ + char *cp; + + for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++) + *cp = cp[1]; + + el->el_line.lastchar--; +} + + /* ce__isword(): * Return if p is part of a word according to emacs */ @@ -460,8 +479,8 @@ ch_init(EditLine *el) el->el_state.argument = 1; el->el_state.lastcmd = ED_UNASSIGNED; - el->el_chared.c_macro.nline = NULL; el->el_chared.c_macro.level = -1; + el->el_chared.c_macro.offset = 0; el->el_chared.c_macro.macro = (char **) el_malloc(EL_MAXMACRO * sizeof(char *)); if (el->el_chared.c_macro.macro == NULL) @@ -582,7 +601,7 @@ ch_enlargebufs(el, addlen) return 0; /* Safe to set enlarged buffer size */ - el->el_line.limit = &newbuffer[newsz - EL_LEAVE]; + el->el_line.limit = &el->el_line.buffer[newsz - EL_LEAVE]; return 1; } |