aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/psql/common.c')
-rw-r--r--src/bin/psql/common.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index 66eeb0ef6b2..05b11651e9d 100644
--- a/src/bin/psql/common.c
+++ b/src/bin/psql/common.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.26 2000/11/27 01:28:40 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.27 2000/11/27 02:20:36 tgl Exp $
*/
#include "postgres.h"
#include "common.h"
@@ -201,7 +201,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
}
#endif
- fgets(destination, maxlen, stdin);
+ if (fgets(destination, maxlen, stdin) == NULL)
+ destination[0] = '\0';
#ifdef HAVE_TERMIOS_H
if (!echo)
@@ -222,7 +223,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
do
{
- fgets(buf, sizeof(buf), stdin);
+ if (fgets(buf, sizeof(buf), stdin) == NULL)
+ break;
buflen = strlen(buf);
} while (buflen > 0 && buf[buflen - 1] != '\n');
}
@@ -389,9 +391,9 @@ SendQuery(const char *query)
"***(press return to proceed or enter x and return to cancel)********************\n",
query);
fflush(stdout);
- fgets(buf, 3, stdin);
- if (buf[0] == 'x')
- return false;
+ if (fgets(buf, sizeof(buf), stdin) != NULL)
+ if (buf[0] == 'x')
+ return false;
}
else
{