summaryrefslogtreecommitdiff
path: root/lib/libedit
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2022-01-31 14:44:49 +0000
committerchristos <christos@NetBSD.org>2022-01-31 14:44:49 +0000
commit2feacb00703d9913c4c9cd886c7b971b9a4abfeb (patch)
treed0791cd867dc8b7007c9e12630581a79eb56d77a /lib/libedit
parentbdf84b8b7e4f83234e50a67401b2c064a2a9a195 (diff)
PR/56622: Walter Lozano: Improve readline compatibility by adding
rl_readline_state support.
Diffstat (limited to 'lib/libedit')
-rw-r--r--lib/libedit/readline.c9
-rw-r--r--lib/libedit/readline/readline.h9
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/libedit/readline.c b/lib/libedit/readline.c
index d8cbc24060b..79a8e5da34d 100644
--- a/lib/libedit/readline.c
+++ b/lib/libedit/readline.c
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.c,v 1.170 2022/01/29 20:52:45 christos Exp $ */
+/* $NetBSD: readline.c,v 1.171 2022/01/31 14:44:49 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.170 2022/01/29 20:52:45 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.171 2022/01/31 14:44:49 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -128,7 +128,7 @@ VFunction *rl_completion_display_matches_hook = NULL;
VFunction *rl_prep_term_function = (VFunction *)rl_prep_terminal;
VFunction *rl_deprep_term_function = (VFunction *)rl_deprep_terminal;
KEYMAP_ENTRY_ARRAY emacs_meta_keymap;
-unsigned long rl_readline_state;
+unsigned long rl_readline_state = RL_STATE_NONE;
int _rl_complete_mark_directories;
rl_icppfunc_t *rl_directory_completion_hook;
int rl_completion_suppress_append;
@@ -311,6 +311,8 @@ rl_initialize(void)
if (h != NULL)
history_end(h);
+ RL_UNSETSTATE(RL_STATE_DONE);
+
if (!rl_instream)
rl_instream = stdin;
if (!rl_outstream)
@@ -2145,6 +2147,7 @@ rl_callback_read_char(void)
if (done == 2) {
if ((wbuf = strdup(buf)) != NULL)
wbuf[count] = '\0';
+ RL_SETSTATE(RL_STATE_DONE);
} else
wbuf = NULL;
(*(void (*)(const char *))rl_linefunc)(wbuf);
diff --git a/lib/libedit/readline/readline.h b/lib/libedit/readline/readline.h
index c17ccc653ea..56e17f21ff5 100644
--- a/lib/libedit/readline/readline.h
+++ b/lib/libedit/readline/readline.h
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.h,v 1.50 2022/01/14 13:31:05 christos Exp $ */
+/* $NetBSD: readline.h,v 1.51 2022/01/31 14:44:49 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -94,6 +94,13 @@ typedef KEYMAP_ENTRY *Keymap;
#define RL_PROMPT_START_IGNORE '\1'
#define RL_PROMPT_END_IGNORE '\2'
+#define RL_STATE_NONE 0x000000
+#define RL_STATE_DONE 0x000001
+
+#define RL_SETSTATE(x) (rl_readline_state |= ((unsigned long) x))
+#define RL_UNSETSTATE(x) (rl_readline_state &= ~((unsigned long) x))
+#define RL_ISSTATE(x) (rl_readline_state & ((unsigned long) x))
+
/* global variables used by readline enabled applications */
#ifdef __cplusplus
extern "C" {