Index: acconfig.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/acconfig.h,v retrieving revision 1.30 diff -u -r1.30 acconfig.h --- acconfig.h 2002/04/25 12:44:00 1.30 +++ acconfig.h 2002/05/16 17:03:38 @@ -47,6 +47,7 @@ #undef FUNCPROTO #undef NARROWPROTO #undef HAVE_LIBREADLINE +#undef HAVE_NEWLIBREADLINE #undef NONBLOCKING_SOCKETS #undef HAVE_FCNTL #undef HAVE_IOCTL Index: configure.in =================================================================== RCS file: /home/freeciv/CVS/freeciv/configure.in,v retrieving revision 1.181 diff -u -r1.181 configure.in --- configure.in 2002/05/02 05:57:37 1.181 +++ configure.in 2002/05/16 17:03:39 @@ -549,77 +549,8 @@ fi dnl Readline library and header files. - if test "$WITH_READLINE" = "yes" || test "$WITH_READLINE" = "maybe"; then - HAVE_TERMCAP=""; - dnl Readline header - AC_CHECK_HEADER(readline/readline.h, - have_readline_header=1, - have_readline_header=0) - if test "$have_readline_header" = "0"; then - if test "$WITH_READLINE" = "yes"; then - AC_MSG_ERROR(Did not find readline header file. -You may need to install a readline \"development\" package.) - else - AC_MSG_WARN(Did not find readline header file. -Configuring server without readline support.) - fi - else - dnl Readline lib - AC_CHECK_LIB(readline, rl_completion_matches, - have_readline_lib=1, have_readline_lib=0) - if test "$have_readline_lib" = "0"; then - dnl Many readline installations are broken in that they - dnl don't set the dependesy on the curses lib up correctly. - dnl We give them a hand by trying to guess what might be needed. - dnl - dnl Some older Unices may need both -lcurses and -ltermlib, - dnl but we don't support that just yet.... + FC_HAS_READLINE() - AC_CHECK_LIB(termlib, initscr, HAVE_TERMCAP="-ltermlib") - AC_CHECK_LIB(termcap, initscr, HAVE_TERMCAP="-ltermcap") - AC_CHECK_LIB(curses, initscr, HAVE_TERMCAP="-lcurses") - AC_CHECK_LIB(ncurses, initscr, HAVE_TERMCAP="-lncurses") - - if test x"$HAVE_TERMCAP" != "x"; then - dnl We can't check for rl_completion_matches() again, - dnl cause the result is cached. And autoconf doesn't - dnl seem to have a way to uncache it. - AC_CHECK_LIB(readline, rl_filename_completion_function, - have_readline_lib=1, have_readline_lib=0, - "$HAVE_TERMCAP") - if test "$have_readline_lib" = "1"; then - AC_MSG_WARN(I had to manually add $HAVE_TERMCAP dependency to -make readline library pass the test.) - fi - fi - fi - - if test "$have_readline_lib" = "1"; then - FC_CHECK_READLINE_RUNTIME($HAVE_TERMCAP, - have_readline_lib=1, have_readline_lib=0) - if test "$have_readline_lib" = "1"; then - SERVER_LIBS="-lreadline $SERVER_LIBS $HAVE_TERMCAP" - AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE) - else - if test "$WITH_READLINE" = "yes"; then - AC_MSG_ERROR(Specified --with-readline but the -runtime test of readline failed.) - else - AC_MSG_WARN(Runtime test of readline failed. -Configuring server without readline support.) - fi - fi - else - if test "$WITH_READLINE" = "yes"; then - AC_MSG_ERROR(Specified --with-readline but the -test to link against the library failed.) - else - AC_MSG_WARN(Test to link against readline library failed. -Configuring server without readline support.) - fi - fi - fi - fi AC_CHECK_FUNC(pow) if test $ac_cv_func_pow = no; then AC_CHECK_LIB(m, pow, SERVER_LIBS="$SERVER_LIBS -lm", Index: configure.ac =================================================================== RCS file: /home/freeciv/CVS/freeciv/configure.ac,v retrieving revision 1.3 diff -u -r1.3 configure.ac --- configure.ac 2002/05/14 21:10:20 1.3 +++ configure.ac 2002/05/16 17:03:39 @@ -555,77 +555,8 @@ fi dnl Readline library and header files. - if test "$WITH_READLINE" = "yes" || test "$WITH_READLINE" = "maybe"; then - HAVE_TERMCAP=""; - dnl Readline header - AC_CHECK_HEADER(readline/readline.h, - have_readline_header=1, - have_readline_header=0) - if test "$have_readline_header" = "0"; then - if test "$WITH_READLINE" = "yes"; then - AC_MSG_ERROR(Did not find readline header file. -You may need to install a readline \"development\" package.) - else - AC_MSG_WARN(Did not find readline header file. -Configuring server without readline support.) - fi - else - dnl Readline lib - AC_CHECK_LIB(readline, rl_completion_matches, - have_readline_lib=1, have_readline_lib=0) - if test "$have_readline_lib" = "0"; then - dnl Many readline installations are broken in that they - dnl don't set the dependesy on the curses lib up correctly. - dnl We give them a hand by trying to guess what might be needed. - dnl - dnl Some older Unices may need both -lcurses and -ltermlib, - dnl but we don't support that just yet.... + FC_HAS_READLINE() - AC_CHECK_LIB(termlib, initscr, HAVE_TERMCAP="-ltermlib") - AC_CHECK_LIB(termcap, initscr, HAVE_TERMCAP="-ltermcap") - AC_CHECK_LIB(curses, initscr, HAVE_TERMCAP="-lcurses") - AC_CHECK_LIB(ncurses, initscr, HAVE_TERMCAP="-lncurses") - - if test x"$HAVE_TERMCAP" != "x"; then - dnl We can't check for rl_completion_matches() again, - dnl cause the result is cached. And autoconf doesn't - dnl seem to have a way to uncache it. - AC_CHECK_LIB(readline, rl_filename_completion_function, - have_readline_lib=1, have_readline_lib=0, - "$HAVE_TERMCAP") - if test "$have_readline_lib" = "1"; then - AC_MSG_WARN(I had to manually add $HAVE_TERMCAP dependency to -make readline library pass the test.) - fi - fi - fi - - if test "$have_readline_lib" = "1"; then - FC_CHECK_READLINE_RUNTIME($HAVE_TERMCAP, - have_readline_lib=1, have_readline_lib=0) - if test "$have_readline_lib" = "1"; then - SERVER_LIBS="-lreadline $SERVER_LIBS $HAVE_TERMCAP" - AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE, 1, [Readline support]) - else - if test "$WITH_READLINE" = "yes"; then - AC_MSG_ERROR(Specified --with-readline but the -runtime test of readline failed.) - else - AC_MSG_WARN(Runtime test of readline failed. -Configuring server without readline support.) - fi - fi - else - if test "$WITH_READLINE" = "yes"; then - AC_MSG_ERROR(Specified --with-readline but the -test to link against the library failed.) - else - AC_MSG_WARN(Test to link against readline library failed. -Configuring server without readline support.) - fi - fi - fi - fi AC_CHECK_FUNC(pow) if test $ac_cv_func_pow = no; then AC_CHECK_LIB(m, pow, SERVER_LIBS="$SERVER_LIBS -lm", Index: m4/readline.m4 =================================================================== RCS file: /home/freeciv/CVS/freeciv/m4/readline.m4,v retrieving revision 1.1 diff -u -r1.1 readline.m4 --- m4/readline.m4 2002/04/13 13:51:48 1.1 +++ m4/readline.m4 2002/05/16 17:03:39 @@ -57,3 +57,114 @@ LIBS="$templibs" ]) +AC_DEFUN([FC_HAS_READLINE], +[ + dnl Readline library and header files. + if test "$WITH_READLINE" = "yes" || test "$WITH_READLINE" = "maybe"; then + HAVE_TERMCAP=""; + dnl Readline header + AC_CHECK_HEADER(readline/readline.h, + have_readline_header=1, + have_readline_header=0) + if test "$have_readline_header" = "0"; then + if test "$WITH_READLINE" = "yes"; then + AC_MSG_ERROR(Did not find readline header file. +You may need to install a readline \"development\" package.) + else + AC_MSG_WARN(Did not find readline header file. +Configuring server without readline support.) + fi + else + dnl Readline lib + AC_CHECK_LIB(readline, completion_matches, + have_readline_lib=1, have_readline_lib=0) + if test "$have_readline_lib" = "0"; then + dnl Many readline installations are broken in that they + dnl don't set the dependency on the curses lib up correctly. + dnl We give them a hand by trying to guess what might be needed. + dnl + dnl Some older Unices may need both -lcurses and -ltermlib, + dnl but we don't support that just yet.... + + AC_CHECK_LIB(termlib, tgetent, HAVE_TERMCAP="-ltermlib") + AC_CHECK_LIB(termcap, tgetent, HAVE_TERMCAP="-ltermcap") + AC_CHECK_LIB(curses, tgetent, HAVE_TERMCAP="-lcurses") + AC_CHECK_LIB(ncurses, tgetent, HAVE_TERMCAP="-lncurses") + + if test x"$HAVE_TERMCAP" != "x"; then + dnl We can't check for completion_matches() again, + dnl cause the result is cached. And autoconf doesn't + dnl seem to have a way to uncache it. + AC_CHECK_LIB(readline, filename_completion_function, + have_readline_lib=1, have_readline_lib=0, + "$HAVE_TERMCAP") + if test "$have_readline_lib" = "1"; then + AC_MSG_WARN(I had to manually add $HAVE_TERMCAP dependency to +make readline library pass the test.) + fi + fi + fi + + dnl Readline lib >= 4.2 + AC_CHECK_LIB(readline, rl_completion_matches, + have_new_readline_lib=1, have_new_readline_lib=0) + if test "$have_new_readline_lib" = "0"; then + if test x"$HAVE_TERMCAP" != "x"; then + dnl We can't check for rl_completion_matches() again, + dnl cause the result is cached. And autoconf doesn't + dnl seem to have a way to uncache it. + AC_CHECK_LIB(readline, rl_filename_completion_function, + have_new_readline_lib=1, have_new_readline_lib=0, + "$HAVE_TERMCAP") + if test "$have_new_readline_lib" = "1"; then + AC_MSG_WARN(I had to manually add $HAVE_TERMCAP dependency to +make readline library pass the test.) + fi + fi + fi + + if test "$have_new_readline_lib" = "1"; then + FC_CHECK_READLINE_RUNTIME($HAVE_TERMCAP, + have_new_readline_lib=1, have_new_readline_lib=0) + if test "$have_new_readline_lib" = "1"; then + SERVER_LIBS="-lreadline $SERVER_LIBS $HAVE_TERMCAP" + AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE, 1, [Readline support]) + AC_DEFINE_UNQUOTED(HAVE_NEWLIBREADLINE, 1, [Modern readline]) + else + if test "$WITH_READLINE" = "yes"; then + AC_MSG_ERROR(Specified --with-readline but the +runtime test of readline failed.) + else + AC_MSG_WARN(Runtime test of readline failed. +Configuring server without readline support.) + fi + fi + else + if test "$have_readline_lib" = "1"; then + FC_CHECK_READLINE_RUNTIME($HAVE_TERMCAP, + have_readline_lib=1, have_readline_lib=0) + if test "$have_readline_lib" = "1"; then + SERVER_LIBS="-lreadline $SERVER_LIBS $HAVE_TERMCAP" + AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE, 1, [Readline support]) + else + if test "$WITH_READLINE" = "yes"; then + AC_MSG_ERROR(Specified --with-readline but the +runtime test of readline failed.) + else + AC_MSG_WARN(Runtime test of readline failed. +Configuring server without readline support.) + fi + fi + else + if test "$WITH_READLINE" = "yes"; then + AC_MSG_ERROR(Specified --with-readline but the +test to link against the library failed.) + else + AC_MSG_WARN(Test to link against readline library failed. +Configuring server without readline support.) + fi + fi + fi + fi + fi +]) Index: server/stdinhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v retrieving revision 1.224 diff -u -r1.224 stdinhand.c --- server/stdinhand.c 2002/05/14 19:40:42 1.224 +++ server/stdinhand.c 2002/05/16 17:03:40 @@ -23,7 +23,11 @@ #ifdef HAVE_LIBREADLINE #include +#ifdef HAVE_NEWLIBREADLINE +#define completion_matches(x,y) rl_completion_matches(x,y) +#define filename_completion_function rl_filename_completion_function #endif +#endif #include "astring.h" #include "attribute.h" @@ -3880,31 +3884,35 @@ in case we want to do some simple parsing. Return the array of matches, or NULL if there aren't any. **************************************************************************/ +#ifndef HAVE_NEWLIBREADLINE +char **freeciv_completion(char *text, int start, int end) +#else char **freeciv_completion(const char *text, int start, int end) +#endif { char **matches = (char **)NULL; if (is_help(start)) { - matches = rl_completion_matches(text, help_generator); + matches = completion_matches(text, help_generator); } else if (is_command(start)) { - matches = rl_completion_matches(text, command_generator); + matches = completion_matches(text, command_generator); } else if (is_rulesout(start)) { - matches = rl_completion_matches(text, rulesout_generator); + matches = completion_matches(text, rulesout_generator); } else if (is_list(start)) { - matches = rl_completion_matches(text, list_generator); + matches = completion_matches(text, list_generator); } else if (is_cmdlevel_arg2(start)) { - matches = rl_completion_matches(text, cmdlevel_arg2_generator); + matches = completion_matches(text, cmdlevel_arg2_generator); } else if (is_cmdlevel_arg1(start)) { - matches = rl_completion_matches(text, cmdlevel_arg1_generator); + matches = completion_matches(text, cmdlevel_arg1_generator); } else if (is_connection(start)) { - matches = rl_completion_matches(text, connection_generator); + matches = completion_matches(text, connection_generator); } else if (is_player(start)) { - matches = rl_completion_matches(text, player_generator); + matches = completion_matches(text, player_generator); } else if (is_server_option(start)) { - matches = rl_completion_matches(text, option_generator); + matches = completion_matches(text, option_generator); } else if (is_filename(start)) { /* This function we get from readline */ - matches = rl_completion_matches(text, rl_filename_completion_function); + matches = completion_matches(text, filename_completion_function); } else /* We have no idea what to do */ matches = NULL; Index: server/stdinhand.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.h,v retrieving revision 1.22 diff -u -r1.22 stdinhand.h --- server/stdinhand.h 2002/02/07 10:24:24 1.22 +++ server/stdinhand.h 2002/05/16 17:03:40 @@ -38,7 +38,11 @@ void notify_if_first_access_level_is_available(void); #ifdef HAVE_LIBREADLINE +#ifndef HAVE_NEWLIBREADLINE +char **freeciv_completion(char *text, int start, int end); +#else char **freeciv_completion(const char *text, int start, int end); +#endif #endif #endif /* FC__STDINHAND_H */