Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
2a70ec1b
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2a70ec1b
编写于
5月 25, 2004
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow relative paths as long as the hardcoded path matches the bin path
up to the last bin directory name.
上级
bfb77c15
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
67 addition
and
81 deletion
+67
-81
src/port/path.c
src/port/path.c
+67
-81
未找到文件。
src/port/path.c
浏览文件 @
2a70ec1b
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/port/path.c,v 1.1
4 2004/05/25 18:18:29
momjian Exp $
* $PostgreSQL: pgsql/src/port/path.c,v 1.1
5 2004/05/25 20:47:41
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#define ISSEP(ch) ((ch) == '/' || (ch) == '\\')
#define ISSEP(ch) ((ch) == '/' || (ch) == '\\')
#endif
#endif
static
bool
relative_path
(
const
char
*
path1
,
const
char
*
path2
);
const
static
char
*
relative_path
(
const
char
*
bin_path
,
const
char
*
other_path
);
static
void
trim_directory
(
char
*
path
);
static
void
trim_directory
(
char
*
path
);
static
void
trim_trailing_separator
(
char
*
path
);
static
void
trim_trailing_separator
(
char
*
path
);
...
@@ -37,6 +37,14 @@ static void trim_trailing_separator(char *path);
...
@@ -37,6 +37,14 @@ static void trim_trailing_separator(char *path);
(p)++; \
(p)++; \
}
}
/* Macro creates a relative path */
#define MAKE_RELATIVE \
do { \
StrNCpy(path, my_exec_path, MAXPGPATH); \
trim_directory(path); \
trim_directory(path); \
snprintf(ret_path, MAXPGPATH, "%s/%s", path, p); \
} while (0)
/*
/*
* first_path_separator
* first_path_separator
...
@@ -114,14 +122,10 @@ void
...
@@ -114,14 +122,10 @@ void
get_share_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
get_share_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
{
{
char
path
[
MAXPGPATH
];
char
path
[
MAXPGPATH
];
const
char
*
p
;
if
(
relative_path
(
PGBINDIR
,
PGSHAREDIR
))
if
((
p
=
relative_path
(
PGBINDIR
,
PGSHAREDIR
)))
{
MAKE_RELATIVE
;
StrNCpy
(
path
,
my_exec_path
,
MAXPGPATH
);
trim_directory
(
path
);
/* trim off binary */
trim_directory
(
path
);
/* trim off /bin */
snprintf
(
ret_path
,
MAXPGPATH
,
"%s/share"
,
path
);
}
else
else
StrNCpy
(
ret_path
,
PGSHAREDIR
,
MAXPGPATH
);
StrNCpy
(
ret_path
,
PGSHAREDIR
,
MAXPGPATH
);
}
}
...
@@ -135,14 +139,10 @@ void
...
@@ -135,14 +139,10 @@ void
get_etc_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
get_etc_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
{
{
char
path
[
MAXPGPATH
];
char
path
[
MAXPGPATH
];
const
char
*
p
;
if
(
relative_path
(
PGBINDIR
,
SYSCONFDIR
))
if
((
p
=
relative_path
(
PGBINDIR
,
SYSCONFDIR
)))
{
MAKE_RELATIVE
;
StrNCpy
(
path
,
my_exec_path
,
MAXPGPATH
);
trim_directory
(
path
);
trim_directory
(
path
);
snprintf
(
ret_path
,
MAXPGPATH
,
"%s/etc"
,
path
);
}
else
else
StrNCpy
(
ret_path
,
SYSCONFDIR
,
MAXPGPATH
);
StrNCpy
(
ret_path
,
SYSCONFDIR
,
MAXPGPATH
);
}
}
...
@@ -156,14 +156,10 @@ void
...
@@ -156,14 +156,10 @@ void
get_include_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
get_include_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
{
{
char
path
[
MAXPGPATH
];
char
path
[
MAXPGPATH
];
const
char
*
p
;
if
(
relative_path
(
PGBINDIR
,
INCLUDEDIR
))
if
((
p
=
relative_path
(
PGBINDIR
,
INCLUDEDIR
)))
{
MAKE_RELATIVE
;
StrNCpy
(
path
,
my_exec_path
,
MAXPGPATH
);
trim_directory
(
path
);
trim_directory
(
path
);
snprintf
(
ret_path
,
MAXPGPATH
,
"%s/include"
,
path
);
}
else
else
StrNCpy
(
ret_path
,
INCLUDEDIR
,
MAXPGPATH
);
StrNCpy
(
ret_path
,
INCLUDEDIR
,
MAXPGPATH
);
}
}
...
@@ -177,14 +173,10 @@ void
...
@@ -177,14 +173,10 @@ void
get_pkginclude_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
get_pkginclude_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
{
{
char
path
[
MAXPGPATH
];
char
path
[
MAXPGPATH
];
const
char
*
p
;
if
(
relative_path
(
PGBINDIR
,
PKGINCLUDEDIR
))
if
((
p
=
relative_path
(
PGBINDIR
,
PKGINCLUDEDIR
)))
{
MAKE_RELATIVE
;
StrNCpy
(
path
,
my_exec_path
,
MAXPGPATH
);
trim_directory
(
path
);
trim_directory
(
path
);
snprintf
(
ret_path
,
MAXPGPATH
,
"%s/include"
,
path
);
}
else
else
StrNCpy
(
ret_path
,
PKGINCLUDEDIR
,
MAXPGPATH
);
StrNCpy
(
ret_path
,
PKGINCLUDEDIR
,
MAXPGPATH
);
}
}
...
@@ -200,14 +192,10 @@ void
...
@@ -200,14 +192,10 @@ void
get_pkglib_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
get_pkglib_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
{
{
char
path
[
MAXPGPATH
];
char
path
[
MAXPGPATH
];
const
char
*
p
;
if
(
relative_path
(
PGBINDIR
,
PKGLIBDIR
))
if
((
p
=
relative_path
(
PGBINDIR
,
PKGLIBDIR
)))
{
MAKE_RELATIVE
;
StrNCpy
(
path
,
my_exec_path
,
MAXPGPATH
);
trim_directory
(
path
);
trim_directory
(
path
);
snprintf
(
ret_path
,
MAXPGPATH
,
"%s/lib"
,
path
);
}
else
else
StrNCpy
(
ret_path
,
PKGLIBDIR
,
MAXPGPATH
);
StrNCpy
(
ret_path
,
PKGLIBDIR
,
MAXPGPATH
);
}
}
...
@@ -223,14 +211,10 @@ void
...
@@ -223,14 +211,10 @@ void
get_locale_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
get_locale_path
(
const
char
*
my_exec_path
,
char
*
ret_path
)
{
{
char
path
[
MAXPGPATH
];
char
path
[
MAXPGPATH
];
const
char
*
p
;
if
(
relative_path
(
PGBINDIR
,
LOCALEDIR
))
if
((
p
=
relative_path
(
PGBINDIR
,
LOCALEDIR
)))
{
MAKE_RELATIVE
;
StrNCpy
(
path
,
my_exec_path
,
MAXPGPATH
);
trim_directory
(
path
);
trim_directory
(
path
);
snprintf
(
ret_path
,
MAXPGPATH
,
"%s/share/locale"
,
path
);
}
else
else
StrNCpy
(
ret_path
,
LOCALEDIR
,
MAXPGPATH
);
StrNCpy
(
ret_path
,
LOCALEDIR
,
MAXPGPATH
);
}
}
...
@@ -271,68 +255,71 @@ set_pglocale(const char *argv0, const char *app)
...
@@ -271,68 +255,71 @@ set_pglocale(const char *argv0, const char *app)
*
*
* Do the supplied paths differ only in their last component?
* Do the supplied paths differ only in their last component?
*/
*/
static
bool
static
const
char
*
relative_path
(
const
char
*
path1
,
const
char
*
path2
)
relative_path
(
const
char
*
bin_path
,
const
char
*
other_path
)
{
{
const
char
*
other_sep
=
other_path
;
#ifdef WIN32
#ifdef WIN32
/* Driver letters match? */
/* Driver letters match? */
if
(
isalpha
(
*
path1
)
&&
path1
[
1
]
==
':'
&&
if
(
isalpha
(
*
bin_path
)
&&
bin_path
[
1
]
==
':'
&&
(
!
isalpha
(
*
path2
)
||
!
path2
[
1
]
==
':'
))
(
!
isalpha
(
*
other_path
)
||
!
other_path
[
1
]
==
':'
))
return
false
;
return
NULL
;
if
((
!
isalpha
(
*
path1
)
||
!
path1
[
1
]
==
':'
)
&&
if
((
!
isalpha
(
*
bin_path
)
||
!
bin_path
[
1
]
==
':'
)
&&
(
isalpha
(
*
path2
)
&&
path2
[
1
]
==
':'
))
(
isalpha
(
*
other_path
)
&&
other_path
[
1
]
==
':'
))
return
false
;
return
NULL
;
if
(
isalpha
(
*
path1
)
&&
path1
[
1
]
==
':'
&&
if
(
isalpha
(
*
bin_path
)
&&
bin_path
[
1
]
==
':'
&&
isalpha
(
*
path2
)
&&
path2
[
1
]
==
':'
)
isalpha
(
*
other_path
)
&&
other_path
[
1
]
==
':'
)
{
{
if
(
toupper
(
*
path1
)
!=
toupper
(
*
path2
))
if
(
toupper
(
*
bin_path
)
!=
toupper
(
*
other_path
))
return
false
;
return
NULL
;
path1
+=
2
;
bin_path
+=
2
;
path2
+=
2
;
other_path
+=
2
;
other_sep
=
other_path
+
1
;
/* past separator */
}
}
#endif
#endif
while
(
1
)
while
(
1
)
{
{
/* Move past adjacent slashes like //, and trailing ones */
/* Move past adjacent slashes like //, and trailing ones */
MOVE_TO_SEP_END
(
path1
);
MOVE_TO_SEP_END
(
bin_path
);
MOVE_TO_SEP_END
(
path2
);
MOVE_TO_SEP_END
(
other_path
);
/* One of the paths is done? */
/* One of the paths is done? */
if
(
!*
path1
||
!*
path2
)
if
(
!*
bin_path
||
!*
other_path
)
break
;
break
;
/* Win32 filesystem is case insensitive */
/* Win32 filesystem is case insensitive */
if
((
!
ISSEP
(
*
bin_path
)
||
!
ISSEP
(
*
other_path
))
&&
#ifndef WIN32
#ifndef WIN32
if
(
*
path1
!=
*
path2
)
*
bin_path
!=
*
other_path
)
#else
#else
if
(
toupper
((
unsigned
char
)
*
path1
)
!=
toupper
((
unsigned
char
)
*
path2
))
toupper
((
unsigned
char
)
*
bin_path
)
!=
toupper
((
unsigned
char
)
*
other_path
))
#endif
#endif
break
;
break
;
path1
++
;
if
(
ISSEP
(
*
other_path
))
path2
++
;
other_sep
=
other_path
+
1
;
/* past separator */
bin_path
++
;
other_path
++
;
}
}
/*
both done,
identical? */
/* identical? */
if
(
!*
path1
&&
!*
path2
)
if
(
!*
bin_path
&&
!*
other_path
)
return
false
;
return
NULL
;
/* advance past directory name */
/* advance past directory name */
while
(
!
ISSEP
(
*
path1
)
&&
*
path1
)
while
(
!
ISSEP
(
*
bin_path
)
&&
*
bin_path
)
path1
++
;
bin_path
++
;
while
(
!
ISSEP
(
*
path2
)
&&
*
path2
)
path2
++
;
MOVE_TO_SEP_END
(
path1
);
MOVE_TO_SEP_END
(
bin_path
);
MOVE_TO_SEP_END
(
path2
);
/*
Are both strings
done? */
/*
Is bin
done? */
if
(
!*
path1
&&
!*
path2
)
if
(
!*
bin_path
)
return
true
;
return
other_path
;
else
else
return
false
;
return
NULL
;
}
}
...
@@ -372,4 +359,3 @@ trim_trailing_separator(char *path)
...
@@ -372,4 +359,3 @@ trim_trailing_separator(char *path)
for
(
p
--
;
p
>=
path
&&
ISSEP
(
*
p
);
p
--
)
for
(
p
--
;
p
>=
path
&&
ISSEP
(
*
p
);
p
--
)
*
p
=
'\0'
;
*
p
=
'\0'
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录