summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2018-07-23 09:15:38 +0100
committerDavid Mitchell <davem@iabyn.com>2018-07-23 09:15:38 +0100
commit3d50648cc4f452d51a0564164a214e51dd6aad95 (patch)
treecb626fb1c0a66a24606ee16961197ddbbfbfe857 /util.c
parent54acf98aab6830e54ddc195615ffed4a8461b183 (diff)
downloadperl-3d50648cc4f452d51a0564164a214e51dd6aad95.tar.gz
Don't compile S_env_alloc() when not used
RT #133360 I recently added S_env_alloc() as a helper function for Perl_my_setenv(); but it's not needed on all platforms, so #ifdef it to only be compiled on platforms where its needed. Avoids a compiler warning.
Diffstat (limited to 'util.c')
-rw-r--r--util.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/util.c b/util.c
index 9d3f5ba0f1..37a71a1a81 100644
--- a/util.c
+++ b/util.c
@@ -2065,10 +2065,19 @@ Perl_new_warnings_bitfield(pTHX_ STRLEN *buffer, const char *const bits,
#ifdef USE_ENVIRON_ARRAY
/* NB: VMS' my_setenv() is in vms.c */
+/* Configure doesn't test for HAS_SETENV yet, so decide based on platform.
+ * For Solaris, setenv() and unsetenv() were introduced in Solaris 9, so
+ * testing for HAS UNSETENV is sufficient.
+ */
+# if defined(__CYGWIN__)|| defined(__SYMBIAN32__) || defined(__riscos__) || (defined(__sun) && defined(HAS_UNSETENV)) || defined(PERL_DARWIN)
+# define MY_HAS_SETENV
+# endif
+
/* small wrapper for use by Perl_my_setenv that mallocs, or reallocs if
* 'current' is non-null, with up to three sizes that are added together.
* It handles integer overflow.
*/
+# ifndef MY_HAS_SETENV
static char *
S_env_alloc(void *current, Size_t l1, Size_t l2, Size_t l3, Size_t size)
{
@@ -2093,6 +2102,7 @@ S_env_alloc(void *current, Size_t l1, Size_t l2, Size_t l3, Size_t size)
panic:
croak_memory_wrap();
}
+# endif
# if !defined(WIN32) && !defined(NETWARE)
@@ -2174,13 +2184,7 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val)
# endif /* !PERL_USE_SAFE_PUTENV */
- /* This next branch should only be called #if defined(HAS_SETENV), but
- Configure doesn't test for that yet. For Solaris, setenv() and
- unsetenv() were introduced in Solaris 9, so testing for HAS
- UNSETENV is sufficient.
- */
-# if defined(__CYGWIN__)|| defined(__SYMBIAN32__) || defined(__riscos__) || (defined(__sun) && defined(HAS_UNSETENV)) || defined(PERL_DARWIN)
-
+# ifdef MY_HAS_SETENV
# if defined(HAS_UNSETENV)
if (val == NULL) {
(void)unsetenv(nam);
@@ -2218,7 +2222,7 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val)
my_setenv_format(new_env, nam, nlen, val, vlen);
(void)putenv(new_env);
-# endif /* __CYGWIN__ */
+# endif /* MY_HAS_SETENV */
# ifndef PERL_USE_SAFE_PUTENV
}