* environ.cc (posify): Revert previous patch.
(_addenv): Remove check_null_empty_path from here. (putenv): Call check_nullempty_path. (setenv): Call check_nullempty_path for name as well here. Don't report an error if value is empty string. (environ_init): Revert usage of newp.
This commit is contained in:
parent
f489e86b8f
commit
0d4c5950ff
|
@ -1,3 +1,12 @@
|
||||||
|
Wed Jul 26 20:44:00 2000 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* environ.cc (posify): Revert previous patch.
|
||||||
|
(_addenv): Remove check_null_empty_path from here.
|
||||||
|
(putenv): Call check_nullempty_path.
|
||||||
|
(setenv): Call check_nullempty_path for name as well here.
|
||||||
|
Don't report an error if value is empty string.
|
||||||
|
(environ_init): Revert usage of newp.
|
||||||
|
|
||||||
Wed Jul 26 14:32:38 2000 Egor Duda <deo@logos-m.ru>
|
Wed Jul 26 14:32:38 2000 Egor Duda <deo@logos-m.ru>
|
||||||
|
|
||||||
* syscalls.cc (stat_worker): Make stat return correct st_blocks for
|
* syscalls.cc (stat_worker): Make stat return correct st_blocks for
|
||||||
|
|
|
@ -121,6 +121,7 @@ posify (int already_posix, char **here, const char *value)
|
||||||
|
|
||||||
debug_printf ("env var converted to %s", outenv);
|
debug_printf ("env var converted to %s", outenv);
|
||||||
*here = outenv;
|
*here = outenv;
|
||||||
|
free (src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,13 +181,6 @@ _addenv (const char *name, const char *value, int overwrite)
|
||||||
int offset;
|
int offset;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
int res;
|
|
||||||
if ((res = check_null_empty_path (name)))
|
|
||||||
{
|
|
||||||
set_errno (res);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int valuelen = strlen (value);
|
unsigned int valuelen = strlen (value);
|
||||||
if ((p = my_findenv (name, &offset)))
|
if ((p = my_findenv (name, &offset)))
|
||||||
{ /* Already exists. */
|
{ /* Already exists. */
|
||||||
|
@ -259,6 +253,14 @@ _addenv (const char *name, const char *value, int overwrite)
|
||||||
extern "C" int
|
extern "C" int
|
||||||
putenv (const char *str)
|
putenv (const char *str)
|
||||||
{
|
{
|
||||||
|
int res;
|
||||||
|
if ((res = check_null_empty_path (str)))
|
||||||
|
{
|
||||||
|
if (res == ENOENT)
|
||||||
|
return 0;
|
||||||
|
set_errno (res);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
char *eq = strchr (str, '=');
|
char *eq = strchr (str, '=');
|
||||||
if (eq)
|
if (eq)
|
||||||
return _addenv (str, eq + 1, -1);
|
return _addenv (str, eq + 1, -1);
|
||||||
|
@ -278,11 +280,18 @@ extern "C" int
|
||||||
setenv (const char *name, const char *value, int overwrite)
|
setenv (const char *name, const char *value, int overwrite)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
if ((res = check_null_empty_path (value)))
|
if ((res = check_null_empty_path (value)) == EFAULT)
|
||||||
{
|
{
|
||||||
set_errno (res);
|
set_errno (res);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if ((res = check_null_empty_path (name)))
|
||||||
|
{
|
||||||
|
if (res == ENOENT)
|
||||||
|
return 0;
|
||||||
|
set_errno (res);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (*value == '=')
|
if (*value == '=')
|
||||||
value++;
|
value++;
|
||||||
return _addenv (name, value, !!overwrite);
|
return _addenv (name, value, !!overwrite);
|
||||||
|
@ -493,7 +502,7 @@ environ_init (int already_posix)
|
||||||
char *rawenv = GetEnvironmentStrings ();
|
char *rawenv = GetEnvironmentStrings ();
|
||||||
int envsize, i;
|
int envsize, i;
|
||||||
char *p;
|
char *p;
|
||||||
char **envp;
|
char *newp, **envp;
|
||||||
int sawTERM = 0;
|
int sawTERM = 0;
|
||||||
static char cygterm[] = "TERM=cygwin";
|
static char cygterm[] = "TERM=cygwin";
|
||||||
|
|
||||||
|
@ -516,21 +525,22 @@ environ_init (int already_posix)
|
||||||
eventually want to use them). */
|
eventually want to use them). */
|
||||||
for (i = 0, p = rawenv; *p != '\0'; p = strchr (p, '\0') + 1, i++)
|
for (i = 0, p = rawenv; *p != '\0'; p = strchr (p, '\0') + 1, i++)
|
||||||
{
|
{
|
||||||
|
newp = strdup (p);
|
||||||
if (i >= envsize)
|
if (i >= envsize)
|
||||||
envp = (char **) realloc (envp, (4 + (envsize += 100)) *
|
envp = (char **) realloc (envp, (4 + (envsize += 100)) *
|
||||||
sizeof (char *));
|
sizeof (char *));
|
||||||
envp[i] = p;
|
envp[i] = newp;
|
||||||
if (*p == '=')
|
if (*newp == '=')
|
||||||
*p = '!';
|
*newp = '!';
|
||||||
char *eq;
|
char *eq;
|
||||||
if ((eq = strchr (p, '=')) == NULL)
|
if ((eq = strchr (newp, '=')) == NULL)
|
||||||
eq = strchr (p, '\0');
|
eq = strchr (newp, '\0');
|
||||||
if (!parent_alive)
|
if (!parent_alive)
|
||||||
ucenv (p, eq);
|
ucenv (newp, eq);
|
||||||
if (strncmp (p, "TERM=", 5) == 0)
|
if (strncmp (newp, "TERM=", 5) == 0)
|
||||||
sawTERM = 1;
|
sawTERM = 1;
|
||||||
if (strncmp (p, "CYGWIN=", sizeof("CYGWIN=") - 1) == 0)
|
if (strncmp (newp, "CYGWIN=", sizeof("CYGWIN=") - 1) == 0)
|
||||||
parse_options (p + sizeof("CYGWIN=") - 1);
|
parse_options (newp + sizeof("CYGWIN=") - 1);
|
||||||
if (*eq)
|
if (*eq)
|
||||||
posify (already_posix, envp + i, *++eq ? eq : --eq);
|
posify (already_posix, envp + i, *++eq ? eq : --eq);
|
||||||
debug_printf ("%s", envp[i]);
|
debug_printf ("%s", envp[i]);
|
||||||
|
|
Loading…
Reference in New Issue