mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-09 13:10:50 +02:00
fix to readline redisplay of invisible chars at end of line; fix to here-document delimiter quote removal; prompt expansion makes invisible chars in w, W, s visible
This commit is contained in:
@@ -439,7 +439,15 @@ expand_prompt (char *pmt, int flags, int *lp, int *lip, int *niflp, int *vlp)
|
||||
to add them, since update_line expects them to be counted before
|
||||
wrapping the line. */
|
||||
if (can_add_invis)
|
||||
local_prompt_newlines[newlines] = r - ret;
|
||||
{
|
||||
local_prompt_newlines[newlines] = r - ret;
|
||||
/* If we're adding to the number of invisible characters on the
|
||||
first line of the prompt, but we've already set the number of
|
||||
invisible characters on that line, we need to adjust the
|
||||
counter. */
|
||||
if (invflset && newlines == 1)
|
||||
invfl = ninvis;
|
||||
}
|
||||
if (p != (igstart + 1))
|
||||
last = r - ret - 1;
|
||||
continue;
|
||||
|
||||
@@ -492,8 +492,10 @@ matching text found by incremental and non-incremental history searches.
|
||||
When set to \fBOn\fP, readline will configure the terminal in a way
|
||||
that will enable it to insert each paste into the editing buffer as a
|
||||
single string of characters, instead of treating each character as if
|
||||
it had been read from the keyboard. This can prevent pasted characters
|
||||
from being interpreted as editing commands.
|
||||
it had been read from the keyboard
|
||||
and executing any editing commands
|
||||
bound to key sequences appearing in the pasted text.
|
||||
This will prevent pasted characters from being interpreted as editing commands.
|
||||
.TP
|
||||
.B enable\-keypad (Off)
|
||||
When set to \fBOn\fP, readline will try to enable the application
|
||||
|
||||
@@ -591,8 +591,11 @@ The default is @samp{On}.
|
||||
When set to @samp{On}, Readline will configure the terminal in a way
|
||||
that will enable it to insert each paste into the editing buffer as a
|
||||
single string of characters, instead of treating each character as if
|
||||
it had been read from the keyboard. This can prevent pasted characters
|
||||
from being interpreted as editing commands. The default is @samp{On}.
|
||||
it had been read from the keyboard
|
||||
and executing any editing commands
|
||||
bound to key sequences appearing in the pasted text.
|
||||
This will prevent pasted characters from being interpreted as editing commands.
|
||||
The default is @samp{On}.
|
||||
|
||||
@item enable-keypad
|
||||
@vindex enable-keypad
|
||||
|
||||
@@ -93,6 +93,8 @@ make_history_line_current (HIST_ENTRY *entry)
|
||||
if (_rl_saved_line_for_history)
|
||||
_rl_free_saved_history_line ();
|
||||
|
||||
rl_maybe_save_line ();
|
||||
|
||||
/* Now we create a new undo list with a single insert for this text.
|
||||
WE DON'T CHANGE THE ORIGINAL HISTORY ENTRY UNDO LIST */
|
||||
_rl_replace_text (entry->line, 0, rl_end);
|
||||
@@ -193,6 +195,7 @@ noninc_dosearch (char *string, int dir, int flags)
|
||||
history_set_pos (oldpos);
|
||||
|
||||
make_history_line_current (entry);
|
||||
_rl_free_saved_history_line ();
|
||||
|
||||
if (_rl_enable_active_region && ((flags & SF_PATTERN) == 0) && ind > 0 && ind < rl_end)
|
||||
{
|
||||
@@ -585,6 +588,7 @@ rl_history_search_internal (int count, int dir)
|
||||
/* Make sure we set the current history position to the last line found so
|
||||
we can do things like operate-and-get-next from here. This is similar to
|
||||
how incremental search behaves. */
|
||||
rl_maybe_replace_line ();
|
||||
history_set_pos (_rl_history_search_pos); /* XXX */
|
||||
|
||||
/* decide where to put rl_point -- need to change this for pattern search */
|
||||
|
||||
+14
-2
@@ -39,6 +39,8 @@
|
||||
extern char *ansic_quote PARAMS((char *, int, int *));
|
||||
extern int ansic_shouldquote PARAMS((const char *));
|
||||
|
||||
extern int sh_charvis PARAMS((const char *, size_t *, size_t, char *, size_t *));
|
||||
|
||||
/* Default set of characters that should be backslash-quoted in strings */
|
||||
static const char bstab[256] =
|
||||
{
|
||||
@@ -314,7 +316,8 @@ sh_backslash_quote (string, table, flags)
|
||||
#if defined (PROMPT_STRING_DECODE) || defined (TRANSLATABLE_STRINGS)
|
||||
/* Quote characters that get special treatment when in double quotes in STRING
|
||||
using backslashes. If FLAGS == 1, also make `unsafe' characters visible by
|
||||
translating them to a standard ^X/M-X representation (not yet implemented).
|
||||
translating them to a standard ^X/M-X representation by calling sh_charvis,
|
||||
which handles multibyte characters as well.
|
||||
Return a new string. */
|
||||
char *
|
||||
sh_backslash_quote_for_double_quotes (string, flags)
|
||||
@@ -330,7 +333,8 @@ sh_backslash_quote_for_double_quotes (string, flags)
|
||||
slen = strlen (string);
|
||||
send = string + slen;
|
||||
mb_cur_max = MB_CUR_MAX;
|
||||
result = (char *)xmalloc ((flags == 1 ? 3 : 2) * slen + 1);
|
||||
/* Max is 4*string length (backslash + three-character visible representation) */
|
||||
result = (char *)xmalloc (4 * slen + 1);
|
||||
|
||||
for (rind = sind = 0; c = string[sind]; sind++)
|
||||
{
|
||||
@@ -338,6 +342,14 @@ sh_backslash_quote_for_double_quotes (string, flags)
|
||||
|
||||
if ((sh_syntaxtab[c] & CBSDQUOTE) && c != '\n')
|
||||
result[rind++] = '\\';
|
||||
|
||||
if (flags & 1)
|
||||
{
|
||||
sh_charvis (string, &sind, slen, result, &rind);
|
||||
sind--; /* sh_charvis consumes an extra character */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* I should probably use the CSPECL flag for these in sh_syntaxtab[] */
|
||||
else if (c == CTLESC || c == CTLNUL)
|
||||
result[rind++] = CTLESC; /* could be '\\'? */
|
||||
|
||||
+8
-5
@@ -52,10 +52,11 @@
|
||||
#define UNMETA(c) ((c) & 0x7f)
|
||||
#endif
|
||||
|
||||
static int
|
||||
charvis (s, sindp, ret, rindp)
|
||||
int
|
||||
sh_charvis (s, sindp, slen, ret, rindp)
|
||||
const char *s;
|
||||
size_t *sindp;
|
||||
size_t slen;
|
||||
char *ret;
|
||||
size_t *rindp;
|
||||
{
|
||||
@@ -68,7 +69,7 @@ charvis (s, sindp, ret, rindp)
|
||||
ri = *rindp;
|
||||
c = s[*sindp];
|
||||
|
||||
send = (locale_mb_cur_max > 1) ? s + strlen (s) : 0;
|
||||
send = (locale_mb_cur_max > 1) ? s + slen : 0;
|
||||
|
||||
if (SAFECHAR (c))
|
||||
{
|
||||
@@ -87,7 +88,9 @@ charvis (s, sindp, ret, rindp)
|
||||
ret[ri++] = UNCTRL (c);
|
||||
si++;
|
||||
}
|
||||
else if (locale_mb_cur_max > 1)
|
||||
else if (locale_utf8locale && (c & 0x80))
|
||||
COPY_CHAR_I (ret, ri, s, send, si);
|
||||
else if (locale_mb_cur_max > 1 && is_basic (c) == 0)
|
||||
COPY_CHAR_I (ret, ri, s, send, si);
|
||||
else if (META_CHAR (c))
|
||||
{
|
||||
@@ -138,7 +141,7 @@ sh_strvis (string)
|
||||
sind = 0;
|
||||
|
||||
while (string[sind])
|
||||
sind = charvis (string, &sind, ret, &retind);
|
||||
sind = sh_charvis (string, &sind, slen, ret, &retind);
|
||||
|
||||
ret[retind] = '\0';
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user