From 55fc91b9d62bec29deaba79e4adb4e85c35cc306 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Wed, 26 Apr 2000 05:13:32 +0000 Subject: * exceptions.cc (interruptible): Allocate slightly more space for directory name check. Windows 95 seems to null-terminate the directory otherwise. (interrupt_on_return): Issue a fatal error if we can't find the caller's stack. * spawn.cc (find_exec): Accept a path_conv argument rather than a buffer so that the caller can find things out about a translated path. (perhaps_suffix): Ditto. (spawn_guts): Allocate path_conv stuff here so that we can find out stuff about the translated path (this is work in progress). * environ.cc (environ_init): Accept an as-yet unused argument indicating whether we were invoked from a cygwin parent or not. (winenv): Ditto. (posify): Accept an argument indicating whether the path has already been translated. * dlfcn.cc (check_access): Provide a path_conv buffer to find_exec. * exec.cc (sexecvpe): Ditto. * path.cc (path_conv::check): Rename from path_conv::path_conv. (mount_item::getmntent): Recognize "Cygwin executable" bit. (symlink_info::check): Remove debugging statements. * path.h (class path_conv): Add iscygexec method. Rewrite constructor to call "check" method to allow multiple operations on a path_conv variable. * pinfo.cc (pinfo_init): Pass argument to environ_init. * shared.h: Bump PROC_MAGIC. * winsup.h: Reflect above changes to function arguments. * include/sys/mount.h: Add MOUNT_CYGWIN_EXEC type. --- winsup/cygwin/environ.cc | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'winsup/cygwin/environ.cc') diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index b09fe90..7b9c33a 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -94,7 +94,7 @@ getwinenv (const char *env, const char *in_posix) /* Convert windows path specs to POSIX, if appropriate. */ static void __stdcall -posify (char **here, const char *value) +posify (int already_posix, char **here, const char *value) { char *src = *here; win_env *conv; @@ -103,17 +103,22 @@ posify (char **here, const char *value) if (!(conv = getwinenv (src))) return; - /* Turn all the items from c:; into their - mounted equivalents - if there is one. */ + if (already_posix) + conv->add_cache (value, NULL); + else + { + /* Turn all the items from c:; into their + mounted equivalents - if there is one. */ - char *outenv = (char *) malloc (1 + len + conv->posix_len (value)); - memcpy (outenv, src, len); - conv->toposix (value, outenv + len); - conv->add_cache (outenv + len, value); + char *outenv = (char *) malloc (1 + len + conv->posix_len (value)); + memcpy (outenv, src, len); + conv->toposix (value, outenv + len); + conv->add_cache (outenv + len, value); - debug_printf ("env var converted to %s", outenv); - *here = outenv; - free (src); + debug_printf ("env var converted to %s", outenv); + *here = outenv; + free (src); + } } /* @@ -435,7 +440,7 @@ regopt (const char *name) * environment variable and set appropriate options from it. */ void -environ_init (void) +environ_init (int already_posix) { const char * const rawenv = GetEnvironmentStrings (); int envsize, i; @@ -479,7 +484,7 @@ environ_init (void) if (strncmp (newp, "CYGWIN=", sizeof("CYGWIN=") - 1) == 0) parse_options (newp + sizeof("CYGWIN=") - 1); if (*eq) - posify (envp + i, *++eq ? eq : --eq); + posify (already_posix, envp + i, *++eq ? eq : --eq); debug_printf ("%s", envp[i]); } @@ -509,7 +514,7 @@ env_sort (const void *a, const void *b) * prior to placing them in the string. */ char * __stdcall -winenv (const char * const *envp) +winenv (const char * const *envp, int keep_posix) { int len, n, tl; const char * const *srcp; @@ -520,12 +525,14 @@ winenv (const char * const *envp) const char *newenvp[n + 1]; + debug_printf ("envp %p, keep_posix %d", envp, keep_posix); + for (tl = 0, srcp = envp, dstp = newenvp; *srcp; srcp++, dstp++) { len = strcspn (*srcp, "=") + 1; win_env *conv; - if ((conv = getwinenv (*srcp, *srcp + len))) + if (!keep_posix && (conv = getwinenv (*srcp, *srcp + len))) *dstp = conv->native; else *dstp = *srcp; -- cgit v1.1