cygcheck .exe magic

Eric Blake ebb9@byu.net
Tue Jul 19 20:36:00 GMT 2005


Christopher Faylor <cgf-no-personal-reply-please <at> cygwin.com> writes:

> 
> Are you sure this is right?  cygcheck.exe isn't a cygwin program so I'd wonder
> about the use of the inodes returned from windows stat() call.
> 

You have a point; revised patch attached.  The original worked for me in 
testing, but only because I was short-circuiting when the first stat failed, 
and appending the .exe happened to be the right thing to do.  Since this is not 
a cygwin app, there is no .exe magic in stat() to counteract, and all we really 
need to do is see if appending the suffix makes stat succeed.


2005-07-19  Eric Blake  <ebb9 <at> byu.net>

	* cygcheck.cc (find_on_path): Perform .exe magic on non-PATH search.

Index: winsup/utils/cygcheck.cc
===================================================================
RCS file: /cvs/src/src/winsup/utils/cygcheck.cc,v
retrieving revision 1.75
diff -p -r1.75 cygcheck.cc
*** winsup/utils/cygcheck.cc    5 Jul 2005 21:41:37 -0000       1.75
--- winsup/utils/cygcheck.cc    19 Jul 2005 19:24:27 -0000
***************
*** 12,17 ****
--- 12,18 ----
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
+ #include <sys/stat.h>
  #include <sys/time.h>
  #include <ctype.h>
  #include <io.h>
*************** find_on_path (char *file, char *default_
*** 218,224 ****
      }
  
    if (strchr (file, ':') || strchr (file, '\\') || strchr (file, '/'))
!     return cygpath (file, NULL);
  
    if (strchr (file, '.'))
      default_extension = (char *) "";
--- 219,235 ----
      }
  
    if (strchr (file, ':') || strchr (file, '\\') || strchr (file, '/'))
!     {
!       struct stat stshort, stlong;
!       char *shortname = cygpath (file, NULL);
!       strcat (strcpy (tmp, shortname), default_extension);
!       /* Check if extension makes a difference.  */
!       if (stat (shortname, &stshort) && ! stat (tmp, &stlong))
! 	strcpy (rv, tmp);
!       else
! 	strcpy (rv, shortname);
!       return rv;
!     }
  
    if (strchr (file, '.'))
      default_extension = (char *) "";





More information about the Cygwin-patches mailing list