forked from enlightenment/enlightenment
e: cleanup env var setting
Return early if there is nothing to append/prepend. Only add ':' if there are two elements to join. SVN revision: 77295
This commit is contained in:
parent
d6e1350427
commit
5969b88a6a
|
@ -199,15 +199,18 @@ copy_args(char **dst, char **src, size_t count)
|
||||||
static void
|
static void
|
||||||
_env_path_prepend(const char *env, const char *path)
|
_env_path_prepend(const char *env, const char *path)
|
||||||
{
|
{
|
||||||
char *p, *p2, *s;
|
char *p, *s;
|
||||||
|
const char *p2;
|
||||||
int len = 0, len2 = 0;
|
int len = 0, len2 = 0;
|
||||||
|
|
||||||
|
if (!path) return;
|
||||||
|
|
||||||
p = getenv(env);
|
p = getenv(env);
|
||||||
if (p) len = strlen(p);
|
p2 = path;
|
||||||
p2 = (char *)path;
|
len2 = strlen(p2);
|
||||||
if (p2) len2 = strlen(p2);
|
if (p)
|
||||||
if (p && p2)
|
|
||||||
{
|
{
|
||||||
|
len = strlen(p);
|
||||||
// path already there at the start. dont prepend. :)
|
// path already there at the start. dont prepend. :)
|
||||||
if ((!strcmp(p, p2)) ||
|
if ((!strcmp(p, p2)) ||
|
||||||
((len > len2) &&
|
((len > len2) &&
|
||||||
|
@ -219,12 +222,12 @@ _env_path_prepend(const char *env, const char *path)
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
s[0] = 0;
|
s[0] = 0;
|
||||||
if (p2)
|
strcat(s, p2);
|
||||||
|
if (p)
|
||||||
{
|
{
|
||||||
strcat(s, p2);
|
|
||||||
strcat(s, ":");
|
strcat(s, ":");
|
||||||
|
strcat(s, p);
|
||||||
}
|
}
|
||||||
if (p) strcat(s, p);
|
|
||||||
env_set(env, s);
|
env_set(env, s);
|
||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
@ -233,16 +236,18 @@ _env_path_prepend(const char *env, const char *path)
|
||||||
static void
|
static void
|
||||||
_env_path_append(const char *env, const char *path)
|
_env_path_append(const char *env, const char *path)
|
||||||
{
|
{
|
||||||
char *p, *p2, *s;
|
char *p, *s;
|
||||||
|
const char *p2;
|
||||||
int len = 0, len2 = 0;
|
int len = 0, len2 = 0;
|
||||||
|
|
||||||
|
if (!path) return;
|
||||||
|
|
||||||
p = getenv(env);
|
p = getenv(env);
|
||||||
if (!p) return;
|
p2 = path;
|
||||||
len = strlen(p);
|
len2 = strlen(p2);
|
||||||
p2 = (char *)path;
|
if (p)
|
||||||
if (p2) len2 = strlen(p2);
|
|
||||||
if (p && p2)
|
|
||||||
{
|
{
|
||||||
|
len = strlen(p);
|
||||||
// path already there at the end. dont append. :)
|
// path already there at the end. dont append. :)
|
||||||
if ((!strcmp(p, p2)) ||
|
if ((!strcmp(p, p2)) ||
|
||||||
((len > len2) &&
|
((len > len2) &&
|
||||||
|
@ -254,12 +259,12 @@ _env_path_append(const char *env, const char *path)
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
s[0] = 0;
|
s[0] = 0;
|
||||||
if (p) strcat(s, p);
|
if (p)
|
||||||
if (p2)
|
|
||||||
{
|
{
|
||||||
|
strcat(s, p);
|
||||||
strcat(s, ":");
|
strcat(s, ":");
|
||||||
strcat(s, p2);
|
|
||||||
}
|
}
|
||||||
|
strcat(s, p2);
|
||||||
env_set(env, s);
|
env_set(env, s);
|
||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue