summaryrefslogtreecommitdiff
path: root/lib/readline
diff options
context:
space:
mode:
Diffstat (limited to 'lib/readline')
-rw-r--r--lib/readline/bind.c28
-rw-r--r--lib/readline/display.c20
-rw-r--r--lib/readline/doc/rluser.texi3
-rw-r--r--lib/readline/readline.c3
-rw-r--r--lib/readline/rlconf.h1
-rw-r--r--lib/readline/terminal.c5
-rw-r--r--lib/readline/text.c8
7 files changed, 47 insertions, 21 deletions
diff --git a/lib/readline/bind.c b/lib/readline/bind.c
index 7559d32..1a804b5 100644
--- a/lib/readline/bind.c
+++ b/lib/readline/bind.c
@@ -723,6 +723,9 @@ rl_function_of_keyseq (keyseq, map, type)
/* The last key bindings file read. */
static char *last_readline_init_file = (char *)NULL;
+/* Flag to read system init file */
+static int read_system_init_file = 0;
+
/* The file we're currently reading key bindings from. */
static const char *current_readline_init_file;
static int current_readline_init_include_level;
@@ -790,7 +793,7 @@ rl_re_read_init_file (count, ignore)
to the first non-null filename from this list:
1. the filename used for the previous call
2. the value of the shell variable `INPUTRC'
- 3. ~/.inputrc
+ 3. /etc/inputrc and ~/.inputrc
If the file existed and could be opened and read, 0 is returned,
otherwise errno is returned. */
int
@@ -801,14 +804,31 @@ rl_read_init_file (filename)
if (filename == 0)
{
filename = last_readline_init_file;
- if (filename == 0)
+ if (filename == 0) {
filename = sh_get_env_value ("INPUTRC");
- if (filename == 0)
+ read_system_init_file = 0;
+ }
+ if (filename == 0) {
filename = DEFAULT_INPUTRC;
+ read_system_init_file = 1;
+ }
}
- if (*filename == 0)
+ if (*filename == 0) {
filename = DEFAULT_INPUTRC;
+ read_system_init_file = 1;
+ }
+
+ if (read_system_init_file)
+ if (filename == last_readline_init_file)
+ {
+ filename = savestring (filename);
+ _rl_read_init_file (SYSTEM_INPUTRC, 0);
+ free (last_readline_init_file);
+ last_readline_init_file = filename;
+ }
+ else
+ _rl_read_init_file (SYSTEM_INPUTRC, 0);
#if defined (__MSDOS__)
if (_rl_read_init_file (filename, 0) == 0)
diff --git a/lib/readline/display.c b/lib/readline/display.c
index b22521b..0d3ae6e 100644
--- a/lib/readline/display.c
+++ b/lib/readline/display.c
@@ -1983,11 +1983,15 @@ _rl_make_prompt_for_search (pchar)
int pchar;
{
int len;
- char *pmt;
+ char *pmt, *p;
rl_save_prompt ();
- if (saved_local_prompt == 0)
+ /* We've saved the prompt, and can do anything with the various prompt
+ strings we need before they're restored. We want the unexpanded
+ portion of the prompt string after any final newline. */
+ p = rl_prompt ? strrchr (rl_prompt, '\n') : 0;
+ if (p == 0)
{
len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0;
pmt = (char *)xmalloc (len + 2);
@@ -1998,19 +2002,17 @@ _rl_make_prompt_for_search (pchar)
}
else
{
- len = *saved_local_prompt ? strlen (saved_local_prompt) : 0;
+ p++;
+ len = strlen (p);
pmt = (char *)xmalloc (len + 2);
if (len)
- strcpy (pmt, saved_local_prompt);
+ strcpy (pmt, p);
pmt[len] = pchar;
pmt[len+1] = '\0';
- local_prompt = savestring (pmt);
- prompt_last_invisible = saved_last_invisible;
- prompt_visible_length = saved_visible_length + 1;
- }
+ }
+ /* will be overwritten by expand_prompt, called from rl_message */
prompt_physical_chars = saved_physical_chars + 1;
-
return pmt;
}
diff --git a/lib/readline/doc/rluser.texi b/lib/readline/doc/rluser.texi
index 478b41f..a689550 100644
--- a/lib/readline/doc/rluser.texi
+++ b/lib/readline/doc/rluser.texi
@@ -336,7 +336,8 @@ file is taken from the value of the shell variable @env{INPUTRC}. If
@ifclear BashFeatures
file is taken from the value of the environment variable @env{INPUTRC}. If
@end ifclear
-that variable is unset, the default is @file{~/.inputrc}.
+that variable is unset, Readline will read both @file{/etc/inputrc} and
+@file{~/.inputrc}.
When a program which uses the Readline library starts up, the
init file is read, and the key bindings are set.
diff --git a/lib/readline/readline.c b/lib/readline/readline.c
index 5e9767a..5eaaf47 100644
--- a/lib/readline/readline.c
+++ b/lib/readline/readline.c
@@ -282,6 +282,7 @@ rl_set_prompt (prompt)
{
FREE (rl_prompt);
rl_prompt = prompt ? savestring (prompt) : (char *)NULL;
+ rl_display_prompt = rl_prompt ? rl_prompt : "";
rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
return 0;
@@ -714,7 +715,7 @@ _rl_dispatch_subseq (key, map, got_subseq)
rl_dispatching = 1;
RL_SETSTATE(RL_STATE_DISPATCHING);
- r = (*map[key].function)(rl_numeric_arg * rl_arg_sign, key);
+ (*map[key].function)(rl_numeric_arg * rl_arg_sign, key);
RL_UNSETSTATE(RL_STATE_DISPATCHING);
rl_dispatching = 0;
diff --git a/lib/readline/rlconf.h b/lib/readline/rlconf.h
index c651fd8..090adb8 100644
--- a/lib/readline/rlconf.h
+++ b/lib/readline/rlconf.h
@@ -39,6 +39,7 @@
/* The final, last-ditch effort file name for an init file. */
#define DEFAULT_INPUTRC "~/.inputrc"
+#define SYSTEM_INPUTRC "/etc/inputrc"
/* If defined, expand tabs to spaces. */
#define DISPLAY_TABS
diff --git a/lib/readline/terminal.c b/lib/readline/terminal.c
index cc61388..eb72c19 100644
--- a/lib/readline/terminal.c
+++ b/lib/readline/terminal.c
@@ -122,7 +122,7 @@ char *_rl_term_up;
static char *_rl_visible_bell;
/* Non-zero means the terminal can auto-wrap lines. */
-int _rl_term_autowrap;
+int _rl_term_autowrap = -1;
/* Non-zero means that this terminal has a meta key. */
static int term_has_meta;
@@ -274,6 +274,9 @@ void
_rl_set_screen_size (rows, cols)
int rows, cols;
{
+ if (_rl_term_autowrap == -1)
+ _rl_init_terminal_io (rl_terminal_name);
+
if (rows > 0)
_rl_screenheight = rows;
if (cols > 0)
diff --git a/lib/readline/text.c b/lib/readline/text.c
index 9053e96..bb87604 100644
--- a/lib/readline/text.c
+++ b/lib/readline/text.c
@@ -1071,8 +1071,6 @@ int
rl_delete (count, key)
int count, key;
{
- int r;
-
if (count < 0)
return (_rl_rubout_char (-count, key));
@@ -1090,17 +1088,17 @@ rl_delete (count, key)
else
rl_forward_byte (count, key);
- r = rl_kill_text (orig_point, rl_point);
+ rl_kill_text (orig_point, rl_point);
rl_point = orig_point;
- return r;
}
else
{
int new_point;
new_point = MB_NEXTCHAR (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO);
- return (rl_delete_text (rl_point, new_point));
+ rl_delete_text (rl_point, new_point);
}
+ return 0;
}
/* Delete the character under the cursor, unless the insertion