summaryrefslogtreecommitdiff
path: root/lib/readline
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2022-11-14 12:08:12 -0500
committerChet Ramey <chet.ramey@case.edu>2022-11-14 12:08:12 -0500
commit96115811d810f97d0f1611864801a93cd320df50 (patch)
tree41f56421b0c98d4349ad53f72808261a2ea9e32d /lib/readline
parent31f4d468b60eb27d768ef56d0a8b4982346465d9 (diff)
downloadbash-96115811d810f97d0f1611864801a93cd320df50.tar.gz
clarify some arithmetic error messages; fix for read builtin readline timeouts; initial implementation of preserving double quotes in readline completion; add starting line number to some "EOF reached" parser error messages
Diffstat (limited to 'lib/readline')
-rw-r--r--lib/readline/complete.c6
-rw-r--r--lib/readline/display.c51
2 files changed, 35 insertions, 22 deletions
diff --git a/lib/readline/complete.c b/lib/readline/complete.c
index e52aaa29..655d3e99 100644
--- a/lib/readline/complete.c
+++ b/lib/readline/complete.c
@@ -1784,6 +1784,11 @@ make_quoted_replacement (char *match, int mtype, char *qc)
should_quote = rl_filename_quote_characters
? (_rl_strpbrk (match, rl_filename_quote_characters) != 0)
: 0;
+ /* If we saw a quote in the original word, but readline thinks the
+ match doesn't need to be quoted, and the application has a filename
+ quoting function, give the application a chance to quote it if
+ needed so we don't second-guess the user. */
+ should_quote |= *qc == 0 && rl_completion_found_quote && mtype != NO_MATCH && rl_filename_quoting_function;
do_replace = should_quote ? mtype : NO_MATCH;
/* Quote the replacement, since we found an embedded
@@ -1791,6 +1796,7 @@ make_quoted_replacement (char *match, int mtype, char *qc)
if (do_replace != NO_MATCH && rl_filename_quoting_function)
replacement = (*rl_filename_quoting_function) (match, do_replace, qc);
}
+
return (replacement);
}
diff --git a/lib/readline/display.c b/lib/readline/display.c
index f7ffd465..09ecd864 100644
--- a/lib/readline/display.c
+++ b/lib/readline/display.c
@@ -609,11 +609,18 @@ rl_expand_prompt (char *prompt)
FREE (local_prompt);
FREE (local_prompt_prefix);
+ /* Set default values for variables expand_prompt sets */
local_prompt = local_prompt_prefix = (char *)0;
local_prompt_len = 0;
prompt_last_invisible = prompt_invis_chars_first_line = 0;
prompt_visible_length = prompt_physical_chars = 0;
+ if (local_prompt_invis_chars == 0)
+ {
+ local_prompt_invis_chars = (int *)xmalloc (sizeof (int));
+ local_prompt_invis_chars[0] = 0;
+ }
+
if (prompt == 0 || *prompt == 0)
return (0);
@@ -776,6 +783,28 @@ _rl_optimize_redisplay (void)
_rl_quick_redisplay = 1;
}
+/* Useful shorthand used by rl_redisplay, update_line, rl_move_cursor_relative */
+#define INVIS_FIRST() (local_prompt_invis_chars[0])
+#define WRAP_OFFSET(line, offset) ((line <= prompt_last_screen_line) ? local_prompt_invis_chars[line] : 0)
+
+#define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)
+#define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
+#define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l])
+#define VIS_CHARS(line) (visible_line + vis_lbreaks[line])
+#define VIS_FACE(line) (vis_face + vis_lbreaks[line])
+#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line)
+#define VIS_LINE_FACE(line) ((line) > _rl_vis_botlin) ? "" : VIS_FACE(line)
+#define INV_LINE(line) (invisible_line + inv_lbreaks[line])
+#define INV_LINE_FACE(line) (inv_face + inv_lbreaks[line])
+
+#define INV_CHARS_CURRENT_PROMPT_LINE(line) \
+ (local_prompt_invis_chars[line] > 0)
+
+#define OLD_CPOS_IN_PROMPT() (cpos_adjusted == 0 && \
+ _rl_last_c_pos != o_cpos && \
+ _rl_last_c_pos > wrap_offset && \
+ o_cpos < prompt_last_invisible)
+
/* Basic redisplay algorithm. See comments inline. */
void
rl_redisplay (void)
@@ -1271,28 +1300,6 @@ rl_redisplay (void)
second and subsequent lines start at inv_lbreaks[N], offset by
OFFSET (which has already been calculated above). */
-#define INVIS_FIRST() (local_prompt_invis_chars[0])
-#define WRAP_OFFSET(line, offset) ((line <= prompt_last_screen_line) ? local_prompt_invis_chars[line] : 0)
-
-#define W_OFFSET(line, offset) ((line) == 0 ? offset : 0)
-#define VIS_LLEN(l) ((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
-#define INV_LLEN(l) (inv_lbreaks[l+1] - inv_lbreaks[l])
-#define VIS_CHARS(line) (visible_line + vis_lbreaks[line])
-#define VIS_FACE(line) (vis_face + vis_lbreaks[line])
-#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line)
-#define VIS_LINE_FACE(line) ((line) > _rl_vis_botlin) ? "" : VIS_FACE(line)
-#define INV_LINE(line) (invisible_line + inv_lbreaks[line])
-#define INV_LINE_FACE(line) (inv_face + inv_lbreaks[line])
-
-#define INV_CHARS_CURRENT_PROMPT_LINE(line) \
- (local_prompt_invis_chars[line] > 0)
-
-#define OLD_CPOS_IN_PROMPT() (cpos_adjusted == 0 && \
- _rl_last_c_pos != o_cpos && \
- _rl_last_c_pos > wrap_offset && \
- o_cpos < prompt_last_invisible)
-
-
/* We don't want to highlight anything that's going to be off the top
of the display; if the current line takes up more than an entire
screen, just mark the lines that won't be displayed as having a