$NetBSD: patch-an,v 1.2 2005/12/14 13:53:24 joerg Exp $

--- readline/readline.c.orig	1995-02-24 21:20:03.000000000 +0000
+++ readline/readline.c
@@ -48,7 +48,11 @@ static char *xmalloc (), *xrealloc ();
 #  include <unistd.h>
 #endif
 
+#if !defined(__linux__)
 #define NEW_TTY_DRIVER
+#else
+#define TERMIOS_TTY_DRIVER
+#endif
 #define HAVE_BSD_SIGNALS
 /* #define USE_XON_XOFF */
 
@@ -80,6 +84,10 @@ static char *xmalloc (), *xrealloc ();
 #  if !defined (O_NDELAY)
 #    define O_NDELAY O_NONBLOCK	/* Posix-style non-blocking i/o */
 #  endif /* O_NDELAY */
+#else
+#  ifdef TERMIOS_TTY_DRIVER
+#    include <termios.h>
+#  endif /* !TERMIOS_MISSING */
 #endif /* _POSIX_VERSION */
 
 /* Other (BSD) machines use sgtty. */
@@ -104,7 +112,6 @@ static char *xmalloc (), *xrealloc ();
 #endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */
 
 #include <errno.h>
-extern int errno;
 
 #include <setjmp.h>
 #if defined (SHELL)
@@ -133,7 +140,7 @@ struct passwd *getpwuid (), *getpwent ()
 #  endif /* USGr3 */
 #endif /* USG && hpux */
 
-#if defined (_POSIX_VERSION) || defined (USGr3)
+#if defined (_POSIX_VERSION) || defined (USGr3) || defined(__linux__)
 #  include <dirent.h>
 #  define direct dirent
 #  if defined (_POSIX_VERSION)
@@ -280,7 +287,7 @@ static jmp_buf readline_top_level;
 static FILE *in_stream, *out_stream;
 
 /* The names of the streams that we do input and output to. */
-FILE *rl_instream = stdin, *rl_outstream = stdout;
+FILE *rl_instream = NULL, *rl_outstream = NULL;
 
 /* Non-zero means echo characters as they are read. */
 int readline_echoing_p = 1;
@@ -1152,6 +1159,8 @@ readline_initialize_everything ()
 {
   /* Find out if we are running in Emacs. */
   running_in_emacs = getenv ("EMACS");
+  rl_instream = stdin;
+  rl_outstream = stdout;
 
   /* Allocate data structures. */
   if (!rl_line_buffer)
@@ -2505,7 +2514,11 @@ rl_prep_terminal ()
 
   tio.c_lflag &= ~(ICANON | ECHO);
 
-  if (otio.c_cc[VEOF] != _POSIX_VDISABLE)
+#ifdef ONLCR
+  tio.c_oflag |= OPOST|ONLCR;
+#endif
+
+  if ((unsigned char)otio.c_cc[VEOF] != (unsigned char)_POSIX_VDISABLE)
     eof_char = otio.c_cc[VEOF];
 
 #if defined (USE_XON_XOFF)
