Package-Name: readline
Gentoo-Package: sys-libs/readline
Requires: ncurses|ncurses4
Homepage: http://www.gnu.org/software/readline/
Source: gnu:///readline/readline-(\d+.\d+(.\d+)?\w*).tar.gz $1
Repack:
	tar xzvfp "$(SOURCE)"
Compile:
	mv -f CHANGE* COPYING README USAGE "$(PREFIX)/"
	CFLAGS="-O2 -I/usr/include/ncurses" \
	$(MAKE) -f ../Makefile configure CONFIGURE_OPTS="--with-curses"
	$(MAKE)
# Avoid problems with overwriting shared libraries; however, shared-link
# bash requires readline, so make sure we keep an accessible copy around
	if test -f /usr/lib/libreadline.so ; then \
		rm -f /usr/lib/libreadline.so.4 ; \
		cp -p /usr/lib/libreadline.so{,.4} ; \
	fi
	if test -f /usr/lib/libhistory.so ; then \
		rm -f /usr/lib/libhistory.so.4 ; \
		cp -p /usr/lib/libhistory.so{,.4} ; \
	fi
	rm -f "$(PREFIX)"/lib/*.so*
	/sbin/ldconfig
	$(MAKE) install
	rm -f /usr/lib/lib{readline,history}.so.4 "$(PREFIX)"/lib/*.old
	/sbin/ldconfig
Install:
	$(MAKE) instlib LIB="history readline"
	$(MAKE) addldso
	$(MAKE) instinc INC=readline
	$(MAKE) instinfo INFO="history readline rluserman"
	$(MAKE) instman SECTION=3 MAN="history readline"
Clean:
	@set -e ; cd "$(PREFIX)"/lib ; \
	for lib in *.so.[0-9] ; do \
		reallib=`/bin/ls -l "$$lib" | sed 's/.* -> //'` ; \
		for file in $$lib.[0-9]*.[0-9]* ; do \
			if test "$$file" != "$$reallib" ; then \
				rm -fv "$$file" ; \
			fi ; \
		done ; \
	done
Patch: <<EOT
######## begin multibyte prompt redisplay bug patch (linebreaks in wrong place)
--- display.c.old	2004-05-28 11:57:51 +0900
+++ display.c	2005-01-30 22:18:46 +0900
@@ -568,7 +568,9 @@
 #if 0
   lpos = out - wrap_offset;
 #else
-  lpos = prompt_physical_chars + modmark;
+  /* achurch@achurch.org: one physical character is not always the same as
+   * one visible character (e.g. Japanese 2-byte characters) */
+  lpos = prompt_visible_length + modmark;
 #endif
 
 #if defined (HANDLE_MULTIBYTE)
######## end multibyte prompt redisplay bug patch
EOT
NoPatch: <<EOT
######## begin unaligned multibyte completion list patch
--- ../readline-5.0-orig/complete.c	2004-07-02 02:57:58 +0900
+++ complete.c	2004-09-06 13:57:03 +0900
@@ -621,6 +621,8 @@
   mbstate_t ps;
   const char *end;
   size_t tlen;
+  int width, w;
+  wchar_t wc;
 
   end = to_print + strlen (to_print) + 1;
   memset (&ps, 0, sizeof (mbstate_t));
@@ -653,21 +655,28 @@
       else
 	{
 #if defined (HANDLE_MULTIBYTE)
-	  tlen = mbrlen (s, end - s, &ps);
+	  tlen = mbrtowc (&wc, s, end - s, &ps);
 	  if (MB_INVALIDCH (tlen))
 	    {
 	      tlen = 1;
+	      width = 1;
 	      memset (&ps, 0, sizeof (mbstate_t));
 	    }
 	  else if (MB_NULLWCH (tlen))
 	    break;
+	  else
+	    {
+	      w = wcwidth (wc);
+	      width = (w >= 0) ? w : 1;
+	    }
 	  fwrite (s, 1, tlen, rl_outstream);
 	  s += tlen;
+	  printed_len += width;
 #else
 	  putc (*s, rl_outstream);
 	  s++;
-#endif
 	  printed_len++;
+#endif
 	}
     }
 
######## end unaligned multibyte completion list patch
EOT

/pkg/readline/
/usr/include/readline
/usr/lib/libhistory.*
/usr/lib/libreadline.*
/usr/info/history.info*
/usr/info/readline.info*
/usr/info/rluserman.info*
/usr/man/man3/history.3.gz
/usr/man/man3/readline.3.gz
