git.postgresql.org Git - postgresql.git/commit

git projects / postgresql.git / commit
? search:
summary | shortlog | log | commit | commitdiff | tree
(parent: 62097a4) | patch
Use setenv() in preference to putenv().
2020年12月30日 17:55:59 +0000 (12:55 -0500)
2020年12月30日 17:56:06 +0000 (12:56 -0500)
commit 7ca37fb0406bc2cbbd864a2ffdbdb4479e338c0c
Use setenv() in preference to putenv().

Since at least 2001 we've used putenv() and avoided setenv(), on the
grounds that the latter was unportable and not in POSIX. However,
POSIX added it that same year, and by now the situation has reversed:
setenv() is probably more portable than putenv(), since POSIX now
treats the latter as not being a core function. And setenv() has
cleaner semantics too. So, let's reverse that old policy.

This commit adds a simple src/port/ implementation of setenv() for
any stragglers (we have one in the buildfarm, but I'd not be surprised
if that code is never used in the field). More importantly, extend
win32env.c to also support setenv(). Then, replace usages of putenv()
with setenv(), and get rid of some ad-hoc implementations of setenv()
wannabees.

Also, adjust our src/port/ implementation of unsetenv() to follow the
POSIX spec that it returns an error indicator, rather than returning
void as per the ancient BSD convention. I don't feel a need to make
all the call sites check for errors, but the portability stub ought
to match real-world practice.

Discussion: https://postgr.es/m/2065122.1609212051@sss.pgh.pa.us
26 files changed:
configure diff | blob | blame | history
configure.ac diff | blob | blame | history
contrib/dblink/input/paths.source diff | blob | blame | history
contrib/dblink/output/paths.source diff | blob | blame | history
src/backend/utils/adt/pg_locale.c diff | blob | blame | history
src/bin/initdb/initdb.c diff | blob | blame | history
src/bin/pg_ctl/pg_ctl.c diff | blob | blame | history
src/bin/pg_upgrade/controldata.c diff | blob | blame | history
src/bin/pg_upgrade/option.c diff | blob | blame | history
src/bin/pg_upgrade/pg_upgrade.h diff | blob | blame | history
src/bin/pg_upgrade/util.c diff | blob | blame | history
src/bin/psql/command.c diff | blob | blame | history
src/common/exec.c diff | blob | blame | history
src/common/restricted_token.c diff | blob | blame | history
src/include/pg_config.h.in diff | blob | blame | history
src/include/port.h diff | blob | blame | history
src/include/port/win32_port.h diff | blob | blame | history
src/interfaces/ecpg/test/pg_regress_ecpg.c diff | blob | blame | history
src/port/setenv.c [new file with mode: 0644] blob
src/port/unsetenv.c diff | blob | blame | history
src/port/win32env.c diff | blob | blame | history
src/test/isolation/isolation_main.c diff | blob | blame | history
src/test/regress/pg_regress.c diff | blob | blame | history
src/test/regress/pg_regress_main.c diff | blob | blame | history
src/test/regress/regress.c diff | blob | blame | history
src/tools/msvc/Solution.pm diff | blob | blame | history
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /