aboutsummaryrefslogtreecommitdiff
path: root/contrib/libedit
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libedit')
-rw-r--r--contrib/libedit/chared.c74
-rw-r--r--contrib/libedit/chartype.c6
-rw-r--r--contrib/libedit/chartype.h3
-rw-r--r--contrib/libedit/config.h255
-rw-r--r--contrib/libedit/editrc.591
-rw-r--r--contrib/libedit/el.c6
-rw-r--r--contrib/libedit/eln.c10
-rw-r--r--contrib/libedit/filecomplete.c45
-rw-r--r--contrib/libedit/filecomplete.h4
-rw-r--r--contrib/libedit/histedit.h6
-rw-r--r--contrib/libedit/map.c13
-rw-r--r--contrib/libedit/read.c25
-rw-r--r--contrib/libedit/read.h4
-rw-r--r--contrib/libedit/readline.c124
-rw-r--r--contrib/libedit/readline/readline.h26
-rw-r--r--contrib/libedit/sig.c8
-rw-r--r--contrib/libedit/sys.h40
-rw-r--r--contrib/libedit/terminal.c38
18 files changed, 344 insertions, 434 deletions
diff --git a/contrib/libedit/chared.c b/contrib/libedit/chared.c
index a96322aa6883..03d31ddeec85 100644
--- a/contrib/libedit/chared.c
+++ b/contrib/libedit/chared.c
@@ -1,4 +1,4 @@
-/* $NetBSD: chared.c,v 1.59 2019/07/23 10:18:52 christos Exp $ */
+/* $NetBSD: chared.c,v 1.63 2022/10/30 19:11:31 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: chared.c,v 1.59 2019/07/23 10:18:52 christos Exp $");
+__RCSID("$NetBSD: chared.c,v 1.63 2022/10/30 19:11:31 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -414,7 +414,7 @@ ch_init(EditLine *el)
el->el_chared.c_redo.buf = el_calloc(EL_BUFSIZ,
sizeof(*el->el_chared.c_redo.buf));
if (el->el_chared.c_redo.buf == NULL)
- return -1;
+ goto out;
el->el_chared.c_redo.pos = el->el_chared.c_redo.buf;
el->el_chared.c_redo.lim = el->el_chared.c_redo.buf + EL_BUFSIZ;
el->el_chared.c_redo.cmd = ED_UNASSIGNED;
@@ -425,7 +425,7 @@ ch_init(EditLine *el)
el->el_chared.c_kill.buf = el_calloc(EL_BUFSIZ,
sizeof(*el->el_chared.c_kill.buf));
if (el->el_chared.c_kill.buf == NULL)
- return -1;
+ goto out;
el->el_chared.c_kill.mark = el->el_line.buffer;
el->el_chared.c_kill.last = el->el_chared.c_kill.buf;
el->el_chared.c_resizefun = NULL;
@@ -442,6 +442,9 @@ ch_init(EditLine *el)
el->el_state.lastcmd = ED_UNASSIGNED;
return 0;
+out:
+ ch_end(el);
+ return -1;
}
/* ch_reset():
@@ -624,6 +627,69 @@ el_deletestr(EditLine *el, int n)
el->el_line.cursor = el->el_line.buffer;
}
+/* el_deletestr1():
+ * Delete characters between start and end
+ */
+int
+el_deletestr1(EditLine *el, int start, int end)
+{
+ size_t line_length, len;
+ wchar_t *p1, *p2;
+
+ if (end <= start)
+ return 0;
+
+ line_length = (size_t)(el->el_line.lastchar - el->el_line.buffer);
+
+ if (start >= (int)line_length || end >= (int)line_length)
+ return 0;
+
+ len = (size_t)(end - start);
+ if (len > line_length - (size_t)end)
+ len = line_length - (size_t)end;
+
+ p1 = el->el_line.buffer + start;
+ p2 = el->el_line.buffer + end;
+ for (size_t i = 0; i < len; i++) {
+ *p1++ = *p2++;
+ el->el_line.lastchar--;
+ }
+
+ if (el->el_line.cursor < el->el_line.buffer)
+ el->el_line.cursor = el->el_line.buffer;
+
+ return end - start;
+}
+
+/* el_wreplacestr():
+ * Replace the contents of the line with the provided string
+ */
+int
+el_wreplacestr(EditLine *el, const wchar_t *s)
+{
+ size_t len;
+ wchar_t * p;
+
+ if (s == NULL || (len = wcslen(s)) == 0)
+ return -1;
+
+ if (el->el_line.buffer + len >= el->el_line.limit) {
+ if (!ch_enlargebufs(el, len))
+ return -1;
+ }
+
+ p = el->el_line.buffer;
+ for (size_t i = 0; i < len; i++)
+ *p++ = *s++;
+
+ el->el_line.buffer[len] = '\0';
+ el->el_line.lastchar = el->el_line.buffer + len;
+ if (el->el_line.cursor > el->el_line.lastchar)
+ el->el_line.cursor = el->el_line.lastchar;
+
+ return 0;
+}
+
/* el_cursor():
* Move the cursor to the left or the right of the current position
*/
diff --git a/contrib/libedit/chartype.c b/contrib/libedit/chartype.c
index 3df4af69b51a..9c74cfeb677a 100644
--- a/contrib/libedit/chartype.c
+++ b/contrib/libedit/chartype.c
@@ -1,4 +1,4 @@
-/* $NetBSD: chartype.c,v 1.35 2019/07/23 10:18:52 christos Exp $ */
+/* $NetBSD: chartype.c,v 1.36 2022/10/30 19:11:31 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: chartype.c,v 1.35 2019/07/23 10:18:52 christos Exp $");
+__RCSID("$NetBSD: chartype.c,v 1.36 2022/10/30 19:11:31 christos Exp $");
#endif /* not lint && not SCCSID */
#include <ctype.h>
@@ -158,6 +158,8 @@ ct_decode_argv(int argc, const char *argv[], ct_buffer_t *conv)
return NULL;
wargv = el_calloc((size_t)(argc + 1), sizeof(*wargv));
+ if (wargv == NULL)
+ return NULL;
for (i = 0, p = conv->wbuff; i < argc; ++i) {
if (!argv[i]) { /* don't pass null pointers to mbstowcs */
diff --git a/contrib/libedit/chartype.h b/contrib/libedit/chartype.h
index bfa3d54ec36c..bcdb293a12f4 100644
--- a/contrib/libedit/chartype.h
+++ b/contrib/libedit/chartype.h
@@ -1,4 +1,4 @@
-/* $NetBSD: chartype.h,v 1.36 2019/09/15 21:09:11 christos Exp $ */
+/* $NetBSD: chartype.h,v 1.37 2022/04/11 19:37:20 tnn Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -35,6 +35,7 @@
* been around since 2001... */
#if !defined(__NetBSD__) && \
!defined(__sun) && \
+ !defined(__osf__) && \
!(defined(__APPLE__) && defined(__MACH__)) && \
!defined(__OpenBSD__) && \
!defined(__FreeBSD__) && \
diff --git a/contrib/libedit/config.h b/contrib/libedit/config.h
index 3eb35d179cbe..b6fe27461b0e 100644
--- a/contrib/libedit/config.h
+++ b/contrib/libedit/config.h
@@ -1,31 +1,6 @@
-/* config.h. Generated from config.h.in by configure. */
-/* config.h.in. Generated from configure.ac by autoheader. */
-
-/* Define to 1 if the `closedir' function returns void instead of `int'. */
-/* #undef CLOSEDIR_VOID */
-
/* Define to 1 if you have the <curses.h> header file. */
#define HAVE_CURSES_H 1
-/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
- */
-#define HAVE_DIRENT_H 1
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the `endpwent' function. */
-#define HAVE_ENDPWENT 1
-
-/* Define to 1 if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define to 1 if you have the `getline' function. */
-#define HAVE_GETLINE 1
-
-/* Define to 1 if you have the `fork' function. */
-#define HAVE_FORK 1
-
/* Define to 1 if you have getpwnam_r and getpwuid_r that are draft POSIX.1
versions. */
/* #undef HAVE_GETPW_R_DRAFT */
@@ -34,253 +9,23 @@
compatible. */
#define HAVE_GETPW_R_POSIX 1
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the `isascii' function. */
-#define HAVE_ISASCII 1
-
/* Define to 1 if you have the `issetugid' function. */
#define HAVE_ISSETUGID 1
-/* Define to 1 if you have the `curses' library (-lcurses). */
-/* #undef HAVE_LIBCURSES */
-
-/* Define to 1 if you have the `ncurses' library (-lncurses). */
-/* #undef HAVE_LIBNCURSES */
-
-/* Define to 1 if you have the `termcap' library (-ltermcap). */
-/* #undef HAVE_LIBTERMCAP */
-
-/* Define to 1 if you have the `terminfo' library (-lterminfo). */
-#define HAVE_LIBTERMINFO 1
-
-/* Define to 1 if you have the `termlib' library (-ltermlib). */
-/* #undef HAVE_LIBTERMLIB */
-
-/* Define to 1 if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
-
-/* Define to 1 if you have the <malloc.h> header file. */
-#define HAVE_MALLOC_H 1
-
-/* Define to 1 if you have the `memchr' function. */
-#define HAVE_MEMCHR 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the `memset' function. */
-#define HAVE_MEMSET 1
-
/* Define to 1 if you have the <ncurses.h> header file. */
/* #undef HAVE_NCURSES_H */
-/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
-/* #undef HAVE_NDIR_H */
-
-/* Define to 1 if you have the `regcomp' function. */
-#define HAVE_REGCOMP 1
-
-/* Define to 1 if you have the `re_comp' function. */
-/* #undef HAVE_RE_COMP */
-
-/* Define to 1 if `stat' has the bug that it succeeds when given the
- zero-length file name argument. */
-/* #undef HAVE_STAT_EMPTY_STRING_BUG */
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the `strcasecmp' function. */
-#define HAVE_STRCASECMP 1
-
-/* Define to 1 if you have the `strchr' function. */
-#define HAVE_STRCHR 1
-
-/* Define to 1 if you have the `strcspn' function. */
-#define HAVE_STRCSPN 1
-
-/* Define to 1 if you have the `strdup' function. */
-#define HAVE_STRDUP 1
-
-/* Define to 1 if you have the `strerror' function. */
-#define HAVE_STRERROR 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the `strlcat' function. */
-#define HAVE_STRLCAT 1
-
-/* Define to 1 if you have the `strlcpy' function. */
-#define HAVE_STRLCPY 1
-
-/* Define to 1 if you have the `strrchr' function. */
-#define HAVE_STRRCHR 1
-
-/* Define to 1 if you have the `strstr' function. */
-#define HAVE_STRSTR 1
-
-/* Define to 1 if you have the `strtol' function. */
-#define HAVE_STRTOL 1
-
/* Define to 1 if struct dirent has member d_namlen */
#define HAVE_STRUCT_DIRENT_D_NAMLEN 1
-/* Define to 1 if you have the `strunvis' function. */
-#define HAVE_STRUNVIS 1
-
-/* Define to 1 if you have the `strvis' function. */
-#define HAVE_STRVIS 1
-
/* Define to 1 if you have the <sys/cdefs.h> header file. */
#define HAVE_SYS_CDEFS_H 1
-/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
- */
-/* #undef HAVE_SYS_DIR_H */
-
-/* Define to 1 if you have the <sys/ioctl.h> header file. */
-#define HAVE_SYS_IOCTL_H 1
-
-/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
- */
-/* #undef HAVE_SYS_NDIR_H */
-
-/* Define to 1 if you have the <sys/param.h> header file. */
-#define HAVE_SYS_PARAM_H 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
-#define HAVE_SYS_WAIT_H 1
-
/* Define to 1 if you have the <termcap.h> header file. */
#define HAVE_TERMCAP_H 1
/* Define to 1 if you have the <term.h> header file. */
#define HAVE_TERM_H 1
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to 1 if the system has the type `u_int32_t'. */
-#define HAVE_U_INT32_T 1
-
-/* Define to 1 if you have the `vfork' function. */
-#define HAVE_VFORK 1
-
-/* Define to 1 if you have the <vfork.h> header file. */
-/* #undef HAVE_VFORK_H */
-
-/* Define to 1 if you have the `vis' function. */
-#define HAVE_VIS 1
-
-/* Define to 1 if `fork' works. */
-#define HAVE_WORKING_FORK 1
-
-/* Define to 1 if `vfork' works. */
-#define HAVE_WORKING_VFORK 1
-
-/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
- slash. */
-#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
-#define LT_OBJDIR ".libs/"
-
-/* Name of package */
-#define PACKAGE "libedit-20110729"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT ""
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "libedit"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libedit 3.0"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libedit-20110729"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "3.0"
-
-/* Define as the return type of signal handlers (`int' or `void'). */
-#define RETSIGTYPE void
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Enable extensions on AIX 3, Interix. */
-#ifndef _ALL_SOURCE
-# define _ALL_SOURCE 1
-#endif
-/* Enable GNU extensions on systems that have them. */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
-/* Enable threading extensions on Solaris. */
-#ifndef _POSIX_PTHREAD_SEMANTICS
-# define _POSIX_PTHREAD_SEMANTICS 1
-#endif
-/* Enable extensions on HP NonStop. */
-#ifndef _TANDEM_SOURCE
-# define _TANDEM_SOURCE 1
-#endif
-/* Enable general extensions on Solaris. */
-#ifndef __EXTENSIONS__
-# define __EXTENSIONS__ 1
-#endif
-
-
-/* Version number of package */
-#define VERSION "3.0"
-
-/* Define to 1 if the system provides the SIZE_MAX constant */
-#define HAVE_SIZE_MAX 1
-
-/* Define to 1 if on MINIX. */
-/* #undef _MINIX */
-
-/* Define to 2 if the system does not provide POSIX.1 features except with
- this defined. */
-/* #undef _POSIX_1_SOURCE */
-
-/* Define to 1 if you need to in order for `stat' and other things to work. */
-/* #undef _POSIX_SOURCE */
-
-/* Define to empty if `const' does not conform to ANSI C. */
-/* #undef const */
-
-/* Define to `int' if <sys/types.h> does not define. */
-/* #undef pid_t */
-
-/* Define to `unsigned int' if <sys/types.h> does not define. */
-/* #undef size_t */
-
-/* Define as `fork' if `vfork' does not work. */
-/* #undef vfork */
-
-
#include "sys.h"
-/* #undef SCCSID */
-/* #undef LIBC_SCCS */
-/* #undef lint */
diff --git a/contrib/libedit/editrc.5 b/contrib/libedit/editrc.5
index fa41dbb7db79..24966e71a275 100644
--- a/contrib/libedit/editrc.5
+++ b/contrib/libedit/editrc.5
@@ -1,4 +1,4 @@
-.\" $NetBSD: editrc.5,v 1.33 2017/06/27 01:22:58 kre Exp $
+.\" $NetBSD: editrc.5,v 1.34 2022/12/06 00:59:20 uwe Exp $
.\"
.\" Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -43,7 +43,7 @@ library.
.Pp
The format of each line is:
.Pp
-.Dl [prog:]command [arg ...]
+.D1 Oo Ar prog Ns Ic \&: Oc Ns Ar command Oo Ar arg ... Oc
.Pp
.Ar command
is one of the
@@ -59,7 +59,7 @@ is the program name string that a program defines when it calls
to set up
.Xr editline 3 ,
which is usually
-.Va argv[0] .
+.Va argv Ns Li [0] .
.Ar command
will be executed for any program which matches
.Ar prog .
@@ -107,15 +107,17 @@ 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.
+Bind all keys to the standard
+.Tn GNU
+Emacs-like bindings.
.It Fl k
.Ar key
is interpreted as a symbolic arrow key name, which may be one of
-.Sq up ,
-.Sq down ,
-.Sq left
+.Ic up ,
+.Ic down ,
+.Ic left
or
-.Sq right .
+.Ic right .
.It Fl l
List all editor commands and a short description of each.
.It Fl r
@@ -146,16 +148,14 @@ about macros and the input queue.
and
.Ar command
can contain control characters of the form
-.Sm off
-.Sq No ^ Ar character
-.Sm on
+.Sq Ic ^ Ns Ar character
.Po
e.g.\&
-.Sq ^A
+.Ql ^A
.Pc ,
and the following backslashed escape sequences:
.Pp
-.Bl -tag -compact -offset indent -width 4n
+.Bl -tag -compact -offset indent -width Ic
.It Ic \ea
Bell
.It Ic \eb
@@ -173,31 +173,33 @@ Horizontal tab
.It Ic \ev
Vertical tab
.Sm off
-.It Sy \e Ar nnn
+.It Ic \e Ar nnn
.Sm on
-The ASCII character corresponding to the octal number
+The
+.Tn ASCII
+character corresponding to the octal number
.Ar nnn .
.El
.Pp
-.Sq \e
+.Ql \e
nullifies the special meaning of the following character,
if it has any, notably
-.Sq \e
+.Ql \e
and
-.Sq ^ .
+.Ql ^ .
.It Ic echotc Oo Fl sv Oc Ar arg Ar ...
Exercise terminal capabilities given in
-.Ar arg ... .
+.Ar arg .
If
.Ar arg
is
-.Sq baud ,
-.Sq cols ,
-.Sq lines ,
-.Sq rows ,
-.Sq meta ,
+.Ql baud ,
+.Ql cols ,
+.Ql lines ,
+.Ql rows ,
+.Ql meta ,
or
-.Sq tabs ,
+.Ql tabs ,
the value of that capability is printed, with
.Dq yes
or
@@ -209,27 +211,27 @@ returns an empty string for non-existent capabilities, rather than
causing an error.
.Fl v
causes messages to be verbose.
-.It Ic edit Op Li on | Li off
+.It Ic edit Op Li on No | Li off
Enable or disable the
.Nm editline
functionality in a program.
-.It Ic history Ar list | Ar size Dv n | Ar unique Dv n
+.It Ic history Li list No | Li size Ar n No | Li unique Ar n
The
-.Ar list
+.Ql list
command lists all entries in the history.
The
-.Ar size
+.Ql size
command sets the history size to
-.Dv n
+.Ar n
entries.
The
-.Ar unique
+.Ql unique
command controls if history should keep duplicate entries.
If
-.Dv n
+.Ar n
is non zero, only keep unique history entries.
If
-.Dv n
+.Ar n
is zero, then keep all entries (the default).
.It Ic settc Ar cap Ar val
Set the terminal capability
@@ -239,8 +241,8 @@ to
as defined in
.Xr termcap 5 .
No sanity checking is done.
-.It Ic setty Oo Fl a Oc Oo Fl d Oc Oo Fl q Oc Oo Fl x Oc Oo Ar +mode Oc \
-Oo Ar -mode Oc Oo Ar mode Oc Oo Ar char=c Oc
+.It Ic setty Oo Fl a Oc Oo Fl d Oc Oo Fl q Oc Oo Fl x Oc Oo Ic \&+ Ns Ar mode Oc \
+Oo Fl Ar mode Oc Oo Ar mode Oc Oo Ar char\| Ns Ic = Ns Ar c Oc
Control which tty modes that
.Nm
won't allow the user to change.
@@ -262,17 +264,17 @@ Without other arguments,
.Ic setty
lists the modes in the chosen set which are fixed on
.Po
-.Sq +mode
+.Ic + Ns Ar mode
.Pc
or off
.Po
-.Sq -mode
+.Fl Ns Ar mode
.Pc .
.Fl a
lists all tty modes in the chosen set regardless of the setting.
With
-.Ar +mode ,
-.Ar -mode
+.Ic + Ns Ar mode ,
+.Fl Ns Ar mode
or
.Ar mode ,
fixes
@@ -283,7 +285,7 @@ in the chosen set.
.Pp
.Ic Setty
can also be used to set tty characters to particular values using
-.Ar char=value .
+.Ar char\| Ns Ic = Ns Ar value .
If
.Ar value
is empty
@@ -294,19 +296,18 @@ List the values of all the terminal capabilities (see
.Xr termcap 5 ) .
.El
.Sh ENVIRONMENT
-.Bl -tag -width "~/.editrcXXX"
+.Bl -tag -width Ev
.It Ev EDITRC
Names the default configuration file for the
.Xr editline 3
library.
.El
.Sh FILES
-.Bl -tag -width "~/.editrcXXX"
+.Bl -tag -width Pa
.It Pa ~/.editrc
-Last resort, if no other file is specified,
-user configuration file for the
+Last resort user configuration file for the
.Xr editline 3
-library.
+library if no other file is specified.
.El
.Sh SEE ALSO
.Xr editline 3 ,
diff --git a/contrib/libedit/el.c b/contrib/libedit/el.c
index 47b76d7a5302..2c06e32de9ff 100644
--- a/contrib/libedit/el.c
+++ b/contrib/libedit/el.c
@@ -1,4 +1,4 @@
-/* $NetBSD: el.c,v 1.100 2021/08/15 10:08:41 christos Exp $ */
+/* $NetBSD: el.c,v 1.101 2022/10/30 19:11:31 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.100 2021/08/15 10:08:41 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.101 2022/10/30 19:11:31 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -142,7 +142,7 @@ el_end(EditLine *el)
if (!(el->el_flags & NO_TTY))
tty_end(el, TCSAFLUSH);
ch_end(el);
- read_end(el->el_read);
+ read_end(el);
search_end(el);
hist_end(el);
prompt_end(el);
diff --git a/contrib/libedit/eln.c b/contrib/libedit/eln.c
index f432a2187c0d..563ec2a672a9 100644
--- a/contrib/libedit/eln.c
+++ b/contrib/libedit/eln.c
@@ -1,4 +1,4 @@
-/* $NetBSD: eln.c,v 1.36 2021/08/15 10:08:41 christos Exp $ */
+/* $NetBSD: eln.c,v 1.37 2022/01/11 18:30:15 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: eln.c,v 1.36 2021/08/15 10:08:41 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.37 2022/01/11 18:30:15 christos Exp $");
#endif /* not lint && not SCCSID */
#include <errno.h>
@@ -386,3 +386,9 @@ el_insertstr(EditLine *el, const char *str)
{
return el_winsertstr(el, ct_decode_string(str, &el->el_lgcyconv));
}
+
+int
+el_replacestr(EditLine *el, const char *str)
+{
+ return el_wreplacestr(el, ct_decode_string(str, &el->el_lgcyconv));
+}
diff --git a/contrib/libedit/filecomplete.c b/contrib/libedit/filecomplete.c
index 6dc7cff1d055..ee017fb406d5 100644
--- a/contrib/libedit/filecomplete.c
+++ b/contrib/libedit/filecomplete.c
@@ -1,4 +1,4 @@
-/* $NetBSD: filecomplete.c,v 1.68 2021/05/05 14:49:59 christos Exp $ */
+/* $NetBSD: filecomplete.c,v 1.72 2023/02/03 22:01:42 christos 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.68 2021/05/05 14:49:59 christos Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.72 2023/02/03 22:01:42 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -69,20 +69,21 @@ fn_tilde_expand(const char *txt)
char pwbuf[1024];
#endif
struct passwd *pass;
+ const char *pos;
char *temp;
size_t len = 0;
if (txt[0] != '~')
return strdup(txt);
- temp = strchr(txt + 1, '/');
- if (temp == NULL) {
+ pos = strchr(txt + 1, '/');
+ if (pos == NULL) {
temp = strdup(txt + 1);
if (temp == NULL)
return NULL;
} else {
/* text until string after slash */
- len = (size_t)(temp - txt + 1);
+ len = (size_t)(pos - txt + 1);
temp = el_calloc(len, sizeof(*temp));
if (temp == NULL)
return NULL;
@@ -126,7 +127,7 @@ fn_tilde_expand(const char *txt)
}
static int
-needs_escaping(char c)
+needs_escaping(wchar_t c)
{
switch (c) {
case '\'':
@@ -212,9 +213,10 @@ escape_filename(EditLine * el, const char *filename, int single_match,
while (temp != el->el_line.cursor) {
/*
* If we see a single quote but have not seen a double quote
- * so far set/unset s_quote
+ * so far set/unset s_quote, unless it is already quoted
*/
- if (temp[0] == '\'' && !d_quoted)
+ if (temp[0] == '\'' && !d_quoted &&
+ (temp == el->el_line.buffer || temp[-1] != '\\'))
s_quoted = !s_quoted;
/*
* vice versa to the above condition
@@ -327,14 +329,15 @@ fn_filename_completion_function(const char *text, int state)
static size_t filename_len = 0;
struct dirent *entry;
char *temp;
+ const char *pos;
size_t len;
if (state == 0 || dir == NULL) {
- temp = strrchr(text, '/');
- if (temp) {
+ pos = strrchr(text, '/');
+ if (pos) {
char *nptr;
- temp++;
- nptr = el_realloc(filename, (strlen(temp) + 1) *
+ pos++;
+ nptr = el_realloc(filename, (strlen(pos) + 1) *
sizeof(*nptr));
if (nptr == NULL) {
el_free(filename);
@@ -342,8 +345,8 @@ fn_filename_completion_function(const char *text, int state)
return NULL;
}
filename = nptr;
- (void)strcpy(filename, temp);
- len = (size_t)(temp - text); /* including last slash */
+ (void)strcpy(filename, pos);
+ len = (size_t)(pos - text); /* including last slash */
nptr = el_realloc(dirname, (len + 1) *
sizeof(*nptr));
@@ -609,13 +612,13 @@ find_word_to_complete(const wchar_t * cursor, const wchar_t * buffer,
for (;;) {
if (ctemp <= buffer)
break;
- if (wcschr(word_break, ctemp[-1])) {
- if (ctemp - buffer >= 2 && ctemp[-2] == '\\') {
- ctemp -= 2;
- continue;
- }
- break;
+ if (ctemp - buffer >= 2 && ctemp[-2] == '\\' &&
+ needs_escaping(ctemp[-1])) {
+ ctemp -= 2;
+ continue;
}
+ if (wcschr(word_break, ctemp[-1]))
+ break;
if (special_prefixes && wcschr(special_prefixes, ctemp[-1]))
break;
ctemp--;
@@ -634,6 +637,8 @@ find_word_to_complete(const wchar_t * cursor, const wchar_t * buffer,
return unescaped_word;
}
temp = el_malloc((len + 1) * sizeof(*temp));
+ if (temp == NULL)
+ return NULL;
(void) wcsncpy(temp, ctemp, len);
temp[len] = '\0';
return temp;
diff --git a/contrib/libedit/filecomplete.h b/contrib/libedit/filecomplete.h
index 60ea4894414b..796ae7ab3276 100644
--- a/contrib/libedit/filecomplete.h
+++ b/contrib/libedit/filecomplete.h
@@ -1,4 +1,4 @@
-/* $NetBSD: filecomplete.h,v 1.13 2021/03/28 13:38:10 christos Exp $ */
+/* $NetBSD: filecomplete.h,v 1.14 2021/09/26 13:45:54 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@ int fn_complete2(EditLine *,
char **(*)(const char *, int, int),
const wchar_t *, const wchar_t *, const char *(*)(const char *), size_t,
int *, int *, int *, int *, unsigned int);
-#define FN_QUOTE_MATCH 1 /* Quote the returned match */
+#define FN_QUOTE_MATCH 1U /* Quote the returned match */
void fn_display_match_list(EditLine *, char **, size_t, size_t,
const char *(*)(const char *));
diff --git a/contrib/libedit/histedit.h b/contrib/libedit/histedit.h
index 511750e0137e..79d641b9d137 100644
--- a/contrib/libedit/histedit.h
+++ b/contrib/libedit/histedit.h
@@ -1,4 +1,4 @@
-/* $NetBSD: histedit.h,v 1.58 2021/08/15 10:08:41 christos Exp $ */
+/* $NetBSD: histedit.h,v 1.62 2023/02/03 22:01:42 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -180,7 +180,8 @@ void el_resize(EditLine *);
const LineInfo *el_line(EditLine *);
int el_insertstr(EditLine *, const char *);
void el_deletestr(EditLine *, int);
-
+int el_replacestr(EditLine *, const char *);
+int el_deletestr1(EditLine *, int, int);
/*
* ==== History ====
@@ -279,6 +280,7 @@ int el_cursor(EditLine *, int);
const LineInfoW *el_wline(EditLine *);
int el_winsertstr(EditLine *, const wchar_t *);
#define el_wdeletestr el_deletestr
+int el_wreplacestr(EditLine *, const wchar_t *);
/*
* ==== History ====
diff --git a/contrib/libedit/map.c b/contrib/libedit/map.c
index 321bb3539222..57d3038ab2e9 100644
--- a/contrib/libedit/map.c
+++ b/contrib/libedit/map.c
@@ -1,4 +1,4 @@
-/* $NetBSD: map.c,v 1.54 2021/08/29 09:41:59 christos Exp $ */
+/* $NetBSD: map.c,v 1.55 2022/10/30 19:11:31 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: map.c,v 1.54 2021/08/29 09:41:59 christos Exp $");
+__RCSID("$NetBSD: map.c,v 1.55 2022/10/30 19:11:31 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -918,18 +918,18 @@ map_init(EditLine *el)
return -1;
el->el_map.key = el_calloc(N_KEYS, sizeof(*el->el_map.key));
if (el->el_map.key == NULL)
- return -1;
+ goto out;
el->el_map.emacs = el_map_emacs;
el->el_map.vic = el_map_vi_command;
el->el_map.vii = el_map_vi_insert;
el->el_map.help = el_calloc(EL_NUM_FCNS, sizeof(*el->el_map.help));
if (el->el_map.help == NULL)
- return -1;
+ goto out;
(void) memcpy(el->el_map.help, el_func_help,
sizeof(*el->el_map.help) * EL_NUM_FCNS);
el->el_map.func = el_calloc(EL_NUM_FCNS, sizeof(*el->el_map.func));
if (el->el_map.func == NULL)
- return -1;
+ goto out;
memcpy(el->el_map.func, el_func, sizeof(*el->el_map.func)
* EL_NUM_FCNS);
el->el_map.nfunc = EL_NUM_FCNS;
@@ -940,6 +940,9 @@ map_init(EditLine *el)
map_init_emacs(el);
#endif /* VIDEFAULT */
return 0;
+out:
+ map_end(el);
+ return -1;
}
diff --git a/contrib/libedit/read.c b/contrib/libedit/read.c
index a49a304de971..8026ca4a209b 100644
--- a/contrib/libedit/read.c
+++ b/contrib/libedit/read.c
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.107 2021/08/15 10:08:41 christos Exp $ */
+/* $NetBSD: read.c,v 1.108 2022/10/30 19:11:31 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: read.c,v 1.107 2021/08/15 10:08:41 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.108 2022/10/30 19:11:31 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -89,28 +89,31 @@ read_init(EditLine *el)
return -1;
ma = &el->el_read->macros;
- if ((ma->macro = el_calloc(EL_MAXMACRO, sizeof(*ma->macro))) == NULL) {
- free(el->el_read);
- return -1;
- }
+ if ((ma->macro = el_calloc(EL_MAXMACRO, sizeof(*ma->macro))) == NULL)
+ goto out;
ma->level = -1;
ma->offset = 0;
/* builtin read_char */
el->el_read->read_char = read_char;
return 0;
+out:
+ read_end(el);
+ return -1;
}
/* el_read_end():
* Free the data structures used by the read stuff.
*/
libedit_private void
-read_end(struct el_read_t *el_read)
+read_end(EditLine *el)
{
- read_clearmacros(&el_read->macros);
- el_free(el_read->macros.macro);
- el_read->macros.macro = NULL;
- el_free(el_read);
+
+ read_clearmacros(&el->el_read->macros);
+ el_free(el->el_read->macros.macro);
+ el->el_read->macros.macro = NULL;
+ el_free(el->el_read);
+ el->el_read = NULL;
}
/* el_read_setfn():
diff --git a/contrib/libedit/read.h b/contrib/libedit/read.h
index 1acf5d67637e..8b710708f6f1 100644
--- a/contrib/libedit/read.h
+++ b/contrib/libedit/read.h
@@ -1,4 +1,4 @@
-/* $NetBSD: read.h,v 1.12 2016/05/22 19:44:26 christos Exp $ */
+/* $NetBSD: read.h,v 1.13 2022/10/30 19:11:31 christos Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
#define _h_el_read
libedit_private int read_init(EditLine *);
-libedit_private void read_end(struct el_read_t *);
+libedit_private void read_end(EditLine *);
libedit_private void read_prepare(EditLine *);
libedit_private void read_finish(EditLine *);
libedit_private int el_read_setfn(struct el_read_t *, el_rfunc_t);
diff --git a/contrib/libedit/readline.c b/contrib/libedit/readline.c
index c12eb7481bf4..ef3abd4b6daa 100644
--- a/contrib/libedit/readline.c
+++ b/contrib/libedit/readline.c
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.c,v 1.168 2021/09/10 18:51:36 rillig Exp $ */
+/* $NetBSD: readline.c,v 1.178 2022/12/02 19:23:15 christos 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.168 2021/09/10 18:51:36 rillig Exp $");
+__RCSID("$NetBSD: readline.c,v 1.178 2022/12/02 19:23:15 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -43,6 +43,7 @@ __RCSID("$NetBSD: readline.c,v 1.168 2021/09/10 18:51:36 rillig Exp $");
#include <limits.h>
#include <pwd.h>
#include <setjmp.h>
+#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -112,8 +113,8 @@ const char *rl_basic_quote_characters = "\"'";
rl_compentry_func_t *rl_completion_entry_function = NULL;
char *(*rl_completion_word_break_hook)(void) = NULL;
rl_completion_func_t *rl_attempted_completion_function = NULL;
-Function *rl_pre_input_hook = NULL;
-Function *rl_startup1_hook = NULL;
+rl_hook_func_t *rl_pre_input_hook = NULL;
+rl_hook_func_t *rl_startup1_hook = NULL;
int (*rl_getc_function)(FILE *) = NULL;
char *rl_terminal_name = NULL;
int rl_already_prompted = 0;
@@ -122,12 +123,12 @@ int rl_ignore_completion_duplicates = 0;
int readline_echoing_p = 1;
int _rl_print_completions_horizontally = 0;
VFunction *rl_redisplay_function = NULL;
-Function *rl_startup_hook = NULL;
+rl_hook_func_t *rl_startup_hook = NULL;
VFunction *rl_completion_display_matches_hook = NULL;
VFunction *rl_prep_term_function = (VFunction *)rl_prep_terminal;
VFunction *rl_deprep_term_function = (VFunction *)rl_deprep_terminal;
KEYMAP_ENTRY_ARRAY emacs_meta_keymap;
-unsigned long rl_readline_state;
+unsigned long rl_readline_state = RL_STATE_NONE;
int _rl_complete_mark_directories;
rl_icppfunc_t *rl_directory_completion_hook;
int rl_completion_suppress_append;
@@ -136,11 +137,13 @@ int _rl_completion_prefix_display_length;
int _rl_echoing_p;
int history_max_entries;
char *rl_display_prompt;
+int rl_erase_empty_line;
/*
* The current prompt string.
*/
char *rl_prompt = NULL;
+char *rl_prompt_saved = NULL;
/*
* This is set to character indicating type of completion being done by
* rl_complete_internal(); this is available for application completion
@@ -237,7 +240,7 @@ _default_history_file(void)
return NULL;
len = strlen(p->pw_dir) + sizeof("/.history");
- if ((path = malloc(len)) == NULL)
+ if ((path = el_malloc(len)) == NULL)
return NULL;
(void)snprintf(path, len, "%s/.history", p->pw_dir);
@@ -278,6 +281,21 @@ rl_set_prompt(const char *prompt)
return 0;
}
+void
+rl_save_prompt(void)
+{
+ rl_prompt_saved = strdup(rl_prompt);
+}
+
+void
+rl_restore_prompt(void)
+{
+ if (!rl_prompt_saved)
+ return;
+ rl_prompt = rl_prompt_saved;
+ rl_prompt_saved = NULL;
+}
+
/*
* initialize rl compat stuff
*/
@@ -293,6 +311,8 @@ rl_initialize(void)
if (h != NULL)
history_end(h);
+ RL_UNSETSTATE(RL_STATE_DONE);
+
if (!rl_instream)
rl_instream = stdin;
if (!rl_outstream)
@@ -425,7 +445,7 @@ readline(const char *p)
if (e == NULL || h == NULL)
rl_initialize();
if (rl_startup_hook) {
- (*rl_startup_hook)(NULL, 0);
+ (*rl_startup_hook)();
}
tty_init(e);
@@ -440,7 +460,7 @@ readline(const char *p)
goto out;
if (rl_pre_input_hook)
- (*rl_pre_input_hook)(NULL, 0);
+ (*rl_pre_input_hook)();
if (rl_event_hook && !(e->el_flags & NO_TTY)) {
el_set(e, EL_GETCFN, _rl_event_read_char);
@@ -458,10 +478,14 @@ readline(const char *p)
ret = el_gets(e, &count);
if (ret && count > 0) {
+ int lastidx;
+
buf = strdup(ret);
if (buf == NULL)
goto out;
- buf[strcspn(buf, "\n")] = '\0';
+ lastidx = count - 1;
+ if (buf[lastidx] == '\n')
+ buf[lastidx] = '\0';
} else
buf = NULL;
@@ -1582,7 +1606,7 @@ replace_history_entry(int num, const char *line, histdata_t data)
if (history(h, &ev, H_NEXT_EVDATA, num, &he->data))
goto out;
- he->line = strdup(ev.str);
+ he->line = ev.str;
if (he->line == NULL)
goto out;
@@ -2127,10 +2151,12 @@ rl_callback_read_char(void)
if (done == 2) {
if ((wbuf = strdup(buf)) != NULL)
wbuf[count] = '\0';
+ RL_SETSTATE(RL_STATE_DONE);
} else
wbuf = NULL;
(*(void (*)(const char *))rl_linefunc)(wbuf);
}
+ _rl_update_pos();
}
void
@@ -2158,6 +2184,7 @@ rl_redisplay(void)
a[0] = (char)e->el_tty.t_c[TS_IO][C_REPRINT];
a[1] = '\0';
el_push(e, a);
+ rl_forced_update_display();
}
int
@@ -2281,6 +2308,58 @@ _rl_update_pos(void)
rl_line_buffer[rl_end] = '\0';
}
+char *
+rl_copy_text(int from, int to)
+{
+ const LineInfo *li;
+ size_t len;
+ char * out;
+
+ if (h == NULL || e == NULL)
+ rl_initialize();
+
+ li = el_line(e);
+
+ if (from > to)
+ return NULL;
+
+ if (li->buffer + from > li->lastchar)
+ from = (int)(li->lastchar - li->buffer);
+
+ if (li->buffer + to > li->lastchar)
+ to = (int)(li->lastchar - li->buffer);
+
+ len = (size_t)(to - from);
+ out = el_malloc((size_t)len + 1);
+ if (out == NULL)
+ return NULL;
+ (void)strlcpy(out, li->buffer + from , len);
+
+ return out;
+}
+
+void
+rl_replace_line(const char * text, int clear_undo __attribute__((__unused__)))
+{
+ if (!text || *text == 0)
+ return;
+
+ if (h == NULL || e == NULL)
+ rl_initialize();
+
+ el_replacestr(e, text);
+}
+
+int
+rl_delete_text(int start, int end)
+{
+
+ if (h == NULL || e == NULL)
+ rl_initialize();
+
+ return el_deletestr1(e, start, end);
+}
+
void
rl_get_screen_size(int *rows, int *cols)
{
@@ -2290,6 +2369,21 @@ rl_get_screen_size(int *rows, int *cols)
el_get(e, EL_GETTC, "co", cols);
}
+#define MAX_MESSAGE 160
+void
+rl_message(const char *format, ...)
+{
+ char msg[MAX_MESSAGE];
+ va_list args;
+
+ va_start(args, format);
+ vsnprintf(msg, sizeof(msg), format, args);
+ va_end(args);
+
+ rl_set_prompt(msg);
+ rl_forced_update_display();
+}
+
void
rl_set_screen_size(int rows, int cols)
{
@@ -2437,6 +2531,14 @@ rl_bind_key_in_map(int key __attribute__((__unused__)),
return 0;
}
+int
+rl_set_key(const char *keyseq __attribute__((__unused__)),
+ rl_command_func_t *function __attribute__((__unused__)),
+ Keymap k __attribute__((__unused__)))
+{
+ return 0;
+}
+
/* unsupported, but needed by python */
void
rl_cleanup_after_signal(void)
diff --git a/contrib/libedit/readline/readline.h b/contrib/libedit/readline/readline.h
index e9f941aeb249..2bd0b7e80ab6 100644
--- a/contrib/libedit/readline/readline.h
+++ b/contrib/libedit/readline/readline.h
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.h,v 1.47 2021/08/21 12:34:59 christos Exp $ */
+/* $NetBSD: readline.h,v 1.53 2022/02/19 17:45:02 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -94,6 +94,13 @@ typedef KEYMAP_ENTRY *Keymap;
#define RL_PROMPT_START_IGNORE '\1'
#define RL_PROMPT_END_IGNORE '\2'
+#define RL_STATE_NONE 0x000000
+#define RL_STATE_DONE 0x000001
+
+#define RL_SETSTATE(x) (rl_readline_state |= ((unsigned long) x))
+#define RL_UNSETSTATE(x) (rl_readline_state &= ~((unsigned long) x))
+#define RL_ISSTATE(x) (rl_readline_state & ((unsigned long) x))
+
/* global variables used by readline enabled applications */
#ifdef __cplusplus
extern "C" {
@@ -120,8 +127,8 @@ extern int rl_completion_query_items;
extern const char *rl_special_prefixes;
extern int rl_completion_append_character;
extern int rl_inhibit_completion;
-extern Function *rl_pre_input_hook;
-extern Function *rl_startup_hook;
+extern rl_hook_func_t *rl_pre_input_hook;
+extern rl_hook_func_t *rl_startup_hook;
extern char *rl_terminal_name;
extern int rl_already_prompted;
extern char *rl_prompt;
@@ -153,6 +160,7 @@ extern int _rl_completion_prefix_display_length;
extern int _rl_echoing_p;
extern int history_max_entries;
extern char *rl_display_prompt;
+extern int rl_erase_empty_line;
/* supported functions */
char *readline(const char *);
@@ -180,7 +188,7 @@ int history_search_prefix(const char *, int);
int history_search_pos(const char *, int, int);
int read_history(const char *);
int write_history(const char *);
-int history_truncate_file (const char *, int);
+int history_truncate_file(const char *, int);
int history_expand(char *, char **);
char **history_tokenize(const char *);
const char *get_history_event(const char *, int *, int);
@@ -215,7 +223,7 @@ int rl_add_defun(const char *, rl_command_func_t *, int);
HISTORY_STATE *history_get_history_state(void);
void rl_get_screen_size(int *, int *);
void rl_set_screen_size(int, int);
-char *rl_filename_completion_function (const char *, int);
+char *rl_filename_completion_function(const char *, int);
int _rl_abort_internal(void);
int _rl_qsort_string_compare(char **, char **);
char **rl_completion_matches(const char *, rl_compentry_func_t *);
@@ -226,6 +234,13 @@ void rl_reset_after_signal(void);
void rl_echo_signal_char(int);
int rl_crlf(void);
int rl_ding(void);
+char *rl_copy_text(int, int);
+void rl_replace_line(const char *, int);
+int rl_delete_text(int, int);
+void rl_message(const char *format, ...)
+ __attribute__((__format__(__printf__, 1, 2)));
+void rl_save_prompt(void);
+void rl_restore_prompt(void);
/*
* The following are not implemented
@@ -236,6 +251,7 @@ void rl_set_keymap(Keymap);
Keymap rl_make_bare_keymap(void);
int rl_generic_bind(int, const char *, const char *, Keymap);
int rl_bind_key_in_map(int, rl_command_func_t *, Keymap);
+int rl_set_key(const char *, rl_command_func_t *, Keymap);
void rl_cleanup_after_signal(void);
void rl_free_line_state(void);
int rl_set_keyboard_input_timeout(int);
diff --git a/contrib/libedit/sig.c b/contrib/libedit/sig.c
index 83742a3d6588..7e7486980253 100644
--- a/contrib/libedit/sig.c
+++ b/contrib/libedit/sig.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sig.c,v 1.26 2016/05/09 21:46:56 christos Exp $ */
+/* $NetBSD: sig.c,v 1.27 2023/02/03 19:47:38 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)sig.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: sig.c,v 1.26 2016/05/09 21:46:56 christos Exp $");
+__RCSID("$NetBSD: sig.c,v 1.27 2023/02/03 19:47:38 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -170,6 +170,7 @@ sig_set(EditLine *el)
nsa.sa_flags = 0;
sigemptyset(&nsa.sa_mask);
+ sel = el;
(void) sigprocmask(SIG_BLOCK, &el->el_signal->sig_set, &oset);
for (i = 0; sighdl[i] != -1; i++) {
@@ -178,7 +179,6 @@ sig_set(EditLine *el)
osa.sa_handler != sig_handler)
el->el_signal->sig_action[i] = osa;
}
- sel = el;
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
}
@@ -199,7 +199,5 @@ sig_clr(EditLine *el)
(void)sigaction(sighdl[i],
&el->el_signal->sig_action[i], NULL);
- sel = NULL; /* we are going to die if the handler is
- * called */
(void)sigprocmask(SIG_SETMASK, &oset, NULL);
}
diff --git a/contrib/libedit/sys.h b/contrib/libedit/sys.h
index dc0a8cb9aa36..5395531a298f 100644
--- a/contrib/libedit/sys.h
+++ b/contrib/libedit/sys.h
@@ -1,4 +1,4 @@
-/* $NetBSD: sys.h,v 1.27 2016/05/09 21:46:56 christos Exp $ */
+/* $NetBSD: sys.h,v 1.28 2023/02/04 14:34:28 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -65,49 +65,11 @@
# define __arraycount(a) (sizeof(a) / sizeof(*(a)))
#endif
-#include <stdio.h>
-
-#ifndef HAVE_STRLCAT
-#define strlcat libedit_strlcat
-size_t strlcat(char *dst, const char *src, size_t size);
-#endif
-
-#ifndef HAVE_STRLCPY
-#define strlcpy libedit_strlcpy
-size_t strlcpy(char *dst, const char *src, size_t size);
-#endif
-
-#ifndef HAVE_GETLINE
-#define getline libedit_getline
-ssize_t getline(char **line, size_t *len, FILE *fp);
-#endif
-
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(x)
-#endif
-
#ifndef __RCSID
#define __RCSID(x)
#endif
-#ifndef HAVE_U_INT32_T
-typedef unsigned int u_int32_t;
-#endif
-
-#ifndef HAVE_SIZE_MAX
-#define SIZE_MAX ((size_t)-1)
-#endif
-
#define REGEX /* Use POSIX.2 regular expression functions */
#undef REGEXP /* Use UNIX V8 regular expression functions */
-#if defined(__sun)
-extern int tgetent(char *, const char *);
-extern int tgetflag(char *);
-extern int tgetnum(char *);
-extern int tputs(const char *, int, int (*)(int));
-extern char* tgoto(const char*, int, int);
-extern char* tgetstr(char*, char**);
-#endif
-
#endif /* _h_sys */
diff --git a/contrib/libedit/terminal.c b/contrib/libedit/terminal.c
index 3bea1fc27a89..895a2176cb32 100644
--- a/contrib/libedit/terminal.c
+++ b/contrib/libedit/terminal.c
@@ -1,4 +1,4 @@
-/* $NetBSD: terminal.c,v 1.44 2021/09/09 20:24:07 christos Exp $ */
+/* $NetBSD: terminal.c,v 1.46 2023/02/04 14:34:28 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
#else
-__RCSID("$NetBSD: terminal.c,v 1.44 2021/09/09 20:24:07 christos Exp $");
+__RCSID("$NetBSD: terminal.c,v 1.46 2023/02/04 14:34:28 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -68,6 +68,15 @@ __RCSID("$NetBSD: terminal.c,v 1.44 2021/09/09 20:24:07 christos Exp $");
#include <term.h>
#endif
+#if defined(__sun)
+extern int tgetent(char *, const char *);
+extern int tgetflag(char *);
+extern int tgetnum(char *);
+extern int tputs(const char *, int, int (*)(int));
+extern char* tgoto(const char*, int, int);
+extern char* tgetstr(char*, char**);
+#endif
+
#ifdef _REENTRANT
#include <pthread.h>
#endif
@@ -272,40 +281,29 @@ terminal_init(EditLine *el)
el->el_terminal.t_buf = el_calloc(TC_BUFSIZE,
sizeof(*el->el_terminal.t_buf));
if (el->el_terminal.t_buf == NULL)
- goto fail1;
+ return -1;
el->el_terminal.t_cap = el_calloc(TC_BUFSIZE,
sizeof(*el->el_terminal.t_cap));
if (el->el_terminal.t_cap == NULL)
- goto fail2;
+ goto out;
el->el_terminal.t_fkey = el_calloc(A_K_NKEYS,
sizeof(*el->el_terminal.t_fkey));
if (el->el_terminal.t_fkey == NULL)
- goto fail3;
+ goto out;
el->el_terminal.t_loc = 0;
el->el_terminal.t_str = el_calloc(T_str,
sizeof(*el->el_terminal.t_str));
if (el->el_terminal.t_str == NULL)
- goto fail4;
+ goto out;
el->el_terminal.t_val = el_calloc(T_val,
sizeof(*el->el_terminal.t_val));
if (el->el_terminal.t_val == NULL)
- goto fail5;
+ goto out;
(void) terminal_set(el, NULL);
terminal_init_arrow(el);
return 0;
-fail5:
- free(el->el_terminal.t_str);
- el->el_terminal.t_str = NULL;
-fail4:
- free(el->el_terminal.t_fkey);
- el->el_terminal.t_fkey = NULL;
-fail3:
- free(el->el_terminal.t_cap);
- el->el_terminal.t_cap = NULL;
-fail2:
- free(el->el_terminal.t_buf);
- el->el_terminal.t_buf = NULL;
-fail1:
+out:
+ terminal_end(el);
return -1;
}