commit bash-20050106 snapshot

This commit is contained in:
Chet Ramey
2011-12-03 13:42:09 -05:00
parent 01ed5ba4e7
commit 6e70dbff65
25 changed files with 598 additions and 115 deletions
+55 -28
View File
@@ -185,6 +185,18 @@ static int prompt_last_screen_line;
static int prompt_physical_chars;
/* Variables to save and restore prompt and display information. */
/* These are getting numerous enough that it's time to create a struct. */
static char *saved_local_prompt;
static char *saved_local_prefix;
static int saved_last_invisible;
static int saved_visible_length;
static int saved_prefix_length;
static int saved_invis_chars_first_line;
static int saved_physical_chars;
/* Expand the prompt string S and return the number of visible
characters in *LP, if LP is not null. This is currently more-or-less
a placeholder for expansion. LIP, if non-null is a place to store the
@@ -1812,9 +1824,9 @@ rl_character_len (c, pos)
return ((ISPRINT (uc)) ? 1 : 2);
}
/* How to print things in the "echo-area". The prompt is treated as a
mini-modeline. */
static int msg_saved_prompt = 0;
#if defined (USE_VARARGS)
int
@@ -1845,8 +1857,19 @@ rl_message (va_alist)
#endif
va_end (args);
if (saved_local_prompt == 0)
{
rl_save_prompt ();
msg_saved_prompt = 1;
}
rl_display_prompt = msg_buf;
local_prompt = expand_prompt (msg_buf, &prompt_visible_length,
&prompt_last_invisible,
&prompt_invis_chars_first_line,
&prompt_physical_chars);
local_prompt_prefix = (char *)NULL;
(*rl_redisplay_function) ();
return 0;
}
#else /* !USE_VARARGS */
@@ -1856,8 +1879,20 @@ rl_message (format, arg1, arg2)
{
sprintf (msg_buf, format, arg1, arg2);
msg_buf[sizeof(msg_buf) - 1] = '\0'; /* overflow? */
rl_display_prompt = msg_buf;
if (saved_local_prompt == 0)
{
rl_save_prompt ();
msg_saved_prompt = 1;
}
local_prompt = expand_prompt (msg_buf, &prompt_visible_length,
&prompt_last_invisible,
&prompt_invis_chars_first_line,
&prompt_physical_chars);
local_prompt_prefix = (char *)NULL;
(*rl_redisplay_function) ();
return 0;
}
#endif /* !USE_VARARGS */
@@ -1867,6 +1902,11 @@ int
rl_clear_message ()
{
rl_display_prompt = rl_prompt;
if (msg_saved_prompt)
{
rl_restore_prompt ();
msg_saved_prompt = 0;
}
(*rl_redisplay_function) ();
return 0;
}
@@ -1881,27 +1921,19 @@ rl_reset_line_state ()
return 0;
}
/* These are getting numerous enough that it's time to create a struct. */
static char *saved_local_prompt;
static char *saved_local_prefix;
static int saved_last_invisible;
static int saved_visible_length;
static int saved_invis_chars_first_line;
static int saved_physical_chars;
void
rl_save_prompt ()
{
saved_local_prompt = local_prompt;
saved_local_prefix = local_prompt_prefix;
saved_prefix_length = prompt_prefix_length;
saved_last_invisible = prompt_last_invisible;
saved_visible_length = prompt_visible_length;
saved_invis_chars_first_line = prompt_invis_chars_first_line;
saved_physical_chars = prompt_physical_chars;
local_prompt = local_prompt_prefix = (char *)0;
prompt_last_invisible = prompt_visible_length = 0;
prompt_last_invisible = prompt_visible_length = prompt_prefix_length = 0;
prompt_invis_chars_first_line = prompt_physical_chars = 0;
}
@@ -1913,10 +1945,16 @@ rl_restore_prompt ()
local_prompt = saved_local_prompt;
local_prompt_prefix = saved_local_prefix;
prompt_prefix_length = saved_prefix_length;
prompt_last_invisible = saved_last_invisible;
prompt_visible_length = saved_visible_length;
prompt_invis_chars_first_line = saved_invis_chars_first_line;
prompt_physical_chars = saved_physical_chars;
/* can test saved_local_prompt to see if prompt info has been saved. */
saved_local_prompt = saved_local_prefix = (char *)0;
saved_last_invisible = saved_visible_length = saved_prefix_length = 0;
saved_invis_chars_first_line = saved_physical_chars = 0;
}
char *
@@ -1950,6 +1988,8 @@ _rl_make_prompt_for_search (pchar)
prompt_visible_length = saved_visible_length + 1;
}
prompt_physical_chars = saved_physical_chars + 1;
return pmt;
}
@@ -2125,18 +2165,10 @@ static void
redraw_prompt (t)
char *t;
{
char *oldp, *oldl, *oldlprefix;
int oldlen, oldlast, oldplen, oldninvis, oldphyschars;
char *oldp;
/* Geez, I should make this a struct. */
oldp = rl_display_prompt;
oldl = local_prompt;
oldlprefix = local_prompt_prefix;
oldlen = prompt_visible_length;
oldplen = prompt_prefix_length;
oldlast = prompt_last_invisible;
oldninvis = prompt_invis_chars_first_line;
oldphyschars = prompt_physical_chars;
rl_save_prompt ();
rl_display_prompt = t;
local_prompt = expand_prompt (t, &prompt_visible_length,
@@ -2144,16 +2176,11 @@ redraw_prompt (t)
&prompt_invis_chars_first_line,
&prompt_physical_chars);
local_prompt_prefix = (char *)NULL;
rl_forced_update_display ();
rl_display_prompt = oldp;
local_prompt = oldl;
local_prompt_prefix = oldlprefix;
prompt_visible_length = oldlen;
prompt_prefix_length = oldplen;
prompt_last_invisible = oldlast;
prompt_invis_chars_first_line = oldninvis;
prompt_physical_chars = oldphyschars;
rl_restore_prompt();
}
/* Redisplay the current line after a SIGWINCH is received. */
+9 -17
View File
@@ -340,7 +340,8 @@ rl_expand_prompt (prompt)
FREE (local_prompt_prefix);
local_prompt = local_prompt_prefix = (char *)0;
prompt_last_invisible = prompt_visible_length = 0;
prompt_last_invisible = prompt_invis_chars_first_line = 0;
prompt_visible_length = prompt_physical_chars = 0;
if (prompt == 0 || *prompt == 0)
return (0);
@@ -883,12 +884,10 @@ rl_redisplay ()
(wrap_offset > visible_wrap_offset) &&
(_rl_last_c_pos < visible_first_line_len))
{
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
nleft = _rl_screenwidth - _rl_last_c_pos;
else
#endif
nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;
nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;
if (nleft)
_rl_clear_to_eol (nleft);
}
@@ -924,11 +923,7 @@ rl_redisplay ()
the physical cursor position on the screen stays the same,
but the buffer position needs to be adjusted to account
for invisible characters. */
#if defined (HANDLE_MULTIBYTE)
if ((MB_CUR_MAX == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset)
#else
if (cursor_linenum == 0 && wrap_offset)
#endif
_rl_last_c_pos += wrap_offset;
}
@@ -970,8 +965,11 @@ rl_redisplay ()
tx = _rl_col_width (&visible_line[pos], 0, nleft);
else
tx = nleft;
_rl_backspace (_rl_last_c_pos - tx); /* XXX */
_rl_last_c_pos = tx;
if (_rl_last_c_pos != tx)
{
_rl_backspace (_rl_last_c_pos - tx); /* XXX */
_rl_last_c_pos = tx;
}
}
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
@@ -1132,12 +1130,10 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
the exact cursor position and cut-and-paste with certain terminal
emulators. In this calculation, TEMP is the physical screen
position of the cursor. */
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
temp = _rl_last_c_pos;
else
#endif
temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
&& _rl_last_v_pos == current_line - 1)
{
@@ -1343,11 +1339,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if (_rl_last_v_pos != current_line)
{
_rl_move_vert (current_line);
#if defined (HANDLE_MULTIBYTE)
if ((MB_CUR_MAX == 1 || rl_byte_oriented) && current_line == 0 && visible_wrap_offset)
#else
if (current_line == 0 && visible_wrap_offset)
#endif
_rl_last_c_pos += visible_wrap_offset;
}
+47 -29
View File
@@ -185,6 +185,18 @@ static int prompt_last_screen_line;
static int prompt_physical_chars;
/* Variables to save and restore prompt and display information. */
/* These are getting numerous enough that it's time to create a struct. */
static char *saved_local_prompt;
static char *saved_local_prefix;
static int saved_last_invisible;
static int saved_visible_length;
static int saved_prefix_length;
static int saved_invis_chars_first_line;
static int saved_physical_chars;
/* Expand the prompt string S and return the number of visible
characters in *LP, if LP is not null. This is currently more-or-less
a placeholder for expansion. LIP, if non-null is a place to store the
@@ -340,7 +352,8 @@ rl_expand_prompt (prompt)
FREE (local_prompt_prefix);
local_prompt = local_prompt_prefix = (char *)0;
prompt_last_invisible = prompt_visible_length = 0;
prompt_last_invisible = prompt_invis_chars_first_line = 0;
prompt_visible_length = prompt_physical_chars = 0;
if (prompt == 0 || *prompt == 0)
return (0);
@@ -1811,9 +1824,9 @@ rl_character_len (c, pos)
return ((ISPRINT (uc)) ? 1 : 2);
}
/* How to print things in the "echo-area". The prompt is treated as a
mini-modeline. */
static int msg_saved_prompt = 0;
#if defined (USE_VARARGS)
int
@@ -1845,7 +1858,13 @@ rl_message (va_alist)
va_end (args);
rl_display_prompt = msg_buf;
if (saved_local_prompt == 0)
{
rl_save_prompt ();
msg_saved_prompt = 1;
}
(*rl_redisplay_function) ();
return 0;
}
#else /* !USE_VARARGS */
@@ -1855,8 +1874,15 @@ rl_message (format, arg1, arg2)
{
sprintf (msg_buf, format, arg1, arg2);
msg_buf[sizeof(msg_buf) - 1] = '\0'; /* overflow? */
rl_display_prompt = msg_buf;
if (saved_local_prompt == 0)
{
rl_save_prompt ();
msg_saved_prompt = 1;
}
(*rl_redisplay_function) ();
return 0;
}
#endif /* !USE_VARARGS */
@@ -1866,6 +1892,11 @@ int
rl_clear_message ()
{
rl_display_prompt = rl_prompt;
if (msg_saved_prompt)
{
rl_restore_prompt ();
msg_saved_prompt = 0;
}
(*rl_redisplay_function) ();
return 0;
}
@@ -1880,27 +1911,19 @@ rl_reset_line_state ()
return 0;
}
/* These are getting numerous enough that it's time to create a struct. */
static char *saved_local_prompt;
static char *saved_local_prefix;
static int saved_last_invisible;
static int saved_visible_length;
static int saved_invis_chars_first_line;
static int saved_physical_chars;
void
rl_save_prompt ()
{
saved_local_prompt = local_prompt;
saved_local_prefix = local_prompt_prefix;
saved_prefix_length = prompt_prefix_length;
saved_last_invisible = prompt_last_invisible;
saved_visible_length = prompt_visible_length;
saved_invis_chars_first_line = prompt_invis_chars_first_line;
saved_physical_chars = prompt_physical_chars;
local_prompt = local_prompt_prefix = (char *)0;
prompt_last_invisible = prompt_visible_length = 0;
prompt_last_invisible = prompt_visible_length = prompt_prefix_length = 0;
prompt_invis_chars_first_line = prompt_physical_chars = 0;
}
@@ -1912,10 +1935,16 @@ rl_restore_prompt ()
local_prompt = saved_local_prompt;
local_prompt_prefix = saved_local_prefix;
prompt_prefix_length = saved_prefix_length;
prompt_last_invisible = saved_last_invisible;
prompt_visible_length = saved_visible_length;
prompt_invis_chars_first_line = saved_invis_chars_first_line;
prompt_physical_chars = saved_physical_chars;
/* can test saved_local_prompt to see if prompt info has been saved. */
saved_local_prompt = saved_local_prefix = (char *)0;
saved_last_invisible = saved_visible_length = saved_prefix_length = 0;
saved_invis_chars_first_line = saved_physical_chars = 0;
}
char *
@@ -1949,6 +1978,8 @@ _rl_make_prompt_for_search (pchar)
prompt_visible_length = saved_visible_length + 1;
}
prompt_physical_chars = saved_physical_chars + 1;
return pmt;
}
@@ -2124,18 +2155,10 @@ static void
redraw_prompt (t)
char *t;
{
char *oldp, *oldl, *oldlprefix;
int oldlen, oldlast, oldplen, oldninvis, oldphyschars;
char *oldp;
/* Geez, I should make this a struct. */
oldp = rl_display_prompt;
oldl = local_prompt;
oldlprefix = local_prompt_prefix;
oldlen = prompt_visible_length;
oldplen = prompt_prefix_length;
oldlast = prompt_last_invisible;
oldninvis = prompt_invis_chars_first_line;
oldphyschars = prompt_physical_chars;
rl_save_prompt ();
rl_display_prompt = t;
local_prompt = expand_prompt (t, &prompt_visible_length,
@@ -2143,16 +2166,11 @@ redraw_prompt (t)
&prompt_invis_chars_first_line,
&prompt_physical_chars);
local_prompt_prefix = (char *)NULL;
rl_forced_update_display ();
rl_display_prompt = oldp;
local_prompt = oldl;
local_prompt_prefix = oldlprefix;
prompt_visible_length = oldlen;
prompt_prefix_length = oldplen;
prompt_last_invisible = oldlast;
prompt_invis_chars_first_line = oldninvis;
prompt_physical_chars = oldphyschars;
rl_restore_prompt();
}
/* Redisplay the current line after a SIGWINCH is received. */
+8 -1
View File
@@ -911,10 +911,14 @@ possibly containing conversion specifications such as @samp{%d}, and
any additional arguments necessary to satisfy the conversion specifications.
The resulting string is displayed in the @dfn{echo area}. The echo area
is also used to display numeric arguments and search strings.
You should call @code{rl_save_prompt} to save the prompt information
before calling this function.
@end deftypefun
@deftypefun int rl_clear_message (void)
Clear the message in the echo area.
Clear the message in the echo area. If the prompt was saved with a call to
@code{rl_save_prompt} before the last call to @code{rl_message},
call @code{rl_restore_prompt} before calling this function.
@end deftypefun
@deftypefun void rl_save_prompt (void)
@@ -925,6 +929,9 @@ displaying a new message in the message area with @code{rl_message()}.
@deftypefun void rl_restore_prompt (void)
Restore the local Readline prompt display state saved by the most
recent call to @code{rl_save_prompt}.
if @code{rl_save_prompt} was called to save the prompt before a call
to @code{rl_message}, this function should be called before the
corresponding call to @coode{rl_clear_message}.
@end deftypefun
@deftypefun int rl_expand_prompt (char *prompt)
+2
View File
@@ -284,6 +284,8 @@ negative argument.
A command function should return 0 if its action completes successfully,
and a non-zero value if some error occurs.
This is the convention obeyed by all of the builtin Readline bindable
command functions.
@node Readline Variables
@section Readline Variables
+1 -1
View File
@@ -1540,7 +1540,7 @@ special variable as delimiters.
Shell quoting is honored.
Each word is then expanded using
brace expansion, tilde expansion, parameter and variable expansion,
command substitution, arithmetic expansion, and pathname expansion,
command substitution, and arithmetic expansion,
as described above (@pxref{Shell Expansions}).
The results are split using the rules described above
(@pxref{Word Splitting}).
+4 -4
View File
@@ -1,10 +1,10 @@
@ignore
Copyright (C) 1988-2004 Free Software Foundation, Inc.
Copyright (C) 1988-2005 Free Software Foundation, Inc.
@end ignore
@set EDITION 5.1-devel
@set VERSION 5.1-devel
@set UPDATED 22 November 2004
@set UPDATED-MONTH November 2004
@set UPDATED 4 January 2005
@set UPDATED-MONTH January 2005
@set LASTCHANGE Mon Nov 22 12:01:42 EST 2004
@set LASTCHANGE Tue Jan 4 17:26:58 EST 2005
+14 -6
View File
@@ -656,19 +656,27 @@ _rl_dispatch_subseq (key, map, got_subseq)
already taken care of pushing any necessary input back onto
the input queue with _rl_unget_char. */
{
#if 0
r = _rl_dispatch (ANYOTHERKEY, FUNCTION_TO_KEYMAP (map, key));
#else
/* XXX - experimental code -- might never be executed. Save
for later. */
Keymap m = FUNCTION_TO_KEYMAP (map, key);
int type = m[ANYOTHERKEY].type;
func = m[ANYOTHERKEY].function;
if (type == ISFUNC && func == rl_do_lowercase_version)
r = _rl_dispatch (_rl_to_lower (key), map);
else if (type == ISFUNC && func == rl_insert)
{
/* If the function that was shadowed was self-insert, we
somehow need a keymap with map[key].func == self-insert.
Let's use this one. */
int nt = m[key].type;
rl_command_func_t *nf = m[key].function;
m[key].type = type;
m[key].function = func;
r = _rl_dispatch (key, m);
m[key].type = nt;
m[key].function = nf;
}
else
r = _rl_dispatch (ANYOTHERKEY, m);
#endif
}
else if (r && map[ANYOTHERKEY].function)
{
+15 -1
View File
@@ -666,6 +666,20 @@ _rl_dispatch_subseq (key, map, got_subseq)
func = m[ANYOTHERKEY].function;
if (type == ISFUNC && func == rl_do_lowercase_version)
r = _rl_dispatch (_rl_to_lower (key), map);
else if (type == ISFUNC && func == rl_insert)
{
/* If the function that was shadowed was self-insert, we
somehow need a keymap with map[key].func == self-insert.
Let's use this one. */
int nt = m[key].type;
rl_command_func_t *nf = m[key].function;
m[key].type = type;
m[key].function = func;
r = _rl_dispatch (key, m);
m[key].type = nt;
m[key].function = nf;
}
else
r = _rl_dispatch (ANYOTHERKEY, m);
#endif
@@ -876,7 +890,7 @@ readline_default_bindings ()
static void
reset_default_bindings ()
{
if (rl_bind_stty_chars)
if (_rl_bind_stty_chars)
{
rl_tty_unset_default_bindings (_rl_keymap);
rl_tty_set_default_bindings (_rl_keymap);