diff options
Diffstat (limited to 'lib/libedit/readline.c')
-rw-r--r-- | lib/libedit/readline.c | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/lib/libedit/readline.c b/lib/libedit/readline.c index caddb9f..00ea369 100644 --- a/lib/libedit/readline.c +++ b/lib/libedit/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,30 +31,29 @@ #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/cdefs.h> __FBSDID("$FreeBSD$"); #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); @@ -169,13 +168,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); @@ -212,14 +211,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; } @@ -269,7 +268,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); @@ -363,7 +362,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. */ @@ -2010,7 +2009,7 @@ rl_callback_read_char(void) } } -void +void rl_callback_handler_install(const char *prompt, rl_vcpfunc_t *linefunc) { if (e == NULL) { @@ -2019,9 +2018,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); @@ -2102,12 +2101,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)(); @@ -2116,7 +2117,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) @@ -2124,12 +2125,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 @@ -2141,6 +2142,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; } @@ -2203,7 +2205,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++) @@ -2221,7 +2223,7 @@ rl_completion_matches(const char *str, rl_compentry_func_t *fun) list[0][min] = '\0'; } return list; - + out: el_free(list); return NULL; @@ -2325,3 +2327,10 @@ void rl_free_line_state(void) { } + +int +/*ARGSUSED*/ +rl_set_keyboard_input_timeout(int u __attribute__((__unused__))) +{ + return 0; +} |