commit bash-20090924 snapshot

This commit is contained in:
Chet Ramey
2011-12-08 20:16:21 -05:00
parent a8fd3f3e51
commit 82a5df635a
24 changed files with 9052 additions and 169 deletions
+25 -25
View File
@@ -94,9 +94,9 @@ static int line_structures_initialized = 0;
#define invisible_line (line_state_invisible->line)
#if defined (HANDLE_MULTIBYTE)
static int _rl_col_width PARAMS((const char *, int, int));
static int _rl_col_width PARAMS((const char *, int, int, int));
#else
# define _rl_col_width(l, s, e) (((e) <= (s)) ? 0 : (e) - (s))
# define _rl_col_width(l, s, e, f) (((e) <= (s)) ? 0 : (e) - (s))
#endif
/* Heuristic used to decide whether it is faster to move from CUR to NEW
@@ -312,7 +312,7 @@ expand_prompt (pmt, lp, lip, niflp, vlp)
not be the same as the number of physical characters
on the screen in the presence of multibyte characters */
rl += ind - pind;
physchars += _rl_col_width (pmt, pind, ind);
physchars += _rl_col_width (pmt, pind, ind, 0);
}
else
ninvis += ind - pind;
@@ -688,7 +688,7 @@ rl_redisplay ()
temp = local_prompt_len;
while (num < temp)
{
z = _rl_col_width (local_prompt, n0, num);
z = _rl_col_width (local_prompt, n0, num, 1);
if (z > _rl_screenwidth)
{
num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY);
@@ -714,7 +714,7 @@ rl_redisplay ()
inv_lbreaks[++newlines] = temp;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
lpos -= _rl_col_width (local_prompt, n0, num);
lpos -= _rl_col_width (local_prompt, n0, num, 1);
else
#endif
lpos -= _rl_screenwidth;
@@ -1087,7 +1087,7 @@ rl_redisplay ()
_rl_output_some_chars (local_prompt, nleft);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
_rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft) - wrap_offset + modmark;
_rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft, 1) - wrap_offset + modmark;
else
_rl_last_c_pos = nleft + modmark;
}
@@ -1111,7 +1111,7 @@ rl_redisplay ()
{
/* TX == new physical cursor position in multibyte locale. */
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
tx = _rl_col_width (&visible_line[pos], 0, nleft) - visible_wrap_offset;
tx = _rl_col_width (&visible_line[pos], 0, nleft, 1) - visible_wrap_offset;
else
tx = nleft;
if (tx >= 0 && _rl_last_c_pos > tx)
@@ -1530,7 +1530,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
{
/* We take wrap_offset into account here so we can pass correct
information to _rl_move_cursor_relative. */
_rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff) - wrap_offset + modmark;
_rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff, 1) - wrap_offset + modmark;
cpos_adjusted = 1;
}
else
@@ -1561,7 +1561,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
When not using multibyte characters, these are equal */
lendiff = (nls - nfd) - (ols - ofd);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
col_lendiff = _rl_col_width (new, nfd - new, nls - new) - _rl_col_width (old, ofd - old, ols - old);
col_lendiff = _rl_col_width (new, nfd - new, nls - new, 1) - _rl_col_width (old, ofd - old, ols - old, 1);
else
col_lendiff = lendiff;
@@ -1586,7 +1586,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
/* Insert (diff (len (old), len (new)) ch. */
temp = ne - nfd;
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
col_temp = _rl_col_width (new, nfd - new, ne - new);
col_temp = _rl_col_width (new, nfd - new, ne - new, 1);
else
col_temp = temp;
@@ -1603,7 +1603,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if (lendiff < 0)
{
_rl_output_some_chars (nfd, temp);
_rl_last_c_pos += _rl_col_width (nfd, 0, temp);
_rl_last_c_pos += _rl_col_width (nfd, 0, temp, 1);
/* If nfd begins before any invisible characters in the prompt,
adjust _rl_last_c_pos to account for wrap_offset and set
cpos_adjusted to let the caller know. */
@@ -1681,7 +1681,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
multibyte characters and prompt strings with invisible
characters, but was previously disabled. */
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
twidth = _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
twidth = _rl_col_width (nfd+lendiff, 0, temp-col_lendiff, 1);
else
twidth = temp - lendiff;
_rl_last_c_pos += twidth;
@@ -1740,7 +1740,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
_rl_output_some_chars (nfd, temp);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
_rl_last_c_pos += _rl_col_width (nfd, 0, temp);
_rl_last_c_pos += _rl_col_width (nfd, 0, temp, 1);
if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
{
_rl_last_c_pos -= wrap_offset;
@@ -1773,7 +1773,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
}
lendiff = (oe - old) - (ne - new);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
col_lendiff = _rl_col_width (old, 0, oe - old) - _rl_col_width (new, 0, ne - new);
col_lendiff = _rl_col_width (old, 0, oe - old, 1) - _rl_col_width (new, 0, ne - new, 1);
else
col_lendiff = lendiff;
@@ -1840,7 +1840,7 @@ rl_on_new_line_with_prompt ()
l = strlen (prompt_last_line);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
_rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l); /* XXX */
_rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l, 1); /* XXX */
else
_rl_last_c_pos = l;
@@ -1924,19 +1924,19 @@ _rl_move_cursor_relative (new, data)
/* 1. prompt string */
if (new == local_prompt_len && memcmp (data, local_prompt, new) == 0)
{
dpos = prompt_visible_length;
dpos = prompt_physical_chars;
cpos_adjusted = 1;
adjust = 0;
}
/* 2. prompt_string + line contents */
else if (new > local_prompt_len && local_prompt && memcmp (data, local_prompt, local_prompt_len) == 0)
{
dpos = prompt_visible_length + _rl_col_width (data, local_prompt_len, new);
dpos = prompt_physical_chars + _rl_col_width (data, local_prompt_len, new, 1);
cpos_adjusted = 1;
adjust = 0;
}
else
dpos = _rl_col_width (data, 0, new);
dpos = _rl_col_width (data, 0, new, 1);
/* Use NEW when comparing against the last invisible character in the
prompt string, since they're both buffer indices and DPOS is a
@@ -2588,9 +2588,9 @@ _rl_current_display_line ()
In the case of multibyte characters with stateful encoding, we have to
scan from the beginning of the string to take the state into account. */
static int
_rl_col_width (str, start, end)
_rl_col_width (str, start, end, flags)
const char *str;
int start, end;
int start, end, flags;
{
wchar_t wc;
mbstate_t ps;
@@ -2612,14 +2612,14 @@ _rl_ttymsg ("_rl_col_width: called with MB_CUR_MAX == 1");
/* Try to short-circuit common cases. The adjustment to remove wrap_offset
is done by the caller. */
/* 1. prompt string */
if (start == 0 && end == local_prompt_len && memcmp (str, local_prompt, local_prompt_len) == 0)
return (prompt_visible_length + wrap_offset);
if (flags && start == 0 && end == local_prompt_len && memcmp (str, local_prompt, local_prompt_len) == 0)
return (prompt_physical_chars + wrap_offset);
/* 2. prompt string + line contents */
else if (start == 0 && end > local_prompt_len && local_prompt && memcmp (str, local_prompt, local_prompt_len) == 0)
else if (flags && start == 0 && local_prompt_len > 0 && end > local_prompt_len && local_prompt && memcmp (str, local_prompt, local_prompt_len) == 0)
{
tmp = prompt_visible_length + wrap_offset;
tmp = prompt_physical_chars + wrap_offset;
/* XXX - try to call ourselves recursively with non-prompt portion */
tmp += _rl_col_width (str, local_prompt_len, end);
tmp += _rl_col_width (str, local_prompt_len, end, flags);
return (tmp);
}
File diff suppressed because it is too large Load Diff
+22 -24
View File
@@ -94,9 +94,9 @@ static int line_structures_initialized = 0;
#define invisible_line (line_state_invisible->line)
#if defined (HANDLE_MULTIBYTE)
static int _rl_col_width PARAMS((const char *, int, int));
static int _rl_col_width PARAMS((const char *, int, int, int));
#else
# define _rl_col_width(l, s, e) (((e) <= (s)) ? 0 : (e) - (s))
# define _rl_col_width(l, s, e, f) (((e) <= (s)) ? 0 : (e) - (s))
#endif
/* Heuristic used to decide whether it is faster to move from CUR to NEW
@@ -312,7 +312,7 @@ expand_prompt (pmt, lp, lip, niflp, vlp)
not be the same as the number of physical characters
on the screen in the presence of multibyte characters */
rl += ind - pind;
physchars += _rl_col_width (pmt, pind, ind);
physchars += _rl_col_width (pmt, pind, ind, 0);
}
else
ninvis += ind - pind;
@@ -688,7 +688,7 @@ rl_redisplay ()
temp = local_prompt_len;
while (num < temp)
{
z = _rl_col_width (local_prompt, n0, num);
z = _rl_col_width (local_prompt, n0, num, 1);
if (z > _rl_screenwidth)
{
num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY);
@@ -714,7 +714,7 @@ rl_redisplay ()
inv_lbreaks[++newlines] = temp;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
lpos -= _rl_col_width (local_prompt, n0, num);
lpos -= _rl_col_width (local_prompt, n0, num, 1);
else
#endif
lpos -= _rl_screenwidth;
@@ -1087,7 +1087,7 @@ rl_redisplay ()
_rl_output_some_chars (local_prompt, nleft);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
_rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft) - wrap_offset + modmark;
_rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft, 1) - wrap_offset + modmark;
else
_rl_last_c_pos = nleft + modmark;
}
@@ -1111,7 +1111,7 @@ rl_redisplay ()
{
/* TX == new physical cursor position in multibyte locale. */
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
tx = _rl_col_width (&visible_line[pos], 0, nleft) - visible_wrap_offset;
tx = _rl_col_width (&visible_line[pos], 0, nleft, 1) - visible_wrap_offset;
else
tx = nleft;
if (tx >= 0 && _rl_last_c_pos > tx)
@@ -1333,12 +1333,10 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
ret = 1;
memmove (old+bytes, old+ret, strlen (old+ret));
memcpy (old, new, bytes);
#if 0
/* Fix up indices if we copy data from one line to another */
omax += bytes - ret;
for (i = current_line+1; i < inv_botlin+1; i++)
vis_lbreaks[i] += bytes - ret;
#endif
}
}
else
@@ -1532,7 +1530,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
{
/* We take wrap_offset into account here so we can pass correct
information to _rl_move_cursor_relative. */
_rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff) - wrap_offset + modmark;
_rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff, 1) - wrap_offset + modmark;
cpos_adjusted = 1;
}
else
@@ -1563,7 +1561,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
When not using multibyte characters, these are equal */
lendiff = (nls - nfd) - (ols - ofd);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
col_lendiff = _rl_col_width (new, nfd - new, nls - new) - _rl_col_width (old, ofd - old, ols - old);
col_lendiff = _rl_col_width (new, nfd - new, nls - new, 1) - _rl_col_width (old, ofd - old, ols - old, 1);
else
col_lendiff = lendiff;
@@ -1588,7 +1586,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
/* Insert (diff (len (old), len (new)) ch. */
temp = ne - nfd;
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
col_temp = _rl_col_width (new, nfd - new, ne - new);
col_temp = _rl_col_width (new, nfd - new, ne - new, 1);
else
col_temp = temp;
@@ -1605,7 +1603,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if (lendiff < 0)
{
_rl_output_some_chars (nfd, temp);
_rl_last_c_pos += _rl_col_width (nfd, 0, temp);
_rl_last_c_pos += _rl_col_width (nfd, 0, temp, 1);
/* If nfd begins before any invisible characters in the prompt,
adjust _rl_last_c_pos to account for wrap_offset and set
cpos_adjusted to let the caller know. */
@@ -1683,7 +1681,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
multibyte characters and prompt strings with invisible
characters, but was previously disabled. */
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
twidth = _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
twidth = _rl_col_width (nfd+lendiff, 0, temp-col_lendiff, 1);
else
twidth = temp - lendiff;
_rl_last_c_pos += twidth;
@@ -1742,7 +1740,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
_rl_output_some_chars (nfd, temp);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
_rl_last_c_pos += _rl_col_width (nfd, 0, temp);
_rl_last_c_pos += _rl_col_width (nfd, 0, temp, 1);
if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
{
_rl_last_c_pos -= wrap_offset;
@@ -1775,7 +1773,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
}
lendiff = (oe - old) - (ne - new);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
col_lendiff = _rl_col_width (old, 0, oe - old) - _rl_col_width (new, 0, ne - new);
col_lendiff = _rl_col_width (old, 0, oe - old, 1) - _rl_col_width (new, 0, ne - new, 1);
else
col_lendiff = lendiff;
@@ -1842,7 +1840,7 @@ rl_on_new_line_with_prompt ()
l = strlen (prompt_last_line);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
_rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l); /* XXX */
_rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l, 1); /* XXX */
else
_rl_last_c_pos = l;
@@ -1933,12 +1931,12 @@ _rl_move_cursor_relative (new, data)
/* 2. prompt_string + line contents */
else if (new > local_prompt_len && local_prompt && memcmp (data, local_prompt, local_prompt_len) == 0)
{
dpos = prompt_visible_length + _rl_col_width (data, local_prompt_len, new);
dpos = prompt_visible_length + _rl_col_width (data, local_prompt_len, new, 1);
cpos_adjusted = 1;
adjust = 0;
}
else
dpos = _rl_col_width (data, 0, new);
dpos = _rl_col_width (data, 0, new, 1);
/* Use NEW when comparing against the last invisible character in the
prompt string, since they're both buffer indices and DPOS is a
@@ -2590,9 +2588,9 @@ _rl_current_display_line ()
In the case of multibyte characters with stateful encoding, we have to
scan from the beginning of the string to take the state into account. */
static int
_rl_col_width (str, start, end)
_rl_col_width (str, start, end, flags)
const char *str;
int start, end;
int start, end, flags;
{
wchar_t wc;
mbstate_t ps;
@@ -2614,14 +2612,14 @@ _rl_ttymsg ("_rl_col_width: called with MB_CUR_MAX == 1");
/* Try to short-circuit common cases. The adjustment to remove wrap_offset
is done by the caller. */
/* 1. prompt string */
if (start == 0 && end == local_prompt_len && memcmp (str, local_prompt, local_prompt_len) == 0)
if (flags && start == 0 && end == local_prompt_len && memcmp (str, local_prompt, local_prompt_len) == 0)
return (prompt_visible_length + wrap_offset);
/* 2. prompt string + line contents */
else if (start == 0 && end > local_prompt_len && local_prompt && memcmp (str, local_prompt, local_prompt_len) == 0)
else if (flags && start == 0 && local_prompt_len > 0 && end > local_prompt_len && local_prompt && memcmp (str, local_prompt, local_prompt_len) == 0)
{
tmp = prompt_visible_length + wrap_offset;
/* XXX - try to call ourselves recursively with non-prompt portion */
tmp += _rl_col_width (str, local_prompt_len, end);
tmp += _rl_col_width (str, local_prompt_len, end, flags);
return (tmp);
}