Here's the patch I promised over on HACKERS - it alters the
authorBruce Momjian
Wed, 19 Feb 2003 04:04:04 +0000 (04:04 +0000)
committerBruce Momjian
Wed, 19 Feb 2003 04:04:04 +0000 (04:04 +0000)
implementation
of '\e' history tracking for systems that have a readline compatability
library without replace_history_entry.  I fall back to pushing the query
onto the history stack after the \e, rather than replacing it.

The patch adds one more place to look for readline headers, and a test
for replace_history_entry. I've only included the patch for configure.in

Ross J. Reedstrom

configure.in
src/bin/psql/command.c
src/bin/psql/input.h
src/include/pg_config.h.in

index 19f6d74defa6236d1b68672624762429b4962e9b..77a63434aa4a6323b6b6e8fdc1ef1bb92a13b099 100644 (file)
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-dnl $Header: /cvsroot/pgsql/configure.in,v 1.236 2003/02/14 14:05:00 momjian Exp $
+dnl $Header: /cvsroot/pgsql/configure.in,v 1.237 2003/02/19 04:04:04 momjian Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
@@ -689,17 +689,19 @@ AC_CHECK_HEADERS(netinet/tcp.h, [], [],
 
 if test "$with_readline" = yes; then
   AC_CHECK_HEADERS(readline/readline.h, [],
-                   [AC_CHECK_HEADERS(readline.h, [],
+                   [AC_CHECK_HEADERS(editline/readline.h, [],
+                         [AC_CHECK_HEADERS(readline.h, [],
                                      [AC_MSG_ERROR([readline header not found
 If you have readline already installed, see config.log for details on the
 failure.  It is possible the compiler isn't looking in the proper directory.
-Use --without-readline to disable readline support.])])])
+Use --without-readline to disable readline support.])])])])
   AC_CHECK_HEADERS(readline/history.h, [],
-                   [AC_CHECK_HEADERS(history.h, [],
+                   [AC_CHECK_HEADERS(editline/history.h, [],
+                         [AC_CHECK_HEADERS(history.h, [],
                                      [AC_MSG_ERROR([history header not found
 If you have readline already installed, see config.log for details on the
 failure.  It is possible the compiler isn't looking in the proper directory.
-Use --without-readline to disable readline support.])])])
+Use --without-readline to disable readline support.])])])])
 fi
 
 if test "$with_zlib" = yes; then
@@ -878,6 +880,7 @@ AC_CHECK_FUNCS(rint, [],
 if test "$with_readline" = yes; then
   PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
   AC_CHECK_FUNCS([rl_completion_matches rl_filename_completion_function])
+  AC_CHECK_FUNCS([replace_history_entry])
 fi
 
 
index 5b727b06bd5b74a65b864d97454565bca7ff119b..0019755c0aa2d19cb7c91a8503673ecc04efbdb0 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2000-2002 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.89 2003/02/13 04:08:16 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.90 2003/02/19 04:04:04 momjian Exp $
  */
 #include "postgres_fe.h"
 #include "command.h"
@@ -1649,7 +1649,12 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
            }
 
 #ifdef USE_READLINE
+#ifdef HAVE_REPLACE_HISTORY_ENTRY
+
            replace_history_entry(where_history(),query_buf->data,NULL);
+#else
+           add_history(query_buf->data);
+#endif
 #endif
            fclose(stream);
        }
index fbb52f20da391ec21f2e0118f843a771f29515e7..4ed51f59cadbd9f57db4766d1b730a4fa81310de 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/input.h,v 1.17 2002/09/04 20:31:36 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/input.h,v 1.18 2003/02/19 04:04:04 momjian Exp $
  */
 #ifndef INPUT_H
 #define INPUT_H
 #define USE_READLINE 1
 #if defined(HAVE_READLINE_READLINE_H)
 #include 
+#elif defined(HAVE_EDITLINE_READLINE_H)
+#include 
 #elif defined(HAVE_READLINE_H)
 #include 
 #endif
 #if defined(HAVE_READLINE_HISTORY_H)
 #include 
+#elif defined(HAVE_EDITLINE_HISTORY_H)
+#include 
 #elif defined(HAVE_HISTORY_H)
 #include 
 #endif
index 953fd4597b2028efececc78ab01b5b6b60e30445..50960bdfd1208d4d7e1d7d342c3b63b8a51ee23f 100644 (file)
@@ -8,7 +8,7 @@
  * or in pg_config.h afterwards.  Of course, if you edit pg_config.h, then your
  * changes will be overwritten the next time you run configure.
  *
- * $Id: pg_config.h.in,v 1.39 2003/02/14 14:05:00 momjian Exp $
+ * $Id: pg_config.h.in,v 1.40 2003/02/19 04:04:04 momjian Exp $
  */
 
 #ifndef PG_CONFIG_H
 /* Set to 1 if you have  */
 #undef HAVE_READLINE_READLINE_H
 
+/* Set to 1 if you have  */
+#undef HAVE_EDITLINE_HISTORY_H
+
+/* Set to 1 if you have  */
+#undef HAVE_EDITLINE_READLINE_H
+
 /* Set to 1 if you have  */
 #undef HAVE_SECURITY_PAM_APPL_H
 
 /* Set to 1 if you have rl_filename_completion_function */
 #undef HAVE_RL_FILENAME_COMPLETION_FUNCTION
 
+/* Set to 1 if you have replace_history_entry */
+#undef HAVE_REPLACE_HISTORY_ENTRY
+
 /* Set to 1 if you have getopt_long() (GNU long options) */
 #undef HAVE_GETOPT_LONG