|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.137 1998/03/16 14:27:38 momjian Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.138 1998/04/05 21:29:36 momjian Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
|
38 | 38 | #ifdef HAVE_LIBREADLINE
|
39 | 39 | #ifdef HAVE_READLINE_H
|
40 | 40 | #include <readline.h>
|
| 41 | +#define USE_READLINE 1 |
41 | 42 | #if defined(HAVE_HISTORY)
|
42 | 43 | #include <history.h>
|
| 44 | +#define USE_HISTORY 1 |
43 | 45 | #endif
|
44 | 46 | #else
|
| 47 | +#if defined(HAVE_READLINE_READLINE_H) |
45 | 48 | #include <readline/readline.h>
|
| 49 | +#define USE_READLINE 1 |
46 | 50 | #if defined(HAVE_READLINE_HISTORY_H)
|
47 | 51 | #include <readline/history.h>
|
| 52 | +#define USE_HISTORY 1 |
| 53 | +#endif |
48 | 54 | #endif
|
49 | 55 | #endif
|
50 | 56 | #endif
|
@@ -931,7 +937,7 @@ gets_readline(char *prompt, FILE *source)
|
931 | 937 | {
|
932 | 938 | char *s;
|
933 | 939 |
|
934 |
| -#ifdef HAVE_LIBREADLINE |
| 940 | +#ifdef USE_READLINE |
935 | 941 | s = readline(prompt);
|
936 | 942 | #else
|
937 | 943 | char buf[500];
|
@@ -2013,7 +2019,7 @@ HandleSlashCmds(PsqlSettings *pset,
|
2013 | 2019 | case 's': /* \s is save history to a file */
|
2014 | 2020 | if (!optarg)
|
2015 | 2021 | optarg = "/dev/tty";
|
2016 |
| -#ifdef HAVE_HISTORY |
| 2022 | +#ifdef USE_HISTORY |
2017 | 2023 | if (write_history(optarg) != 0)
|
2018 | 2024 | fprintf(stderr, "cannot write history to %s\n", optarg);
|
2019 | 2025 | #endif
|
@@ -2137,7 +2143,7 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source)
|
2137 | 2143 | sprintf(pset->prompt, "%s%s", PQdb(pset->db), PROMPT);
|
2138 | 2144 | if (pset->useReadline)
|
2139 | 2145 | {
|
2140 |
| -#ifdef HAVE_HISTORY |
| 2146 | +#ifdef USE_HISTORY |
2141 | 2147 | using_history();
|
2142 | 2148 | #endif
|
2143 | 2149 | GetNextLine = gets_readline;
|
@@ -2187,7 +2193,7 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source)
|
2187 | 2193 | pset->prompt[strlen(pset->prompt) - 3] = PROMPT_READY;
|
2188 | 2194 | }
|
2189 | 2195 | line = GetNextLine(pset->prompt, source);
|
2190 |
| -#ifdef HAVE_HISTORY |
| 2196 | +#ifdef USE_HISTORY |
2191 | 2197 | if (interactive && pset->useReadline && line != NULL)
|
2192 | 2198 | add_history(line); /* save non-empty lines in history */
|
2193 | 2199 | #endif
|
@@ -2454,7 +2460,7 @@ main(int argc, char **argv)
|
2454 | 2460 | settings.opt.pager = 1;
|
2455 | 2461 | if (!isatty(0) || !isatty(1))
|
2456 | 2462 | settings.notty = 1;
|
2457 |
| -#ifdef HAVE_LIBREADLINE |
| 2463 | +#ifdef USE_READLINE |
2458 | 2464 | else
|
2459 | 2465 | settings.useReadline = 1;
|
2460 | 2466 | #endif
|
|
0 commit comments