diff options
| author | christos <christos@NetBSD.org> | 2009-03-31 17:53:03 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2009-03-31 17:53:03 +0000 |
| commit | e6ec3d065cc04727ae7c9511ceecab2f9754ebc6 (patch) | |
| tree | f254af353bd9471b7de06ae6d651c6b146dee98a /lib/libedit | |
| parent | c8754a5b44108dcc32d67b214f3ddaeec4f75149 (diff) | |
implement RL_PROMPT_{START,END}_IGNORE
Diffstat (limited to 'lib/libedit')
| -rw-r--r-- | lib/libedit/readline.c | 16 | ||||
| -rw-r--r-- | lib/libedit/readline/readline.h | 4 |
2 files changed, 15 insertions, 5 deletions
diff --git a/lib/libedit/readline.c b/lib/libedit/readline.c index fef69895cb2..20ab4040a10 100644 --- a/lib/libedit/readline.c +++ b/lib/libedit/readline.c @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.81 2009/02/21 23:31:56 christos Exp $ */ +/* $NetBSD: readline.c,v 1.82 2009/03/31 17:53:03 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.81 2009/02/21 23:31:56 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.82 2009/03/31 17:53:03 christos Exp $"); #endif /* not lint && not SCCSID */ #include <sys/types.h> @@ -225,6 +225,8 @@ _getc_function(EditLine *el, char *c) int rl_set_prompt(const char *prompt) { + char *p; + if (!prompt) prompt = ""; if (rl_prompt != NULL && strcmp(rl_prompt, prompt) == 0) @@ -232,7 +234,13 @@ rl_set_prompt(const char *prompt) if (rl_prompt) free(rl_prompt); rl_prompt = strdup(prompt); - return rl_prompt == NULL ? -1 : 0; + if (rl_prompt == NULL) + return -1; + + while ((p = strchr(rl_prompt, RL_PROMPT_END_IGNORE)) != NULL) + *p = RL_PROMPT_START_IGNORE; + + return 0; } /* @@ -286,7 +294,7 @@ rl_initialize(void) el_end(e); return -1; } - el_set(e, EL_PROMPT, _get_prompt); + el_set(e, EL_PROMPT, _get_prompt, RL_PROMPT_START_IGNORE); el_set(e, EL_SIGNAL, rl_catch_signals); /* set default mode to "emacs"-style and read setting afterwards */ diff --git a/lib/libedit/readline/readline.h b/lib/libedit/readline/readline.h index 53ae1dc39d6..2fc08fc2767 100644 --- a/lib/libedit/readline/readline.h +++ b/lib/libedit/readline/readline.h @@ -1,4 +1,4 @@ -/* $NetBSD: readline.h,v 1.25 2009/02/12 13:39:49 sketch Exp $ */ +/* $NetBSD: readline.h,v 1.26 2009/03/31 17:53:03 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -79,6 +79,8 @@ typedef KEYMAP_ENTRY *Keymap; #define RUBOUT 0x7f #define ABORT_CHAR CTRL('G') +#define RL_PROMPT_START_IGNORE '\1' +#define RL_PROMPT_END_IGNORE '\2' /* global variables used by readline enabled applications */ #ifdef __cplusplus |
