cygcheck .exe magic

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


I was annoyed that "cygcheck bash" worked but "cygcheck /bin/bash" did not.

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

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

--
Eric Blake

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,237 ----
      }
  
    if (strchr (file, ':') || strchr (file, '\\') || strchr (file, '/'))
!     {
!       struct stat stshort, stlong;
!       char *shortname = cygpath (file, NULL);
!       strcat (strcpy (tmp, shortname), default_extension);
!       /* if short name doesn't exist, or if short name and extension name are
!          same file, append the extension */
!       if (stat (shortname, &stshort)
!           || (! stat (tmp, &stlong) && stshort.st_ino == stlong.st_ino))
!         strcpy (rv, tmp);
!       else
!         strcpy (rv, shortname);
!       return rv;
!     }
  
    if (strchr (file, '.'))
      default_extension = (char *) "";




More information about the Cygwin-patches mailing list