libedit: vendor import version 2026-03-04

MFC After:	1 week
This commit is contained in:
Baptiste Daroussin
2026-03-05 08:17:09 +01:00
25 changed files with 6358 additions and 105 deletions
+6119 -4
View File
File diff suppressed because it is too large Load Diff
+27 -23
View File
@@ -1,4 +1,4 @@
/* $NetBSD: chared.c,v 1.64 2024/06/29 14:13:14 christos Exp $ */
/* $NetBSD: chared.c,v 1.66 2026/03/03 15:05:17 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.64 2024/06/29 14:13:14 christos Exp $");
__RCSID("$NetBSD: chared.c,v 1.66 2026/03/03 15:05:17 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -202,9 +202,9 @@ c_delbefore1(EditLine *el)
* Return if p is part of a word according to emacs
*/
libedit_private int
ce__isword(wint_t p)
ce__isword(EditLine *el, wint_t p)
{
return iswalnum(p) || wcschr(L"*?_-.[]~=", p) != NULL;
return iswalnum(p) || wcschr(el->el_map.wordchars, p) != NULL;
}
@@ -212,9 +212,9 @@ ce__isword(wint_t p)
* Return if p is part of a word according to vi
*/
libedit_private int
cv__isword(wint_t p)
cv__isword(EditLine *el, wint_t p)
{
if (iswalnum(p) || p == L'_')
if (iswalnum(p) || wcschr(el->el_map.wordchars, p) != NULL)
return 1;
if (iswgraph(p))
return 2;
@@ -226,7 +226,7 @@ cv__isword(wint_t p)
* Return if p is part of a big word according to vi
*/
libedit_private int
cv__isWord(wint_t p)
cv__isWord(EditLine *el __attribute__((__unused__)), wint_t p)
{
return !iswspace(p);
}
@@ -236,14 +236,15 @@ cv__isWord(wint_t p)
* Find the previous word
*/
libedit_private wchar_t *
c__prev_word(wchar_t *p, wchar_t *low, int n, int (*wtest)(wint_t))
c__prev_word(EditLine *el, wchar_t *p, wchar_t *low, int n,
int (*wtest)(EditLine *, wint_t))
{
p--;
while (n--) {
while ((p >= low) && !(*wtest)(*p))
while ((p >= low) && !(*wtest)(el, *p))
p--;
while ((p >= low) && (*wtest)(*p))
while ((p >= low) && (*wtest)(el, *p))
p--;
}
@@ -260,12 +261,13 @@ c__prev_word(wchar_t *p, wchar_t *low, int n, int (*wtest)(wint_t))
* Find the next word
*/
libedit_private wchar_t *
c__next_word(wchar_t *p, wchar_t *high, int n, int (*wtest)(wint_t))
c__next_word(EditLine *el, wchar_t *p, wchar_t *high, int n,
int (*wtest)(EditLine *, wint_t))
{
while (n--) {
while ((p < high) && !(*wtest)(*p))
while ((p < high) && !(*wtest)(el, *p))
p++;
while ((p < high) && (*wtest)(*p))
while ((p < high) && (*wtest)(el, *p))
p++;
}
if (p > high)
@@ -279,13 +281,13 @@ c__next_word(wchar_t *p, wchar_t *high, int n, int (*wtest)(wint_t))
*/
libedit_private wchar_t *
cv_next_word(EditLine *el, wchar_t *p, wchar_t *high, int n,
int (*wtest)(wint_t))
int (*wtest)(EditLine *el, wint_t))
{
int test;
while (n--) {
test = (*wtest)(*p);
while ((p < high) && (*wtest)(*p) == test)
test = (*wtest)(el, *p);
while ((p < high) && (*wtest)(el, *p) == test)
p++;
/*
* vi historically deletes with cw only the word preserving the
@@ -308,7 +310,8 @@ cv_next_word(EditLine *el, wchar_t *p, wchar_t *high, int n,
* Find the previous word vi style
*/
libedit_private wchar_t *
cv_prev_word(wchar_t *p, wchar_t *low, int n, int (*wtest)(wint_t))
cv_prev_word(EditLine *el, wchar_t *p, wchar_t *low, int n,
int (*wtest)(EditLine *el, wint_t))
{
int test;
@@ -316,8 +319,8 @@ cv_prev_word(wchar_t *p, wchar_t *low, int n, int (*wtest)(wint_t))
while (n--) {
while ((p > low) && iswspace(*p))
p--;
test = (*wtest)(*p);
while ((p >= low) && (*wtest)(*p) == test)
test = (*wtest)(el, *p);
while ((p >= low) && (*wtest)(el, *p) == test)
p--;
if (p < low)
return low;
@@ -374,7 +377,8 @@ cv_delfini(EditLine *el)
* Go to the end of this word according to vi
*/
libedit_private wchar_t *
cv__endword(wchar_t *p, wchar_t *high, int n, int (*wtest)(wint_t))
cv__endword(EditLine *el, wchar_t *p, wchar_t *high, int n,
int (*wtest)(EditLine *, wint_t))
{
int test;
@@ -384,8 +388,8 @@ cv__endword(wchar_t *p, wchar_t *high, int n, int (*wtest)(wint_t))
while ((p < high) && iswspace(*p))
p++;
test = (*wtest)(*p);
while ((p < high) && (*wtest)(*p) == test)
test = (*wtest)(el, *p);
while ((p < high) && (*wtest)(el, *p) == test)
p++;
}
p--;
@@ -557,7 +561,7 @@ ch_enlargebufs(EditLine *el, size_t addlen)
(el->el_chared.c_redo.lim - el->el_chared.c_redo.buf);
el->el_chared.c_redo.buf = newbuffer;
if (!hist_enlargebuf(el, sz, newsz))
if (!hist_enlargebuf(el, newsz))
return 0;
/* Safe to set enlarged buffer size */
+13 -9
View File
@@ -1,4 +1,4 @@
/* $NetBSD: chared.h,v 1.30 2016/05/22 19:44:26 christos Exp $ */
/* $NetBSD: chared.h,v 1.31 2025/12/14 18:07:40 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -125,18 +125,22 @@ typedef struct el_chared_t {
#define MODE_REPLACE_1 2
libedit_private int cv__isword(wint_t);
libedit_private int cv__isWord(wint_t);
libedit_private int cv__isword(EditLine *, wint_t);
libedit_private int cv__isWord(EditLine *, wint_t);
libedit_private void cv_delfini(EditLine *);
libedit_private wchar_t *cv__endword(wchar_t *, wchar_t *, int, int (*)(wint_t));
libedit_private int ce__isword(wint_t);
libedit_private wchar_t *cv__endword(EditLine *, wchar_t *, wchar_t *, int,
int (*)(EditLine *, wint_t));
libedit_private int ce__isword(EditLine *, wint_t);
libedit_private void cv_undo(EditLine *);
libedit_private void cv_yank(EditLine *, const wchar_t *, int);
libedit_private wchar_t *cv_next_word(EditLine*, wchar_t *, wchar_t *, int,
int (*)(wint_t));
libedit_private wchar_t *cv_prev_word(wchar_t *, wchar_t *, int, int (*)(wint_t));
libedit_private wchar_t *c__next_word(wchar_t *, wchar_t *, int, int (*)(wint_t));
libedit_private wchar_t *c__prev_word(wchar_t *, wchar_t *, int, int (*)(wint_t));
int (*)(EditLine *, wint_t));
libedit_private wchar_t *cv_prev_word(EditLine *, wchar_t *, wchar_t *, int,
int (*)(EditLine *, wint_t));
libedit_private wchar_t *c__next_word(EditLine *, wchar_t *, wchar_t *, int,
int (*)(EditLine *, wint_t));
libedit_private wchar_t *c__prev_word(EditLine *, wchar_t *, wchar_t *, int,
int (*)(EditLine *, wint_t));
libedit_private void c_insert(EditLine *, int);
libedit_private void c_delbefore(EditLine *, int);
libedit_private void c_delbefore1(EditLine *);
+6 -6
View File
@@ -1,4 +1,4 @@
/* $NetBSD: common.c,v 1.50 2024/06/30 16:29:42 christos Exp $ */
/* $NetBSD: common.c,v 1.52 2026/03/03 15:05:17 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: common.c,v 1.50 2024/06/30 16:29:42 christos Exp $");
__RCSID("$NetBSD: common.c,v 1.52 2026/03/03 15:05:17 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -123,7 +123,7 @@ ed_delete_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
if (el->el_line.cursor == el->el_line.buffer)
return CC_ERROR;
cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
cp = c__prev_word(el, el->el_line.cursor, el->el_line.buffer,
el->el_state.argument, ce__isword);
for (p = cp, kp = el->el_chared.c_kill.buf; p < el->el_line.cursor; p++)
@@ -320,7 +320,7 @@ ed_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
if (el->el_line.cursor == el->el_line.buffer)
return CC_ERROR;
el->el_line.cursor = c__prev_word(el->el_line.cursor,
el->el_line.cursor = c__prev_word(el, el->el_line.cursor,
el->el_line.buffer,
el->el_state.argument,
ce__isword);
@@ -569,7 +569,7 @@ ed_prev_history(EditLine *el, wint_t c __attribute__((__unused__)))
if (el->el_history.eventno == 0) { /* save the current buffer
* away */
(void) wcsncpy(el->el_history.buf, el->el_line.buffer,
EL_BUFSIZ);
el->el_history.sz);
el->el_history.last = el->el_history.buf +
(el->el_line.lastchar - el->el_line.buffer);
}
@@ -641,7 +641,7 @@ ed_search_prev_history(EditLine *el, wint_t c __attribute__((__unused__)))
}
if (el->el_history.eventno == 0) {
(void) wcsncpy(el->el_history.buf, el->el_line.buffer,
EL_BUFSIZ);
el->el_history.sz);
el->el_history.last = el->el_history.buf +
(el->el_line.lastchar - el->el_line.buffer);
}
+1
View File
@@ -143,6 +143,7 @@ rl_initialize
rl_insert
rl_insert_text
rl_instream
rl_kill_full_line
rl_kill_text
rl_library_version
rl_line_buffer
+36 -2
View File
@@ -1,4 +1,4 @@
.\" $NetBSD: editline.3,v 1.102 2024/02/04 18:47:27 andvar Exp $
.\" $NetBSD: editline.3,v 1.104 2025/12/16 02:40:48 kre 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 August 15, 2021
.Dd December 16, 2025
.Dt EDITLINE 3
.Os
.Sh NAME
@@ -568,6 +568,18 @@ or
.Dv 2
from
.Fa fp .
.It Dv EL_GETENV , Fa "char * (*funcp)(const char *)"
Cause the function
.Nm editline
uses to obtain the value of an environment variable
to be the one provided as the parameter
.Fa funcp ,
a pointer to a function taking a
.Fa "const char *"
as its parameter, and returning
.Fa "char *" .
The default is
.Xr getenv 3 .
.El
.It Fn el_get
Get
@@ -667,6 +679,28 @@ or
.Fa fd
=
.Dv 2 .
.It Dv EL_WORDCHARS , Fa "Char *wordchars"
Define the list of characters that and be part of a word, in addition
to alphanumeric characters.
This list is
.Dq *?_-.[]~=
for
.Dv emacs
mode and
.Dq _
for
.Dv vi
mode.
Resetting the editor binding to either
.Dv emacs or
.Dv vi
also resets the wordchars to their default value.
.It Dv EL_GETENV , Fa "char * (**funcp)(const char *)"
Return, via the pointer to a pointer to a function,
.Fa funcp ,
the function being used by
.Nm editline
to obtain the values of environment variables.
.El
.It Fn el_source
Initialize
+8 -2
View File
@@ -1,4 +1,4 @@
.\" $NetBSD: editline.7,v 1.6 2024/04/06 13:36:11 christos Exp $
.\" $NetBSD: editline.7,v 1.7 2026/02/01 01:52:58 uwe Exp $
.\" $OpenBSD: editline.7,v 1.1 2016/04/20 01:11:45 schwarze Exp $
.\"
.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd April 6, 2024
.Dd January 31, 2026
.Dt EDITLINE 7
.Os
.Sh NAME
@@ -637,6 +637,12 @@ cursor, move the cursor after to the character after the inserted
word, and switch to vi insert mode.
It is an error if there is no history entry or the most recent
history entry is empty.
.It Ic vi-histedit Pq vi command: v
Edit the buffer with the editor and return the edit buffer to the program.
The editor specified by the
.Ev EDITOR
environment variable will be invoked instead of the default editor
.Xr vi 1 .
.It Ic vi-insert Pq vi command: i
Enter insert mode.
.It Ic vi-insert-at-bol Pq vi command: I
+26 -4
View File
@@ -1,4 +1,4 @@
/* $NetBSD: el.c,v 1.102 2025/01/03 00:40:08 rillig Exp $ */
/* $NetBSD: el.c,v 1.104 2025/12/16 02:40:48 kre 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.102 2025/01/03 00:40:08 rillig Exp $");
__RCSID("$NetBSD: el.c,v 1.104 2025/12/16 02:40:48 kre Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -57,6 +57,8 @@ __RCSID("$NetBSD: el.c,v 1.102 2025/01/03 00:40:08 rillig Exp $");
#include "parse.h"
#include "read.h"
typedef char * (*func_t)(const char *);
/* el_init():
* Initialize editline and set default parameters.
*/
@@ -84,6 +86,8 @@ el_init_internal(const char *prog, FILE *fin, FILE *fout, FILE *ferr,
el->el_outfd = fdout;
el->el_errfd = fderr;
el->el_getenv = getenv;
el->el_prog = wcsdup(ct_decode_string(prog, &el->el_scratch));
if (el->el_prog == NULL) {
el_free(el);
@@ -382,6 +386,14 @@ el_wset(EditLine *el, int op, ...)
terminal__flush(el);
break;
case EL_WORDCHARS:
rv = map_set_wordchars(el, va_arg(ap, wchar_t *));
break;
case EL_GETENV:
el->el_getenv = va_arg(ap, func_t);
break;
default:
rv = -1;
break;
@@ -496,6 +508,16 @@ el_wget(EditLine *el, int op, ...)
}
break;
}
case EL_WORDCHARS:
rv = map_get_wordchars(el, va_arg(ap, const wchar_t **));
break;
case EL_GETENV:
*va_arg(ap, func_t *) = el->el_getenv;
rv = 0;
break;
default:
rv = -1;
break;
@@ -537,11 +559,11 @@ el_source(EditLine *el, const char *fname)
if (issetugid())
return -1;
if ((fname = getenv("EDITRC")) == NULL) {
if ((fname = (el->el_getenv)("EDITRC")) == NULL) {
static const char elpath[] = "/.editrc";
size_t plen = sizeof(elpath);
if ((ptr = getenv("HOME")) == NULL)
if ((ptr = (el->el_getenv)("HOME")) == NULL)
return -1;
plen += strlen(ptr);
if ((path = el_calloc(plen, sizeof(*path))) == NULL)
+2 -1
View File
@@ -1,4 +1,4 @@
/* $NetBSD: el.h,v 1.48 2025/01/03 00:40:08 rillig Exp $ */
/* $NetBSD: el.h,v 1.49 2025/12/16 02:40:48 kre Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -141,6 +141,7 @@ struct editline {
ct_buffer_t el_scratch; /* Scratch conversion buffer */
ct_buffer_t el_lgcyconv; /* Buffer for legacy wrappers */
LineInfo el_lgcylinfo; /* Legacy LineInfo buffer */
char * (*el_getenv)(const char *); /* getenv(3) or ... */
};
libedit_private int el_editmode(EditLine *, int, const wchar_t **);
+6 -6
View File
@@ -1,4 +1,4 @@
/* $NetBSD: eln.c,v 1.38 2024/05/17 02:59:08 christos Exp $ */
/* $NetBSD: eln.c,v 1.40 2026/03/03 23:04:02 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.38 2024/05/17 02:59:08 christos Exp $");
__RCSID("$NetBSD: eln.c,v 1.40 2026/03/03 23:04:02 christos Exp $");
#endif /* not lint && not SCCSID */
#include <errno.h>
@@ -147,6 +147,7 @@ el_set(EditLine *el, int op, ...)
break;
case EL_EDITOR: /* const wchar_t * */
case EL_WORDCHARS: /* const wchar_t * */
ret = el_wset(el, op, ct_decode_string(va_arg(ap, char *),
&el->el_lgcyconv));
break;
@@ -224,9 +225,7 @@ el_set(EditLine *el, int op, ...)
ret = -1;
goto out;
}
/* XXX: The two strdup's leak */
ret = map_addfunc(el, wcsdup(wargv[0]), wcsdup(wargv[1]),
func);
ret = map_addfunc(el, wargv[0], wargv[1], func);
el_free(wargv);
break;
}
@@ -300,7 +299,8 @@ el_get(EditLine *el, int op, ...)
break;
}
case EL_EDITOR: {
case EL_EDITOR:
case EL_WORDCHARS: {
const char **p = va_arg(ap, const char **);
const wchar_t *pw;
ret = el_wget(el, op, &pw);
+8 -8
View File
@@ -1,4 +1,4 @@
/* $NetBSD: emacs.c,v 1.38 2024/06/29 17:28:07 christos Exp $ */
/* $NetBSD: emacs.c,v 1.39 2025/12/14 18:07:40 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: emacs.c,v 1.38 2024/06/29 17:28:07 christos Exp $");
__RCSID("$NetBSD: emacs.c,v 1.39 2025/12/14 18:07:40 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -99,7 +99,7 @@ em_delete_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
if (el->el_line.cursor == el->el_line.lastchar)
return CC_ERROR;
cp = c__next_word(el->el_line.cursor, el->el_line.lastchar,
cp = c__next_word(el, el->el_line.cursor, el->el_line.lastchar,
el->el_state.argument, ce__isword);
for (p = el->el_line.cursor, kp = el->el_chared.c_kill.buf; p < cp; p++)
@@ -266,7 +266,7 @@ em_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
if (el->el_line.cursor == el->el_line.lastchar)
return CC_ERROR;
el->el_line.cursor = c__next_word(el->el_line.cursor,
el->el_line.cursor = c__next_word(el, el->el_line.cursor,
el->el_line.lastchar,
el->el_state.argument,
ce__isword);
@@ -290,7 +290,7 @@ em_upper_case(EditLine *el, wint_t c __attribute__((__unused__)))
{
wchar_t *cp, *ep;
ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
ep = c__next_word(el, el->el_line.cursor, el->el_line.lastchar,
el->el_state.argument, ce__isword);
for (cp = el->el_line.cursor; cp < ep; cp++)
@@ -314,7 +314,7 @@ em_capitol_case(EditLine *el, wint_t c __attribute__((__unused__)))
{
wchar_t *cp, *ep;
ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
ep = c__next_word(el, el->el_line.cursor, el->el_line.lastchar,
el->el_state.argument, ce__isword);
for (cp = el->el_line.cursor; cp < ep; cp++) {
@@ -346,7 +346,7 @@ em_lower_case(EditLine *el, wint_t c __attribute__((__unused__)))
{
wchar_t *cp, *ep;
ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
ep = c__next_word(el, el->el_line.cursor, el->el_line.lastchar,
el->el_state.argument, ce__isword);
for (cp = el->el_line.cursor; cp < ep; cp++)
@@ -449,7 +449,7 @@ em_copy_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
return CC_ERROR;
/* does a bounds check */
cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
cp = c__prev_word(el, el->el_line.cursor, el->el_line.buffer,
el->el_state.argument, ce__isword);
c_insert(el, (int)(el->el_line.cursor - cp));
+7 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: hist.c,v 1.34 2019/07/23 10:19:35 christos Exp $ */
/* $NetBSD: hist.c,v 1.35 2026/03/03 15:05:17 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: hist.c,v 1.34 2019/07/23 10:19:35 christos Exp $");
__RCSID("$NetBSD: hist.c,v 1.35 2026/03/03 15:05:17 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -223,9 +223,13 @@ hist_command(EditLine *el, int argc, const wchar_t **argv)
*/
libedit_private int
/*ARGSUSED*/
hist_enlargebuf(EditLine *el, size_t oldsz, size_t newsz)
hist_enlargebuf(EditLine *el, size_t newsz)
{
wchar_t *newbuf;
size_t oldsz = el->el_history.sz;
if (newsz <= oldsz)
return 1;
newbuf = el_realloc(el->el_history.buf, newsz * sizeof(*newbuf));
if (!newbuf)
+2 -2
View File
@@ -1,4 +1,4 @@
/* $NetBSD: hist.h,v 1.23 2017/09/01 10:19:10 christos Exp $ */
/* $NetBSD: hist.h,v 1.24 2026/03/03 15:05:17 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -74,7 +74,7 @@ libedit_private void hist_end(EditLine *);
libedit_private el_action_t hist_get(EditLine *);
libedit_private int hist_set(EditLine *, hist_fun_t, void *);
libedit_private int hist_command(EditLine *, int, const wchar_t **);
libedit_private int hist_enlargebuf(EditLine *, size_t, size_t);
libedit_private int hist_enlargebuf(EditLine *, size_t);
libedit_private wchar_t *hist_convert(EditLine *, int, void *);
#endif /* _h_el_hist */
+3 -1
View File
@@ -1,4 +1,4 @@
/* $NetBSD: histedit.h,v 1.62 2023/02/03 22:01:42 christos Exp $ */
/* $NetBSD: histedit.h,v 1.64 2025/12/16 02:40:48 kre Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -159,6 +159,8 @@ unsigned char _el_fn_sh_complete(EditLine *, int);
#define EL_RESIZE 23 /* , el_zfunc_t, void *); set */
#define EL_ALIAS_TEXT 24 /* , el_afunc_t, void *); set */
#define EL_SAFEREAD 25 /* , int); set/get */
#define EL_WORDCHARS 26 /* , const Char *); set/get */
#define EL_GETENV 27 /* , char *(*func)(const char *); set/get */
#define EL_BUILTIN_GETCFN (NULL)
+3 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: history.c,v 1.64 2024/07/11 05:41:24 kre Exp $ */
/* $NetBSD: history.c,v 1.65 2026/03/03 15:06:35 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: history.c,v 1.64 2024/07/11 05:41:24 kre Exp $");
__RCSID("$NetBSD: history.c,v 1.65 2026/03/03 15:06:35 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -800,7 +800,7 @@ history_load(TYPE(History) *h, const char *fname)
for (i = 0; (sz = getline(&line, &llen, fp)) != -1; i++) {
if (sz > 0 && line[sz - 1] == '\n')
line[--sz] = '\0';
if (max_size < (size_t)sz) {
if (max_size <= (size_t)sz) {
char *nptr;
max_size = ((size_t)sz + 1024) & (size_t)~1023;
nptr = h_realloc(ptr, max_size * sizeof(*ptr));
+2 -2
View File
@@ -1,5 +1,5 @@
#!/bin/sh -
# $NetBSD: makelist,v 1.29 2016/05/09 21:46:56 christos Exp $
# $NetBSD: makelist,v 1.31 2026/03/04 10:31:46 christos Exp $
#
# Copyright (c) 1992, 1993
# The Regents of the University of California. All rights reserved.
@@ -102,7 +102,7 @@ case $FLAG in
fname = fname s;
}
printf(" { %-30.30s %-30.30s\n","L\"" fname "\",", uname ",");
printf(" { %-30.30s %-30.30s\n", uname ",", "L\"" fname "\",");
ok = 1;
}
}
+41 -4
View File
@@ -1,4 +1,4 @@
/* $NetBSD: map.c,v 1.56 2025/01/03 00:40:08 rillig Exp $ */
/* $NetBSD: map.c,v 1.59 2026/03/04 10:31:46 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.56 2025/01/03 00:40:08 rillig Exp $");
__RCSID("$NetBSD: map.c,v 1.59 2026/03/04 10:31:46 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -933,6 +933,7 @@ map_init(EditLine *el)
memcpy(el->el_map.func, el_func, sizeof(*el->el_map.func)
* EL_NUM_FCNS);
el->el_map.nfunc = EL_NUM_FCNS;
el->el_map.wordchars = NULL;
#ifdef VIDEFAULT
map_init_vi(el);
@@ -954,6 +955,7 @@ map_end(EditLine *el)
{
el_free(el->el_map.alt);
el_free(el->el_map.wordchars);
el->el_map.alt = NULL;
el_free(el->el_map.key);
el->el_map.key = NULL;
@@ -962,6 +964,10 @@ map_end(EditLine *el)
el->el_map.vii = NULL;
el_free(el->el_map.help);
el->el_map.help = NULL;
for (size_t nf = EL_NUM_FCNS; nf < el->el_map.nfunc; nf++) {
el_free((void *)(intptr_t)el->el_map.help[nf].name);
el_free((void *)(intptr_t)el->el_map.help[nf].description);
}
el_free(el->el_map.func);
el->el_map.func = NULL;
}
@@ -1051,6 +1057,8 @@ map_init_vi(EditLine *el)
tty_bind_char(el, 1);
terminal_bind_arrow(el);
el_free(el->el_map.wordchars);
el->el_map.wordchars = wcsdup(L"_");
}
@@ -1085,6 +1093,8 @@ map_init_emacs(EditLine *el)
tty_bind_char(el, 1);
terminal_bind_arrow(el);
el_free(el->el_map.wordchars);
el->el_map.wordchars = wcsdup(L"*?_-.[]~=");
}
@@ -1128,6 +1138,33 @@ map_get_editor(EditLine *el, const wchar_t **editor)
}
/* map_set_wordchars():
* Set the wordchars
*/
libedit_private int
map_set_wordchars(EditLine *el, wchar_t *wordchars)
{
el_free(el->el_map.wordchars);
el->el_map.wordchars = wcsdup(wordchars);
return 0;
}
/* map_get_wordchars():
* Retrieve the wordhars
*/
libedit_private int
map_get_wordchars(EditLine *el, const wchar_t **wordchars)
{
if (wordchars == NULL)
return -1;
*wordchars = el->el_map.wordchars;
return 0;
}
/* map_print_key():
* Print the function description for 1 key
*/
@@ -1420,9 +1457,9 @@ map_addfunc(EditLine *el, const wchar_t *name, const wchar_t *help,
nf = (size_t)el->el_map.nfunc;
el->el_map.func[nf] = func;
el->el_map.help[nf].name = name;
el->el_map.help[nf].name = wcsdup(name);
el->el_map.help[nf].func = (int)nf;
el->el_map.help[nf].description = help;
el->el_map.help[nf].description = wcsdup(help);
el->el_map.nfunc++;
return 0;
+5 -2
View File
@@ -1,4 +1,4 @@
/* $NetBSD: map.h,v 1.13 2016/05/09 21:46:56 christos Exp $ */
/* $NetBSD: map.h,v 1.16 2026/03/04 10:31:47 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -43,8 +43,8 @@
typedef el_action_t (*el_func_t)(EditLine *, wint_t);
typedef struct el_bindings_t { /* for the "bind" shell command */
const wchar_t *name; /* function name for bind command */
int func; /* function numeric value */
const wchar_t *name; /* function name for bind command */
const wchar_t *description; /* description of function */
} el_bindings_t;
@@ -59,6 +59,7 @@ typedef struct el_map_t {
el_bindings_t *help; /* The help for the editor functions */
el_func_t *func; /* List of available functions */
size_t nfunc; /* The number of functions/help items */
wchar_t *wordchars; /* The word character separators */
} el_map_t;
#define MAP_EMACS 0
@@ -73,6 +74,8 @@ libedit_private void map_init_vi(EditLine *);
libedit_private void map_init_emacs(EditLine *);
libedit_private int map_set_editor(EditLine *, wchar_t *);
libedit_private int map_get_editor(EditLine *, const wchar_t **);
libedit_private int map_set_wordchars(EditLine *, wchar_t *);
libedit_private int map_get_wordchars(EditLine *, const wchar_t **);
libedit_private int map_addfunc(EditLine *, const wchar_t *, const wchar_t *,
el_func_t);
+13 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: readline.c,v 1.182 2024/03/26 18:02:04 christos Exp $ */
/* $NetBSD: readline.c,v 1.184 2026/01/09 17:49:12 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.182 2024/03/26 18:02:04 christos Exp $");
__RCSID("$NetBSD: readline.c,v 1.184 2026/01/09 17:49:12 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -55,6 +55,7 @@ __RCSID("$NetBSD: readline.c,v 1.182 2024/03/26 18:02:04 christos Exp $");
#include "readline/readline.h"
#undef completion_matches
#include "el.h"
#include "emacs.h"
#include "fcns.h"
#include "filecomplete.h"
@@ -1922,7 +1923,7 @@ username_completion_function(const char *text, int state)
static unsigned char
_el_rl_tstp(EditLine *el __attribute__((__unused__)), int ch __attribute__((__unused__)))
{
(void)kill(0, SIGTSTP);
(void)raise(SIGTSTP);
return CC_NORM;
}
@@ -2488,6 +2489,15 @@ history_get_history_state(void)
return hs;
}
int
/*ARGSUSED*/
rl_kill_full_line(int count __attribute__((__unused__)),
int key __attribute__((__unused__)))
{
em_kill_line(e, 0);
return 0;
}
int
/*ARGSUSED*/
rl_kill_text(int from __attribute__((__unused__)),
+2 -1
View File
@@ -1,4 +1,4 @@
/* $NetBSD: readline.h,v 1.55 2023/04/25 17:51:32 christos Exp $ */
/* $NetBSD: readline.h,v 1.56 2026/01/09 17:49:12 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -223,6 +223,7 @@ void rl_callback_handler_install(const char *, rl_vcpfunc_t *);
void rl_callback_handler_remove(void);
void rl_redisplay(void);
int rl_get_previous_history(int, int);
int rl_kill_full_line(int, int);
void rl_prep_terminal(int);
void rl_deprep_terminal(void);
int rl_read_init_file(const char *);
+11 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: refresh.c,v 1.60 2024/12/05 22:21:53 christos Exp $ */
/* $NetBSD: refresh.c,v 1.61 2026/01/18 17:18:37 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: refresh.c,v 1.60 2024/12/05 22:21:53 christos Exp $");
__RCSID("$NetBSD: refresh.c,v 1.61 2026/01/18 17:18:37 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -1214,16 +1214,24 @@ re_clear_display(EditLine *el)
libedit_private void
re_clear_lines(EditLine *el)
{
int i;
if (EL_CAN_CEOL) {
int i;
for (i = el->el_refresh.r_oldcv; i >= 0; i--) {
if (i > 0) {
terminal__putc(el, '\r');
terminal__putc(el, '\n');
}
/* for each line on the screen */
terminal_move_to_line(el, i);
terminal_move_to_char(el, 0);
terminal_clear_EOL(el, el->el_terminal.t_size.h);
}
} else {
for (i = el->el_refresh.r_oldcv; i > 0; i--) {
terminal__putc(el, '\r');
terminal__putc(el, '\n');
}
terminal_move_to_line(el, el->el_refresh.r_oldcv);
/* go to last line */
terminal__putc(el, '\r'); /* go to BOL */
+4 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: search.c,v 1.52 2024/06/30 16:26:30 christos Exp $ */
/* $NetBSD: search.c,v 1.53 2025/12/14 18:07:40 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: search.c,v 1.52 2024/06/30 16:26:30 christos Exp $");
__RCSID("$NetBSD: search.c,v 1.53 2025/12/14 18:07:40 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -300,7 +300,8 @@ ce_inc_search(EditLine *el, int dir)
break;
el->el_line.cursor +=
el->el_search.patlen - LEN - 1;
cp = c__next_word(el->el_line.cursor,
cp = c__next_word(el,
el->el_line.cursor,
el->el_line.lastchar, 1,
ce__isword);
while (el->el_line.cursor < cp &&
+3 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: sig.c,v 1.28 2024/12/18 15:38:52 christos Exp $ */
/* $NetBSD: sig.c,v 1.29 2025/06/14 13:43:50 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.28 2024/12/18 15:38:52 christos Exp $");
__RCSID("$NetBSD: sig.c,v 1.29 2025/06/14 13:43:50 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -107,7 +107,7 @@ sig_handler(int signo)
sel->el_signal->sig_action[i].sa_flags = 0;
sigemptyset(&sel->el_signal->sig_action[i].sa_mask);
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
(void) kill(0, signo);
(void) raise(signo);
errno = save_errno;
}
+3 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: terminal.c,v 1.46 2023/02/04 14:34:28 christos Exp $ */
/* $NetBSD: terminal.c,v 1.47 2025/12/16 02:40:48 kre 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.46 2023/02/04 14:34:28 christos Exp $");
__RCSID("$NetBSD: terminal.c,v 1.47 2025/12/16 02:40:48 kre Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -851,7 +851,7 @@ terminal_set(EditLine *el, const char *term)
if (term == NULL)
term = getenv("TERM");
term = (el->el_getenv)("TERM");
if (!term || !term[0])
term = "dumb";
+7 -7
View File
@@ -1,4 +1,4 @@
/* $NetBSD: vi.c,v 1.64 2021/08/28 17:17:47 christos Exp $ */
/* $NetBSD: vi.c,v 1.66 2025/12/16 02:40:48 kre Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: vi.c,v 1.64 2021/08/28 17:17:47 christos Exp $");
__RCSID("$NetBSD: vi.c,v 1.66 2025/12/16 02:40:48 kre Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -161,7 +161,7 @@ vi_prev_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
if (el->el_line.cursor == el->el_line.buffer)
return CC_ERROR;
el->el_line.cursor = cv_prev_word(el->el_line.cursor,
el->el_line.cursor = cv_prev_word(el, el->el_line.cursor,
el->el_line.buffer,
el->el_state.argument,
cv__isWord);
@@ -186,7 +186,7 @@ vi_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
if (el->el_line.cursor == el->el_line.buffer)
return CC_ERROR;
el->el_line.cursor = cv_prev_word(el->el_line.cursor,
el->el_line.cursor = cv_prev_word(el, el->el_line.cursor,
el->el_line.buffer,
el->el_state.argument,
cv__isword);
@@ -478,7 +478,7 @@ vi_end_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
if (el->el_line.cursor == el->el_line.lastchar)
return CC_ERROR;
el->el_line.cursor = cv__endword(el->el_line.cursor,
el->el_line.cursor = cv__endword(el, el->el_line.cursor,
el->el_line.lastchar, el->el_state.argument, cv__isWord);
if (el->el_chared.c_vcmd.action != NOP) {
@@ -502,7 +502,7 @@ vi_end_word(EditLine *el, wint_t c __attribute__((__unused__)))
if (el->el_line.cursor == el->el_line.lastchar)
return CC_ERROR;
el->el_line.cursor = cv__endword(el->el_line.cursor,
el->el_line.cursor = cv__endword(el, el->el_line.cursor,
el->el_line.lastchar, el->el_state.argument, cv__isword);
if (el->el_chared.c_vcmd.action != NOP) {
@@ -1015,7 +1015,7 @@ vi_histedit(EditLine *el, wint_t c __attribute__((__unused__)))
return CC_ERROR;
}
if ((editor = getenv("EDITOR")) == NULL)
if ((editor = (el->el_getenv)("EDITOR")) == NULL)
editor = "vi";
fd = mkstemp(tempfile);
if (fd < 0)