bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: prompt with \[ \] corrupted by vi history search


From: Eric Blake
Subject: Re: prompt with \[ \] corrupted by vi history search
Date: Fri, 17 Feb 2006 22:55:32 -0700
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Eric Blake on 2/17/2006 9:48 PM:
> 
> It seems I spoke too soon.  Your patch works great on single-line prompts
> with invisible characters, but breaks on multiline prompts.

I have tested this patch with both emacs (M-p) and vi (ESC /) modes, using
both single and multiline prompts, with the last line of the prompt either
having or not having invisible characters.  Perhaps it is time for
readline official patch 3/bash official patch 9?

2006-02-17  Eric Blake  <ebb9@byu.net>

        * display.c (_rl_make_prompt_for_search): Avoid double expansion
        of prompt in non-incremental search mode.

- --
Life is short - so eat dessert first!

Eric Blake             ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFD9rbT84KuGfSFAYARAhvXAKCJ3NgV8fdUWoC219uFvbjWcaMXqgCeM2VP
Fa5c66DyGAwQ4BTridlaEWc=
=EnPi
-----END PGP SIGNATURE-----
--- bash-3.1-orig/lib/readline/display.c        2005-11-30 12:05:02.000000000 
-0700
+++ bash-3.1/lib/readline/display.c     2006-02-17 22:44:13.468750000 -0700
@@ -1,6 +1,6 @@
 /* display.c -- readline redisplay facility. */
 
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2006 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library, a library for
    reading lines of text with interactive input and history editing.
@@ -1984,10 +1984,16 @@
 {
   int len;
   char *pmt;
+  char *p;
 
   rl_save_prompt ();
 
-  if (saved_local_prompt == 0)
+/*   if (saved_local_prompt == 0) */
+  /* See http://lists.gnu.org/archive/html/bug-bash/2006-02/msg00004.html -
+     saved_local_prompt was just set by rl_save_prompt, but does not take
+     into account any invisible characters it inherited from rl_prompt.  */
+  p = rl_prompt ? strrchr (rl_prompt, '\n') : 0;
+  if (p == 0)
     {
       len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0;
       pmt = (char *)xmalloc (len + 2);
@@ -1998,10 +2007,10 @@
     }
   else
     {
-      len = *saved_local_prompt ? strlen (saved_local_prompt) : 0;
+      len = strlen (p + 1);
       pmt = (char *)xmalloc (len + 2);
       if (len)
-       strcpy (pmt, saved_local_prompt);
+       strcpy (pmt, p + 1);
       pmt[len] = pchar;
       pmt[len+1] = '\0';
       local_prompt = savestring (pmt);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]