Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
9e16195f
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,发现更多精彩内容 >>
提交
9e16195f
编写于
5月 05, 2004
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Second try at a portable unsetenv().
上级
dadce650
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
71 addition
and
25 deletion
+71
-25
configure
configure
+2
-1
configure.in
configure.in
+2
-2
src/bin/initdb/initdb.c
src/bin/initdb/initdb.c
+3
-21
src/include/c.h
src/include/c.h
+5
-1
src/include/pg_config.h.in
src/include/pg_config.h.in
+3
-0
src/port/unsetenv.c
src/port/unsetenv.c
+56
-0
未找到文件。
configure
浏览文件 @
9e16195f
...
...
@@ -11744,7 +11744,8 @@ fi
for ac_func in crypt fseeko getopt getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul
for ac_func in crypt fseeko getopt getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul unsetenv
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
...
...
configure.in
浏览文件 @
9e16195f
dnl Process this file with autoconf to produce a configure script.
dnl $PostgreSQL: pgsql/configure.in,v 1.34
3 2004/04/30 16:08:01 momjian
Exp $
dnl $PostgreSQL: pgsql/configure.in,v 1.34
4 2004/05/05 21:18:29 tgl
Exp $
dnl
dnl Developers, please strive to achieve this order:
dnl
...
...
@@ -858,7 +858,7 @@ else
AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
fi
AC_REPLACE_FUNCS([crypt fseeko getopt getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul])
AC_REPLACE_FUNCS([crypt fseeko getopt getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul
unsetenv
])
# system's version of getaddrinfo(), if any, may be used only if we found
# a definition for struct addrinfo; see notes in src/include/getaddrinfo.h
...
...
src/bin/initdb/initdb.c
浏览文件 @
9e16195f
...
...
@@ -43,7 +43,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD.
*
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.2
4 2004/05/05 16:09:31
tgl Exp $
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.2
5 2004/05/05 21:18:29
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -263,24 +263,6 @@ xstrdup(const char *s)
return
result
;
}
/*
* unsetenv() doesn't exist everywhere, so emulate it with this ugly
* but well-tested technique (borrowed from backend's variable.c).
*/
static
void
pg_unsetenv
(
const
char
*
varname
)
{
char
*
envstr
=
xmalloc
(
strlen
(
varname
)
+
2
);
/* First, override any existing setting by forcibly defining the var */
sprintf
(
envstr
,
"%s="
,
varname
);
putenv
(
envstr
);
/* Now we can clobber the variable definition this way: */
strcpy
(
envstr
,
"="
);
putenv
(
envstr
);
}
/*
* delete a directory tree recursively
* assumes path points to a valid directory
...
...
@@ -1260,10 +1242,10 @@ bootstrap_template1(char *short_version)
snprintf
(
cmd
,
sizeof
(
cmd
),
"LC_CTYPE=%s"
,
lc_ctype
);
putenv
(
xstrdup
(
cmd
));
pg_
unsetenv
(
"LC_ALL"
);
unsetenv
(
"LC_ALL"
);
/* Also ensure backend isn't confused by this environment var: */
pg_
unsetenv
(
"PGCLIENTENCODING"
);
unsetenv
(
"PGCLIENTENCODING"
);
snprintf
(
cmd
,
sizeof
(
cmd
),
"
\"
%s/postgres
\"
-boot -x1 %s %s template1"
,
...
...
src/include/c.h
浏览文件 @
9e16195f
...
...
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/c.h,v 1.16
2 2004/04/30 20:47:33 momjian
Exp $
* $PostgreSQL: pgsql/src/include/c.h,v 1.16
3 2004/05/05 21:18:29 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -720,6 +720,10 @@ extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#define memmove(d, s, c) bcopy(s, d, c)
#endif
#ifndef HAVE_UNSETENV
extern
void
unsetenv
(
const
char
*
name
);
#endif
#ifndef DLLIMPORT
#define DLLIMPORT
/* no special DLL markers on most ports */
#endif
...
...
src/include/pg_config.h.in
浏览文件 @
9e16195f
...
...
@@ -530,6 +530,9 @@
/* Define to 1 if you have unix sockets. */
#undef HAVE_UNIX_SOCKETS
/* Define to 1 if you have the `unsetenv' function. */
#undef HAVE_UNSETENV
/* Define to 1 if you have the `utime' function. */
#undef HAVE_UTIME
...
...
src/port/unsetenv.c
0 → 100644
浏览文件 @
9e16195f
/*-------------------------------------------------------------------------
*
* unsetenv.c
* unsetenv() emulation for machines without it
*
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/port/unsetenv.c,v 1.1 2004/05/05 21:18:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "c.h"
void
unsetenv
(
const
char
*
name
)
{
char
*
envstr
;
if
(
getenv
(
name
)
==
NULL
)
return
;
/* no work */
/*
* The technique embodied here works if libc follows the Single Unix Spec
* and actually uses the storage passed to putenv() to hold the environ
* entry. When we clobber the entry in the second step we are ensuring
* that we zap the actual environ member. However, there are some libc
* implementations (notably recent BSDs) that do not obey SUS but copy
* the presented string. This method fails on such platforms. Hopefully
* all such platforms have unsetenv() and thus won't be using this hack.
*
* Note that repeatedly setting and unsetting a var using this code
* will leak memory.
*/
envstr
=
(
char
*
)
malloc
(
strlen
(
name
)
+
2
);
if
(
!
envstr
)
/* not much we can do if no memory */
return
;
/* Override the existing setting by forcibly defining the var */
sprintf
(
envstr
,
"%s="
,
name
);
putenv
(
envstr
);
/* Now we can clobber the variable definition this way: */
strcpy
(
envstr
,
"="
);
/*
* This last putenv cleans up if we have multiple zero-length names
* as a result of unsetting multiple things.
*/
putenv
(
envstr
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录