aboutsummaryrefslogtreecommitdiff
path: root/lib/libedit/src/readline.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libedit/src/readline.c')
-rw-r--r--lib/libedit/src/readline.c652
1 files changed, 388 insertions, 264 deletions
diff --git a/lib/libedit/src/readline.c b/lib/libedit/src/readline.c
index aeb6c46f41e5..f4e0a39e3925 100644
--- a/lib/libedit/src/readline.c
+++ b/lib/libedit/src/readline.c
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.c,v 1.92 2010/09/16 20:08:51 christos Exp $ */
+/* $NetBSD: readline.c,v 1.139 2016/10/28 18:32:26 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,33 +31,31 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.92 2010/09/16 20:08:51 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.139 2016/10/28 18:32:26 christos Exp $");
#endif /* not lint && not SCCSID */
+#include "config.h"
+
#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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#include <vis.h>
-#include "editline/readline.h"
+
+#include "readline/readline.h"
#include "el.h"
-#include "fcns.h" /* for EL_NUM_FCNS */
-#include "histedit.h"
+#include "fcns.h"
#include "filecomplete.h"
-#if !defined(SIZE_T_MAX)
-# define SIZE_T_MAX (size_t)(-1)
-#endif
-
void rl_prep_terminal(int);
void rl_deprep_terminal(void);
@@ -81,15 +79,24 @@ FILE *rl_outstream = NULL;
int rl_point = 0;
int rl_end = 0;
char *rl_line_buffer = NULL;
-VCPFunction *rl_linefunc = NULL;
+rl_vcpfunc_t *rl_linefunc = NULL;
int rl_done = 0;
VFunction *rl_event_hook = NULL;
KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
emacs_meta_keymap,
emacs_ctlx_keymap;
+/*
+ * The following is not implemented; we always catch signals in the
+ * libedit fashion: set handlers on entry to el_gets() and clear them
+ * on the way out. This simplistic approach works for most cases; if
+ * it does not work for your application, please let us know.
+ */
+int rl_catch_signals = 1;
+int rl_catch_sigwinch = 1;
int history_base = 1; /* probably never subject to change */
int history_length = 0;
+int history_offset = 0;
int max_input_history = 0;
char history_expansion_char = '!';
char history_subst_char = '^';
@@ -102,8 +109,9 @@ int rl_attempted_completion_over = 0;
char *rl_basic_word_break_characters = break_chars;
char *rl_completer_word_break_characters = NULL;
char *rl_completer_quote_characters = NULL;
-Function *rl_completion_entry_function = NULL;
-CPPFunction *rl_attempted_completion_function = NULL;
+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;
int (*rl_getc_function)(FILE *) = NULL;
@@ -111,7 +119,6 @@ char *rl_terminal_name = NULL;
int rl_already_prompted = 0;
int rl_filename_completion_desired = 0;
int rl_ignore_completion_duplicates = 0;
-int rl_catch_signals = 1;
int readline_echoing_p = 1;
int _rl_print_completions_horizontally = 0;
VFunction *rl_redisplay_function = NULL;
@@ -155,48 +162,29 @@ int rl_completion_append_character = ' ';
static History *h = NULL;
static EditLine *e = NULL;
-static Function *map[256];
+static rl_command_func_t *map[256];
static jmp_buf topbuf;
/* internal functions */
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 HIST_ENTRY *_move_history(int);
+static int _getc_function(EditLine *, wchar_t *);
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);
+static HIST_ENTRY rl_he;
/* ARGSUSED */
static char *
_get_prompt(EditLine *el __attribute__((__unused__)))
{
rl_already_prompted = 1;
- return (rl_prompt);
-}
-
-
-/*
- * generic function for moving around history
- */
-static HIST_ENTRY *
-_move_history(int op)
-{
- HistEvent ev;
- static HIST_ENTRY rl_he;
-
- if (history(h, &ev, op) != 0)
- return (HIST_ENTRY *) NULL;
-
- rl_he.line = ev.str;
- rl_he.data = NULL;
-
- return (&rl_he);
+ return rl_prompt;
}
@@ -205,14 +193,14 @@ _move_history(int op)
*/
static int
/*ARGSUSED*/
-_getc_function(EditLine *el, char *c)
+_getc_function(EditLine *el __attribute__((__unused__)), wchar_t *c)
{
int i;
- i = (*rl_getc_function)(NULL);
+ i = (*rl_getc_function)(rl_instream);
if (i == -1)
return 0;
- *c = i;
+ *c = (wchar_t)i;
return 1;
}
@@ -224,23 +212,27 @@ _resize_fun(EditLine *el, void *a)
li = el_line(el);
/* a cheesy way to get rid of const cast. */
- *ap = memchr(li->buffer, *li->buffer, 1);
+ *ap = memchr(li->buffer, *li->buffer, (size_t)1);
}
-static const char _dothistory[] = "/.history";
-
static const char *
_default_history_file(void)
{
struct passwd *p;
- static char path[PATH_MAX];
+ static char *path;
+ size_t len;
- if (*path)
+ if (path)
return path;
+
if ((p = getpwuid(getuid())) == NULL)
return NULL;
- strlcpy(path, p->pw_dir, PATH_MAX);
- strlcat(path, _dothistory, PATH_MAX);
+
+ len = strlen(p->pw_dir) + sizeof("/.history");
+ if ((path = malloc(len)) == NULL)
+ return NULL;
+
+ (void)snprintf(path, len, "%s/.history", p->pw_dir);
return path;
}
@@ -261,7 +253,7 @@ rl_set_prompt(const char *prompt)
if (rl_prompt != NULL && strcmp(rl_prompt, prompt) == 0)
return 0;
if (rl_prompt)
- free(rl_prompt);
+ el_free(rl_prompt);
rl_prompt = strdup(prompt);
if (rl_prompt == NULL)
return -1;
@@ -305,7 +297,7 @@ rl_initialize(void)
h = history_init();
if (!e || !h)
- return (-1);
+ return -1;
history(h, &ev, H_SETSIZE, INT_MAX); /* unlimited */
history_length = 0;
@@ -329,7 +321,7 @@ rl_initialize(void)
el_set(e, EL_SIGNAL, rl_catch_signals);
/* set default mode to "emacs"-style and read setting afterwards */
- /* so this can be overriden */
+ /* so this can be overridden */
el_set(e, EL_EDITOR, "emacs");
if (rl_terminal_name != NULL)
el_set(e, EL_TERMINAL, rl_terminal_name);
@@ -353,6 +345,37 @@ rl_initialize(void)
_el_rl_tstp);
el_set(e, EL_BIND, "^Z", "rl_tstp", NULL);
+ /*
+ * Set some readline compatible key-bindings.
+ */
+ el_set(e, EL_BIND, "^R", "em-inc-search-prev", NULL);
+
+ /*
+ * Allow the use of Home/End keys.
+ */
+ el_set(e, EL_BIND, "\\e[1~", "ed-move-to-beg", NULL);
+ el_set(e, EL_BIND, "\\e[4~", "ed-move-to-end", NULL);
+ el_set(e, EL_BIND, "\\e[7~", "ed-move-to-beg", NULL);
+ el_set(e, EL_BIND, "\\e[8~", "ed-move-to-end", NULL);
+ el_set(e, EL_BIND, "\\e[H", "ed-move-to-beg", NULL);
+ el_set(e, EL_BIND, "\\e[F", "ed-move-to-end", NULL);
+
+ /*
+ * Allow the use of the Delete/Insert keys.
+ */
+ el_set(e, EL_BIND, "\\e[3~", "ed-delete-next-char", NULL);
+ el_set(e, EL_BIND, "\\e[2~", "ed-quoted-insert", NULL);
+
+ /*
+ * Ctrl-left-arrow and Ctrl-right-arrow for word moving.
+ */
+ el_set(e, EL_BIND, "\\e[1;5C", "em-next-word", NULL);
+ el_set(e, EL_BIND, "\\e[1;5D", "ed-prev-word", NULL);
+ el_set(e, EL_BIND, "\\e[5C", "em-next-word", NULL);
+ el_set(e, EL_BIND, "\\e[5D", "ed-prev-word", NULL);
+ el_set(e, EL_BIND, "\\e\\e[C", "em-next-word", NULL);
+ el_set(e, EL_BIND, "\\e\\e[D", "ed-prev-word", NULL);
+
/* read settings from configuration file */
el_source(e, NULL);
@@ -366,7 +389,7 @@ rl_initialize(void)
if (rl_startup_hook)
(*rl_startup_hook)(NULL, 0);
- return (0);
+ return 0;
}
@@ -444,6 +467,7 @@ using_history(void)
{
if (h == NULL || e == NULL)
rl_initialize();
+ history_offset = history_length;
}
@@ -475,7 +499,7 @@ _rl_compat_sub(const char *str, const char *what, const char *with,
} else
s++;
}
- r = result = malloc(len + 1);
+ r = result = el_malloc((len + 1) * sizeof(*r));
if (result == NULL)
return NULL;
s = str;
@@ -486,13 +510,13 @@ _rl_compat_sub(const char *str, const char *what, const char *with,
s += what_len;
if (!globally) {
(void)strcpy(r, s);
- return(result);
+ return result;
}
} else
*r++ = *s++;
}
*r = '\0';
- return(result);
+ return result;
}
static char *last_search_pat; /* last !?pat[?] search pattern */
@@ -509,12 +533,12 @@ get_history_event(const char *cmd, int *cindex, int qchar)
idx = *cindex;
if (cmd[idx++] != history_expansion_char)
- return(NULL);
+ return NULL;
/* find out which event to take */
if (cmd[idx] == history_expansion_char || cmd[idx] == '\0') {
if (history(h, &ev, H_FIRST) != 0)
- return(NULL);
+ return NULL;
*cindex = cmd[idx]? (idx + 1):idx;
return ev.str;
}
@@ -525,7 +549,7 @@ get_history_event(const char *cmd, int *cindex, int qchar)
}
if ('0' <= cmd[idx] && cmd[idx] <= '9') {
- HIST_ENTRY *rl_he;
+ HIST_ENTRY *he;
num = 0;
while (cmd[idx] && '0' <= cmd[idx] && cmd[idx] <= '9') {
@@ -535,11 +559,11 @@ get_history_event(const char *cmd, int *cindex, int qchar)
if (sign)
num = history_length - num + 1;
- if (!(rl_he = history_get(num)))
- return(NULL);
+ if (!(he = history_get(num)))
+ return NULL;
*cindex = idx;
- return(rl_he->line);
+ return he->line;
}
sub = 0;
if (cmd[idx] == '?') {
@@ -557,15 +581,15 @@ get_history_event(const char *cmd, int *cindex, int qchar)
break;
idx++;
}
- len = idx - begin;
+ len = (size_t)idx - (size_t)begin;
if (sub && cmd[idx] == '?')
idx++;
if (sub && len == 0 && last_search_pat && *last_search_pat)
pat = last_search_pat;
else if (len == 0)
- return(NULL);
+ return NULL;
else {
- if ((pat = malloc(len + 1)) == NULL)
+ if ((pat = el_malloc((len + 1) * sizeof(*pat))) == NULL)
return NULL;
(void)strncpy(pat, cmd + begin, len);
pat[len] = '\0';
@@ -573,15 +597,15 @@ get_history_event(const char *cmd, int *cindex, int qchar)
if (history(h, &ev, H_CURR) != 0) {
if (pat != last_search_pat)
- free(pat);
- return (NULL);
+ el_free(pat);
+ return NULL;
}
num = ev.num;
if (sub) {
if (pat != last_search_pat) {
if (last_search_pat)
- free(last_search_pat);
+ el_free(last_search_pat);
last_search_pat = pat;
}
ret = history_search(pat, -1);
@@ -593,21 +617,21 @@ get_history_event(const char *cmd, int *cindex, int qchar)
history(h, &ev, H_FIRST);
(void)fprintf(rl_outstream, "%s: Event not found\n", pat);
if (pat != last_search_pat)
- free(pat);
- return(NULL);
+ el_free(pat);
+ return NULL;
}
if (sub && len) {
if (last_search_match && last_search_match != pat)
- free(last_search_match);
+ el_free(last_search_match);
last_search_match = pat;
}
if (pat != last_search_pat)
- free(pat);
+ el_free(pat);
if (history(h, &ev, H_CURR) != 0)
- return(NULL);
+ return NULL;
*cindex = idx;
rptr = ev.str;
@@ -625,7 +649,7 @@ get_history_event(const char *cmd, int *cindex, int qchar)
* returns 0 if data was not modified, 1 if it was and 2 if the string
* should be only printed and not executed; in case of error,
* returns -1 and *result points to NULL
- * it's callers responsibility to free() string returned in *result
+ * it's the caller's responsibility to free() the string returned in *result
*/
static int
_history_expand_command(const char *command, size_t offs, size_t cmdlen,
@@ -659,7 +683,8 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
} else {
if (command[offs + 1] == '#') {
/* use command so far */
- if ((aptr = malloc(offs + 1)) == NULL)
+ if ((aptr = el_malloc((offs + 1) * sizeof(*aptr)))
+ == NULL)
return -1;
(void)strncpy(aptr, command, offs);
aptr[offs] = '\0';
@@ -670,19 +695,19 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
qchar = (offs > 0 && command[offs - 1] == '"')? '"':0;
ptr = get_history_event(command + offs, &idx, qchar);
}
- has_mods = command[offs + idx] == ':';
+ has_mods = command[offs + (size_t)idx] == ':';
}
if (ptr == NULL && aptr == NULL)
- return(-1);
+ return -1;
if (!has_mods) {
*result = strdup(aptr ? aptr : ptr);
if (aptr)
- free(aptr);
+ el_free(aptr);
if (*result == NULL)
return -1;
- return(1);
+ return 1;
}
cmd = command + offs + idx + 1;
@@ -727,18 +752,18 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
(void)fprintf(rl_outstream, "%s: Bad word specifier",
command + offs + idx);
if (aptr)
- free(aptr);
- return(-1);
+ el_free(aptr);
+ return -1;
}
} else
tmp = strdup(aptr? aptr:ptr);
if (aptr)
- free(aptr);
+ el_free(aptr);
if (*cmd == '\0' || ((size_t)(cmd - (command + offs)) >= cmdlen)) {
*result = tmp;
- return(1);
+ return 1;
}
for (; *cmd; cmd++) {
@@ -750,7 +775,7 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
} else if (*cmd == 't') { /* remove leading path */
if ((aptr = strrchr(tmp, '/')) != NULL) {
aptr = strdup(aptr + 1);
- free(tmp);
+ el_free(tmp);
tmp = aptr;
}
} else if (*cmd == 'r') { /* remove trailing suffix */
@@ -759,7 +784,7 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
} else if (*cmd == 'e') { /* remove all but suffix */
if ((aptr = strrchr(tmp, '.')) != NULL) {
aptr = strdup(aptr);
- free(tmp);
+ el_free(tmp);
tmp = aptr;
}
} else if (*cmd == 'p') /* print only */
@@ -776,10 +801,10 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
else if (*cmd == 's') {
delim = *(++cmd), cmd++;
size = 16;
- what = realloc(from, size);
+ what = el_realloc(from, size * sizeof(*what));
if (what == NULL) {
- free(from);
- free(tmp);
+ el_free(from);
+ el_free(tmp);
return 0;
}
len = 0;
@@ -788,11 +813,12 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
cmd++;
if (len >= size) {
char *nwhat;
- nwhat = realloc(what,
- (size <<= 1));
+ nwhat = el_realloc(what,
+ (size <<= 1) *
+ sizeof(*nwhat));
if (nwhat == NULL) {
- free(what);
- free(tmp);
+ el_free(what);
+ el_free(tmp);
return 0;
}
what = nwhat;
@@ -802,17 +828,17 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
what[len] = '\0';
from = what;
if (*what == '\0') {
- free(what);
+ el_free(what);
if (search) {
from = strdup(search);
if (from == NULL) {
- free(tmp);
+ el_free(tmp);
return 0;
}
} else {
from = NULL;
- free(tmp);
- return (-1);
+ el_free(tmp);
+ return -1;
}
}
cmd++; /* shift after delim */
@@ -820,10 +846,10 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
continue;
size = 16;
- with = realloc(to, size);
+ with = el_realloc(to, size * sizeof(*with));
if (with == NULL) {
- free(to);
- free(tmp);
+ el_free(to);
+ el_free(tmp);
return -1;
}
len = 0;
@@ -832,10 +858,11 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
if (len + from_len + 1 >= size) {
char *nwith;
size += from_len + 1;
- nwith = realloc(with, size);
+ nwith = el_realloc(with,
+ size * sizeof(*nwith));
if (nwith == NULL) {
- free(with);
- free(tmp);
+ el_free(with);
+ el_free(tmp);
return -1;
}
with = nwith;
@@ -858,14 +885,14 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen,
aptr = _rl_compat_sub(tmp, from, to, g_on);
if (aptr) {
- free(tmp);
+ el_free(tmp);
tmp = aptr;
}
g_on = 0;
}
}
*result = tmp;
- return (p_on? 2:1);
+ return p_on? 2:1;
}
@@ -884,13 +911,13 @@ history_expand(char *str, char **output)
if (history_expansion_char == 0) {
*output = strdup(str);
- return(0);
+ return 0;
}
*output = NULL;
if (str[0] == history_subst_char) {
/* ^foo^foo2^ is equivalent to !!:s^foo^foo2^ */
- *output = malloc(strlen(str) + 4 + 1);
+ *output = el_malloc((strlen(str) + 4 + 1) * sizeof(**output));
if (*output == NULL)
return 0;
(*output)[0] = (*output)[1] = history_expansion_char;
@@ -907,11 +934,12 @@ history_expand(char *str, char **output)
#define ADD_STRING(what, len, fr) \
{ \
if (idx + len + 1 > size) { \
- char *nresult = realloc(result, (size += len + 1));\
+ char *nresult = el_realloc(result, \
+ (size += len + 1) * sizeof(*nresult)); \
if (nresult == NULL) { \
- free(*output); \
+ el_free(*output); \
if (/*CONSTCOND*/fr) \
- free(tmp); \
+ el_free(tmp); \
return 0; \
} \
result = nresult; \
@@ -935,7 +963,8 @@ loop:
for (; str[j]; j++) {
if (str[j] == '\\' &&
str[j + 1] == history_expansion_char) {
- (void)strcpy(&str[j], &str[j + 1]);
+ len = strlen(&str[j + 1]) + 1;
+ memmove(&str[j], &str[j + 1], len);
continue;
}
if (!loop_again) {
@@ -978,7 +1007,7 @@ loop:
ADD_STRING(tmp, len, 1);
}
if (tmp) {
- free(tmp);
+ el_free(tmp);
tmp = NULL;
}
i = j;
@@ -995,10 +1024,10 @@ loop:
ret = -1;
#endif
}
- free(*output);
+ el_free(*output);
*output = result;
- return (ret);
+ return ret;
}
/*
@@ -1033,14 +1062,14 @@ history_arg_extract(int start, int end, const char *str)
(size_t)end > max || start > end)
goto out;
- for (i = start, len = 0; i <= (size_t)end; i++)
+ for (i = (size_t)start, len = 0; i <= (size_t)end; i++)
len += strlen(arr[i]) + 1;
len++;
- result = malloc(len);
+ result = el_malloc(len * sizeof(*result));
if (result == NULL)
goto out;
- for (i = start, len = 0; i <= (size_t)end; i++) {
+ for (i = (size_t)start, len = 0; i <= (size_t)end; i++) {
(void)strcpy(result + len, arr[i]);
len += strlen(arr[i]);
if (i < (size_t)end)
@@ -1050,8 +1079,8 @@ history_arg_extract(int start, int end, const char *str)
out:
for (i = 0; arr[i]; i++)
- free(arr[i]);
- free(arr);
+ el_free(arr[i]);
+ el_free(arr);
return result;
}
@@ -1090,19 +1119,19 @@ history_tokenize(const char *str)
if (idx + 2 >= size) {
char **nresult;
size <<= 1;
- nresult = realloc(result, size * sizeof(char *));
+ nresult = el_realloc(result, (size_t)size * sizeof(*nresult));
if (nresult == NULL) {
- free(result);
+ el_free(result);
return NULL;
}
result = nresult;
}
- len = i - start;
- temp = malloc(len + 1);
+ len = (size_t)i - (size_t)start;
+ temp = el_malloc((size_t)(len + 1) * sizeof(*temp));
if (temp == NULL) {
for (i = 0; i < idx; i++)
- free(result[i]);
- free(result);
+ el_free(result[i]);
+ el_free(result);
return NULL;
}
(void)strncpy(temp, &str[start], len);
@@ -1112,7 +1141,7 @@ history_tokenize(const char *str)
if (str[i])
i++;
}
- return (result);
+ return result;
}
@@ -1123,12 +1152,22 @@ void
stifle_history(int max)
{
HistEvent ev;
+ HIST_ENTRY *he;
if (h == NULL || e == NULL)
rl_initialize();
- if (history(h, &ev, H_SETSIZE, max) == 0)
+ if (history(h, &ev, H_SETSIZE, max) == 0) {
max_input_history = max;
+ if (history_length > max)
+ history_base = history_length - max;
+ while (history_length > max) {
+ he = remove_history(0);
+ el_free(he->data);
+ el_free((void *)(unsigned long)he->line);
+ el_free(he);
+ }
+ }
}
@@ -1144,7 +1183,7 @@ unstifle_history(void)
history(h, &ev, H_SETSIZE, INT_MAX);
omax = max_input_history;
max_input_history = INT_MAX;
- return (omax); /* some value _must_ be returned */
+ return omax; /* some value _must_ be returned */
}
@@ -1153,7 +1192,7 @@ history_is_stifled(void)
{
/* cannot return true answer */
- return (max_input_history != INT_MAX);
+ return max_input_history != INT_MAX;
}
static const char _history_tmp_template[] = "/tmp/.historyXXXXXX";
@@ -1188,7 +1227,7 @@ history_truncate_file (const char *filename, int nlines)
}
for(;;) {
- if (fread(buf, sizeof(buf), 1, fp) != 1) {
+ if (fread(buf, sizeof(buf), (size_t)1, fp) != 1) {
if (ferror(fp)) {
ret = errno;
break;
@@ -1198,7 +1237,7 @@ history_truncate_file (const char *filename, int nlines)
ret = errno;
break;
}
- left = fread(buf, 1, sizeof(buf), fp);
+ left = (ssize_t)fread(buf, (size_t)1, sizeof(buf), fp);
if (ferror(fp)) {
ret = errno;
break;
@@ -1206,14 +1245,15 @@ history_truncate_file (const char *filename, int nlines)
if (left == 0) {
count--;
left = sizeof(buf);
- } else if (fwrite(buf, (size_t)left, 1, tp) != 1) {
+ } else if (fwrite(buf, (size_t)left, (size_t)1, tp)
+ != 1) {
ret = errno;
break;
}
fflush(tp);
break;
}
- if (fwrite(buf, sizeof(buf), 1, tp) != 1) {
+ if (fwrite(buf, sizeof(buf), (size_t)1, tp) != 1) {
ret = errno;
break;
}
@@ -1243,7 +1283,7 @@ history_truncate_file (const char *filename, int nlines)
ret = errno;
break;
}
- if (fread(buf, sizeof(buf), 1, tp) != 1) {
+ if (fread(buf, sizeof(buf), (size_t)1, tp) != 1) {
if (ferror(tp)) {
ret = errno;
break;
@@ -1257,7 +1297,7 @@ history_truncate_file (const char *filename, int nlines)
if (ret || nlines > 0)
goto out3;
- if (fseeko(fp, 0, SEEK_SET) == (off_t)-1) {
+ if (fseeko(fp, (off_t)0, SEEK_SET) == (off_t)-1) {
ret = errno;
goto out3;
}
@@ -1269,12 +1309,12 @@ history_truncate_file (const char *filename, int nlines)
}
for(;;) {
- if ((left = fread(buf, 1, sizeof(buf), tp)) == 0) {
+ if ((left = (ssize_t)fread(buf, (size_t)1, sizeof(buf), tp)) == 0) {
if (ferror(fp))
ret = errno;
break;
}
- if (fwrite(buf, (size_t)left, 1, fp) != 1) {
+ if (fwrite(buf, (size_t)left, (size_t)1, fp) != 1) {
ret = errno;
break;
}
@@ -1305,8 +1345,8 @@ read_history(const char *filename)
rl_initialize();
if (filename == NULL && (filename = _default_history_file()) == NULL)
return errno;
- return (history(h, &ev, H_LOAD, filename) == -1 ?
- (errno ? errno : EINVAL) : 0);
+ return history(h, &ev, H_LOAD, filename) == -1 ?
+ (errno ? errno : EINVAL) : 0;
}
@@ -1322,8 +1362,8 @@ write_history(const char *filename)
rl_initialize();
if (filename == NULL && (filename = _default_history_file()) == NULL)
return errno;
- return (history(h, &ev, H_SAVE, filename) == -1 ?
- (errno ? errno : EINVAL) : 0);
+ return history(h, &ev, H_SAVE, filename) == -1 ?
+ (errno ? errno : EINVAL) : 0;
}
@@ -1342,25 +1382,37 @@ history_get(int num)
if (h == NULL || e == NULL)
rl_initialize();
+ if (num < history_base)
+ return NULL;
+
/* save current position */
if (history(h, &ev, H_CURR) != 0)
- return (NULL);
+ return NULL;
curr_num = ev.num;
- /* start from the oldest */
- if (history(h, &ev, H_LAST) != 0)
- return (NULL); /* error */
-
- /* look forwards for event matching specified offset */
- if (history(h, &ev, H_NEXT_EVDATA, num, &she.data))
- return (NULL);
+ /*
+ * use H_DELDATA to set to nth history (without delete) by passing
+ * (void **)-1 -- as in history_set_pos
+ */
+ if (history(h, &ev, H_DELDATA, num - history_base, (void **)-1) != 0)
+ goto out;
+ /* get current entry */
+ if (history(h, &ev, H_CURR) != 0)
+ goto out;
+ if (history(h, &ev, H_NEXT_EVDATA, ev.num, &she.data) != 0)
+ goto out;
she.line = ev.str;
/* restore pointer to where it was */
(void)history(h, &ev, H_SET, curr_num);
- return (&she);
+ return &she;
+
+out:
+ /* restore pointer to where it was */
+ (void)history(h, &ev, H_SET, curr_num);
+ return NULL;
}
@@ -1375,11 +1427,15 @@ add_history(const char *line)
if (h == NULL || e == NULL)
rl_initialize();
- (void)history(h, &ev, H_ENTER, line);
- if (history(h, &ev, H_GETSIZE) == 0)
- history_length = ev.num;
+ if (history(h, &ev, H_ENTER, line) == -1)
+ return 0;
- return (!(history_length > 0)); /* return 0 if all is okay */
+ (void)history(h, &ev, H_GETSIZE);
+ if (ev.num == history_length)
+ history_base++;
+ else
+ history_length = ev.num;
+ return 0;
}
@@ -1395,11 +1451,11 @@ remove_history(int num)
if (h == NULL || e == NULL)
rl_initialize();
- if ((he = malloc(sizeof(*he))) == NULL)
+ if ((he = el_malloc(sizeof(*he))) == NULL)
return NULL;
if (history(h, &ev, H_DELDATA, num, &he->data) != 0) {
- free(he);
+ el_free(he);
return NULL;
}
@@ -1433,7 +1489,7 @@ replace_history_entry(int num, const char *line, histdata_t data)
if (history(h, &ev, H_LAST) != 0)
return NULL; /* error */
- if ((he = malloc(sizeof(*he))) == NULL)
+ if ((he = el_malloc(sizeof(*he))) == NULL)
return NULL;
/* look forwards for event matching specified offset */
@@ -1453,7 +1509,7 @@ replace_history_entry(int num, const char *line, histdata_t data)
return he;
out:
- free(he);
+ el_free(he);
return NULL;
}
@@ -1465,8 +1521,11 @@ clear_history(void)
{
HistEvent ev;
+ if (h == NULL || e == NULL)
+ rl_initialize();
+
(void)history(h, &ev, H_CLEAR);
- history_length = 0;
+ history_offset = history_length = 0;
}
@@ -1476,21 +1535,42 @@ clear_history(void)
int
where_history(void)
{
+ return history_offset;
+}
+
+static HIST_ENTRY **_history_listp;
+static HIST_ENTRY *_history_list;
+
+HIST_ENTRY **
+history_list(void)
+{
HistEvent ev;
- int curr_num, off;
+ HIST_ENTRY **nlp, *nl;
+ int i;
- if (history(h, &ev, H_CURR) != 0)
- return (0);
- curr_num = ev.num;
+ if (history(h, &ev, H_LAST) != 0)
+ return NULL;
- (void)history(h, &ev, H_FIRST);
- off = 1;
- while (ev.num != curr_num && history(h, &ev, H_NEXT) == 0)
- off++;
+ if ((nlp = el_realloc(_history_listp,
+ (size_t)history_length * sizeof(*nlp))) == NULL)
+ return NULL;
+ _history_listp = nlp;
- return (off);
-}
+ if ((nl = el_realloc(_history_list,
+ (size_t)history_length * sizeof(*nl))) == NULL)
+ return NULL;
+ _history_list = nl;
+ i = 0;
+ do {
+ _history_listp[i] = &_history_list[i];
+ _history_list[i].line = ev.str;
+ _history_list[i].data = NULL;
+ if (i++ == history_length)
+ abort();
+ } while (history(h, &ev, H_PREV) == 0);
+ return _history_listp;
+}
/*
* returns current history event or NULL if there is no such event
@@ -1498,8 +1578,14 @@ where_history(void)
HIST_ENTRY *
current_history(void)
{
+ HistEvent ev;
+
+ if (history(h, &ev, H_PREV_EVENT, history_offset + 1) != 0)
+ return NULL;
- return (_move_history(H_CURR));
+ rl_he.line = ev.str;
+ rl_he.data = NULL;
+ return &rl_he;
}
@@ -1514,7 +1600,7 @@ history_total_bytes(void)
size_t size;
if (history(h, &ev, H_CURR) != 0)
- return (-1);
+ return -1;
curr_num = ev.num;
(void)history(h, &ev, H_FIRST);
@@ -1526,7 +1612,7 @@ history_total_bytes(void)
/* get to the same position as before */
history(h, &ev, H_PREV_EVENT, curr_num);
- return (int)(size);
+ return (int)size;
}
@@ -1536,35 +1622,31 @@ history_total_bytes(void)
int
history_set_pos(int pos)
{
- HistEvent ev;
- int curr_num;
-
if (pos >= history_length || pos < 0)
- return (-1);
-
- (void)history(h, &ev, H_CURR);
- curr_num = ev.num;
+ return 0;
- /*
- * use H_DELDATA to set to nth history (without delete) by passing
- * (void **)-1
- */
- if (history(h, &ev, H_DELDATA, pos, (void **)-1)) {
- (void)history(h, &ev, H_SET, curr_num);
- return(-1);
- }
- return (0);
+ history_offset = pos;
+ return 1;
}
/*
* returns previous event in history and shifts pointer accordingly
+ * Note that readline and editline define directions in opposite ways.
*/
HIST_ENTRY *
previous_history(void)
{
+ HistEvent ev;
+
+ if (history_offset == 0)
+ return NULL;
- return (_move_history(H_PREV));
+ if (history(h, &ev, H_LAST) != 0)
+ return NULL;
+
+ history_offset--;
+ return current_history();
}
@@ -1574,8 +1656,16 @@ previous_history(void)
HIST_ENTRY *
next_history(void)
{
+ HistEvent ev;
+
+ if (history_offset >= history_length)
+ return NULL;
+
+ if (history(h, &ev, H_LAST) != 0)
+ return NULL;
- return (_move_history(H_NEXT));
+ history_offset++;
+ return current_history();
}
@@ -1590,17 +1680,17 @@ history_search(const char *str, int direction)
int curr_num;
if (history(h, &ev, H_CURR) != 0)
- return (-1);
+ return -1;
curr_num = ev.num;
for (;;) {
if ((strp = strstr(ev.str, str)) != NULL)
- return (int) (strp - ev.str);
+ return (int)(strp - ev.str);
if (history(h, &ev, direction < 0 ? H_NEXT:H_PREV) != 0)
break;
}
(void)history(h, &ev, H_SET, curr_num);
- return (-1);
+ return -1;
}
@@ -1633,15 +1723,15 @@ history_search_pos(const char *str,
pos = (pos > 0) ? 1 : -1;
if (history(h, &ev, H_CURR) != 0)
- return (-1);
+ return -1;
curr_num = ev.num;
- if (history_set_pos(off) != 0 || history(h, &ev, H_CURR) != 0)
- return (-1);
+ if (!history_set_pos(off) || history(h, &ev, H_CURR) != 0)
+ return -1;
for (;;) {
if (strstr(ev.str, str))
- return (off);
+ return off;
if (history(h, &ev, (pos < 0) ? H_PREV : H_NEXT) != 0)
break;
}
@@ -1650,7 +1740,7 @@ history_search_pos(const char *str,
(void)history(h, &ev,
pos < 0 ? H_NEXT_EVENT : H_PREV_EVENT, curr_num);
- return (-1);
+ return -1;
}
@@ -1673,16 +1763,20 @@ filename_completion_function(const char *name, int state)
* a completion generator for usernames; returns _first_ username
* which starts with supplied text
* text contains a partial username preceded by random character
- * (usually '~'); state is ignored
- * it's callers responsibility to free returned value
+ * (usually '~'); state resets search from start (??? should we do that anyway)
+ * it's the caller's responsibility to free the returned value
*/
char *
username_completion_function(const char *text, int state)
{
- struct passwd *pwd;
+#if defined(HAVE_GETPW_R_POSIX) || defined(HAVE_GETPW_R_DRAFT)
+ struct passwd pwres;
+ char pwbuf[1024];
+#endif
+ struct passwd *pass = NULL;
if (text[0] == '\0')
- return (NULL);
+ return NULL;
if (*text == '~')
text++;
@@ -1690,15 +1784,17 @@ username_completion_function(const char *text, int state)
if (state == 0)
setpwent();
- while ((pwd = getpwent())
- && pwd != NULL && text[0] == pwd->pw_name[0]
- && strcmp(text, pwd->pw_name) == 0);
+ while (
+ (pass = getpwent()) != NULL
+ && text[0] == pass->pw_name[0]
+ && strcmp(text, pass->pw_name) == 0)
+ continue;
- if (pwd == NULL) {
+ if (pass == NULL) {
endpwent();
return NULL;
}
- return strdup(pwd->pw_name);
+ return strdup(pass->pw_name);
}
@@ -1731,7 +1827,7 @@ _rl_completion_append_character_function(const char *dummy
__attribute__((__unused__)))
{
static char buf[2];
- buf[0] = rl_completion_append_character;
+ buf[0] = (char)rl_completion_append_character;
buf[1] = '\0';
return buf;
}
@@ -1744,9 +1840,8 @@ _rl_completion_append_character_function(const char *dummy
int
rl_complete(int ignore __attribute__((__unused__)), int invoking_key)
{
-#ifdef WIDECHAR
static ct_buffer_t wbreak_conv, sprefix_conv;
-#endif
+ char *breakchars;
if (h == NULL || e == NULL)
rl_initialize();
@@ -1756,15 +1851,22 @@ rl_complete(int ignore __attribute__((__unused__)), int invoking_key)
arr[0] = (char)invoking_key;
arr[1] = '\0';
el_insertstr(e, arr);
- return (CC_REFRESH);
+ return CC_REFRESH;
}
+ if (rl_completion_word_break_hook != NULL)
+ breakchars = (*rl_completion_word_break_hook)();
+ else
+ breakchars = rl_basic_word_break_characters;
+
+ _rl_update_pos();
+
/* Just look at how many global variables modify this operation! */
return fn_complete(e,
- (CPFunction *)rl_completion_entry_function,
+ (rl_compentry_func_t *)rl_completion_entry_function,
rl_attempted_completion_function,
ct_decode_string(rl_basic_word_break_characters, &wbreak_conv),
- ct_decode_string(rl_special_prefixes, &sprefix_conv),
+ ct_decode_string(breakchars, &sprefix_conv),
_rl_completion_append_character_function,
(size_t)rl_completion_query_items,
&rl_completion_type, &rl_attempted_completion_over,
@@ -1801,7 +1903,7 @@ rl_bind_key(int c, rl_command_func_t *func)
e->el_map.key[c] = ED_INSERT;
retval = 0;
}
- return (retval);
+ return retval;
}
@@ -1817,7 +1919,7 @@ rl_read_key(void)
if (e == NULL || h == NULL)
rl_initialize();
- return (el_getc(e, fooarr));
+ return el_getc(e, fooarr);
}
@@ -1847,32 +1949,33 @@ rl_insert(int count, int c)
rl_initialize();
/* XXX - int -> char conversion can lose on multichars */
- arr[0] = c;
+ arr[0] = (char)c;
arr[1] = '\0';
for (; count > 0; count--)
el_push(e, arr);
- return (0);
+ return 0;
}
int
rl_insert_text(const char *text)
{
if (!text || *text == 0)
- return (0);
+ return 0;
if (h == NULL || e == NULL)
rl_initialize();
if (el_insertstr(e, text) < 0)
- return (0);
+ return 0;
return (int)strlen(text);
}
/*ARGSUSED*/
int
-rl_newline(int count, int c)
+rl_newline(int count __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
/*
* Readline-4.0 appears to ignore the args.
@@ -1882,14 +1985,14 @@ rl_newline(int count, int c)
/*ARGSUSED*/
static unsigned char
-rl_bind_wrapper(EditLine *el, unsigned char c)
+rl_bind_wrapper(EditLine *el __attribute__((__unused__)), unsigned char c)
{
if (map[c] == NULL)
return CC_ERROR;
_rl_update_pos();
- (*map[c])(NULL, c);
+ (*map[c])(1, c);
/* If rl_done was set by the above call, deal with it here */
if (rl_done)
@@ -1899,7 +2002,7 @@ rl_bind_wrapper(EditLine *el, unsigned char c)
}
int
-rl_add_defun(const char *name, Function *fun, int c)
+rl_add_defun(const char *name, rl_command_func_t *fun, int c)
{
char dest[8];
if ((size_t)c >= sizeof(map) / sizeof(map[0]) || c < 0)
@@ -1907,12 +2010,12 @@ rl_add_defun(const char *name, Function *fun, int c)
map[(unsigned char)c] = fun;
el_set(e, EL_ADDFN, name, name, rl_bind_wrapper);
vis(dest, c, VIS_WHITE|VIS_NOSLASH, 0);
- el_set(e, EL_BIND, dest, name);
+ el_set(e, EL_BIND, dest, name, NULL);
return 0;
}
void
-rl_callback_read_char()
+rl_callback_read_char(void)
{
int count = 0, done = 0;
const char *buf = el_gets(e, &count);
@@ -1933,12 +2036,12 @@ rl_callback_read_char()
} else
wbuf = NULL;
(*(void (*)(const char *))rl_linefunc)(wbuf);
- //el_set(e, EL_UNBUFFERED, 1);
+ el_set(e, EL_UNBUFFERED, 1);
}
}
void
-rl_callback_handler_install(const char *prompt, VCPFunction *linefunc)
+rl_callback_handler_install(const char *prompt, rl_vcpfunc_t *linefunc)
{
if (e == NULL) {
rl_initialize();
@@ -1959,7 +2062,7 @@ void
rl_redisplay(void)
{
char a[2];
- a[0] = e->el_tty.t_c[TS_IO][C_REPRINT];
+ a[0] = (char)e->el_tty.t_c[TS_IO][C_REPRINT];
a[1] = '\0';
el_push(e, a);
}
@@ -1968,7 +2071,7 @@ int
rl_get_previous_history(int count, int key)
{
char a[2];
- a[0] = key;
+ a[0] = (char)key;
a[1] = '\0';
while (count--)
el_push(e, a);
@@ -1977,7 +2080,7 @@ rl_get_previous_history(int count, int key)
void
/*ARGSUSED*/
-rl_prep_terminal(int meta_flag)
+rl_prep_terminal(int meta_flag __attribute__((__unused__)))
{
el_set(e, EL_PREP_TERM, 1);
}
@@ -1991,7 +2094,7 @@ rl_deprep_terminal(void)
int
rl_read_init_file(const char *s)
{
- return(el_source(e, s));
+ return el_source(e, s);
}
int
@@ -2005,7 +2108,7 @@ rl_parse_and_bind(const char *line)
tok_str(tok, line, &argc, &argv);
argc = el_parse(e, argc, argv);
tok_end(tok);
- return (argc ? 1 : 0);
+ return argc ? 1 : 0;
}
int
@@ -2015,7 +2118,7 @@ rl_variable_bind(const char *var, const char *value)
* The proper return value is undocument, but this is what the
* readline source seems to do.
*/
- return ((el_set(e, EL_BIND, "", var, value) == -1) ? 1 : 0);
+ return el_set(e, EL_BIND, "", var, value, NULL) == -1 ? 1 : 0;
}
void
@@ -2023,41 +2126,43 @@ rl_stuff_char(int c)
{
char buf[2];
- buf[0] = c;
+ buf[0] = (char)c;
buf[1] = '\0';
el_insertstr(e, buf);
}
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)();
#if defined(FIONREAD)
if (ioctl(el->el_infd, FIONREAD, &n) < 0)
- return(-1);
+ return -1;
if (n)
- num_read = read(el->el_infd, cp, 1);
+ num_read = read(el->el_infd, &ch, (size_t)1);
else
num_read = 0;
#elif defined(F_SETFL) && defined(O_NDELAY)
if ((n = fcntl(el->el_infd, F_GETFL, 0)) < 0)
- return(-1);
+ return -1;
if (fcntl(el->el_infd, F_SETFL, n|O_NDELAY) < 0)
- return(-1);
- num_read = read(el->el_infd, cp, 1);
+ return -1;
+ num_read = read(el->el_infd, &ch, 1);
if (fcntl(el->el_infd, F_SETFL, n))
- return(-1);
+ return -1;
#else
/* not non-blocking, but what you gonna do? */
- num_read = read(el->el_infd, cp, 1);
- return(-1);
+ num_read = read(el->el_infd, &ch, 1);
+ return -1;
#endif
if (num_read < 0 && errno == EAGAIN)
@@ -2068,6 +2173,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;
}
@@ -2084,9 +2190,9 @@ void
rl_get_screen_size(int *rows, int *cols)
{
if (rows)
- el_get(e, EL_GETTC, "li", rows);
+ el_get(e, EL_GETTC, "li", rows, (void *)0);
if (cols)
- el_get(e, EL_GETTC, "co", cols);
+ el_get(e, EL_GETTC, "co", cols, (void *)0);
}
void
@@ -2094,9 +2200,9 @@ rl_set_screen_size(int rows, int cols)
{
char buf[64];
(void)snprintf(buf, sizeof(buf), "%d", rows);
- el_set(e, EL_SETTC, "li", buf);
+ el_set(e, EL_SETTC, "li", buf, NULL);
(void)snprintf(buf, sizeof(buf), "%d", cols);
- el_set(e, EL_SETTC, "co", buf);
+ el_set(e, EL_SETTC, "co", buf, NULL);
}
char **
@@ -2107,7 +2213,7 @@ rl_completion_matches(const char *str, rl_compentry_func_t *fun)
len = 1;
max = 10;
- if ((list = malloc(max * sizeof(*list))) == NULL)
+ if ((list = el_malloc(max * sizeof(*list))) == NULL)
return NULL;
while ((match = (*fun)(str, (int)(len - 1))) != NULL) {
@@ -2115,7 +2221,7 @@ rl_completion_matches(const char *str, rl_compentry_func_t *fun)
if (len == max) {
char **nl;
max += 10;
- if ((nl = realloc(list, max * sizeof(*nl))) == NULL)
+ if ((nl = el_realloc(list, max * sizeof(*nl))) == NULL)
goto out;
list = nl;
}
@@ -2130,7 +2236,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++)
@@ -2142,7 +2248,7 @@ rl_completion_matches(const char *str, rl_compentry_func_t *fun)
if ((list[0] = strdup(str)) == NULL)
goto out;
} else {
- if ((list[0] = malloc(min + 1)) == NULL)
+ if ((list[0] = el_malloc((min + 1) * sizeof(*list[0]))) == NULL)
goto out;
(void)memcpy(list[0], list[1], min);
list[0][min] = '\0';
@@ -2150,7 +2256,7 @@ rl_completion_matches(const char *str, rl_compentry_func_t *fun)
return list;
out:
- free(list);
+ el_free(list);
return NULL;
}
@@ -2185,15 +2291,16 @@ history_get_history_state(void)
{
HISTORY_STATE *hs;
- if ((hs = malloc(sizeof(HISTORY_STATE))) == NULL)
- return (NULL);
+ if ((hs = el_malloc(sizeof(*hs))) == NULL)
+ return NULL;
hs->length = history_length;
- return (hs);
+ return hs;
}
int
/*ARGSUSED*/
-rl_kill_text(int from, int to)
+rl_kill_text(int from __attribute__((__unused__)),
+ int to __attribute__((__unused__)))
{
return 0;
}
@@ -2212,20 +2319,25 @@ rl_get_keymap(void)
void
/*ARGSUSED*/
-rl_set_keymap(Keymap k)
+rl_set_keymap(Keymap k __attribute__((__unused__)))
{
}
int
/*ARGSUSED*/
-rl_generic_bind(int type, const char * keyseq, const char * data, Keymap k)
+rl_generic_bind(int type __attribute__((__unused__)),
+ const char * keyseq __attribute__((__unused__)),
+ const char * data __attribute__((__unused__)),
+ Keymap k __attribute__((__unused__)))
{
return 0;
}
int
/*ARGSUSED*/
-rl_bind_key_in_map(int key, rl_command_func_t *fun, Keymap k)
+rl_bind_key_in_map(int key __attribute__((__unused__)),
+ rl_command_func_t *fun __attribute__((__unused__)),
+ Keymap k __attribute__((__unused__)))
{
return 0;
}
@@ -2241,3 +2353,15 @@ rl_on_new_line(void)
{
return 0;
}
+
+void
+rl_free_line_state(void)
+{
+}
+
+int
+/*ARGSUSED*/
+rl_set_keyboard_input_timeout(int u __attribute__((__unused__)))
+{
+ return 0;
+}