File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,30 @@ AC_TYPE_UINT64_T
4343AC_FUNC_STRCOLL
4444AC_CHECK_FUNCS ( [ memchr memmove memset stpcpy strchr strcspn strdup strerror strpbrk strrchr strspn strstr] )
4545
46+ # Then check for the variable considering both possible locations
47+ AC_CHECK_DECL ( [ rl_change_environment] ,
48+ [ AC_DEFINE ( [ HAVE_RL_CHANGE_ENVIRONMENT] , [ 1] , [ Define if rl_change_environment is available] ) ] ,
49+ [ AC_MSG_WARN ( [ rl_change_environment not found] ) ] ,
50+ [ [ #ifdef HAVE_READLINE_H
51+ #include <readline.h>
52+ #endif
53+ #ifdef HAVE_READLINE_READLINE_H
54+ #include <readline/readline.h>
55+ #endif
56+ ] ] )
57+
58+ AC_CHECK_DECL ( [ rl_input_available_hook] ,
59+ [ AC_DEFINE ( [ HAVE_RL_INPUT_AVAILABLE_HOOK] , [ 1] , [ Define if rl_input_available_hook is available] ) ] ,
60+ [ AC_MSG_WARN ( [ rl_input_available_hook not found] ) ] ,
61+ [ [ #ifdef HAVE_READLINE_H
62+ #include <readline.h>
63+ #endif
64+ #ifdef HAVE_READLINE_READLINE_H
65+ #include <readline/readline.h>
66+ #endif
67+ ] ] )
68+
69+
4670AC_CONFIG_FILES ( [ Makefile] )
4771
4872AC_ARG_ENABLE ( [ gcov] ,
Original file line number Diff line number Diff line change 44#include <string.h>
55#include <inttypes.h>
66#include <ctype.h>
7+ #include <unistd.h>
78#include "bitwise.h"
89#include "shunting-yard.h"
910
@@ -225,6 +226,12 @@ static int readline_input_avail(void)
225226
226227static int readline_getc (FILE * dummy )
227228{
229+ #ifndef HAVE_RL_INPUT_AVAILABLE_HOOK
230+ /* Block until input is available when hook is not supported */
231+ while (!g_input_avail ) {
232+ usleep (1000 );
233+ }
234+ #endif
228235 g_input_avail = false;
229236 return g_input ;
230237}
@@ -272,9 +279,13 @@ void init_readline(void)
272279 rl_catch_sigwinch = 0 ;
273280 rl_deprep_term_function = NULL ;
274281 rl_prep_term_function = NULL ;
282+ #ifdef HAVE_RL_CHANGE_ENVIRONMENT
275283 rl_change_environment = 0 ;
284+ #endif
276285 rl_getc_function = readline_getc ;
286+ #ifdef HAVE_RL_INPUT_AVAILABLE_HOOK
277287 rl_input_available_hook = readline_input_avail ;
288+ #endif
278289 rl_redisplay_function = readline_redisplay ;
279290 //rl_bind_key('\t', rl_insert);
280291 rl_callback_handler_install (":" , got_command );
You can’t perform that action at this time.
0 commit comments