diff options
author | Thomas Munro <tmunro@postgresql.org> | 2022-08-05 09:38:36 +1200 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2022-08-05 09:38:36 +1200 |
commit | 71f5dc6dfb3de50de28ddde53793540c2fa98b1f (patch) | |
tree | bda25fad6c14f222f5f0e6416fe92bb3b3fc03af /src/port/setenv.c | |
parent | b79ec732d29fe42e91aeab4da62d446f226b594a (diff) | |
download | postgresql-71f5dc6dfb3de50de28ddde53793540c2fa98b1f.tar.gz |
Remove dead setenv, unsetenv replacement code.
setenv() and unsetenv() are in SUSv3 and targeted Unix systems have
them. We still need special code for these on Windows, but that doesn't
require a configure probe.
This marks the first time we require a SUSv3 (POSIX.1-2001) facility
(rather than SUSv2). The replacement code removed here was not needed
on any targeted system or any known non-EOL'd Unix system, and was
therefore dead and untested.
No need for vestigial HAVE_SETENV and HAVE_UNSETENV macros, because we
provide a replacement for Windows, and we didn't previously test the
macros.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Greg Stark <stark@mit.edu>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CA+hUKGJ3LHeP9w5Fgzdr4G8AnEtJ=z=p6hGDEm4qYGEUX5B6fQ@mail.gmail.com
Diffstat (limited to 'src/port/setenv.c')
-rw-r--r-- | src/port/setenv.c | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/src/port/setenv.c b/src/port/setenv.c deleted file mode 100644 index d13c882467..0000000000 --- a/src/port/setenv.c +++ /dev/null @@ -1,48 +0,0 @@ -/*------------------------------------------------------------------------- - * - * setenv.c - * setenv() emulation for machines without it - * - * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * - * IDENTIFICATION - * src/port/setenv.c - * - *------------------------------------------------------------------------- - */ - -#include "c.h" - - -int -setenv(const char *name, const char *value, int overwrite) -{ - char *envstr; - - /* Error conditions, per POSIX */ - if (name == NULL || name[0] == '\0' || strchr(name, '=') != NULL || - value == NULL) - { - errno = EINVAL; - return -1; - } - - /* No work if variable exists and we're not to replace it */ - if (overwrite == 0 && getenv(name) != NULL) - return 0; - - /* - * Add or replace the value using putenv(). This will leak memory if the - * same variable is repeatedly redefined, but there's little we can do - * about that when sitting atop putenv(). - */ - envstr = (char *) malloc(strlen(name) + strlen(value) + 2); - if (!envstr) /* not much we can do if no memory */ - return -1; - - sprintf(envstr, "%s=%s", name, value); - - return putenv(envstr); -} |