File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -121,9 +121,11 @@ void
121
121
SetDataDir (const char * dir )
122
122
{
123
123
char * new ;
124
+ int newlen ;
124
125
125
126
AssertArg (dir );
126
127
128
+ /* If presented path is relative, convert to absolute */
127
129
if (dir [0 ] != '/' )
128
130
{
129
131
char * buf ;
@@ -164,6 +166,14 @@ SetDataDir(const char *dir)
164
166
elog (FATAL , "out of memory" );
165
167
}
166
168
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
+
167
177
if (DataDir )
168
178
free (DataDir );
169
179
DataDir = new ;
You can’t perform that action at this time.
0 commit comments