From: John Darrington Date: Tue, 1 Oct 2013 07:36:06 +0000 (+0200) Subject: Detect absence of rl_outstream and handle accordingly. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;h=6da9ed01e15953f12bc1ba35fbee53a7a7e46da0;p=pspp Detect absence of rl_outstream and handle accordingly. 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. --- diff --git a/acinclude.m4 b/acinclude.m4 index 52ac81acd3..ee7c9b0be6 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -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. diff --git a/src/ui/terminal/terminal-reader.c b/src/ui/terminal/terminal-reader.c index 43f3b92f67..2d72acf39c 100644 --- a/src/ui/terminal/terminal-reader.c +++ b/src/ui/terminal/terminal-reader.c @@ -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)