Index: BOOK/patches.ent
===================================================================
--- BOOK/patches.ent	(revision 24cc73c6e0d49dbbea99a0c4d5533bbf631f46cb)
+++ BOOK/patches.ent	(revision 4232f0ec5782cb09e93ddfbb43a3d9ea0caf1654)
@@ -81,6 +81,6 @@
 <!ENTITY perl-libc-patch-size "4 KB">
 
-<!ENTITY readline-fixes-patch "readline-&readline-version;-fixes-1.patch">
-<!ENTITY readline-fixes-patch-md5 "c3483d9d4e44614a740e190d25100cdf">
+<!ENTITY readline-fixes-patch "readline-&readline-version;-fixes-2.patch">
+<!ENTITY readline-fixes-patch-md5 "0255d82297983150e0473bd81aeb8346">
 <!ENTITY readline-fixes-patch-size "4 KB">
 
Index: tches/readline-5.2-fixes-1.patch
===================================================================
--- patches/readline-5.2-fixes-1.patch	(revision 24cc73c6e0d49dbbea99a0c4d5533bbf631f46cb)
+++ 	(revision )
@@ -1,19 +1,0 @@
-Submitted By: Jim Gifford (jim at linuxfromscratch dot org)
-Date: 2006-12-12
-Initial Package Version: 5.2
-Origin: ftp://ftp.cwru.edu/pub/bash/readline-5.2-patches
-Upstream Status: From Upstream
-Description: Contains patches 001 from upstream
-
-diff -Naur readline-5.2.orig/display.c readline-5.2/display.c
---- readline-5.2.orig/display.c	2006-09-14 11:20:12.000000000 -0700
-+++ readline-5.2/display.c	2006-12-12 14:57:06.000000000 -0800
-@@ -2380,6 +2380,8 @@
- 
-   if (end <= start)
-     return 0;
-+  if (MB_CUR_MAX == 1 || rl_byte_oriented)
-+    return (end - start);
- 
-   memset (&ps, 0, sizeof (mbstate_t));
- 
Index: patches/readline-5.2-fixes-2.patch
===================================================================
--- patches/readline-5.2-fixes-2.patch	(revision 4232f0ec5782cb09e93ddfbb43a3d9ea0caf1654)
+++ patches/readline-5.2-fixes-2.patch	(revision 4232f0ec5782cb09e93ddfbb43a3d9ea0caf1654)
@@ -0,0 +1,102 @@
+Submitted By: Joe Ciccone <jciccone@gmail.com>
+Date: 2007-07-23
+Initial Package Version: 5.2
+Origin: ftp://ftp.cwru.edu/pub/bash/readline-5.2-patches
+Upstream Status: From Upstream
+Description: Contains patches 001 - 004 from upstream
+
+diff -Naur readline-5.2.orig/display.c readline-5.2/display.c
+--- readline-5.2.orig/display.c	2007-07-23 20:10:10.000000000 -0400
++++ readline-5.2/display.c	2007-07-23 20:10:27.000000000 -0400
+@@ -561,6 +561,17 @@
+       wrap_offset = prompt_invis_chars_first_line = 0;
+     }
+ 
++#if defined (HANDLE_MULTIBYTE)
++#define CHECK_INV_LBREAKS() \
++      do { \
++	if (newlines >= (inv_lbsize - 2)) \
++	  { \
++	    inv_lbsize *= 2; \
++	    inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
++	    _rl_wrapped_line = (int *)xrealloc (_rl_wrapped_line, inv_lbsize * sizeof (int)); \
++	  } \
++      } while (0)
++#else
+ #define CHECK_INV_LBREAKS() \
+       do { \
+ 	if (newlines >= (inv_lbsize - 2)) \
+@@ -569,6 +580,7 @@
+ 	    inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
+ 	  } \
+       } while (0)
++#endif /* HANDLE_MULTIBYTE */
+ 
+ #if defined (HANDLE_MULTIBYTE)	  
+ #define CHECK_LPOS() \
+@@ -1586,8 +1598,22 @@
+ 	  temp = nls - nfd;
+ 	  if (temp > 0)
+ 	    {
++	      /* If nfd begins at the prompt, or before the invisible
++		 characters in the prompt, we need to adjust _rl_last_c_pos
++		 in a multibyte locale to account for the wrap offset and
++		 set cpos_adjusted accordingly. */
+ 	      _rl_output_some_chars (nfd, temp);
+-	      _rl_last_c_pos += _rl_col_width (nfd, 0, temp);;
++	      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
++		{
++                  _rl_last_c_pos += _rl_col_width (nfd, 0, temp);
++                  if (current_line == 0 && wrap_offset &&  ((nfd - new) <= prompt_last_invisible))
++		    {
++		      _rl_last_c_pos -= wrap_offset;
++		      cpos_adjusted = 1;
++		    }
++		}
++              else
++                _rl_last_c_pos += temp;
+ 	    }
+ 	}
+       /* Otherwise, print over the existing material. */
+@@ -1595,8 +1621,20 @@
+ 	{
+ 	  if (temp > 0)
+ 	    {
++	      /* If nfd begins at the prompt, or before the invisible
++		 characters in the prompt, we need to adjust _rl_last_c_pos
++		 in a multibyte locale to account for the wrap offset and
++		 set cpos_adjusted accordingly. */
+ 	      _rl_output_some_chars (nfd, temp);
+ 	      _rl_last_c_pos += col_temp;		/* XXX */
++	      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
++		{
++		  if (current_line == 0 && wrap_offset &&  ((nfd - new) <= prompt_last_invisible))
++		    {
++		      _rl_last_c_pos -= wrap_offset;
++		      cpos_adjusted = 1;
++		    }
++		}
+ 	    }
+ 	  lendiff = (oe - old) - (ne - new);
+ 	  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+@@ -1732,7 +1770,10 @@
+   if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+     {
+       dpos = _rl_col_width (data, 0, new);
+-      if (dpos > prompt_last_invisible)		/* XXX - don't use woff here */
++      /* Use NEW when comparing against the last invisible character in the
++	 prompt string, since they're both buffer indices and DPOS is a
++	 desired display position. */
++      if (new > prompt_last_invisible)		/* XXX - don't use woff here */
+ 	{
+ 	  dpos -= woff;
+ 	  /* Since this will be assigned to _rl_last_c_pos at the end (more
+@@ -2380,6 +2421,8 @@
+ 
+   if (end <= start)
+     return 0;
++  if (MB_CUR_MAX == 1 || rl_byte_oriented)
++    return (end - start);
+ 
+   memset (&ps, 0, sizeof (mbstate_t));
+ 
