Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3fe7042

Browse files
committed
Canonicalize Win32 path coming in from pg_ctl -D, idea from Magnus.
1 parent118bd91 commit3fe7042

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.42 2004/10/22 00:24:18 tgl Exp $
7+
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.43 2004/10/27 17:17:07 momjian Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -1279,19 +1279,23 @@ main(int argc, char **argv)
12791279
{
12801280
case'D':
12811281
{
1282-
intlen=strlen(optarg);
1283-
char*env_var;
1282+
char*pgdata_D=xmalloc(strlen(optarg));
1283+
char*env_var=xmalloc(strlen(optarg)+8);
12841284

1285-
env_var=xmalloc(len+8);
1286-
snprintf(env_var,len+8,"PGDATA=%s",optarg);
1285+
strcpy(pgdata_D,optarg);
1286+
canonicalize_path(pgdata_D);
1287+
snprintf(env_var,strlen(pgdata_D)+8,"PGDATA=%s",
1288+
pgdata_D);
12871289
putenv(env_var);
12881290

12891291
/*
1290-
* Show -D for easier postmaster 'ps'
1291-
* identification
1292+
*We could pass PGDATA just in an environment
1293+
*variable but we do -D too for clearer
1294+
*postmaster 'ps' display
12921295
*/
1293-
pgdata_opt=xmalloc(len+7);
1294-
snprintf(pgdata_opt,len+7,"-D \"%s\" ",optarg);
1296+
pgdata_opt=xmalloc(strlen(pgdata_D)+7);
1297+
snprintf(pgdata_opt,strlen(pgdata_D)+7,"-D \"%s\" ",
1298+
pgdata_D);
12951299
break;
12961300
}
12971301
case'l':

‎src/port/path.c

Lines changed: 11 additions & 6 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.37 2004/10/24 22:08:19 tgl Exp $
11+
* $PostgreSQL: pgsql/src/port/path.c,v 1.38 2004/10/27 17:17:09 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -115,7 +115,12 @@ make_native_path(char *filename)
115115

116116

117117
/*
118-
* Make all paths look like Unix
118+
*Clean up path by:
119+
*o make Win32 path use Unix slashes
120+
*o remove trailling quote on Win32
121+
*o remove trailling slash
122+
*o remove trailing '.'
123+
*o process trailing '..' ourselves
119124
*/
120125
void
121126
canonicalize_path(char*path)
@@ -145,13 +150,13 @@ canonicalize_path(char *path)
145150

146151
/*
147152
* Removing the trailing slash on a path means we never get ugly
148-
* double slashes.Also, Win32 can't stat() a directory with a
149-
* trailing slash. Don't remove a leading slash, though.
153+
* doubletrailingslashes.Also, Win32 can't stat() a directory
154+
*with atrailing slash. Don't remove a leading slash, though.
150155
*/
151156
trim_trailing_separator(path);
152157

153158
/*
154-
* Remove any trailing uses of "."or"..", too.
159+
* Remove any trailing uses of "."and process".." ourselves
155160
*/
156161
for (;;)
157162
{
@@ -165,7 +170,7 @@ canonicalize_path(char *path)
165170
elseif (len >=3&&strcmp(path+len-3,"/..")==0)
166171
{
167172
trim_directory(path);
168-
trim_directory(path);
173+
trim_directory(path);/* remove directory above */
169174
trim_trailing_separator(path);
170175
}
171176
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp