libedit: update to snapshot 2023-01-06

MFC atfer:	1 week
This commit is contained in:
Baptiste Daroussin 2023-02-06 14:25:06 +01:00
commit baff81958c
14 changed files with 122 additions and 399 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: chared.c,v 1.62 2022/02/08 21:13:22 rillig 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.62 2022/02/08 21:13:22 rillig 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():

View File

@ -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 */

View File

@ -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 */

View File

@ -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 ,

View File

@ -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);

View File

@ -1,4 +1,4 @@
/* $NetBSD: filecomplete.c,v 1.70 2022/03/12 15:29:17 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.70 2022/03/12 15:29:17 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>
@ -637,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;

View File

@ -1,4 +1,4 @@
/* $NetBSD: histedit.h,v 1.61 2022/02/08 21:13:22 rillig Exp $ */
/* $NetBSD: histedit.h,v 1.62 2023/02/03 22:01:42 christos Exp $ */
/*-
* Copyright (c) 1992, 1993

View File

@ -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;
}

View File

@ -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():

View File

@ -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);

View File

@ -1,4 +1,4 @@
/* $NetBSD: readline.c,v 1.174 2022/04/08 20:11:31 christos 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.174 2022/04/08 20:11:31 christos 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>
@ -240,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);
@ -478,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;
@ -1602,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;
@ -2327,6 +2331,8 @@ rl_copy_text(int from, int to)
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;

View File

@ -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);
}

View File

@ -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 */

View File

@ -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;
}