aboutsummaryrefslogtreecommitdiff
path: root/readline.c
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2016-02-28 15:57:37 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2016-02-28 15:57:37 +0000
commit4593a7cde52b7d8dae0d524a1bb89fee1bdc11a0 (patch)
tree247af74937552b0d3cea603c49a65ef2078046da /readline.c
parentc729c39672cd6bc2e7f57dccc8aab4eb761f0ba6 (diff)
downloadsrc-4593a7cde52b7d8dae0d524a1bb89fee1bdc11a0.tar.gz
src-4593a7cde52b7d8dae0d524a1bb89fee1bdc11a0.zip
Import libedit 2016-02-27vendor/NetBSD/libedit/2016-02-27
Obtained from: NetBSD
Notes
Notes: svn path=/vendor/NetBSD/libedit/dist/; revision=296159 svn path=/vendor/NetBSD/libedit/2016-02-27/; revision=296160; tag=vendor/NetBSD/libedit/2016-02-27
Diffstat (limited to 'readline.c')
-rw-r--r--readline.c63
1 files changed, 36 insertions, 27 deletions
diff --git a/readline.c b/readline.c
index a2bced4f2a75..12250daf860d 100644
--- a/readline.c
+++ b/readline.c
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.c,v 1.117 2015/06/02 15:35:31 christos Exp $ */
+/* $NetBSD: readline.c,v 1.126 2016/02/24 17:13:22 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,28 +31,27 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.117 2015/06/02 15:35:31 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.126 2016/02/24 17:13:22 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
#include <sys/stat.h>
-#include <stdio.h>
-#include <dirent.h>
-#include <string.h>
-#include <pwd.h>
#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <limits.h>
+#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
+#include <limits.h>
+#include <pwd.h>
#include <setjmp.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#include <vis.h>
#include "readline/readline.h"
#include "el.h"
-#include "fcns.h" /* for EL_NUM_FCNS */
-#include "histedit.h"
#include "filecomplete.h"
void rl_prep_terminal(int);
@@ -167,13 +166,13 @@ static jmp_buf topbuf;
static unsigned char _el_rl_complete(EditLine *, int);
static unsigned char _el_rl_tstp(EditLine *, int);
static char *_get_prompt(EditLine *);
-static int _getc_function(EditLine *, char *);
+static int _getc_function(EditLine *, wchar_t *);
static HIST_ENTRY *_move_history(int);
static int _history_expand_command(const char *, size_t, size_t,
char **);
static char *_rl_compat_sub(const char *, const char *,
const char *, int);
-static int _rl_event_read_char(EditLine *, char *);
+static int _rl_event_read_char(EditLine *, wchar_t *);
static void _rl_update_pos(void);
@@ -210,14 +209,14 @@ _move_history(int op)
*/
static int
/*ARGSUSED*/
-_getc_function(EditLine *el __attribute__((__unused__)), char *c)
+_getc_function(EditLine *el __attribute__((__unused__)), wchar_t *c)
{
int i;
i = (*rl_getc_function)(NULL);
if (i == -1)
return 0;
- *c = (char)i;
+ *c = (wchar_t)i;
return 1;
}
@@ -267,7 +266,7 @@ rl_set_prompt(const char *prompt)
if (!prompt)
prompt = "";
- if (rl_prompt != NULL && strcmp(rl_prompt, prompt) == 0)
+ if (rl_prompt != NULL && strcmp(rl_prompt, prompt) == 0)
return 0;
if (rl_prompt)
el_free(rl_prompt);
@@ -361,7 +360,7 @@ rl_initialize(void)
"ReadLine compatible suspend function",
_el_rl_tstp);
el_set(e, EL_BIND, "^Z", "rl_tstp", NULL);
-
+
/*
* Set some readline compatible key-bindings.
*/
@@ -2008,7 +2007,7 @@ rl_callback_read_char(void)
}
}
-void
+void
rl_callback_handler_install(const char *prompt, rl_vcpfunc_t *linefunc)
{
if (e == NULL) {
@@ -2017,9 +2016,9 @@ rl_callback_handler_install(const char *prompt, rl_vcpfunc_t *linefunc)
(void)rl_set_prompt(prompt);
rl_linefunc = linefunc;
el_set(e, EL_UNBUFFERED, 1);
-}
+}
-void
+void
rl_callback_handler_remove(void)
{
el_set(e, EL_UNBUFFERED, 0);
@@ -2100,12 +2099,14 @@ rl_stuff_char(int c)
}
static int
-_rl_event_read_char(EditLine *el, char *cp)
+_rl_event_read_char(EditLine *el, wchar_t *wc)
{
+ char ch;
int n;
ssize_t num_read = 0;
- *cp = '\0';
+ ch = '\0';
+ *wc = L'\0';
while (rl_event_hook) {
(*rl_event_hook)();
@@ -2114,7 +2115,7 @@ _rl_event_read_char(EditLine *el, char *cp)
if (ioctl(el->el_infd, FIONREAD, &n) < 0)
return -1;
if (n)
- num_read = read(el->el_infd, cp, (size_t)1);
+ num_read = read(el->el_infd, &ch, (size_t)1);
else
num_read = 0;
#elif defined(F_SETFL) && defined(O_NDELAY)
@@ -2122,12 +2123,12 @@ _rl_event_read_char(EditLine *el, char *cp)
return -1;
if (fcntl(el->el_infd, F_SETFL, n|O_NDELAY) < 0)
return -1;
- num_read = read(el->el_infd, cp, 1);
+ num_read = read(el->el_infd, &ch, 1);
if (fcntl(el->el_infd, F_SETFL, n))
return -1;
#else
/* not non-blocking, but what you gonna do? */
- num_read = read(el->el_infd, cp, 1);
+ num_read = read(el->el_infd, &ch, 1);
return -1;
#endif
@@ -2139,6 +2140,7 @@ _rl_event_read_char(EditLine *el, char *cp)
}
if (!rl_event_hook)
el_set(el, EL_GETCFN, EL_BUILTIN_GETCFN);
+ *wc = (wchar_t)ch;
return (int)num_read;
}
@@ -2201,7 +2203,7 @@ rl_completion_matches(const char *str, rl_compentry_func_t *fun)
}
qsort(&list[1], len - 1, sizeof(*list),
(int (*)(const void *, const void *)) strcmp);
- min = SIZE_T_MAX;
+ min = SIZE_MAX;
for (i = 1, a = list[i]; i < len - 1; i++, a = b) {
b = list[i + 1];
for (j = 0; a[j] && a[j] == b[j]; j++)
@@ -2219,7 +2221,7 @@ rl_completion_matches(const char *str, rl_compentry_func_t *fun)
list[0][min] = '\0';
}
return list;
-
+
out:
el_free(list);
return NULL;
@@ -2323,3 +2325,10 @@ void
rl_free_line_state(void)
{
}
+
+int
+/*ARGSUSED*/
+rl_set_keyboard_input_timeout(int u __attribute__((__unused__)))
+{
+ return 0;
+}