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:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.57 2002/09/02 02:47:05 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.58 2003/04/04 20:42:12 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -271,7 +271,7 @@ expand_dynamic_library_name(const char *name)
|
||||
|
||||
AssertArg(name);
|
||||
|
||||
have_slash = (strchr(name, '/') != NULL);
|
||||
have_slash = (first_path_separator(name) != NULL);
|
||||
|
||||
if (!have_slash)
|
||||
{
|
||||
@@ -326,7 +326,13 @@ substitute_libpath_macro(const char *name)
|
||||
if (name[0] != '$')
|
||||
return pstrdup(name);
|
||||
|
||||
macroname_len = strcspn(name + 1, "/") + 1;
|
||||
macroname_len = strcspn(name + 1,
|
||||
#ifndef WIN32
|
||||
"/"
|
||||
#else
|
||||
"/\\"
|
||||
#endif
|
||||
) + 1;
|
||||
|
||||
if (strncmp(name, "$libdir", macroname_len) == 0)
|
||||
replacement = PKGLIBDIR;
|
||||
@@ -362,7 +368,7 @@ find_in_dynamic_libpath(const char *basename)
|
||||
size_t baselen;
|
||||
|
||||
AssertArg(basename != NULL);
|
||||
AssertArg(strchr(basename, '/') == NULL);
|
||||
AssertArg(first_path_separator(basename) == NULL);
|
||||
AssertState(Dynamic_library_path != NULL);
|
||||
|
||||
p = Dynamic_library_path;
|
||||
@@ -391,7 +397,7 @@ find_in_dynamic_libpath(const char *basename)
|
||||
pfree(piece);
|
||||
|
||||
/* only absolute paths */
|
||||
if (mangled[0] != '/')
|
||||
if (!is_absolute_path(mangled))
|
||||
elog(ERROR, "dynamic_library_path component is not absolute");
|
||||
|
||||
full = palloc(strlen(mangled) + 1 + baselen + 1);
|
||||
|
||||
@@ -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, "/");
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.55 2003/03/10 22:28:19 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.56 2003/04/04 20:42:12 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -50,10 +50,10 @@ ExpandDatabasePath(const char *dbpath)
|
||||
return NULL; /* ain't gonna fit nohow */
|
||||
|
||||
/* leading path delimiter? then already absolute path */
|
||||
if (*dbpath == '/')
|
||||
if (is_absolute_path(dbpath))
|
||||
{
|
||||
#ifdef ALLOW_ABSOLUTE_DBPATHS
|
||||
cp = strrchr(dbpath, '/');
|
||||
cp = last_path_separator(dbpath);
|
||||
len = cp - dbpath;
|
||||
strncpy(buf, dbpath, len);
|
||||
snprintf(&buf[len], MAXPGPATH - len, "/base/%s", (cp + 1));
|
||||
@@ -62,7 +62,7 @@ ExpandDatabasePath(const char *dbpath)
|
||||
#endif
|
||||
}
|
||||
/* path delimiter somewhere? then has leading environment variable */
|
||||
else if ((cp = strchr(dbpath, '/')) != NULL)
|
||||
else if ((cp = first_path_separator(dbpath)) != NULL)
|
||||
{
|
||||
const char *envvar;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user