[patch] fix for cygcheck -s if run from /usr/bin

2005-03-24 Thread Brian Dessent

Currently, if you run cygcheck -s with the current directory as /usr/bin
you get every cyg*.dll found twice, once with .\ prefix and the second
time with \cygwin\bin\ prefix.  The user gets a spurious Multiple
Cygwin DLLs found warning even if there is only one present.

The following patch tries to correct this.  In init_paths(), the
paths[1] value is populated by GetCurrentDirectory() instead of just
..  This causes the existing duplicate checking code in add_path() to
reject a later attempt to add a directory from $PATH that is the same as
CWD.

However, this also means that if . is in $PATH it will no longer be
rejected by that same duplicate checking code, so init_paths() is also
modified to not add . since we already have the CWD added explicitly.

Finally, in dump_sysinfo() the loop is changed to check starting with
paths[1] instead of paths[0], since paths[0] is a special placeholder
value that is initialized to ..  paths[1] contains the CWD anyway so
there's no need to examine paths[0].

Brian

===

2005-03-24  Brian Dessent  [EMAIL PROTECTED]

* cygcheck.cc (init_paths): Use full path instead of . for the
current directory.  Do not add . if present in $PATH.
(dump_sysinfo): Skip placeholder first value of paths[].Index: cygcheck.cc
===
RCS file: /cvs/src/src/winsup/utils/cygcheck.cc,v
retrieving revision 1.64
diff -u -p -r1.64 cygcheck.cc
--- cygcheck.cc 18 Nov 2004 05:20:23 -  1.64
+++ cygcheck.cc 24 Mar 2005 09:41:40 -
@@ -158,7 +158,12 @@ init_paths ()
 {
   char tmp[4000], *sl;
   add_path ((char *) ., 1);  /* to be replaced later */
-  add_path ((char *) ., 1);  /* the current directory */
+  
+  if (GetCurrentDirectory (4000, tmp))
+add_path (tmp, strlen (tmp));
+  else
+display_error (init_paths: GetCurrentDirectory());  
+  
   if (GetSystemDirectory (tmp, 4000))
 add_path (tmp, strlen (tmp));
   else
@@ -180,7 +185,8 @@ init_paths ()
   while (1)
{
  for (e = b; *e  *e != ';'; e++);
- add_path (b, e - b);
+ if (strncmp(b, ., 1)  strncmp(b, .\\, 2))
+   add_path (b, e - b);
  if (!*e)
break;
  b = e + 1;
@@ -1237,7 +1243,7 @@ dump_sysinfo ()
   if (givehelp)
 printf (Looking for various Cygnus DLLs...  (-v gives version info)\n);
   int cygwin_dll_count = 0;
-  for (i = 0; i  num_paths; i++)
+  for (i = 1; i  num_paths; i++)
 {
   WIN32_FIND_DATA ffinfo;
   sprintf (tmp, %s/*.*, paths[i]);



Re: [patch] fix for cygcheck -s if run from /usr/bin

2005-03-24 Thread Corinna Vinschen
On Mar 24 01:53, Brian Dessent wrote:
   * cygcheck.cc (init_paths): Use full path instead of . for the
   current directory.  Do not add . if present in $PATH.
   (dump_sysinfo): Skip placeholder first value of paths[].

Looks good.  I've checked this in.


Thanks,
Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  mailto:cygwin@cygwin.com
Red Hat, Inc.