Added configure test for readline's filename_completion_function
authorPeter Eisentraut
Sun, 5 Mar 2000 13:30:20 +0000 (13:30 +0000)
committerPeter Eisentraut
Sun, 5 Mar 2000 13:30:20 +0000 (13:30 +0000)
Completed psql's \? help

src/bin/psql/common.c
src/bin/psql/common.h
src/bin/psql/help.c
src/bin/psql/mainloop.c
src/bin/psql/tab-complete.c
src/bin/psql/tab-complete.h
src/configure.in
src/include/config.h.in
src/include/port/win.h

index 30e0cb5473e4ca136f32484f323c9a7682f72fd2..fbf6950ffd3c24f05b2380547cdcb10b12348272 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.18 2000/03/01 21:09:58 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.19 2000/03/05 13:30:19 petere Exp $
  */
 #include "postgres.h"
 #include "common.h"
@@ -247,6 +247,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
 PGconn *cancelConn;
 volatile bool cancel_pressed;
 
+#ifndef WIN32
+
 #define write_stderr(String) write(fileno(stderr), String, strlen(String))
 
 void
@@ -269,7 +271,7 @@ handle_sigint(SIGNAL_ARGS)
        write_stderr(PQerrorMessage(cancelConn));
    }
 }
-
+#endif /* not WIN32 */
 
 
 /*
index 96c8a7994894a74420491b02db6ba0fd050bcd0d..2f343e425a670fd896e4537f06b57f06037c6e39 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.8 2000/03/01 21:09:58 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.9 2000/03/05 13:30:19 petere Exp $
  */
 #ifndef COMMON_H
 #define COMMON_H
@@ -30,7 +30,9 @@ char *        simple_prompt(const char *prompt, int maxlen, bool echo);
 
 extern volatile bool cancel_pressed;
 extern PGconn *cancelConn;
+#ifndef WIN32
 void        handle_sigint(SIGNAL_ARGS);
+#endif /* not WIN32 */
 
 PGresult * PSQLexec(const char *query);
 
index 33c187bdb2a74d26b400a5665deba3c9dc55a8b3..a1bff8a31b15dbf685e1f896457fde97295df2ec 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.23 2000/03/01 21:09:58 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.24 2000/03/05 13:30:19 petere Exp $
  */
 #include "postgres.h"
 #include "help.h"
@@ -183,7 +183,7 @@ slashUsage(void)
    if (pset.notty == 0 &&
        (pagerenv = getenv("PAGER")) &&
        (pagerenv[0] != '\0') &&
-       screen_size.ws_row <= 36 &&
+       screen_size.ws_row <= 39 &&
        (fout = popen(pagerenv, "w")))
    {
        usePipe = true;
@@ -195,6 +195,7 @@ slashUsage(void)
        fout = stdout;
 
    /* if you add/remove a line here, change the row test above */
+    fprintf(fout, " \\a             toggle between unaligned and aligned mode\n");
    fprintf(fout, " \\c[onnect] [dbname|- [user]]\n"
          "                 connect to new database (currently '%s')\n", PQdb(pset.db));
    fprintf(fout, " \\copy ...      perform SQL COPY with data stream to the client machine\n");
@@ -209,8 +210,11 @@ slashUsage(void)
    fprintf(fout, " \\e [fname]     edit the current query buffer or  with external editor\n");
    fprintf(fout, " \\echo    write text to stdout\n");
    fprintf(fout, " \\encoding   set client encoding\n");
+    fprintf(fout, " \\f        change field separator\n");
    fprintf(fout, " \\g [fname]     send query to backend (and results in  or |pipe)\n");
    fprintf(fout, " \\h [cmd]       help on syntax of sql commands, * for all commands\n");
+    fprintf(fout, " \\H             toggle HTML mode (currently %s)\n",
+            ON(pset.popt.topt.format==PRINT_HTML));
    fprintf(fout, " \\i      read and execute queries from filename\n");
    fprintf(fout, " \\l             list all databases\n");
    fprintf(fout, " \\lo_export, \\lo_import, \\lo_list, \\lo_unlink\n"
@@ -226,8 +230,8 @@ slashUsage(void)
    fprintf(fout, " \\set    set internal variable\n");
    fprintf(fout, " \\t             don't show table headers or footers (currently %s)\n", ON(pset.popt.topt.tuples_only));
    fprintf(fout, " \\unset    unset (delete) internal variable\n");
-   fprintf(fout, " \\x             toggle expanded output (currently %s)\n", ON(pset.popt.topt.expanded));
    fprintf(fout, " \\w      write current query buffer to a file\n");
+   fprintf(fout, " \\x             toggle expanded output (currently %s)\n", ON(pset.popt.topt.expanded));
    fprintf(fout, " \\z             list table access permissions\n");
    fprintf(fout, " \\! [cmd]       shell escape or command\n");
 
index 4c5c7c55858869dcff7d053ae780cf012658c11c..4bd4608e5cecf37c5b6b99a485311348f0912f3a 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.23 2000/03/01 21:09:58 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.24 2000/03/05 13:30:19 petere Exp $
  */
 #include "postgres.h"
 #include "mainloop.h"
@@ -92,6 +92,7 @@ MainLoop(FILE *source)
    /* main loop to get queries and execute them */
    while (1)
    {
+#ifndef WIN32
         /*
          * Welcome code for Control-C
          */
@@ -133,7 +134,7 @@ MainLoop(FILE *source)
                 break;
             }
         }
-
+#endif /* not WIN32 */
 
        if (slashCmdStatus == CMD_NEWEDIT)
        {
index 9edfc6b6da8fc3fae32eeb2f5a957d41ac150f1c..54561cb377872ff618705d8df91deaf41107140c 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.14 2000/02/20 14:28:20 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.15 2000/03/05 13:30:19 petere Exp $
  */
 
 /*-----------
 #include "common.h"
 #include "settings.h"
 
+#if defined(HAVE_FILENAME_COMPLETION_FUNCTION) && !defined(HAVE_FILENAME_COMPLETION_FUNCTION_DECL)
+char * filename_completion_function (char *, int);
+#endif
+
 #define BUF_SIZE 2048
 #define ERROR_QUERY_TOO_LONG /* empty */
 
@@ -532,7 +536,15 @@ char ** psql_completion(char *text, int start, int end)
              strcmp(prev_wd, "\\s")==0 ||
              strcmp(prev_wd, "\\w")==0 || strcmp(prev_wd, "\\write")==0
         ) {
+#ifdef HAVE_FILENAME_COMPLETION_FUNCTION
         matches = completion_matches(text, filename_completion_function);
+#else
+        /*
+         * This will probably have the same effect, but you never know what
+         * the heck some readline incarnation out there is going to do.
+         */
+        matches = NULL;
+#endif
     }
 
 
index 8c54cffeb64fa3503bc838f096cfeb3a18d329ec..c7d44bd2f07a61995e1410edc1d682a5e340db87 100644 (file)
@@ -3,11 +3,13 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.h,v 1.3 2000/01/29 16:58:49 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.h,v 1.4 2000/03/05 13:30:19 petere Exp $
  */
 #ifndef TAB_COMPLETE_H
 #define TAB_COMPLETE_H
 
+#include "postgres.h"
+
 void initialize_readline(void);
 
 #endif
index fc91938220eb3ccbd282da068a7d352fc1949d89..dd79e1a9774398ca3e5fd94fd9d0f20fe0e6625f 100644 (file)
@@ -846,6 +846,18 @@ AC_EGREP_HEADER(rl_completion_append_character, readline.h,
        AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER))])
 AC_SUBST(HAVE_RL_COMPLETION_APPEND_CHARACTER)
 
+dnl Check for readline's filename_completion_function.
+dnl Some versions have it but it's not in the headers, so we have to take
+dnl care of that, too.
+AC_CHECK_FUNCS(filename_completion_function,
+    AC_EGREP_HEADER(filename_completion_function, readline.h,
+        AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL),
+        [AC_EGREP_HEADER(filename_completion_function, readline/readline.h,
+            AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL))])
+)
+AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION)
+AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION_DECL)
+
 dnl Check for GNU style long options support (getopt_long)
 AC_CHECK_FUNCS(getopt_long)
 
index 806aae9675b313676b6a63014554c4caad86533f..fb472061f5913fdbb7e355c46b54f1be5eff3106 100644 (file)
@@ -468,6 +468,12 @@ extern void srandom(unsigned int seed);
 /* Set to 1 if your libreadline defines rl_completion_append_character */
 #undef HAVE_RL_COMPLETION_APPEND_CHARACTER
 
+/* Set to 1 if your libreadline has filename_completion_function */
+#undef HAVE_FILENAME_COMPLETION_FUNCTION
+
+/* Set to 1 if your readline headers actually declare the above */
+#undef HAVE_FILENAME_COMPLETION_FUNCTION_DECL
+
 /* Set to 1 if you have getopt_long() (GNU long options) */
 #undef HAVE_GETOPT_LONG
 
index 77081fa36afb97e66a51c4800d0587b4f87c4751..61acdb3e21e75b05e9b53eac13f2891896b6db3a 100644 (file)
@@ -14,6 +14,3 @@ typedef unsigned char slock_t;
 #if (CYGWIN_VERSION_API_MAJOR >= 0) && (CYGWIN_VERSION_API_MINOR >= 8)
 #define sys_nerr _sys_nerr
 #endif
-
-/* not exported in readline.h */
-char * filename_completion_function();