From: Bruce Momjian Date: Mon, 12 Jul 2004 18:17:13 +0000 (+0000) Subject: Use strdup in pg_ctl for canonicalize_path on environment variable. X-Git-Tag: REL8_0_0BETA1~210 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=76e7e2e776cca5bb3133c6b0421ce9ba3747b04f;p=postgresql Use strdup in pg_ctl for canonicalize_path on environment variable. Simplify postmaster call too. --- diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 4231ff22d4..208175c2c6 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -37,7 +37,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.409 2004/07/11 23:49:45 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.410 2004/07/12 18:17:13 momjian Exp $ * * NOTES * @@ -526,10 +526,7 @@ PostmasterMain(int argc, char *argv[]) } if (userPGDATA) - { - userPGDATA = strdup(userPGDATA); - canonicalize_path(userPGDATA); - } + canonicalize_path(userPGDATA = strdup(userPGDATA)); if (onlyConfigSpecified(userPGDATA)) { diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 44941c5acb..6cd562345c 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -4,7 +4,7 @@ * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.18 2004/06/25 08:49:28 dennis Exp $ + * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.19 2004/07/12 18:17:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1308,10 +1308,7 @@ main(int argc, char **argv) /* Note we put any -D switch into the env var above */ pg_data = getenv("PGDATA"); if (pg_data) - { - /* XXX modifies environment var in-place ... ugly ... */ - canonicalize_path(pg_data); - } + canonicalize_path(pg_data = xstrdup(pg_data)); if (pg_data == NULL && ctl_command != KILL_COMMAND && ctl_command != UNREGISTER_COMMAND)