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
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2006-04-21 21:21:41 +0400
committerCorinna Vinschen <corinna@vinschen.de>2006-04-21 21:21:41 +0400
commit33b0abd1c32ac1c49c31039a89ebf00480b64439 (patch)
tree5276794666c47365f3f7a4beed6ab8c5210bd558 /winsup
parent053fc4771a6d76d42bcb3027e25cd735ede656e8 (diff)
* environ.cc (getearly): New function.
(findenv_func): New function pointer, predefined to getearly. (getenv): Call findenv function over the findenv_func pointer. (environ_init): Change findenv_func pointer to my_findenv after Cygwin environment is initialized.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog9
-rw-r--r--winsup/cygwin/environ.cc39
2 files changed, 46 insertions, 2 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index c5e937d2b..d4efcd112 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,12 @@
+2006-04-21 Pierre Humblet <Pierre.Humblet@ieee.org>
+ Corinna Vinschen <corinna@vinschen.de>
+
+ * environ.cc (getearly): New function.
+ (findenv_func): New function pointer, predefined to getearly.
+ (getenv): Call findenv function over the findenv_func pointer.
+ (environ_init): Change findenv_func pointer to my_findenv after Cygwin
+ environment is initialized.
+
2006-04-21 Lars Munch <lars@segv.dk>
* include/asm/byteorder.h (__ntohl): Fix the missing uint32_t.
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 99f61e7d6..edefb8c40 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -224,6 +224,41 @@ my_findenv (const char *name, int *offset)
}
/*
+ * getearly --
+ * Primitive getenv before the environment is built.
+ */
+
+static char * __stdcall
+getearly (const char * name, int *offset __attribute__ ((unused)))
+{
+ int s = strlen (name);
+ char * rawenv;
+ char ** ptr;
+ child_info *get_cygwin_startup_info ();
+ child_info_spawn *ci = (child_info_spawn *) get_cygwin_startup_info ();
+
+ if (ci && (ptr = ci->moreinfo->envp))
+ {
+ for (; *ptr; ptr++)
+ if (strncasematch (name, *ptr, s)
+ && (*(*ptr + s) == '='))
+ return *ptr + s + 1;
+ }
+ else if ((rawenv = GetEnvironmentStrings ()))
+ {
+ while (*rawenv)
+ if (strncasematch (name, rawenv, s)
+ && (*(rawenv + s) == '='))
+ return rawenv + s + 1;
+ else
+ rawenv = strchr (rawenv, 0) + 1;
+ }
+ return NULL;
+}
+
+static char * (*findenv_func)(const char *, int *) = (char * (*)(const char *, int *)) getearly;
+
+/*
* getenv --
* Returns ptr to value associated with name, if any, else NULL.
*/
@@ -232,8 +267,7 @@ extern "C" char *
getenv (const char *name)
{
int offset;
-
- return my_findenv (name, &offset);
+ return findenv_func (name, &offset);
}
static int __stdcall
@@ -808,6 +842,7 @@ environ_init (char **envp, int envc)
FreeEnvironmentStrings (rawenv);
out:
+ findenv_func = (char * (*)(const char*, int*)) my_findenv;
__cygwin_environ = envp;
update_envptrs ();
if (envp_passed_in)