summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/Makefile7
-rw-r--r--src/bin/psql/psql.c19
-rw-r--r--src/bin/psql/rlstubs.c43
-rw-r--r--src/bin/psql/rlstubs.h17
4 files changed, 19 insertions, 67 deletions
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index c0fc92ed5b0..c10b63925b6 100644
--- a/src/bin/psql/Makefile
+++ b/src/bin/psql/Makefile
@@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/psql/Makefile,v 1.18 1997/01/25 22:51:26 scrappy Exp $
+# $Header: /cvsroot/pgsql/src/bin/psql/Makefile,v 1.19 1997/01/25 23:53:59 scrappy Exp $
#
#-------------------------------------------------------------------------
@@ -50,11 +50,10 @@ ifeq ($(USE_READLINE), true)
endif
endif
endif
- OBJS= psql.o stringutils.o
-else
- OBJS= psql.o stringutils.o rlstubs.o
endif
+OBJS= psql.o stringutils.o
+
ifeq ($(PORTNAME), ultrix4)
OBJS+= ../../utils/strdup.o
endif
diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c
index 0c6e19e65be..19a549c33a3 100644
--- a/src/bin/psql/psql.c
+++ b/src/bin/psql/psql.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.53 1997/01/25 22:51:56 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.54 1997/01/25 23:54:02 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -404,7 +404,14 @@ gets_noreadline(char *prompt, FILE * source)
char *
gets_readline(char *prompt, FILE * source)
{
- char *s = readline(prompt);
+ char *s;
+#ifdef HAVE_LIBREADLINE
+ s = readline(prompt);
+#else
+ char buf[500];
+ printf("%s", prompt);
+ s = fgets(buf, 500, stdin);
+#endif
fputc('\r', stdout);
fflush(stdout);
return s;
@@ -1158,8 +1165,10 @@ HandleSlashCmds(PsqlSettings * settings,
case 's': /* \s is save history to a file */
if (!optarg)
optarg = "/dev/tty";
+#ifdef HAVE_HISTORY
if (write_history(optarg) != 0)
fprintf(stderr, "cannot write history to %s\n", optarg);
+#endif
break;
case 'm': /* monitor like type-setting */
if (toggle(settings, &settings->opt.standard, "standard SQL separaters and padding")) {
@@ -1254,7 +1263,9 @@ MainLoop(PsqlSettings * settings, FILE * source)
else
sprintf(settings->prompt, "%s%s", PQdb(settings->db), PROMPT);
if (settings->useReadline) {
+#ifdef HAVE_HISTORY
using_history();
+#endif
GetNextLine = gets_readline;
} else
GetNextLine = gets_noreadline;
@@ -1282,8 +1293,10 @@ MainLoop(PsqlSettings * settings, FILE * source)
settings->prompt[strlen(settings->prompt)-3] = '=';
}
line = GetNextLine(settings->prompt, source);
+#ifdef HAVE_HISTORY
if (interactive && settings->useReadline && line != NULL)
add_history(line); /* save non-empty lines in history */
+#endif
}
query_start = line;
@@ -1448,7 +1461,7 @@ main(int argc, char **argv)
settings.opt.pager = 1;
if (!isatty(0) || !isatty(1))
settings.quiet = settings.notty = 1;
-#ifndef NOREADLINE
+#ifdef HAVE_LIBREADLINE
else
settings.useReadline = 1;
#endif
diff --git a/src/bin/psql/rlstubs.c b/src/bin/psql/rlstubs.c
deleted file mode 100644
index 64c11dbe7b6..00000000000
--- a/src/bin/psql/rlstubs.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * rlstubs.c--
- * stub routines when compiled without readline and history libraries
- *
- * Copyright (c) 1994-5, Regents of the University of California
- *
- *
- * IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/rlstubs.c,v 1.6 1997/01/25 22:52:08 scrappy Exp $
- *
- *-------------------------------------------------------------------------
- */
-#include <stdio.h>
-
-#include "rlstubs.h"
-
-char *
-readline(const char *prompt)
-{
- static char buf[500];
-
- printf("%s", prompt);
- return fgets(buf, 500, stdin);
-}
-
-int
-write_history(const char *dum)
-{
- return 0;
-}
-
-int
-using_history(void)
-{
- return 0;
-}
-
-int
-add_history(const char *dum)
-{
- return 0;
-}
diff --git a/src/bin/psql/rlstubs.h b/src/bin/psql/rlstubs.h
deleted file mode 100644
index 49f7ef747c9..00000000000
--- a/src/bin/psql/rlstubs.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * rlstubs.h
- * stub routines when compiled without readline and history libraries
- *
- * Copyright (c) 1994-5, Regents of the University of California
- *
- *
- * IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/rlstubs.h,v 1.2 1996/11/11 14:55:49 scrappy Exp $
- *
- *-------------------------------------------------------------------------
- */
-extern char *readline(const char *prompt);
-extern int write_history(const char *dum);
-extern int using_history(void);
-extern int add_history(const char *dum);