Index: Makefile.in =================================================================== RCS file: /cvs/src/src/readline/Makefile.in,v retrieving revision 1.9 diff -u -p -r1.9 Makefile.in --- Makefile.in 27 Mar 2007 18:09:35 -0000 1.9 +++ Makefile.in 26 Jun 2007 09:42:55 -0000 @@ -36,6 +36,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ CC = @CC@ +CXX = @CXX@ RANLIB = @RANLIB@ AR = @AR@ ARFLAGS = @ARFLAGS@ @@ -70,6 +71,7 @@ ETAGS = etags -tw CTAGS = ctags -tw CFLAGS = @CFLAGS@ +CXXFLAGS = @CXXFLAGS@ LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"' CPPFLAGS = @CPPFLAGS@ @@ -94,12 +96,21 @@ GCC_LINT_CFLAGS = $(XCCFLAGS) $(GCC_LINT ${RM} $@ $(CC) -c $(CCFLAGS) $< +.C.o: + ${RM} $@ + $(CXX) -c $(CXXFLAGS) $< + # The name of the main library target. LIBRARY_NAME = libreadline.a STATIC_LIBS = libreadline.a libhistory.a WCWIDTH_OBJ = @WCWIDTH_OBJ@ +@CPLUSPLUS_TRUE@OPTCSOURCES = cleanup-unwind.C +@CPLUSPLUS_TRUE@OPTOBJECTS = cleanup-unwind.o +@CPLUSPLUS_FALSE@OPTCSOURCES = cleanup-none.c +@CPLUSPLUS_FALSE@OPTOBJECTS = cleanup-none.o + # The C code source files for this library. CSOURCES = $(srcdir)/readline.c $(srcdir)/funmap.c $(srcdir)/keymaps.c \ $(srcdir)/vi_mode.c $(srcdir)/parens.c $(srcdir)/rltty.c \ @@ -112,13 +123,13 @@ CSOURCES = $(srcdir)/readline.c $(srcdir $(srcdir)/histfile.c $(srcdir)/nls.c $(srcdir)/search.c \ $(srcdir)/shell.c $(srcdir)/savestring.c $(srcdir)/tilde.c \ $(srcdir)/text.c $(srcdir)/misc.c $(srcdir)/compat.c \ - $(srcdir)/mbutil.c $(srcdir)/support/wcwidth.c + $(srcdir)/mbutil.c $(srcdir)/support/wcwidth.c $(OPTCSOURCES) # The header files for this library. HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \ posixstat.h posixdir.h posixjmp.h tilde.h rlconf.h rltty.h \ ansi_stdlib.h tcap.h rlstdc.h xmalloc.h rlprivate.h rlshell.h \ - rltypedefs.h rlmbutil.h + rltypedefs.h rlmbutil.h cleanup.h HISTOBJ = history.o histexpand.o histfile.o histsearch.o shell.o mbutil.o TILDEOBJ = tilde.o @@ -126,7 +137,7 @@ OBJECTS = readline.o vi_mode.o funmap.o rltty.o complete.o bind.o isearch.o display.o signals.o \ util.o kill.o undo.o macro.o input.o callback.o terminal.o \ text.o nls.o misc.o compat.o xmalloc.o $(HISTOBJ) $(TILDEOBJ) \ - $(WCWIDTH_OBJ) + $(WCWIDTH_OBJ) $(OPTOBJECTS) # The texinfo files which document this library. DOCSOURCE = doc/rlman.texinfo doc/rltech.texinfo doc/rluser.texinfo @@ -484,6 +495,10 @@ search.o: rlmbutil.h text.o: rlmbutil.h vi_mode.o: rlmbutil.h +readline.o: cleanup.h +cleanup-none.o: cleanup.h +cleanup-unwind.o: cleanup.h + bind.o: $(srcdir)/bind.c callback.o: $(srcdir)/callback.c compat.o: $(srcdir)/compat.c @@ -518,6 +533,9 @@ histfile.o: $(srcdir)/histfile.c history.o: $(srcdir)/history.c histsearch.o: $(srcdir)/histsearch.c +cleanup-none.o: $(srcdir)/cleanup-none.c +cleanup-unwind.o: $(srcdir)/cleanup-unwind.C + bind.o: bind.c callback.o: callback.c compat.o: compat.c @@ -551,3 +569,6 @@ histexpand.o: histexpand.c histfile.o: histfile.c history.o: history.c histsearch.o: histsearch.c + +cleanup-none.o: cleanup-none.c +cleanup-unwind.o: cleanup-unwind.C Index: cleanup-none.c =================================================================== RCS file: cleanup-none.c diff -N cleanup-none.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ cleanup-none.c 26 Jun 2007 09:42:55 -0000 @@ -0,0 +1,11 @@ +#include "cleanup.h" + +void *_rl_cleanup (void *(*body) (void *data), void (*cleanup) (void *data), + void *data) +{ + void *retval; + + retval = (*body) (data); + (*cleanup) (data); + return retval; +} Index: cleanup-unwind.C =================================================================== RCS file: cleanup-unwind.C diff -N cleanup-unwind.C --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ cleanup-unwind.C 26 Jun 2007 09:42:55 -0000 @@ -0,0 +1,14 @@ +#include "cleanup.h" + +void *_rl_cleanup (void *(*body) (void *data), void (*cleanup) (void *data), + void *data) +{ + try + { + return (*body) (data); + } + catch (...) + { + (*cleanup) (data); + } +} Index: cleanup.h =================================================================== RCS file: cleanup.h diff -N cleanup.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ cleanup.h 26 Jun 2007 09:42:55 -0000 @@ -0,0 +1,8 @@ +#ifdef __cplusplus +extern "C" { +#endif +void *_rl_cleanup (void *(*body) (void *data), void (*cleanup) (void *data), + void *data); +#ifdef __cplusplus +} +#endif Index: configure.in =================================================================== RCS file: /cvs/src/src/readline/configure.in,v retrieving revision 1.10 diff -u -p -r1.10 configure.in --- configure.in 5 May 2006 18:26:12 -0000 1.10 +++ configure.in 26 Jun 2007 09:42:56 -0000 @@ -112,6 +112,26 @@ AC_PROG_CC dnl AC_AIX AC_MINIX +m4_pushdef([AC_MSG_ERROR], [cxx_error=yes]) +AC_PROG_CXX +AC_LANG_PUSH([C++]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[const char hw[] = "hello world\n";]], + [[cout << hw;]])], + [AC_PROG_CXXCPP + cxx_available=no], + [cxx_available=yes]) +AC_LANG_POP([C++]) +m4_popdef([AC_MSG_ERROR]) +if test "x$cxx_available" = "xyes"; then + CPLUSPLUS_TRUE="" + CPLUSPLUS_FALSE="#" +else + CPLUSPLUS_TRUE="#" + CPLUSPLUS_FALSE="" +fi +AC_SUBST(CPLUSPLUS_TRUE) +AC_SUBST(CPLUSPLUS_FALSE) + dnl BEGIN changes for CYGNUS cross-building for Cygwin dnl NOTE: Some of these changes may no longer be necessary. Index: readline.c =================================================================== RCS file: /cvs/src/src/readline/readline.c,v retrieving revision 1.10 diff -u -p -r1.10 readline.c --- readline.c 5 May 2006 18:26:12 -0000 1.10 +++ readline.c 26 Jun 2007 09:42:56 -0000 @@ -66,6 +66,7 @@ #include "rlprivate.h" #include "rlshell.h" #include "xmalloc.h" +#include "cleanup.h" #ifndef RL_LIBRARY_VERSION # define RL_LIBRARY_VERSION "5.1" @@ -287,6 +288,14 @@ rl_set_prompt (prompt) rl_visible_prompt_length = rl_expand_prompt (rl_prompt); return 0; } + +static void +readline_cleanup (in_callback_pointer) + int *in_callback_pointer; +{ + if (*in_callback_pointer) + RL_SETSTATE (RL_STATE_CALLBACK); +} /* Read a line of input. Prompt with PROMPT. An empty PROMPT means none. A return value of NULL means that EOF was encountered. */ @@ -295,6 +304,7 @@ readline (prompt) const char *prompt; { char *value; + int in_callback; /* If we are at EOF return a NULL string. */ if (rl_pending_input == EOF) @@ -303,6 +313,13 @@ readline (prompt) return ((char *)NULL); } + /* When we call readline, we have to make sure that readline isn't in + the callback state. Otherwise, it will get really confused. + PR gdb tui/2173. */ + in_callback = RL_ISSTATE (RL_STATE_CALLBACK); + if (in_callback) + RL_UNSETSTATE (RL_STATE_CALLBACK); + rl_set_prompt (prompt); rl_initialize (); @@ -313,7 +330,10 @@ readline (prompt) rl_set_signals (); #endif - value = readline_internal (); + /* readline_internal () has no parameters. */ + value = _rl_cleanup ((void *(*) ()) readline_internal, readline_cleanup, + &in_callback); + if (rl_deprep_term_function) (*rl_deprep_term_function) ();