1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-12 05:01:15 +03:00

Add Win32 path handling for / vs. \ and drive letters.

This commit is contained in:
Bruce Momjian
2003-04-04 20:42:13 +00:00
parent 9bad936f67
commit d46e643822
22 changed files with 147 additions and 88 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.31 2002/11/02 15:54:13 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.32 2003/04/04 20:42:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -159,14 +159,14 @@ FindExec(char *full_path, const char *argv0, const char *binary_name)
* (making sure that a relative path is made absolute before returning
* it).
*/
if (argv0 && (p = strrchr(argv0, '/')) && *++p)
if (argv0 && (p = last_path_separator(argv0)) && *++p)
{
if (*argv0 == '/' || !getcwd(buf, MAXPGPATH))
if (is_absolute_path(argv0) || !getcwd(buf, MAXPGPATH))
buf[0] = '\0';
else
strcat(buf, "/");
strcat(buf, argv0);
p = strrchr(buf, '/');
p = last_path_separator(buf);
strcpy(++p, binary_name);
if (ValidateBinary(buf) == 0)
{
@@ -194,7 +194,7 @@ FindExec(char *full_path, const char *argv0, const char *binary_name)
continue;
if (endp)
*endp = '\0';
if (*startp == '/' || !getcwd(buf, MAXPGPATH))
if (is_absolute_path(startp) || !getcwd(buf, MAXPGPATH))
buf[0] = '\0';
else
strcat(buf, "/");

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.101 2003/03/20 04:51:44 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.102 2003/04/04 20:42:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -134,7 +134,7 @@ SetDataDir(const char *dir)
AssertArg(dir);
/* If presented path is relative, convert to absolute */
if (dir[0] != '/')
if (!is_absolute_path(dir))
{
char *buf;
size_t buflen;
@@ -179,7 +179,11 @@ SetDataDir(const char *dir)
* generating funny-looking paths to individual files.
*/
newlen = strlen(new);
if (newlen > 1 && new[newlen - 1] == '/')
if (newlen > 1 && new[newlen - 1] == '/'
#ifdef WIN32
|| new[newlen - 1] == '\\'
#endif
)
new[newlen - 1] = '\0';
if (DataDir)