[PATCH 1 of 2] readline rl_prompt corruption fix
Elena Zannoni
ezannoni@cygnus.com
Tue Aug 1 10:17:00 GMT 2000
In general patches to readline should be sent to the official
readline maintainer, Chet Ramey. ftp://ftp.cwru.edu/pub/bash/ We don't
want to diverge from the official readline release unless absolutely
necessary.
In any event, I am sligltly confused about the 2 patches.
What was the original problem? The positioning of the cursor in the TUI?
Can you explain a little more?
Thanks
Elena
Jimmy Guo writes:
> This is part 1 of 2 patches to fix readline rl_prompt string corruption
> problem. This patch is for the readline library that readline will
> store a copy of the passed in prompt string. The next patch is for
> gdb/event-top.c to plug a mem leak due to this change.
>
> - Jimmy
>
> Fri Jul 28 09:58:55 Jimmy Guo <guo@cup.hp.com>
>
> * readline.c: Initalize globals rl_initialized rl_prompt.
> (readline): Use a copy of prompt instead of itself when
> assigning to rl_prompt in readline ().
>
> * callback.c (rl_callback_handler_install): Use a copy of
> prompt instead of itself when assigning to rl_prompt.
>
> * display.c: Initialize local_prompt and local_prompt_prefix.
>
> Index: readline.c
> /usr/local/bin/diff -c -w -L readline.c readline.c@@/main/cygnus/6 readline.c
> *** readline.c
> --- readline.c Fri Jul 28 09:57:29 2000
> ***************
> *** 119,125 ****
> int rl_arg_sign = 1;
>
> /* Non-zero means we have been called at least once before. */
> ! static int rl_initialized;
>
> /* If non-zero, this program is running in an EMACS buffer. */
> static int running_in_emacs;
> --- 119,125 ----
> int rl_arg_sign = 1;
>
> /* Non-zero means we have been called at least once before. */
> ! static int rl_initialized = 0;
>
> /* If non-zero, this program is running in an EMACS buffer. */
> static int running_in_emacs;
> ***************
> *** 153,159 ****
> int readline_echoing_p = 1;
>
> /* Current prompt. */
> ! char *rl_prompt;
> int rl_visible_prompt_length = 0;
>
> /* Set to non-zero by calling application if it has already printed rl_prompt
> --- 153,159 ----
> int readline_echoing_p = 1;
>
> /* Current prompt. */
> ! char *rl_prompt = NULL;
> int rl_visible_prompt_length = 0;
>
> /* Set to non-zero by calling application if it has already printed rl_prompt
> ***************
> *** 251,257 ****
> {
> char *value;
>
> ! rl_prompt = prompt;
>
> /* If we are at EOF return a NULL string. */
> if (rl_pending_input == EOF)
> --- 251,259 ----
> {
> char *value;
>
> ! if (rl_prompt)
> ! free (rl_prompt);
> ! rl_prompt = prompt ? strdup (prompt) : 0;
>
> /* If we are at EOF return a NULL string. */
> if (rl_pending_input == EOF)
> ***************
> *** 260,266 ****
> return ((char *)NULL);
> }
>
> ! rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
>
> rl_initialize ();
> (*rl_prep_term_function) (_rl_meta_flag);
> --- 262,269 ----
> return ((char *)NULL);
> }
>
> ! rl_visible_prompt_length = (rl_prompt && *rl_prompt) ?
> ! rl_expand_prompt (rl_prompt) : 0;
>
> rl_initialize ();
> (*rl_prep_term_function) (_rl_meta_flag);
> Index: callback.c
> /usr/local/bin/diff -c -w -L callback.c callback.c@@/main/cygnus/2 callback.c
> *** callback.c
> --- callback.c Fri Jul 28 09:55:11 2000
> ***************
> *** 81,88 ****
> char *prompt;
> VFunction *linefunc;
> {
> ! rl_prompt = prompt;
> ! rl_visible_prompt_length = rl_prompt ? rl_expand_prompt (rl_prompt) : 0;
> rl_linefunc = linefunc;
> _rl_callback_newline ();
> }
> --- 81,91 ----
> char *prompt;
> VFunction *linefunc;
> {
> ! if (rl_prompt)
> ! free (rl_prompt);
> ! rl_prompt = prompt ? strdup (prompt) : 0;
> ! rl_visible_prompt_length = (rl_prompt && *rl_prompt) ?
> ! rl_expand_prompt (rl_prompt) : 0;
> rl_linefunc = linefunc;
> _rl_callback_newline ();
> }
> Index: display.c
> /usr/local/bin/diff -c -w -L display.c display.c@@/main/cygnus/7 display.c
> *** display.c
> --- display.c Fri Jul 28 09:56:05 2000
> ***************
> *** 146,152 ****
> /* Default and initial buffer size. Can grow. */
> static int line_size = 1024;
>
> ! static char *local_prompt, *local_prompt_prefix;
> static int visible_length, prefix_length;
>
> /* The number of invisible characters in the line currently being
> --- 146,152 ----
> /* Default and initial buffer size. Can grow. */
> static int line_size = 1024;
>
> ! static char *local_prompt = NULL, *local_prompt_prefix = NULL;
> static int visible_length, prefix_length;
>
> /* The number of invisible characters in the line currently being
>
More information about the Gdb-patches
mailing list