summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2004-08-18 02:59:12 +0000
committerBruce Momjian <bruce@momjian.us>2004-08-18 02:59:12 +0000
commit1abf13db3c7f1ffa4e40c9f51f7ba76f390e7f06 (patch)
treeebd668ab6ae559e447a1799bf611c449eb86da23 /src/bin
parent19cd31b0682d32142edf7599b653d4eff7031a8c (diff)
downloadpostgresql-1abf13db3c7f1ffa4e40c9f51f7ba76f390e7f06.tar.gz
Add get_home_path() to use USERPROFILE on Win32 and HOME on Unix.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/psql/common.c12
-rw-r--r--src/bin/psql/input.c12
-rw-r--r--src/bin/psql/startup.c6
3 files changed, 14 insertions, 16 deletions
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index 681c88cc4e..40316c5d8a 100644
--- a/src/bin/psql/common.c
+++ b/src/bin/psql/common.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.87 2004/05/23 22:20:10 neilc Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.88 2004/08/18 02:59:11 momjian Exp $
*/
#include "postgres_fe.h"
#include "common.h"
@@ -1078,13 +1078,13 @@ expand_tilde(char **filename)
if (**filename == '~')
{
char *fn;
- char *home;
char oldp,
*p;
struct passwd *pw;
+ char home[MAXPGPATH];
fn = *filename;
- home = NULL;
+ *home = '\0';
p = fn + 1;
while (*p != '/' && *p != '\0')
@@ -1094,12 +1094,12 @@ expand_tilde(char **filename)
*p = '\0';
if (*(fn + 1) == '\0')
- home = getenv("HOME");
+ get_home_path(home);
else if ((pw = getpwnam(fn + 1)) != NULL)
- home = pw->pw_dir;
+ StrNCpy(home, pw->pw_dir, MAXPGPATH);
*p = oldp;
- if (home)
+ if (strlen(home) != 0)
{
char *newfn;
diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index 326f91ef67..d1ad9dd615 100644
--- a/src/bin/psql/input.c
+++ b/src/bin/psql/input.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.34 2004/01/25 03:07:22 neilc Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.35 2004/08/18 02:59:11 momjian Exp $
*/
#include "postgres_fe.h"
#include "input.h"
@@ -171,7 +171,7 @@ initializeInput(int flags)
#ifdef USE_READLINE
if (flags & 1)
{
- const char *home;
+ char home[MAXPGPATH];
useReadline = true;
initialize_readline();
@@ -180,8 +180,7 @@ initializeInput(int flags)
if (GetVariable(pset.vars, "HISTSIZE") == NULL)
SetVariable(pset.vars, "HISTSIZE", "500");
using_history();
- home = getenv("HOME");
- if (home)
+ if (get_home_path(home))
{
char *psql_history;
@@ -231,10 +230,9 @@ finishInput(int exitstatus, void *arg)
#ifdef USE_READLINE
if (useHistory)
{
- char *home;
+ char home[MAXPGPATH];
- home = getenv("HOME");
- if (home)
+ if (get_home_path(home))
{
char *psql_history;
int hist_size;
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index e0f55c536d..2bd2b50aff 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.95 2004/06/03 00:07:37 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.96 2004/08/18 02:59:11 momjian Exp $
*/
#include "postgres_fe.h"
@@ -570,8 +570,8 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
static void
process_psqlrc(char *argv0)
{
- char *home;
char *psqlrc;
+ char home[MAXPGPATH];
char global_file[MAXPGPATH];
char my_exec_path[MAXPGPATH];
char etc_path[MAXPGPATH];
@@ -582,7 +582,7 @@ process_psqlrc(char *argv0)
snprintf(global_file, MAXPGPATH, "%s/%s", etc_path, SYSPSQLRC);
process_psqlrc_file(global_file);
- if ((home = getenv("HOME")) != NULL)
+ if (get_home_path(home))
{
psqlrc = pg_malloc(strlen(home) + 1 + strlen(PSQLRC) + 1);
sprintf(psqlrc, "%s/%s", home, PSQLRC);