Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a4c71af

Browse files
committed
Put back canonicalization of PGDATA environment variable.
1 parent 76e7e2e commit a4c71af

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.410 2004/07/12 18:17:13 momjian Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.411 2004/07/12 19:14:56 momjian Exp $
4141
*
4242
* NOTES
4343
*
@@ -526,7 +526,10 @@ PostmasterMain(int argc, char *argv[])
526526
}
527527

528528
if (userPGDATA)
529-
canonicalize_path(userPGDATA = strdup(userPGDATA));
529+
{
530+
userPGDATA = strdup(userPGDATA);
531+
canonicalize_path(userPGDATA);
532+
}
530533

531534
if (onlyConfigSpecified(userPGDATA))
532535
{

src/bin/pg_ctl/pg_ctl.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.19 2004/07/12 18:17:13 momjian Exp $
7+
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.20 2004/07/12 19:15:07 momjian Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -1308,7 +1308,10 @@ main(int argc, char **argv)
13081308
/* Note we put any -D switch into the env var above */
13091309
pg_data = getenv("PGDATA");
13101310
if (pg_data)
1311-
canonicalize_path(pg_data = xstrdup(pg_data));
1311+
{
1312+
/* XXX modifies environment var in-place ... ugly ... */
1313+
canonicalize_path(pg_data);
1314+
}
13121315

13131316
if (pg_data == NULL &&
13141317
ctl_command != KILL_COMMAND && ctl_command != UNREGISTER_COMMAND)

src/port/path.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/port/path.c,v 1.23 2004/07/11 21:34:04 momjian Exp $
11+
* $PostgreSQL: pgsql/src/port/path.c,v 1.24 2004/07/12 19:15:14 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -88,27 +88,37 @@ last_dir_separator(const char *filename)
8888

8989

9090
/*
91-
* make all paths look like unix, with forward slashes
92-
* also strip any trailing slash.
93-
*
94-
* The Windows command processor will accept suitably quoted paths
95-
* with forward slashes, but barfs badly with mixed forward and back
96-
* slashes. Removing the trailing slash on a path means we never get
97-
* ugly double slashes. Don't remove a leading slash, though.
91+
* Make all paths look like Unix
9892
*/
9993
void
10094
canonicalize_path(char *path)
10195
{
10296
#ifdef WIN32
97+
/*
98+
* The Windows command processor will accept suitably quoted paths
99+
* with forward slashes, but barfs badly with mixed forward and back
100+
* slashes.
101+
*/
103102
char *p;
104103

105104
for (p = path; *p; p++)
106105
{
107106
if (*p == '\\')
108107
*p = '/';
109108
}
109+
/* In Win32, if you do:
110+
* prog.exe "a b" "\c\d\"
111+
* the system will pass \c\d" as argv[2].
112+
*/
113+
if (p > path && *(p-1) == '"')
114+
*(p-1) = '/';
110115
#endif
111116

117+
/*
118+
* Removing the trailing slash on a path means we never get
119+
* ugly double slashes. Don't remove a leading slash, though.
120+
* Also, Win32 can't stat() a directory with a trailing slash.
121+
*/
112122
trim_trailing_separator(path);
113123
}
114124

0 commit comments

Comments
 (0)