Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2000-07-26 22:51:14 +0400
committerCorinna Vinschen <corinna@vinschen.de>2000-07-26 22:51:14 +0400
commit0d4c5950ff6bf63e4567aec1413015417017a4a6 (patch)
treeae0652e703909b431d095d09fabb3a33f7005f0c
parentf489e86b8f70856412603fabbceba3cc8039500c (diff)
* 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.
-rw-r--r--winsup/cygwin/ChangeLog9
-rw-r--r--winsup/cygwin/environ.cc46
2 files changed, 37 insertions, 18 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 99afaf997..20f14e7a0 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -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>
* syscalls.cc (stat_worker): Make stat return correct st_blocks for
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index ccf61515a..03ea6347c 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -121,6 +121,7 @@ posify (int already_posix, char **here, const char *value)
debug_printf ("env var converted to %s", outenv);
*here = outenv;
+ free (src);
}
}
@@ -180,13 +181,6 @@ _addenv (const char *name, const char *value, int overwrite)
int offset;
char *p;
- int res;
- if ((res = check_null_empty_path (name)))
- {
- set_errno (res);
- return -1;
- }
-
unsigned int valuelen = strlen (value);
if ((p = my_findenv (name, &offset)))
{ /* Already exists. */
@@ -259,6 +253,14 @@ _addenv (const char *name, const char *value, int overwrite)
extern "C" int
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, '=');
if (eq)
return _addenv (str, eq + 1, -1);
@@ -278,8 +280,15 @@ extern "C" int
setenv (const char *name, const char *value, int overwrite)
{
int res;
- if ((res = check_null_empty_path (value)))
+ if ((res = check_null_empty_path (value)) == EFAULT)
+ {
+ set_errno (res);
+ return -1;
+ }
+ if ((res = check_null_empty_path (name)))
{
+ if (res == ENOENT)
+ return 0;
set_errno (res);
return -1;
}
@@ -493,7 +502,7 @@ environ_init (int already_posix)
char *rawenv = GetEnvironmentStrings ();
int envsize, i;
char *p;
- char **envp;
+ char *newp, **envp;
int sawTERM = 0;
static char cygterm[] = "TERM=cygwin";
@@ -516,21 +525,22 @@ environ_init (int already_posix)
eventually want to use them). */
for (i = 0, p = rawenv; *p != '\0'; p = strchr (p, '\0') + 1, i++)
{
+ newp = strdup (p);
if (i >= envsize)
envp = (char **) realloc (envp, (4 + (envsize += 100)) *
sizeof (char *));
- envp[i] = p;
- if (*p == '=')
- *p = '!';
+ envp[i] = newp;
+ if (*newp == '=')
+ *newp = '!';
char *eq;
- if ((eq = strchr (p, '=')) == NULL)
- eq = strchr (p, '\0');
+ if ((eq = strchr (newp, '=')) == NULL)
+ eq = strchr (newp, '\0');
if (!parent_alive)
- ucenv (p, eq);
- if (strncmp (p, "TERM=", 5) == 0)
+ ucenv (newp, eq);
+ if (strncmp (newp, "TERM=", 5) == 0)
sawTERM = 1;
- if (strncmp (p, "CYGWIN=", sizeof("CYGWIN=") - 1) == 0)
- parse_options (p + sizeof("CYGWIN=") - 1);
+ if (strncmp (newp, "CYGWIN=", sizeof("CYGWIN=") - 1) == 0)
+ parse_options (newp + sizeof("CYGWIN=") - 1);
if (*eq)
posify (already_posix, envp + i, *++eq ? eq : --eq);
debug_printf ("%s", envp[i]);