summaryrefslogtreecommitdiff
path: root/src/bin/psql/common.c
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/psql/common.c
parent19cd31b0682d32142edf7599b653d4eff7031a8c (diff)
Add get_home_path() to use USERPROFILE on Win32 and HOME on Unix.
Diffstat (limited to 'src/bin/psql/common.c')
-rw-r--r--src/bin/psql/common.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index 681c88cc4e7..40316c5d8a7 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;