Detect absence of rl_outstream and handle accordingly. 20131001030504/pspp
authorJohn Darrington <john@darrington.wattle.id.au>
Tue, 1 Oct 2013 07:36:06 +0000 (09:36 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 1 Oct 2013 07:36:06 +0000 (09:36 +0200)
Older versions of readline do not appear to have the variable rl_outstream.  This variable,
almost certainly points to the same stream as stdout, so this change detects its absence
and uses stdout in those cases.

acinclude.m4
src/ui/terminal/terminal-reader.c

index 52ac81acd3dc99e5b16d9405e518227d640fa604..ee7c9b0be68b98ad8ec071497da577f9cf3c29bd 100644 (file)
@@ -123,6 +123,9 @@ AC_DEFUN([PSPP_READLINE],
     AC_DEFINE(HAVE_READLINE, 1, [Define if you have the readline library.])
     AC_MSG_CHECKING([how to link with libreadline])
     AC_MSG_RESULT([$LIBREADLINE])
+    AC_SEARCH_LIBS([rl_outstream], [readline],
+        AC_DEFINE(HAVE_RL_OUTSTREAM, 1, [Define if the readline library provides rl_outstream.])
+    )
   else
     dnl If $LIBREADLINE didn't lead to a usable library, we don't
     dnl need $INCREADLINE either.
index 43f3b92f673dd281bc5746c688bbb759f2a2e2e1..2d72acf39cddbe654555e3525edc582a3f9b00b3 100644 (file)
@@ -107,6 +107,14 @@ terminal_reader_cast (struct lex_reader *r)
   return UP_CAST (r, struct terminal_reader, reader);
 }
 
+/* 
+   Older libreadline versions do not provide rl_outstream.
+   However, it is almost always going to be the same as stdout.
+ */
+#if HAVE_RL_OUTSTREAM
+# define rl_outstream stdout
+#endif
+
 static size_t
 terminal_reader_read (struct lex_reader *r_, char *buf, size_t n,
                       enum prompt_style prompt_style)