Commit 653556cc authored by Tom Lane's avatar Tom Lane

If presented db path has a trailing slash, remove it to avoid generating

double slashes in generated filenames.  This is not strictly necessary
on standard Unixen, but I'm being a neatnik...
parent 3382fbb6
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.84 2002/03/02 21:39:33 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.85 2002/03/04 04:45:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -121,9 +121,11 @@ void ...@@ -121,9 +121,11 @@ void
SetDataDir(const char *dir) SetDataDir(const char *dir)
{ {
char *new; char *new;
int newlen;
AssertArg(dir); AssertArg(dir);
/* If presented path is relative, convert to absolute */
if (dir[0] != '/') if (dir[0] != '/')
{ {
char *buf; char *buf;
...@@ -164,6 +166,14 @@ SetDataDir(const char *dir) ...@@ -164,6 +166,14 @@ SetDataDir(const char *dir)
elog(FATAL, "out of memory"); elog(FATAL, "out of memory");
} }
/*
* Strip any trailing slash. Not strictly necessary, but avoids
* generating funny-looking paths to individual files.
*/
newlen = strlen(new);
if (newlen > 1 && new[newlen-1] == '/')
new[newlen-1] = '\0';
if (DataDir) if (DataDir)
free(DataDir); free(DataDir);
DataDir = new; DataDir = new;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment