--- pwsafe-0.1.4/configure.ac Thu Feb 12 07:57:30 2004 +++ pwsafe/configure.ac Mon Feb 16 20:18:01 2004 @@ -101,6 +101,7 @@ AC_CHECK_FUNC(readline, [], [AC_MSG_ERROR(readline() is needed)]) fi + if test "$with_readline" != no; then dnl older readline.h's declared readline() without any arguments and outside of 'extern "C"', which freaks out C++ AC_LANG_PUSH(C++) @@ -120,6 +121,37 @@ AC_MSG_RESULT(yes)]) AC_LANG_POP(C++) fi + + +if test "$with_readline" != no; then +dnl slightly newer but still broken readline.h's use extern "C" but don't declare arguments, so C++ freaks out because of the lack of 'const'ness +AC_LANG_PUSH(C++) +AC_MSG_CHECKING([if readline.h lacks 'const' in its declarations]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include +#if READLINE_H_NEEDS_EXTERN_C +extern "C" { +#endif +#include +#if READLINE_H_NEEDS_EXTERN_C +} // terminate extern "C" +#endif + +char* dummy_completion(const char*, int) { return 0; } + ]],[[ + const char* prompt = "abc"; + rl_completion_entry_function = dummy_completion; + char*x = readline(prompt); + ]] + )], + [AC_MSG_RESULT(no)], + [AC_DEFINE(READLINE_H_USES_NO_CONST, 1, [Define to 1 if readline/readline.h doesn't properly declare arguments to be const]) + AC_MSG_RESULT(yes)]) +AC_LANG_POP(C++) +fi + dnl different versions of g++ implement allocators differently. Figure out what kind this g++ uses. dnl Note: g++ 3.0 is too broken to be supported, use 2.96 or 3.y, y>=1. --- pwsafe-0.1.4/pwsafe.cpp Thu Feb 12 07:57:33 2004 +++ pwsafe/pwsafe.cpp Mon Feb 16 20:14:37 2004 @@ -736,6 +736,8 @@ #if READLINE_H_NEEDS_EXTERN_C extern "C" { static dummy_completion() // more hack job to keep compile warnings away +#elif READLINE_H_USES_NO_CONST +static char* dummy_completion(char*, int) #else static char* dummy_completion(const char*, int) #endif @@ -760,7 +762,11 @@ #if WITH_READLINE rl_completion_entry_function = dummy_completion; // we don't need readline doing any tab completion (and especially not filenames) #endif +#if READLINE_H_USES_NO_CONST + char* x = readline(const_cast(prompt)); +#else char* x = readline(prompt); +#endif // restore echo tcsetattr(STDIN_FILENO, TCSANOW, &tio); // echo a linefeed since the user's was not echoed @@ -782,7 +788,11 @@ #if WITH_READLINE rl_completion_entry_function = dummy_completion; // we don't need readline doing any tab completion (and especially not filenames) #endif +#if READLINE_H_USES_NO_CONST + char* x = readline(const_cast(prompt)); +#else char* x = readline(prompt); +#endif if (x) { secstring xx(x); memset(x,0,strlen(x)); --- pwsafe-0.1.4/configure Thu Feb 12 07:58:06 2004 +++ pwsafe/configure Mon Feb 16 20:19:43 2004 @@ -6561,6 +6561,7 @@ fi + if test "$with_readline" != no; then ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' @@ -6629,6 +6630,85 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu fi + + +if test "$with_readline" != no; then +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +echo "$as_me:$LINENO: checking if readline.h lacks 'const' in its declarations" >&5 +echo $ECHO_N "checking if readline.h lacks 'const' in its declarations... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" + +#include +#if READLINE_H_NEEDS_EXTERN_C +extern "C" { +#endif +#include +#if READLINE_H_NEEDS_EXTERN_C +} // terminate extern "C" +#endif + +char* dummy_completion(const char*, int) { return 0; } + +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ + + const char* prompt = "abc"; + rl_completion_entry_function = dummy_completion; + char*x = readline(prompt); + + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 + +cat >>confdefs.h <<\_ACEOF +#define READLINE_H_USES_NO_CONST 1 +_ACEOF + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi + ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS'