[RFC] Use STATIC_GETENV macro.
Ondřej Bílka
neleai@seznam.cz
Sat Nov 9 11:24:00 GMT 2013
Hi, I converted a getenv to STATIC_GETENV by a script which is below.
I used script to catch all uses. Most of uses happen rarely so they
migth not make sense.
It adds test failures of tst-gettext, tzset and wordexp.
These are caused by tests switching environment.
For gettext do we support changing locales by rewritting LC_ALL
environment variable?
In tz case this migth be legitimate. Could somebody comment about it?
For glob, wordexp, fnmatch we should split tests or run them with
different environment variables.
---
argp/argp-help.c | 2 +-
catgets/catgets.c | 4 ++--
crypt/speeds.c | 2 +-
debug/pcprofile.c | 2 +-
debug/segfault.c | 6 +++---
elf/dl-support.c | 12 ++++++------
elf/ldconfig.c | 2 +-
elf/sotruss-lib.c | 10 +++++-----
gmon/gmon.c | 2 +-
iconv/gconv_cache.c | 2 +-
intl/dcigettext.c | 4 ++--
io/getdirname.c | 2 +-
libidn/toutf8.c | 2 +-
locale/findlocale.c | 4 ++--
locale/newlocale.c | 2 +-
locale/programs/charmap.c | 2 +-
locale/programs/locale.c | 4 ++--
locale/programs/localedef.c | 2 +-
locale/programs/locfile.c | 2 +-
locale/programs/repertoire.c | 2 +-
locale/setlocale.c | 2 +-
localedata/bug-setlocale1.c | 2 +-
malloc/memusage.c | 12 ++++++------
nis/nis_local_names.c | 2 +-
nis/nis_subr.c | 2 +-
posix/execvpe.c | 2 +-
posix/fnmatch_loop.c | 6 +++---
posix/getconf.c | 2 +-
posix/getopt.c | 2 +-
posix/glob.c | 2 +-
posix/wordexp.c | 4 ++--
resolv/res_init.c | 4 ++--
resolv/res_query.c | 2 +-
stdlib/fmtmsg.c | 4 ++--
time/getdate.c | 2 +-
time/tzfile.c | 2 +-
time/tzset.c | 2 +-
37 files changed, 62 insertions(+), 62 deletions(-)
diff --git a/argp/argp-help.c b/argp/argp-help.c
index ace71b4..c2f1bca 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -164,7 +164,7 @@ static const struct uparam_name uparam_names[] =
static void
fill_in_uparams (const struct argp_state *state)
{
- const char *var = getenv ("ARGP_HELP_FMT");
+ const char *var = STATIC_GETENV ("ARGP_HELP_FMT");
#define SKIPWS(p) do { while (isspace (*p)) p++; } while (0);
diff --git a/catgets/catgets.c b/catgets/catgets.c
index 08a7905..216d08f 100644
--- a/catgets/catgets.c
+++ b/catgets/catgets.c
@@ -43,13 +43,13 @@ catopen (const char *cat_name, int flag)
env_var = setlocale (LC_MESSAGES, NULL);
else
/* Use the LANG environment variable. */
- env_var = getenv ("LANG");
+ env_var = STATIC_GETENV ("LANG");
if (env_var == NULL || *env_var == '\0'
|| (__libc_enable_secure && strchr (env_var, '/') != NULL))
env_var = "C";
- nlspath = getenv ("NLSPATH");
+ nlspath = STATIC_GETENV ("NLSPATH");
if (nlspath != NULL && *nlspath != '\0')
{
/* Append the system dependent directory. */
diff --git a/crypt/speeds.c b/crypt/speeds.c
index 810ecb0..7aac606 100644
--- a/crypt/speeds.c
+++ b/crypt/speeds.c
@@ -86,7 +86,7 @@ main (void)
#endif
#ifdef NO_ITIMER
- if ((hz = getenv("HZ")) == NULL) {
+ if ((hz = STATIC_GETENV("HZ")) == NULL) {
fprintf(stderr, "HZ environment parameter undefined\n");
exit(1);
}
diff --git a/debug/pcprofile.c b/debug/pcprofile.c
index ad860df..7d2a6fc 100644
--- a/debug/pcprofile.c
+++ b/debug/pcprofile.c
@@ -37,7 +37,7 @@ install (void)
{
/* See whether the environment variable `PCPROFILE_OUTPUT' is defined.
If yes, it should name a FIFO. We open it and mark ourself as active. */
- const char *outfile = getenv ("PCPROFILE_OUTPUT");
+ const char *outfile = STATIC_GETENV ("PCPROFILE_OUTPUT");
if (outfile != NULL && *outfile != '\0')
{
diff --git a/debug/segfault.c b/debug/segfault.c
index e1d058f..8e41863 100644
--- a/debug/segfault.c
+++ b/debug/segfault.c
@@ -145,7 +145,7 @@ __attribute__ ((constructor))
install_handler (void)
{
struct sigaction sa;
- const char *sigs = getenv ("SEGFAULT_SIGNALS");
+ const char *sigs = STATIC_GETENV ("SEGFAULT_SIGNALS");
const char *name;
sa.sa_handler = (void *) catch_segfault;
@@ -153,7 +153,7 @@ install_handler (void)
sa.sa_flags = SA_RESTART;
/* Maybe we are expected to use an alternative stack. */
- if (getenv ("SEGFAULT_USE_ALTSTACK") != 0)
+ if (STATIC_GETENV ("SEGFAULT_USE_ALTSTACK") != 0)
{
void *stack_mem = malloc (2 * SIGSTKSZ);
struct sigaltstack ss;
@@ -199,7 +199,7 @@ install_handler (void)
}
/* Preserve the output file name if there is any given. */
- name = getenv ("SEGFAULT_OUTPUT_NAME");
+ name = STATIC_GETENV ("SEGFAULT_OUTPUT_NAME");
if (name != NULL && name[0] != '\0')
{
int ret = access (name, R_OK | W_OK);
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 2023bd0..ffe7246 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -315,7 +315,7 @@ _dl_non_dynamic_init (void)
if (HP_TIMING_AVAIL)
HP_TIMING_NOW (_dl_cpuclock_offset);
- _dl_verbose = *(getenv ("LD_WARN") ?: "") == '\0' ? 0 : 1;
+ _dl_verbose = *(STATIC_GETENV ("LD_WARN") ?: "") == '\0' ? 0 : 1;
/* Set up the data structures for the system-supplied DSO early,
so they can influence _dl_init_paths. */
@@ -323,18 +323,18 @@ _dl_non_dynamic_init (void)
/* Initialize the data structures for the search paths for shared
objects. */
- _dl_init_paths (getenv ("LD_LIBRARY_PATH"));
+ _dl_init_paths (STATIC_GETENV ("LD_LIBRARY_PATH"));
/* Remember the last search directory added at startup. */
_dl_init_all_dirs = GL(dl_all_dirs);
- _dl_lazy = *(getenv ("LD_BIND_NOW") ?: "") == '\0';
+ _dl_lazy = *(STATIC_GETENV ("LD_BIND_NOW") ?: "") == '\0';
- _dl_bind_not = *(getenv ("LD_BIND_NOT") ?: "") != '\0';
+ _dl_bind_not = *(STATIC_GETENV ("LD_BIND_NOT") ?: "") != '\0';
- _dl_dynamic_weak = *(getenv ("LD_DYNAMIC_WEAK") ?: "") == '\0';
+ _dl_dynamic_weak = *(STATIC_GETENV ("LD_DYNAMIC_WEAK") ?: "") == '\0';
- _dl_profile_output = getenv ("LD_PROFILE_OUTPUT");
+ _dl_profile_output = STATIC_GETENV ("LD_PROFILE_OUTPUT");
if (_dl_profile_output == NULL || _dl_profile_output[0] == '\0')
_dl_profile_output
= &"/var/tmp\0/var/profile"[__libc_enable_secure ? 9 : 0];
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index c7b9eb9..1231ce3 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -1236,7 +1236,7 @@ parse_conf_include (const char *config_file, unsigned int lineno,
static void
set_hwcap (void)
{
- char *mask = getenv ("LD_HWCAP_MASK");
+ char *mask = STATIC_GETENV ("LD_HWCAP_MASK");
if (mask)
hwcap_mask = strtoul (mask, NULL, 0);
diff --git a/elf/sotruss-lib.c b/elf/sotruss-lib.c
index acf0638..73f326d 100644
--- a/elf/sotruss-lib.c
+++ b/elf/sotruss-lib.c
@@ -65,22 +65,22 @@ match_pid (pid_t pid, const char *which)
static void
init (void)
{
- fromlist = getenv ("SOTRUSS_FROMLIST");
+ fromlist = STATIC_GETENV ("SOTRUSS_FROMLIST");
if (fromlist != NULL && fromlist[0] == '\0')
fromlist = NULL;
- tolist = getenv ("SOTRUSS_TOLIST");
+ tolist = STATIC_GETENV ("SOTRUSS_TOLIST");
if (tolist != NULL && tolist[0] == '\0')
tolist = NULL;
- do_exit = (getenv ("SOTRUSS_EXIT") ?: "")[0] != '\0';
+ do_exit = (STATIC_GETENV ("SOTRUSS_EXIT") ?: "")[0] != '\0';
/* Determine whether this process is supposed to be traced and if
yes, whether we should print into a file. */
- const char *which_process = getenv ("SOTRUSS_WHICH");
+ const char *which_process = STATIC_GETENV ("SOTRUSS_WHICH");
pid_t pid = getpid ();
int out_fd = -1;
if (match_pid (pid, which_process))
{
- const char *out_filename = getenv ("SOTRUSS_OUTNAME");
+ const char *out_filename = STATIC_GETENV ("SOTRUSS_OUTNAME");
if (out_filename != NULL && out_filename[0] != 0)
{
diff --git a/gmon/gmon.c b/gmon/gmon.c
index 9774d57..38124fb 100644
--- a/gmon/gmon.c
+++ b/gmon/gmon.c
@@ -346,7 +346,7 @@ write_gmon (void)
# define O_NOFOLLOW 0
#endif
- env = getenv ("GMON_OUT_PREFIX");
+ env = STATIC_GETENV ("GMON_OUT_PREFIX");
if (env != NULL && !__libc_enable_secure)
{
size_t len = strlen (env);
diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c
index ccd2d6e..bff35c1 100644
--- a/iconv/gconv_cache.c
+++ b/iconv/gconv_cache.c
@@ -54,7 +54,7 @@ __gconv_load_cache (void)
/* We cannot use the cache if the GCONV_PATH environment variable is
set. */
- __gconv_path_envvar = getenv ("GCONV_PATH");
+ __gconv_path_envvar = STATIC_GETENV ("GCONV_PATH");
if (__gconv_path_envvar != NULL)
return -1;
diff --git a/intl/dcigettext.c b/intl/dcigettext.c
index f4aa215..892025f 100644
--- a/intl/dcigettext.c
+++ b/intl/dcigettext.c
@@ -1353,7 +1353,7 @@ guess_category_value (category, categoryname)
/* The highest priority value is the `LANGUAGE' environment
variable. But we don't use the value if the currently selected
locale is the C locale. This is a GNU extension. */
- language = getenv ("LANGUAGE");
+ language = STATIC_GETENV ("LANGUAGE");
if (language != NULL && language[0] == '\0')
language = NULL;
@@ -1393,7 +1393,7 @@ get_output_charset (domainbinding)
if (!output_charset_cached)
{
- const char *value = getenv ("OUTPUT_CHARSET");
+ const char *value = STATIC_GETENV ("OUTPUT_CHARSET");
if (value != NULL && value[0] != '\0')
{
diff --git a/io/getdirname.c b/io/getdirname.c
index a360eb9..7c4a4ca 100644
--- a/io/getdirname.c
+++ b/io/getdirname.c
@@ -30,7 +30,7 @@ get_current_dir_name (void)
char *pwd;
struct stat64 dotstat, pwdstat;
- pwd = getenv ("PWD");
+ pwd = STATIC_GETENV ("PWD");
if (pwd != NULL
&& stat64 (".", &dotstat) == 0
&& stat64 (pwd, &pwdstat) == 0
diff --git a/libidn/toutf8.c b/libidn/toutf8.c
index c7e67ca..7f4a90a 100644
--- a/libidn/toutf8.c
+++ b/libidn/toutf8.c
@@ -72,7 +72,7 @@
const char *
stringprep_locale_charset (void)
{
- const char *charset = getenv ("CHARSET"); /* flawfinder: ignore */
+ const char *charset = STATIC_GETENV ("CHARSET"); /* flawfinder: ignore */
if (charset && *charset)
return charset;
diff --git a/locale/findlocale.c b/locale/findlocale.c
index 3c04aa8..711c87d 100644
--- a/locale/findlocale.c
+++ b/locale/findlocale.c
@@ -77,12 +77,12 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
{
/* The user decides which locale to use by setting environment
variables. */
- *name = getenv ("LC_ALL");
+ *name = STATIC_GETENV ("LC_ALL");
if (*name == NULL || (*name)[0] == '\0')
*name = getenv (_nl_category_names.str
+ _nl_category_name_idxs[category]);
if (*name == NULL || (*name)[0] == '\0')
- *name = getenv ("LANG");
+ *name = STATIC_GETENV ("LANG");
}
if (*name == NULL || (*name)[0] == '\0'
diff --git a/locale/newlocale.c b/locale/newlocale.c
index b9a696b..16887a6 100644
--- a/locale/newlocale.c
+++ b/locale/newlocale.c
@@ -102,7 +102,7 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
locale_path = NULL;
locale_path_len = 0;
- locpath_var = getenv ("LOCPATH");
+ locpath_var = STATIC_GETENV ("LOCPATH");
if (locpath_var != NULL && locpath_var[0] != '\0')
{
if (__argz_create_sep (locpath_var, ':',
diff --git a/locale/programs/charmap.c b/locale/programs/charmap.c
index 6ce9b18..89b605b 100644
--- a/locale/programs/charmap.c
+++ b/locale/programs/charmap.c
@@ -104,7 +104,7 @@ charmap_read (const char *filename, int verbose, int error_not_found,
in the I18NPATH if this is a simple name. */
if (strchr (filename, '/') == NULL)
{
- char *i18npath = getenv ("I18NPATH");
+ char *i18npath = STATIC_GETENV ("I18NPATH");
if (i18npath != NULL && *i18npath != '\0')
{
const size_t pathlen = strlen (i18npath);
diff --git a/locale/programs/locale.c b/locale/programs/locale.c
index 14d34e6..076d94a 100644
--- a/locale/programs/locale.c
+++ b/locale/programs/locale.c
@@ -793,8 +793,8 @@ static void
show_locale_vars (void)
{
size_t cat_no;
- const char *lcall = getenv ("LC_ALL") ? : "";
- const char *lang = getenv ("LANG") ? : "";
+ const char *lcall = STATIC_GETENV ("LC_ALL") ? : "";
+ const char *lang = STATIC_GETENV ("LANG") ? : "";
auto void get_source (const char *name);
diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c
index d664232..ddfa4d9 100644
--- a/locale/programs/localedef.c
+++ b/locale/programs/localedef.c
@@ -192,7 +192,7 @@ main (int argc, char *argv[])
/* Set initial values for global variables. */
copy_list = NULL;
- posix_conformance = getenv ("POSIXLY_CORRECT") != NULL;
+ posix_conformance = STATIC_GETENV ("POSIXLY_CORRECT") != NULL;
error_print_progname = error_print;
/* Set locale. Do not set LC_ALL because the other categories must
diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c
index ef7adbf..480640b 100644
--- a/locale/programs/locfile.c
+++ b/locale/programs/locfile.c
@@ -65,7 +65,7 @@ locfile_read (struct localedef_t *result, const struct charmap_t *charmap)
{
if (filename != NULL && filename[0] != '/')
{
- char *i18npath = getenv ("I18NPATH");
+ char *i18npath = STATIC_GETENV ("I18NPATH");
if (i18npath != NULL && *i18npath != '\0')
{
const size_t pathlen = strlen (i18npath);
diff --git a/locale/programs/repertoire.c b/locale/programs/repertoire.c
index be77b3e..68845a7 100644
--- a/locale/programs/repertoire.c
+++ b/locale/programs/repertoire.c
@@ -76,7 +76,7 @@ repertoire_read (const char *filename)
{
if (strchr (filename, '/') == NULL)
{
- char *i18npath = getenv ("I18NPATH");
+ char *i18npath = STATIC_GETENV ("I18NPATH");
if (i18npath != NULL && *i18npath != '\0')
{
const size_t pathlen = strlen (i18npath);
diff --git a/locale/setlocale.c b/locale/setlocale.c
index e83a156..0c77a31 100644
--- a/locale/setlocale.c
+++ b/locale/setlocale.c
@@ -251,7 +251,7 @@ setlocale (int category, const char *locale)
locale_path = NULL;
locale_path_len = 0;
- locpath_var = getenv ("LOCPATH");
+ locpath_var = STATIC_GETENV ("LOCPATH");
if (locpath_var != NULL && locpath_var[0] != '\0')
{
if (__argz_create_sep (locpath_var, ':',
diff --git a/localedata/bug-setlocale1.c b/localedata/bug-setlocale1.c
index dc7f6f3..a9af894 100644
--- a/localedata/bug-setlocale1.c
+++ b/localedata/bug-setlocale1.c
@@ -25,7 +25,7 @@ do_test (int argc, char *argv[])
char *env[3];
env[0] = (char *) "LC_CTYPE=de_DE.UTF-8";
- char *loc = getenv ("LOCPATH");
+ char *loc = STATIC_GETENV ("LOCPATH");
if (loc == NULL || loc[0] == '\0')
{
puts ("LOCPATH not set");
diff --git a/malloc/memusage.c b/malloc/memusage.c
index e32f6ba..498e861 100644
--- a/malloc/memusage.c
+++ b/malloc/memusage.c
@@ -217,7 +217,7 @@ int_handler (int signo)
static void
me (void)
{
- const char *env = getenv ("MEMUSAGE_PROG_NAME");
+ const char *env = STATIC_GETENV ("MEMUSAGE_PROG_NAME");
size_t prog_len = strlen (__progname);
initialized = -1;
@@ -253,7 +253,7 @@ me (void)
if (!start_sp)
start_sp = GETSP ();
- outname = getenv ("MEMUSAGE_OUTPUT");
+ outname = STATIC_GETENV ("MEMUSAGE_OUTPUT");
if (outname != NULL && outname[0] != '\0'
&& (access (outname, R_OK | W_OK) == 0 || errno == ENOENT))
{
@@ -276,15 +276,15 @@ me (void)
/* Determine the buffer size. We use the default if the
environment variable is not present. */
buffer_size = DEFAULT_BUFFER_SIZE;
- if (getenv ("MEMUSAGE_BUFFER_SIZE") != NULL)
+ if (STATIC_GETENV ("MEMUSAGE_BUFFER_SIZE") != NULL)
{
- buffer_size = atoi (getenv ("MEMUSAGE_BUFFER_SIZE"));
+ buffer_size = atoi (STATIC_GETENV ("MEMUSAGE_BUFFER_SIZE"));
if (buffer_size == 0 || buffer_size > DEFAULT_BUFFER_SIZE)
buffer_size = DEFAULT_BUFFER_SIZE;
}
/* Possibly enable timer-based stack pointer retrieval. */
- if (getenv ("MEMUSAGE_NO_TIMER") == NULL)
+ if (STATIC_GETENV ("MEMUSAGE_NO_TIMER") == NULL)
{
struct sigaction act;
@@ -305,7 +305,7 @@ me (void)
}
}
- if (!not_me && getenv ("MEMUSAGE_TRACE_MMAP") != NULL)
+ if (!not_me && STATIC_GETENV ("MEMUSAGE_TRACE_MMAP") != NULL)
trace_mmap = true;
}
}
diff --git a/nis/nis_local_names.c b/nis/nis_local_names.c
index c69af72..8997f23 100644
--- a/nis/nis_local_names.c
+++ b/nis/nis_local_names.c
@@ -29,7 +29,7 @@ nis_local_group (void)
char *cptr;
if (__nisgroup[0] == '\0'
- && (cptr = getenv ("NIS_GROUP")) != NULL
+ && (cptr = STATIC_GETENV ("NIS_GROUP")) != NULL
&& strlen (cptr) < NIS_MAXNAMELEN)
{
char *cp = stpcpy (__nisgroup, cptr);
diff --git a/nis/nis_subr.c b/nis/nis_subr.c
index a03600d..ee6f3be 100644
--- a/nis/nis_subr.c
+++ b/nis/nis_subr.c
@@ -177,7 +177,7 @@ nis_getnames (const_nis_name name)
}
/* Get the search path, where we have to search "name" */
- path = getenv ("NIS_PATH");
+ path = STATIC_GETENV ("NIS_PATH");
if (path == NULL)
path = strdupa ("$");
else
diff --git a/posix/execvpe.c b/posix/execvpe.c
index 588e7a7..09b18e9 100644
--- a/posix/execvpe.c
+++ b/posix/execvpe.c
@@ -89,7 +89,7 @@ __execvpe (file, argv, envp)
{
size_t pathlen;
size_t alloclen = 0;
- char *path = getenv ("PATH");
+ char *path = STATIC_GETENV ("PATH");
if (path == NULL)
{
pathlen = confstr (_CS_PATH, (char *) NULL, 0);
diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c
index 078b982..065ecf0 100644
--- a/posix/fnmatch_loop.c
+++ b/posix/fnmatch_loop.c
@@ -242,7 +242,7 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
UCHAR fn;
if (posixly_correct == 0)
- posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
+ posixly_correct = STATIC_GETENV ("POSIXLY_CORRECT") != NULL ? 1 : -1;
if (n == string_end)
return FNM_NOMATCH;
@@ -1028,7 +1028,7 @@ END (const CHAR *pattern)
{
/* Handle brackets special. */
if (posixly_correct == 0)
- posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
+ posixly_correct = STATIC_GETENV ("POSIXLY_CORRECT") != NULL ? 1 : -1;
/* Skip the not sign. We have to recognize it because of a possibly
following ']'. */
@@ -1086,7 +1086,7 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
{
/* Handle brackets special. */
if (posixly_correct == 0)
- posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
+ posixly_correct = STATIC_GETENV ("POSIXLY_CORRECT") != NULL ? 1 : -1;
/* Skip the not sign. We have to recognize it because of a possibly
following ']'. */
diff --git a/posix/getconf.c b/posix/getconf.c
index 8787720..aa2d596 100644
--- a/posix/getconf.c
+++ b/posix/getconf.c
@@ -1123,7 +1123,7 @@ environment SPEC.\n\n"));
return 0;
}
- const char *getconf_dir = getenv ("GETCONF_DIR") ?: GETCONF_DIR;
+ const char *getconf_dir = STATIC_GETENV ("GETCONF_DIR") ?: GETCONF_DIR;
size_t getconf_dirlen = strlen (getconf_dir);
const char *spec = NULL;
diff --git a/posix/getopt.c b/posix/getopt.c
index 5497fc4..3af6c27 100644
--- a/posix/getopt.c
+++ b/posix/getopt.c
@@ -279,7 +279,7 @@ _getopt_initialize (int argc, char *const *argv, const char *optstring,
d->__nextchar = NULL;
- d->__posixly_correct = posixly_correct | !!getenv ("POSIXLY_CORRECT");
+ d->__posixly_correct = posixly_correct | !!STATIC_GETENV ("POSIXLY_CORRECT");
/* Determine how to handle the ordering of options and nonoptions. */
diff --git a/posix/glob.c b/posix/glob.c
index 85237c2..336bbf7 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -597,7 +597,7 @@ glob (pattern, flags, errfunc, pglob)
&& (dirname[2] == '\0' || dirname[2] == '/')))
{
/* Look up home directory. */
- char *home_dir = getenv ("HOME");
+ char *home_dir = STATIC_GETENV ("HOME");
int malloc_home_dir = 0;
# ifdef _AMIGA
if (home_dir == NULL || home_dir[0] == '\0')
diff --git a/posix/wordexp.c b/posix/wordexp.c
index 96ce8a4..45df120 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -319,7 +319,7 @@ parse_tilde (char **word, size_t *word_length, size_t *max_length,
results are unspecified. We do a lookup on the uid if
HOME is unset. */
- home = getenv ("HOME");
+ home = STATIC_GETENV ("HOME");
if (home != NULL)
{
*word = w_addstr (*word, word_length, max_length, home);
@@ -2304,7 +2304,7 @@ wordexp (const char *words, wordexp_t *pwordexp, int flags)
/* Find out what the field separators are.
* There are two types: whitespace and non-whitespace.
*/
- ifs = getenv ("IFS");
+ ifs = STATIC_GETENV ("IFS");
if (ifs == NULL)
/* IFS unset - use <space><tab><newline>. */
diff --git a/resolv/res_init.c b/resolv/res_init.c
index 5e1a747..6fdeccb 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -195,7 +195,7 @@ __res_vinit(res_state statp, int preinit) {
#endif
/* Allow user to override the local domain definition */
- if ((cp = getenv("LOCALDOMAIN")) != NULL) {
+ if ((cp = STATIC_GETENV("LOCALDOMAIN")) != NULL) {
(void)strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
statp->defdname[sizeof(statp->defdname) - 1] = '\0';
haveenv++;
@@ -469,7 +469,7 @@ __res_vinit(res_state statp, int preinit) {
#endif /* !RFC1535 */
}
- if ((cp = getenv("RES_OPTIONS")) != NULL)
+ if ((cp = STATIC_GETENV("RES_OPTIONS")) != NULL)
res_setoptions(statp, cp, "env");
statp->options |= RES_INIT;
return (0);
diff --git a/resolv/res_query.c b/resolv/res_query.c
index 1325f97..5f9c9c7 100644
--- a/resolv/res_query.c
+++ b/resolv/res_query.c
@@ -605,7 +605,7 @@ res_hostalias(const res_state statp, const char *name, char *dst, size_t siz) {
if (statp->options & RES_NOALIASES)
return (NULL);
- file = getenv("HOSTALIASES");
+ file = STATIC_GETENV("HOSTALIASES");
if (file == NULL || (fp = fopen(file, "rce")) == NULL)
return (NULL);
setbuf(fp, NULL);
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 5185de4..f1cfb9e 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -210,8 +210,8 @@ fmtmsg (long int classification, const char *label, int severity,
static void
init (void)
{
- const char *msgverb_var = getenv ("MSGVERB");
- const char *sevlevel_var = getenv ("SEV_LEVEL");
+ const char *msgverb_var = STATIC_GETENV ("MSGVERB");
+ const char *sevlevel_var = STATIC_GETENV ("SEV_LEVEL");
if (msgverb_var != NULL && msgverb_var[0] != '\0')
{
diff --git a/time/getdate.c b/time/getdate.c
index eadebc3..526e24b 100644
--- a/time/getdate.c
+++ b/time/getdate.c
@@ -116,7 +116,7 @@ __getdate_r (const char *string, struct tm *tp)
struct stat64 st;
int mday_ok = 0;
- datemsk = getenv ("DATEMSK");
+ datemsk = STATIC_GETENV ("DATEMSK");
if (datemsk == NULL || *datemsk == '\0')
return 1;
diff --git a/time/tzfile.c b/time/tzfile.c
index 3ea3051..5ab47e6 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -147,7 +147,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap)
{
const char *tzdir;
- tzdir = getenv ("TZDIR");
+ tzdir = STATIC_GETENV ("TZDIR");
if (tzdir == NULL || *tzdir == '\0')
tzdir = default_tzdir;
if (__asprintf (&new, "%s/%s", tzdir, file) == -1)
diff --git a/time/tzset.c b/time/tzset.c
index 4f8af8d..4ccdbaa 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -407,7 +407,7 @@ tzset_internal (always, explicit)
is_initialized = 1;
/* Examine the TZ environment variable. */
- tz = getenv ("TZ");
+ tz = STATIC_GETENV ("TZ");
if (tz == NULL && !explicit)
/* Use the site-wide default. This is a file name which means we
would not see changes to the file if we compare only the file
--
1.8.4.rc3
More information about the Libc-alpha
mailing list