Implement os_unsetenv()

- In UNIX systems where unsetenv() is available, it is used. Otherwise
  the variables are set with the empty string.
- New check HAVE_UNSETENV for unsetenv()
- Added unit test to env_spec.lua
This commit is contained in:
Rui Abreu Ferreira
2015-02-25 10:33:04 +00:00
committed by Scott Prager
parent a9ee85b9fc
commit 71487a935e
4 changed files with 32 additions and 0 deletions

View File

@@ -37,6 +37,19 @@ int os_setenv(const char *name, const char *value, int overwrite)
return setenv(name, value, overwrite);
}
/// Unset environment variable
///
/// For systems where unsetenv() is not available the value will be set as an
/// empty string
int os_unsetenv(const char *name)
{
#ifdef HAVE_UNSETENV
return unsetenv(name);
#else
return os_setenv(name, "", 1);
#endif
}
char *os_getenvname_at_index(size_t index)
{
# if defined(HAVE__NSGETENVIRON)