Submitted By: Matthew Burgess (matthew at linuxfromscratch dot org)
Date: 2006-03-17
Initial Package Version: 5.1
Origin: http://ftp.gnu.org/gnu/readline/readline-5.1-patches/
Upstream Status: From Upstream 
Description: Contains Patch 001-004 from Upstream

diff -Naur readline-5.1.orig/display.c readline-5.1/display.c
--- readline-5.1.orig/display.c	2005-11-30 19:05:02.000000000 +0000
+++ readline-5.1/display.c	2006-03-17 16:03:09.000000000 +0000
@@ -1983,11 +1983,15 @@
      int pchar;
 {
   int len;
-  char *pmt;
+  char *pmt, *p;
 
   rl_save_prompt ();
 
-  if (saved_local_prompt == 0)
+  /* We've saved the prompt, and can do anything with the various prompt
+     strings we need before they're restored.  We want the unexpanded
+     portion of the prompt string after any final newline. */
+  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,19 +2002,17 @@
     }
   else
     {
-      len = *saved_local_prompt ? strlen (saved_local_prompt) : 0;
+      p++;
+      len = strlen (p);
       pmt = (char *)xmalloc (len + 2);
       if (len)
-	strcpy (pmt, saved_local_prompt);
+	strcpy (pmt, p);
       pmt[len] = pchar;
       pmt[len+1] = '\0';
-      local_prompt = savestring (pmt);
-      prompt_last_invisible = saved_last_invisible;
-      prompt_visible_length = saved_visible_length + 1;
-    }
+    }  
 
+  /* will be overwritten by expand_prompt, called from rl_message */
   prompt_physical_chars = saved_physical_chars + 1;
-
   return pmt;
 }
 
diff -Naur readline-5.1.orig/readline.c readline-5.1/readline.c
--- readline-5.1.orig/readline.c	2005-07-05 02:29:35.000000000 +0000
+++ readline-5.1/readline.c	2006-03-17 16:03:05.000000000 +0000
@@ -282,6 +282,7 @@
 {
   FREE (rl_prompt);
   rl_prompt = prompt ? savestring (prompt) : (char *)NULL;
+  rl_display_prompt = rl_prompt ? rl_prompt : "";
 
   rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
   return 0;
@@ -714,7 +715,7 @@
 
 	  rl_dispatching = 1;
 	  RL_SETSTATE(RL_STATE_DISPATCHING);
-	  r = (*map[key].function)(rl_numeric_arg * rl_arg_sign, key);
+	  (*map[key].function)(rl_numeric_arg * rl_arg_sign, key);
 	  RL_UNSETSTATE(RL_STATE_DISPATCHING);
 	  rl_dispatching = 0;
 
diff -Naur readline-5.1.orig/terminal.c readline-5.1/terminal.c
--- readline-5.1.orig/terminal.c	2005-11-13 01:46:54.000000000 +0000
+++ readline-5.1/terminal.c	2006-03-17 16:03:02.000000000 +0000
@@ -122,7 +122,7 @@
 static char *_rl_visible_bell;
 
 /* Non-zero means the terminal can auto-wrap lines. */
-int _rl_term_autowrap;
+int _rl_term_autowrap = -1;
 
 /* Non-zero means that this terminal has a meta key. */
 static int term_has_meta;
@@ -274,6 +274,9 @@
 _rl_set_screen_size (rows, cols)
      int rows, cols;
 {
+  if (_rl_term_autowrap == -1)
+    _rl_init_terminal_io (rl_terminal_name);
+
   if (rows > 0)
     _rl_screenheight = rows;
   if (cols > 0)
diff -Naur readline-5.1.orig/text.c readline-5.1/text.c
--- readline-5.1.orig/text.c	2005-09-24 23:06:07.000000000 +0000
+++ readline-5.1/text.c	2006-03-17 16:02:58.000000000 +0000
@@ -1071,8 +1071,6 @@
 rl_delete (count, key)
      int count, key;
 {
-  int r;
-
   if (count < 0)
     return (_rl_rubout_char (-count, key));
 
@@ -1090,17 +1088,17 @@
       else
 	rl_forward_byte (count, key);
 
-      r = rl_kill_text (orig_point, rl_point);
+      rl_kill_text (orig_point, rl_point);
       rl_point = orig_point;
-      return r;
     }
   else
     {
       int new_point;
 
       new_point = MB_NEXTCHAR (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO);
-      return (rl_delete_text (rl_point, new_point));
+      rl_delete_text (rl_point, new_point);
     }
+  return 0;
 }
 
 /* Delete the character under the cursor, unless the insertion
