aboutsummaryrefslogtreecommitdiff
path: root/winsup/utils
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-05-20 16:38:42 +0000
committerChristopher Faylor <me@cgf.cx>2005-05-20 16:38:42 +0000
commitceb7fa1c4ac1c6f277502a83237337c2fb213312 (patch)
tree09f04628d3bc69c1583af12931874d81ca39eb27 /winsup/utils
parentfece73ae83dd6a5f76ad78273ce25fd08c163487 (diff)
downloadnewlib-ceb7fa1c4ac1c6f277502a83237337c2fb213312.zip
newlib-ceb7fa1c4ac1c6f277502a83237337c2fb213312.tar.gz
newlib-ceb7fa1c4ac1c6f277502a83237337c2fb213312.tar.bz2
* cygcheck.cc (dump_sysinfo): Don't attempt to use path if it is not set.
(nuke): Fix off by one error in allocation of environment variable. (load_cygwin): Always set PATH even if cygwin environment is empty.
Diffstat (limited to 'winsup/utils')
-rw-r--r--winsup/utils/ChangeLog7
-rw-r--r--winsup/utils/cygcheck.cc47
2 files changed, 34 insertions, 20 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog
index 826f959..a028b80 100644
--- a/winsup/utils/ChangeLog
+++ b/winsup/utils/ChangeLog
@@ -1,3 +1,10 @@
+2005-05-20 Christopher Faylor <cgf@timesys.com>
+
+ * cygcheck.cc (dump_sysinfo): Don't attempt to use path if it is not
+ set.
+ (nuke): Fix off by one error in allocation of environment variable.
+ (load_cygwin): Always set PATH even if cygwin environment is empty.
+
2005-05-16 Christopher Faylor <cgf@timesys.com>
* cygcheck.cc (cygwin_internal): Define as a "C" function.
diff --git a/winsup/utils/cygcheck.cc b/winsup/utils/cygcheck.cc
index 07d5823..00585c2 100644
--- a/winsup/utils/cygcheck.cc
+++ b/winsup/utils/cygcheck.cc
@@ -977,19 +977,24 @@ dump_sysinfo ()
printf ("Path:");
char *s = getenv ("PATH"), *e;
- char sep = strchr (s, ';') ? ';' : ':';
- int count_path_items = 0;
- while (1)
+ if (!s)
+ puts ("");
+ else
{
- for (e = s; *e && *e != sep; e++);
- if (e-s)
- printf ("\t%.*s\n", e - s, s);
- else
- puts ("\t.");
- count_path_items++;
- if (!*e)
- break;
- s = e + 1;
+ char sep = strchr (s, ';') ? ';' : ':';
+ int count_path_items = 0;
+ while (1)
+ {
+ for (e = s; *e && *e != sep; e++);
+ if (e-s)
+ printf ("\t%.*s\n", e - s, s);
+ else
+ puts ("\t.");
+ count_path_items++;
+ if (!*e)
+ break;
+ s = e + 1;
+ }
}
fflush (stdout);
@@ -1432,8 +1437,8 @@ Compiled on %s\n\
void
nuke (char *ev)
{
- int n = 1 + strchr (*_environ, '=') - ev;
- char *s = (char *) alloca (n);
+ int n = 1 + strchr (ev, '=') - ev;
+ char *s = (char *) alloca (n + 1);
memcpy (s, ev, n);
s[n] = '\0';
putenv (s);
@@ -1461,22 +1466,24 @@ load_cygwin (int& argc, char **&argv)
char **envp = (char **) cygwin_internal (CW_ENVP);
if (envp)
{
+ cygwin_internal (CW_DEBUG_SELF, "d:\\cygwin\\bin\\gdb.exe");
/* Store path and revert to this value, otherwise path gets overwritten
by the POSIXy Cygwin variation, which breaks cygcheck.
Another approach would be to use the Cygwin PATH and convert it to
Win32 again. */
char *path = NULL;
- while (*_environ)
+ char **env;
+ while (*(env = _environ))
{
- if (strncmp (*_environ, "PATH=", 5) == 0)
- path = strdup (*_environ);
- nuke (*_environ);
+ if (strncmp (*env, "PATH=", 5) == 0)
+ path = strdup (*env);
+ nuke (*env);
}
for (char **ev = envp; *ev; ev++)
if (strncmp (*ev, "PATH=", 5) != 0)
putenv (*ev);
- else if (path)
- putenv (path);
+ if (path)
+ putenv (path);
}
}