diff options
author | David Mitchell <davem@iabyn.com> | 2018-06-29 14:30:17 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2018-06-29 14:30:17 +0100 |
commit | adebb90ded7502ff44bd789b300b1193c89c047c (patch) | |
tree | 87b83b74a97252b17097ffb2781159c1550c8284 /util.c | |
parent | de5576aa52889a6b4c37e8137a9ebfe0abe75619 (diff) | |
download | perl-adebb90ded7502ff44bd789b300b1193c89c047c.tar.gz |
Perl_my_setenv(): re-indent cpp directive lines
The indentation was all over the place. Whitespace-only changes apart
from fixing code comments at end of '#endif' lines.
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 78 |
1 files changed, 51 insertions, 27 deletions
@@ -2060,6 +2060,8 @@ Perl_new_warnings_bitfield(pTHX_ STRLEN *buffer, const char *const bits, Copy(val, s+(nlen+1), vlen, char); \ *(s+(nlen+1+vlen)) = '\0' + + #ifdef USE_ENVIRON_ARRAY /* NB: VMS' my_setenv() is in vms.c */ @@ -2093,21 +2095,23 @@ S_env_alloc(void *current, Size_t l1, Size_t l2, Size_t l3, Size_t size) } -#if !defined(WIN32) && !defined(NETWARE) +# if !defined(WIN32) && !defined(NETWARE) void Perl_my_setenv(pTHX_ const char *nam, const char *val) { dVAR; -#ifdef __amigaos4__ +# ifdef __amigaos4__ amigaos4_obtain_environ(__FUNCTION__); -#endif -#ifdef USE_ITHREADS +# endif + +# ifdef USE_ITHREADS /* only parent thread can modify process environment */ if (PL_curinterp == aTHX) -#endif +# endif { -#ifndef PERL_USE_SAFE_PUTENV + +# ifndef PERL_USE_SAFE_PUTENV if (!PL_use_safe_putenv) { /* most putenv()s leak, so we manipulate environ directly */ UV i; @@ -2126,28 +2130,33 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val) max = i; while (environ[max]) max++; + /* XXX shouldn't that be max+1 rather than max+2 ??? - DAPM */ tmpenv = (char**)S_env_alloc(NULL, max, 2, 0, sizeof(char*)); + for (j=0; j<max; j++) { /* copy environment */ const Size_t len = strlen(environ[j]); tmpenv[j] = S_env_alloc(NULL, len, 1, 0, 1); Copy(environ[j], tmpenv[j], len+1, char); } + tmpenv[max] = NULL; environ = tmpenv; /* tell exec where it is now */ } + if (!val) { safesysfree(environ[i]); while (environ[i]) { environ[i] = environ[i+1]; i++; } -#ifdef __amigaos4__ +# ifdef __amigaos4__ goto my_setenv_out; -#else +# else return; -#endif +# endif } + if (!environ[i]) { /* does not exist yet */ environ = (char**)S_env_alloc(environ, i, 2, 0, sizeof(char*)); environ[i+1] = NULL; /* make sure it's null terminated */ @@ -2160,23 +2169,30 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val) environ[i] = S_env_alloc(NULL, nlen, vlen, 2, 1); /* all that work just for this */ my_setenv_format(environ[i], nam, nlen, val, vlen); - } else { -# endif + } + else { + +# 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. + 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) -# if defined(HAS_UNSETENV) +# if defined(__CYGWIN__)|| defined(__SYMBIAN32__) || defined(__riscos__) || (defined(__sun) && defined(HAS_UNSETENV)) || defined(PERL_DARWIN) + +# if defined(HAS_UNSETENV) if (val == NULL) { (void)unsetenv(nam); } else { (void)setenv(nam, val, 1); } -# else /* ! HAS_UNSETENV */ +# else /* ! HAS_UNSETENV */ (void)setenv(nam, val, 1); -# endif /* HAS_UNSETENV */ -# elif defined(HAS_UNSETENV) +# endif /* HAS_UNSETENV */ + +# elif defined(HAS_UNSETENV) + if (val == NULL) { if (environ) /* old glibc can crash with null environ */ (void)unsetenv(nam); @@ -2187,7 +2203,9 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val) my_setenv_format(new_env, nam, nlen, val, vlen); (void)putenv(new_env); } -# else /* ! HAS_UNSETENV */ + +# else /* ! HAS_UNSETENV */ + char *new_env; const Size_t nlen = strlen(nam); Size_t vlen; @@ -2199,18 +2217,21 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val) /* all that work just for this */ my_setenv_format(new_env, nam, nlen, val, vlen); (void)putenv(new_env); -# endif /* __CYGWIN__ */ -#ifndef PERL_USE_SAFE_PUTENV + +# endif /* __CYGWIN__ */ + +# ifndef PERL_USE_SAFE_PUTENV } -#endif +# endif } -#ifdef __amigaos4__ + +# ifdef __amigaos4__ my_setenv_out: amigaos4_release_environ(__FUNCTION__); -#endif +# endif } -#else /* WIN32 || NETWARE */ +# else /* WIN32 || NETWARE */ void Perl_my_setenv(pTHX_ const char *nam, const char *val) @@ -2230,9 +2251,12 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val) Safefree(envstr); } -#endif /* WIN32 || NETWARE */ +# endif /* WIN32 || NETWARE */ + +#endif /* USE_ENVIRON_ARRAY */ + + -#endif /* !VMS */ #ifdef UNLINK_ALL_VERSIONS I32 |