aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/input.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2002-09-05 22:05:50 +0000
committerBruce Momjian <bruce@momjian.us>2002-09-05 22:05:50 +0000
commit5fc10c3d17f12fbdc9b676b2c2e5efb6ef588334 (patch)
treed813c30b2818566fed58e18596105e6e5cc8277e /src/bin/psql/input.c
parentf4aecac468d6602eb03c4f8ee80e00b3d279b961 (diff)
downloadpostgresql-5fc10c3d17f12fbdc9b676b2c2e5efb6ef588334.tar.gz
postgresql-5fc10c3d17f12fbdc9b676b2c2e5efb6ef588334.zip
Remove PGPASSWORDFILE and default to always trying $HOME/.pgpass.
Cleanup up memory allocation for $HOME in related psql places. Update mention of $HOME/.pgpass in the docs; add mention in pg_dumpall.
Diffstat (limited to 'src/bin/psql/input.c')
-rw-r--r--src/bin/psql/input.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index 6e083506f3e..7ac11102669 100644
--- a/src/bin/psql/input.c
+++ b/src/bin/psql/input.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.19 2002/04/10 22:46:58 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/input.c,v 1.20 2002/09/05 22:05:50 momjian Exp $
*/
#include "postgres_fe.h"
#include "input.h"
@@ -30,6 +30,8 @@ static void finishInput(void);
static void finishInput(int, void *);
#endif
+#define PSQLHISTORY "/.psql_history"
+
/*
* gets_interactive()
@@ -142,11 +144,12 @@ initializeInput(int flags)
home = getenv("HOME");
if (home)
{
- char *psql_history = (char *) malloc(strlen(home) + 20);
+ char *psql_history = (char *) malloc(strlen(home) +
+ strlen(PSQLHISTORY) + 1);
if (psql_history)
{
- sprintf(psql_history, "%s/.psql_history", home);
+ sprintf(psql_history, "%s" PSQLHISTORY, home);
read_history(psql_history);
free(psql_history);
}
@@ -201,14 +204,15 @@ finishInput(int exitstatus, void *arg)
home = getenv("HOME");
if (home)
{
- psql_history = (char *) malloc(strlen(home) + 20);
+ psql_history = (char *) malloc(strlen(home) +
+ strlen(PSQLHISTORY) + 1);
if (psql_history)
{
const char *var = GetVariable(pset.vars, "HISTSIZE");
if (var)
stifle_history(atoi(var));
- sprintf(psql_history, "%s/.psql_history", home);
+ sprintf(psql_history, "%s" PSQLHISTORY, home);
write_history(psql_history);
free(psql_history);
}