diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1997-01-16 05:18:56 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1997-01-16 05:18:56 +0000 |
commit | d811c9277c942ef81ec5f325ae55337ff3089842 (patch) | |
tree | af13e7c0dcb8d4e9d9d938bce60eb610f8bb6748 /lib/libedit/hist.c | |
parent | 891d48fc5656bed485ad5e2b5e154786b9f84d2e (diff) |
Merge in NetBSD libedit changes and new man pages. Also fix some
strncpy() usage in their code. NetBSD change log was:
* add a man page for the editline routines
* add a man page describing editrc
* fix bugs in el_parse():
* didn't execute command when program name matched (test reversed)
* was checking against empty string instead of program name
* after checks, command to run also pointed to empty string
* document ^char and \ escape sequences
* when parsing ^char control chars, check the correct char when determining
validity (previously, ^char was a NOP interpreted as the literal string
because of this bug)
* Implement CC_REDISPLAY, which (unlike CC_REFRESH) redraws the entire input
* line (a la ^R). This is useful if the binding outputs information and
* mucks up the input line. To be used in ``list-choices'' bindings (refer
* to the ^D binding in csh when filec is set)
Diffstat (limited to 'lib/libedit/hist.c')
-rw-r--r-- | lib/libedit/hist.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/libedit/hist.c b/lib/libedit/hist.c index 394df63e9d3..b9a6e20c677 100644 --- a/lib/libedit/hist.c +++ b/lib/libedit/hist.c @@ -1,3 +1,5 @@ +/* $OpenBSD: hist.c,v 1.2 1997/01/16 05:18:33 millert Exp $ */ + /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -35,7 +37,11 @@ */ #if !defined(lint) && !defined(SCCSID) +#if 0 static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93"; +#else +static char rcsid[] = "$OpenBSD: hist.c,v 1.2 1997/01/16 05:18:33 millert Exp $"; +#endif #endif /* not lint && not SCCSID */ /* @@ -100,7 +106,8 @@ hist_get(el) int h; if (el->el_history.eventno == 0) { /* if really the current line */ - (void) strncpy(el->el_line.buffer, el->el_history.buf, EL_BUFSIZ); + (void) strncpy(el->el_line.buffer, el->el_history.buf, EL_BUFSIZ - 1); + el->el_line.buffer[EL_BUFSIZ - 1] = '\0'; el->el_line.lastchar = el->el_line.buffer + (el->el_history.last - el->el_history.buf); @@ -128,7 +135,8 @@ hist_get(el) return CC_ERROR; } - (void) strncpy(el->el_line.buffer, hp, EL_BUFSIZ); + (void) strncpy(el->el_line.buffer, hp, EL_BUFSIZ - 1); + el->el_line.buffer[EL_BUFSIZ - 1] = '\0'; el->el_line.lastchar = el->el_line.buffer + strlen(el->el_line.buffer); if (el->el_line.lastchar > el->el_line.buffer) { |