* 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.
This commit is contained in:
		| @@ -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> | 2005-05-16  Christopher Faylor  <cgf@timesys.com> | ||||||
|  |  | ||||||
| 	* cygcheck.cc (cygwin_internal): Define as a "C" function. | 	* cygcheck.cc (cygwin_internal): Define as a "C" function. | ||||||
|   | |||||||
| @@ -977,19 +977,24 @@ dump_sysinfo () | |||||||
|  |  | ||||||
|   printf ("Path:"); |   printf ("Path:"); | ||||||
|   char *s = getenv ("PATH"), *e; |   char *s = getenv ("PATH"), *e; | ||||||
|   char sep = strchr (s, ';') ? ';' : ':'; |   if (!s) | ||||||
|   int count_path_items = 0; |     puts (""); | ||||||
|   while (1) |   else | ||||||
|     { |     { | ||||||
|       for (e = s; *e && *e != sep; e++); |       char sep = strchr (s, ';') ? ';' : ':'; | ||||||
|       if (e-s) |       int count_path_items = 0; | ||||||
| 	printf ("\t%.*s\n", e - s, s); |       while (1) | ||||||
|       else | 	{ | ||||||
| 	puts ("\t."); | 	  for (e = s; *e && *e != sep; e++); | ||||||
|       count_path_items++; | 	  if (e-s) | ||||||
|       if (!*e) | 	    printf ("\t%.*s\n", e - s, s); | ||||||
| 	break; | 	  else | ||||||
|       s = e + 1; | 	    puts ("\t."); | ||||||
|  | 	  count_path_items++; | ||||||
|  | 	  if (!*e) | ||||||
|  | 	    break; | ||||||
|  | 	  s = e + 1; | ||||||
|  | 	} | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   fflush (stdout); |   fflush (stdout); | ||||||
| @@ -1432,8 +1437,8 @@ Compiled on %s\n\ | |||||||
| void | void | ||||||
| nuke (char *ev) | nuke (char *ev) | ||||||
| { | { | ||||||
|   int n = 1 + strchr (*_environ, '=') - ev; |   int n = 1 + strchr (ev, '=') - ev; | ||||||
|   char *s = (char *) alloca (n); |   char *s = (char *) alloca (n + 1); | ||||||
|   memcpy (s, ev, n); |   memcpy (s, ev, n); | ||||||
|   s[n] = '\0'; |   s[n] = '\0'; | ||||||
|   putenv (s); |   putenv (s); | ||||||
| @@ -1461,22 +1466,24 @@ load_cygwin (int& argc, char **&argv) | |||||||
|   char **envp = (char **) cygwin_internal (CW_ENVP); |   char **envp = (char **) cygwin_internal (CW_ENVP); | ||||||
|   if (envp) |   if (envp) | ||||||
|     { |     { | ||||||
|  |       cygwin_internal (CW_DEBUG_SELF, "d:\\cygwin\\bin\\gdb.exe"); | ||||||
|       /* Store path and revert to this value, otherwise path gets overwritten |       /* Store path and revert to this value, otherwise path gets overwritten | ||||||
|          by the POSIXy Cygwin variation, which breaks cygcheck. |          by the POSIXy Cygwin variation, which breaks cygcheck. | ||||||
| 	 Another approach would be to use the Cygwin PATH and convert it to | 	 Another approach would be to use the Cygwin PATH and convert it to | ||||||
| 	 Win32 again. */ | 	 Win32 again. */ | ||||||
|       char *path = NULL; |       char *path = NULL; | ||||||
|       while (*_environ) |       char **env; | ||||||
|  |       while (*(env = _environ)) | ||||||
| 	{ | 	{ | ||||||
| 	  if (strncmp (*_environ, "PATH=", 5) == 0) | 	  if (strncmp (*env, "PATH=", 5) == 0) | ||||||
| 	    path = strdup (*_environ); | 	    path = strdup (*env); | ||||||
| 	  nuke (*_environ); | 	  nuke (*env); | ||||||
|         } |         } | ||||||
|       for (char **ev = envp; *ev; ev++) |       for (char **ev = envp; *ev; ev++) | ||||||
| 	if (strncmp (*ev, "PATH=", 5) != 0) | 	if (strncmp (*ev, "PATH=", 5) != 0) | ||||||
| 	 putenv (*ev); | 	 putenv (*ev); | ||||||
| 	else if (path) |       if (path) | ||||||
| 	  putenv (path); | 	putenv (path); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user