Win32: unify environment function names
Environment helper functions use random naming ('env' prefix or suffix or both, with or without '_'). Change to POSIX naming scheme ('env' suffix, no '_'). Env_setenv has more in common with putenv than setenv. Change to do_putenv. Signed-off-by: Karsten Blees <blees@dcon.de> Signed-off-by: Stepan Kasal <kasal@ucw.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
38d2750126
commit
26c7b21ab1
|
@ -899,7 +899,7 @@ static char *path_lookup(const char *cmd, char **path, int exe_only)
|
||||||
return prog;
|
return prog;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int env_compare(const void *a, const void *b)
|
static int compareenv(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
char *const *ea = a;
|
char *const *ea = a;
|
||||||
char *const *eb = b;
|
char *const *eb = b;
|
||||||
|
@ -993,7 +993,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,
|
||||||
/* environment must be sorted */
|
/* environment must be sorted */
|
||||||
sorted_env = xmalloc(sizeof(*sorted_env) * (count + 1));
|
sorted_env = xmalloc(sizeof(*sorted_env) * (count + 1));
|
||||||
memcpy(sorted_env, env, sizeof(*sorted_env) * (count + 1));
|
memcpy(sorted_env, env, sizeof(*sorted_env) * (count + 1));
|
||||||
qsort(sorted_env, count, sizeof(*sorted_env), env_compare);
|
qsort(sorted_env, count, sizeof(*sorted_env), compareenv);
|
||||||
|
|
||||||
/* create environment block from temporary environment */
|
/* create environment block from temporary environment */
|
||||||
for (e = sorted_env; *e; e++) {
|
for (e = sorted_env; *e; e++) {
|
||||||
|
@ -1194,7 +1194,7 @@ void free_environ(char **env)
|
||||||
free(env);
|
free(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lookup_env(char **env, const char *name, size_t nmln)
|
static int lookupenv(char **env, const char *name, size_t nmln)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -1209,10 +1209,10 @@ static int lookup_env(char **env, const char *name, size_t nmln)
|
||||||
/*
|
/*
|
||||||
* If name contains '=', then sets the variable, otherwise it unsets it
|
* If name contains '=', then sets the variable, otherwise it unsets it
|
||||||
*/
|
*/
|
||||||
static char **env_setenv(char **env, const char *name)
|
static char **do_putenv(char **env, const char *name)
|
||||||
{
|
{
|
||||||
char *eq = strchrnul(name, '=');
|
char *eq = strchrnul(name, '=');
|
||||||
int i = lookup_env(env, name, eq-name);
|
int i = lookupenv(env, name, eq-name);
|
||||||
|
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
if (*eq) {
|
if (*eq) {
|
||||||
|
@ -1243,7 +1243,7 @@ char **make_augmented_environ(const char *const *vars)
|
||||||
|
|
||||||
while (*vars) {
|
while (*vars) {
|
||||||
const char *v = *vars++;
|
const char *v = *vars++;
|
||||||
env = env_setenv(env, strchr(v, '=') ? xstrdup(v) : v);
|
env = do_putenv(env, strchr(v, '=') ? xstrdup(v) : v);
|
||||||
}
|
}
|
||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
@ -1263,7 +1263,7 @@ char *mingw_getenv(const char *name)
|
||||||
|
|
||||||
int mingw_putenv(const char *namevalue)
|
int mingw_putenv(const char *namevalue)
|
||||||
{
|
{
|
||||||
environ = env_setenv(environ, namevalue);
|
environ = do_putenv(environ, namevalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue