aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-07-10 22:58:42 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-07-10 22:58:42 +0000
commitb9f698eccb0cf75dc949913b2946a81053f27d88 (patch)
tree708771cb9d1e69ddab2dcc826b9644aeeba8c68d
parent82f755ec800849d1c0092fc90c9eba0225b10139 (diff)
downloadpostgresql-b9f698eccb0cf75dc949913b2946a81053f27d88.tar.gz
postgresql-b9f698eccb0cf75dc949913b2946a81053f27d88.zip
Fix BSD-only coding in port.c (passing a local variable to putenv).
Also a quick but half-baked attempt to make trim_trailing_separator do the right thing with path consisting only of '/' --- still needs work for Windows I think.
-rw-r--r--src/port/path.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/port/path.c b/src/port/path.c
index 1f2eb025785..7621e39a0d6 100644
--- a/src/port/path.c
+++ b/src/port/path.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/port/path.c,v 1.20 2004/06/11 17:09:13 momjian Exp $
+ * $PostgreSQL: pgsql/src/port/path.c,v 1.21 2004/07/10 22:58:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -266,21 +266,21 @@ set_pglocale_pgservice(const char *argv0, const char *app)
bindtextdomain(app, path);
textdomain(app);
- if (!getenv("PGLOCALEDIR"))
+ if (getenv("PGLOCALEDIR") == NULL)
{
/* set for libpq to use */
- sprintf(env_path, "PGLOCALEDIR=%s", path);
- putenv(env_path);
+ snprintf(env_path, sizeof(env_path), "PGLOCALEDIR=%s", path);
+ putenv(strdup(env_path));
}
#endif
- if (!getenv("PGSYSCONFDIR"))
+ if (getenv("PGSYSCONFDIR") == NULL)
{
get_etc_path(my_exec_path, path);
/* set for libpq to use */
- sprintf(env_path, "PGSYSCONFDIR=%s", path);
- putenv(env_path);
+ snprintf(env_path, sizeof(env_path), "PGSYSCONFDIR=%s", path);
+ putenv(strdup(env_path));
}
}
@@ -328,11 +328,12 @@ relative_path(const char *bin_path, const char *other_path)
/* Win32 filesystem is case insensitive */
if ((!IS_DIR_SEP(*bin_path) || !IS_DIR_SEP(*other_path)) &&
#ifndef WIN32
- *bin_path != *other_path)
+ *bin_path != *other_path
#else
- toupper((unsigned char) *bin_path) != toupper((unsigned char)*other_path))
+ toupper((unsigned char) *bin_path) != toupper((unsigned char)*other_path)
#endif
- break;
+ )
+ break;
if (IS_DIR_SEP(*other_path))
other_sep = other_path + 1; /* past separator */
@@ -377,7 +378,6 @@ trim_directory(char *path)
for (; !IS_DIR_SEP(*p) && p > path; p--)
;
*p = '\0';
- return;
}
@@ -392,6 +392,6 @@ trim_trailing_separator(char *path)
/* trim off trailing slashes */
if (p > path)
- for (p--; p >= path && IS_DIR_SEP(*p); p--)
+ for (p--; p > path && IS_DIR_SEP(*p); p--)
*p = '\0';
}