Module Name: src
Committed By: martin
Date: Wed May 13 13:33:55 UTC 2015
Modified Files:
src/lib/libedit [netbsd-7]: Makefile chartype.h editline.3 editrc.5
eln.c filecomplete.c readline.c
Log Message:
Sync lib/libedit with head, requested by christos in #753:
lib/libedit/Makefile 1.53
lib/libedit/chartype.h 1.13
lib/libedit/editline.3 1.83-1.84
lib/libedit/editrc.5 1.28-1.29
lib/libedit/eln.c 1.18
lib/libedit/filecomplete.c 1.33-1.34
lib/libedit/readline.c 1.112-1.115
Man page improvements, fix overlapping strcpy, improve readline
compatibility, clang build fix.
To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.52.2.1 src/lib/libedit/Makefile
cvs rdiff -u -r1.10.18.1 -r1.10.18.2 src/lib/libedit/chartype.h
cvs rdiff -u -r1.82 -r1.82.2.1 src/lib/libedit/editline.3
cvs rdiff -u -r1.27 -r1.27.8.1 src/lib/libedit/editrc.5
cvs rdiff -u -r1.17 -r1.17.2.1 src/lib/libedit/eln.c
cvs rdiff -u -r1.32 -r1.32.2.1 src/lib/libedit/filecomplete.c
cvs rdiff -u -r1.111 -r1.111.2.1 src/lib/libedit/readline.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libedit/Makefile
diff -u src/lib/libedit/Makefile:1.52 src/lib/libedit/Makefile:1.52.2.1
--- src/lib/libedit/Makefile:1.52 Sat Jun 14 20:49:37 2014
+++ src/lib/libedit/Makefile Wed May 13 13:33:55 2015
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.52 2014/06/14 20:49:37 mrg Exp $
+# $NetBSD: Makefile,v 1.52.2.1 2015/05/13 13:33:55 martin Exp $
# @(#)Makefile 8.1 (Berkeley) 6/4/93
USE_SHLIBDIR= yes
@@ -13,6 +13,7 @@ LIBDPLIBS+= terminfo ${.CURDIR}/../l
COPTS+= -Wunused-parameter
CWARNFLAGS.gcc+= -Wconversion
+CWARNFLAGS.clang+= -Wno-cast-qual
OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \
hist.c keymacro.c map.c chartype.c \
Index: src/lib/libedit/chartype.h
diff -u src/lib/libedit/chartype.h:1.10.18.1 src/lib/libedit/chartype.h:1.10.18.2
--- src/lib/libedit/chartype.h:1.10.18.1 Tue Apr 14 05:30:24 2015
+++ src/lib/libedit/chartype.h Wed May 13 13:33:55 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: chartype.h,v 1.10.18.1 2015/04/14 05:30:24 snj Exp $ */
+/* $NetBSD: chartype.h,v 1.10.18.2 2015/05/13 13:33:55 martin Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
* supports non-BMP code points without requiring UTF-16, but nothing
* seems to actually advertise this properly, despite Unicode 3.1 having
* been around since 2001... */
-#if !defined(__NetBSD__) && !defined(__sun) && !(defined(__APPLE__) && defined(__MACH__))
+#if !defined(__NetBSD__) && !defined(__sun) && !(defined(__APPLE__) && defined(__MACH__)) && !defined(__OpenBSD__)
#ifndef __STDC_ISO_10646__
/* In many places it is assumed that the first 127 code points are ASCII
* compatible, so ensure wchar_t indeed does ISO 10646 and not some other
Index: src/lib/libedit/editline.3
diff -u src/lib/libedit/editline.3:1.82 src/lib/libedit/editline.3:1.82.2.1
--- src/lib/libedit/editline.3:1.82 Sun May 11 09:01:42 2014
+++ src/lib/libedit/editline.3 Wed May 13 13:33:55 2015
@@ -1,4 +1,4 @@
-.\" $NetBSD: editline.3,v 1.82 2014/05/11 09:01:42 wiz Exp $
+.\" $NetBSD: editline.3,v 1.82.2.1 2015/05/13 13:33:55 martin Exp $
.\"
.\" Copyright (c) 1997-2014 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -26,7 +26,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd May 10, 2014
+.Dd December 25, 2014
.Dt EDITLINE 3
.Os
.Sh NAME
@@ -190,7 +190,9 @@ The following functions are available:
.Bl -tag -width 4n
.It Fn el_init
Initialise the line editor, and return a data structure
-to be used by all other line editing functions.
+to be used by all other line editing functions, or
+.Dv NULL
+on failure.
.Fa prog
is the name of the invoking program, used when reading the
.Xr editrc 5
@@ -290,6 +292,7 @@ parameters.
.Fa op
determines which parameter to set, and each operation has its
own parameter list.
+Returns 0 on success, \-1 on failure.
.Pp
The following values for
.Fa op
@@ -605,6 +608,8 @@ Refer to
.Xr editrc 5
for details on the format of
.Fa file .
+.Fn el_source
+returns 0 on success and \-1 on error.
.It Fn el_resize
Must be called if the terminal size changes.
If
@@ -665,7 +670,9 @@ The following functions are available:
.Bl -tag -width 4n
.It Fn history_init
Initialise the history list, and return a data structure
-to be used by all other history list functions.
+to be used by all other history list functions, or
+.Dv NULL
+on failure.
.It Fn history_end
Clean up and finish with
.Fa h ,
@@ -734,12 +741,12 @@ as a new element to the history, and, if
removing the oldest entry to keep the list to the created size.
If
.Dv H_SETUNIQUE
-was has been called with a non-zero arguments, the element
+has been called with a non-zero argument, the element
will not be entered into the history if its contents match
the ones of the current history element.
If the element is entered
.Fn history
-returns 1, if it is ignored as a duplicate returns 0.
+returns 1; if it is ignored as a duplicate returns 0.
Finally
.Fn history
returns \-1 if an error occurred.
Index: src/lib/libedit/editrc.5
diff -u src/lib/libedit/editrc.5:1.27 src/lib/libedit/editrc.5:1.27.8.1
--- src/lib/libedit/editrc.5:1.27 Thu Jan 10 16:03:42 2013
+++ src/lib/libedit/editrc.5 Wed May 13 13:33:55 2015
@@ -1,4 +1,4 @@
-.\" $NetBSD: editrc.5,v 1.27 2013/01/10 16:03:42 wiz Exp $
+.\" $NetBSD: editrc.5,v 1.27.8.1 2015/05/13 13:33:55 martin Exp $
.\"
.\" Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -26,7 +26,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd January 10, 2013
+.Dd December 25, 2014
.Dt EDITRC 5
.Os
.Sh NAME
@@ -42,7 +42,8 @@ file defines various settings to be used
library.
.Pp
The format of each line is:
-.Dl [prog:]command [arg [...]]
+.Pp
+.Dl [prog:]command [arg ...]
.Pp
.Ar command
is one of the
@@ -103,16 +104,12 @@ to
.Ar key .
Options include:
.Bl -tag -width 4n
-.It Fl e
-Bind all keys to the standard GNU Emacs-like bindings.
-.It Fl v
-Bind all keys to the standard
-.Xr vi 1 Ns -like
-bindings.
.It Fl a
List or change key bindings in the
.Xr vi 1
mode alternate (command mode) key map.
+.It Fl e
+Bind all keys to the standard GNU Emacs-like bindings.
.It Fl k
.Ar key
is interpreted as a symbolic arrow key name, which may be one of
@@ -134,6 +131,10 @@ Bound keys in
.Ar command
are themselves reinterpreted, and this continues for ten levels of
interpretation.
+.It Fl v
+Bind all keys to the standard
+.Xr vi 1 Ns -like
+bindings.
.El
.Pp
.Ar command
@@ -149,7 +150,7 @@ can contain control characters of the fo
.Sq No ^ Ar character
.Sm on
.Po
-e.g.
+e.g.\&
.Sq ^A
.Pc ,
and the following backslashed escape sequences:
@@ -186,7 +187,7 @@ and
.Sq ^ .
.It Ic echotc Oo Fl sv Oc Ar arg Ar ...
Exercise terminal capabilities given in
-.Ar arg Ar ... .
+.Ar arg ... .
If
.Ar arg
is
@@ -230,9 +231,6 @@ is non zero, only keep unique history en
If
.Dv n
is zero, then keep all entries (the default).
-.It Ic telltc
-List the values of all the terminal capabilities (see
-.Xr termcap 5 ) .
.It Ic settc Ar cap Ar val
Set the terminal capability
.Ar cap
@@ -291,6 +289,9 @@ If
is empty
then the character is set to
.Dv _POSIX_VDISABLE .
+.It Ic telltc
+List the values of all the terminal capabilities (see
+.Xr termcap 5 ) .
.El
.Sh EDITOR COMMANDS
The following editor commands are available for use in key bindings:
@@ -300,11 +301,11 @@ The following editor commands are availa
Vi paste previous deletion to the right of the cursor.
.It Ic vi-paste-prev
Vi paste previous deletion to the left of the cursor.
-.It Ic vi-prev-space-word
+.It Ic vi-prev-big-word
Vi move to the previous space delimited word.
.It Ic vi-prev-word
Vi move to the previous word.
-.It Ic vi-next-space-word
+.It Ic vi-next-big-word
Vi move to the next space delimited word.
.It Ic vi-next-word
Vi move to the next word.
@@ -332,9 +333,9 @@ Vi enter insert mode after the cursor.
Vi enter insert mode at end of line.
.It Ic vi-delete-meta
Vi delete prefix command.
-.It Ic vi-end-word
+.It Ic vi-end-big-word
Vi move to the end of the current space delimited word.
-.It Ic vi-to-end-word
+.It Ic vi-end-word
Vi move to the end of the current word.
.It Ic vi-undo
Vi undo last change.
@@ -368,6 +369,28 @@ Vi move up to the character specified pr
Vi repeat current character search in the same search direction.
.It Ic vi-repeat-prev-char
Vi repeat current character search in the opposite search direction.
+.It Ic vi-match
+Vi go to matching () {} or [].
+.It Ic vi-undo-line
+Vi undo all changes to line.
+.It Ic vi-to-column
+Vi go to specified column.
+.It Ic vi-yank-end
+Vi yank to end of line.
+.It Ic vi-yank
+Vi yank.
+.It Ic vi-comment-out
+Vi comment out current command.
+.It Ic vi-alias
+Vi include shell alias.
+.It Ic vi-to-history-line
+Vi go to specified history file line..
+.It Ic vi-histedit
+Vi edit history line with vi.
+.It Ic vi-history-word
+Vi append word from previous input line.
+.It Ic vi-redo
+Vi redo last non-motion command.
.It Ic em-delete-or-list
Delete character under cursor or list completions if at end of line.
.It Ic em-delete-next-word
@@ -490,9 +513,12 @@ library.
.Xr regex 3 ,
.Xr termcap 5
.Sh AUTHORS
+.An -nosplit
The
.Nm editline
-library was written by Christos Zoulas,
-and this manual was written by Luke Mewburn,
+library was written by
+.An Christos Zoulas ,
+and this manual was written by
+.An Luke Mewburn ,
with some sections inspired by
.Xr tcsh 1 .
Index: src/lib/libedit/eln.c
diff -u src/lib/libedit/eln.c:1.17 src/lib/libedit/eln.c:1.17.2.1
--- src/lib/libedit/eln.c:1.17 Wed Jun 18 18:12:28 2014
+++ src/lib/libedit/eln.c Wed May 13 13:33:55 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: eln.c,v 1.17 2014/06/18 18:12:28 christos Exp $ */
+/* $NetBSD: eln.c,v 1.17.2.1 2015/05/13 13:33:55 martin Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: eln.c,v 1.17 2014/06/18 18:12:28 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.17.2.1 2015/05/13 13:33:55 martin Exp $");
#endif /* not lint && not SCCSID */
#include "histedit.h"
@@ -76,9 +76,11 @@ el_gets(EditLine *el, int *nread)
{
const wchar_t *tmp;
- el->el_flags |= IGNORE_EXTCHARS;
+ if (!(el->el_flags & CHARSET_IS_UTF8))
+ el->el_flags |= IGNORE_EXTCHARS;
tmp = el_wgets(el, nread);
- el->el_flags &= ~IGNORE_EXTCHARS;
+ if (!(el->el_flags & CHARSET_IS_UTF8))
+ el->el_flags &= ~IGNORE_EXTCHARS;
return ct_encode_string(tmp, &el->el_lgcyconv);
}
Index: src/lib/libedit/filecomplete.c
diff -u src/lib/libedit/filecomplete.c:1.32 src/lib/libedit/filecomplete.c:1.32.2.1
--- src/lib/libedit/filecomplete.c:1.32 Thu Jun 5 22:07:42 2014
+++ src/lib/libedit/filecomplete.c Wed May 13 13:33:55 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: filecomplete.c,v 1.32 2014/06/05 22:07:42 christos Exp $ */
+/* $NetBSD: filecomplete.c,v 1.32.2.1 2015/05/13 13:33:55 martin Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: filecomplete.c,v 1.32 2014/06/05 22:07:42 christos Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.32.2.1 2015/05/13 13:33:55 martin Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -64,7 +64,7 @@ static const Char break_chars[] = { ' ',
* if ``user'' isn't valid user name or ``txt'' doesn't start
* w/ '~', returns pointer to strdup()ed copy of ``txt''
*
- * it's callers's responsibility to free() returned string
+ * it's the caller's responsibility to free() the returned string
*/
char *
fn_tilde_expand(const char *txt)
@@ -137,7 +137,7 @@ fn_tilde_expand(const char *txt)
* such file can be found
* value of ``state'' is ignored
*
- * it's caller's responsibility to free returned string
+ * it's the caller's responsibility to free the returned string
*/
char *
fn_filename_completion_function(const char *text, int state)
Index: src/lib/libedit/readline.c
diff -u src/lib/libedit/readline.c:1.111 src/lib/libedit/readline.c:1.111.2.1
--- src/lib/libedit/readline.c:1.111 Sun Jul 6 18:09:04 2014
+++ src/lib/libedit/readline.c Wed May 13 13:33:55 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.c,v 1.111 2014/07/06 18:09:04 christos Exp $ */
+/* $NetBSD: readline.c,v 1.111.2.1 2015/05/13 13:33:55 martin Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.111 2014/07/06 18:09:04 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.111.2.1 2015/05/13 13:33:55 martin Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -338,7 +338,7 @@ rl_initialize(void)
el_set(e, EL_SIGNAL, rl_catch_signals);
/* set default mode to "emacs"-style and read setting afterwards */
- /* so this can be overriden */
+ /* so this can be overridden */
el_set(e, EL_EDITOR, "emacs");
if (rl_terminal_name != NULL)
el_set(e, EL_TERMINAL, rl_terminal_name);
@@ -362,6 +362,37 @@ rl_initialize(void)
_el_rl_tstp);
el_set(e, EL_BIND, "^Z", "rl_tstp", NULL);
+ /*
+ * Set some readline compatible key-bindings.
+ */
+ el_set(e, EL_BIND, "^R", "em-inc-search-prev", NULL);
+
+ /*
+ * Allow the use of Home/End keys.
+ */
+ el_set(e, EL_BIND, "\\e[1~", "ed-move-to-beg", NULL);
+ el_set(e, EL_BIND, "\\e[4~", "ed-move-to-end", NULL);
+ el_set(e, EL_BIND, "\\e[7~", "ed-move-to-beg", NULL);
+ el_set(e, EL_BIND, "\\e[8~", "ed-move-to-end", NULL);
+ el_set(e, EL_BIND, "\\e[H", "ed-move-to-beg", NULL);
+ el_set(e, EL_BIND, "\\e[F", "ed-move-to-end", NULL);
+
+ /*
+ * Allow the use of the Delete/Insert keys.
+ */
+ el_set(e, EL_BIND, "\\e[3~", "ed-delete-next-char", NULL);
+ el_set(e, EL_BIND, "\\e[2~", "ed-quoted-insert", NULL);
+
+ /*
+ * Ctrl-left-arrow and Ctrl-right-arrow for word moving.
+ */
+ el_set(e, EL_BIND, "\\e[1;5C", "em-next-word", NULL);
+ el_set(e, EL_BIND, "\\e[1;5D", "ed-prev-word", NULL);
+ el_set(e, EL_BIND, "\\e[5C", "em-next-word", NULL);
+ el_set(e, EL_BIND, "\\e[5D", "ed-prev-word", NULL);
+ el_set(e, EL_BIND, "\\e\\e[C", "em-next-word", NULL);
+ el_set(e, EL_BIND, "\\e\\e[D", "ed-prev-word", NULL);
+
/* read settings from configuration file */
el_source(e, NULL);
@@ -634,7 +665,7 @@ get_history_event(const char *cmd, int *
* returns 0 if data was not modified, 1 if it was and 2 if the string
* should be only printed and not executed; in case of error,
* returns -1 and *result points to NULL
- * it's callers responsibility to free() string returned in *result
+ * it's the caller's responsibility to free() the string returned in *result
*/
static int
_history_expand_command(const char *command, size_t offs, size_t cmdlen,
@@ -948,7 +979,8 @@ loop:
for (; str[j]; j++) {
if (str[j] == '\\' &&
str[j + 1] == history_expansion_char) {
- (void)strcpy(&str[j], &str[j + 1]);
+ len = strlen(&str[j + 1]) + 1;
+ memmove(&str[j], &str[j + 1], len);
continue;
}
if (!loop_again) {
@@ -1694,7 +1726,7 @@ filename_completion_function(const char
* which starts with supplied text
* text contains a partial username preceded by random character
* (usually '~'); state resets search from start (??? should we do that anyway)
- * it's callers responsibility to free returned value
+ * it's the caller's responsibility to free the returned value
*/
char *
username_completion_function(const char *text, int state)