Skip to content

Commit 653556c

Browse files
committed
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...
1 parent 3382fbb commit 653556c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/backend/utils/init/miscinit.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.84 2002/03/02 21:39:33 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.85 2002/03/04 04:45:27 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -121,9 +121,11 @@ void
121121
SetDataDir(const char *dir)
122122
{
123123
char *new;
124+
int newlen;
124125

125126
AssertArg(dir);
126127

128+
/* If presented path is relative, convert to absolute */
127129
if (dir[0] != '/')
128130
{
129131
char *buf;
@@ -164,6 +166,14 @@ SetDataDir(const char *dir)
164166
elog(FATAL, "out of memory");
165167
}
166168

169+
/*
170+
* Strip any trailing slash. Not strictly necessary, but avoids
171+
* generating funny-looking paths to individual files.
172+
*/
173+
newlen = strlen(new);
174+
if (newlen > 1 && new[newlen-1] == '/')
175+
new[newlen-1] = '\0';
176+
167177
if (DataDir)
168178
free(DataDir);
169179
DataDir = new;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy