* src/NSFileManager.m ([NSFileManager -isExecutableFileAtPath:]):
Add check of all extensions in env var PATHEXT over windows for executable files

--- NSFileManager-orig.m	2010-09-21 18:41:35 -0300
+++ NSFileManager.m	2010-09-21 23:39:13 -0300
@@ -1580,7 +1580,7 @@
  */
 - (BOOL) isExecutableFileAtPath: (NSString*)path
 {
-  const _CHAR* lpath = [self fileSystemRepresentationWithPath: path];
+  const _CHAR *lpath = [self fileSystemRepresentationWithPath: path];
 
   if (lpath == 0 || *lpath == _NUL)
     {
@@ -1594,21 +1594,44 @@
       res = GetFileAttributesW(lpath);
 
       if (res == WIN32ERR)
-	{
-	  return NO;
-	}
-	// TODO: Actually should check all extensions in env var PATHEXT
-      if ([[[path pathExtension] lowercaseString] isEqualToString: @"exe"])
-	{
-	  return YES;
-	}
+        {
+          return NO;
+        }
+
       /* FIXME: On unix, directory accessible == executable, so we simulate that
       here for Windows. Is there a better check for directory access? */
+      /* If is a directory, exit now */
       if (res & FILE_ATTRIBUTE_DIRECTORY)
-	{
-	  return YES;
-	}
-      return NO;
+        {
+          return YES;
+        }
+        
+
+      // Check for extensions in PATHEXT evn var.
+      CREATE_AUTORELEASE_POOL(pool);
+      NSString *environmentVariables = [NSString stringWithUTF8String: getenv("PATHEXT")];
+      NSString *fileExtension = [path pathExtension];
+      NSRange found = [environmentVariables rangeOfString: fileExtension
+                                                  options: NSCaseInsensitiveSearch];
+      NSUInteger length = [environmentVariables length];
+
+      /*
+       * If extension is found but the next character is not the env path separator,
+       * we continue to look because this is not the extension sought.
+       */
+      while(found.location != NSNotFound &&
+            [environmentVariables characterAtIndex: (found.location + found.length)] != ';')
+        {
+          found.location++;
+          found.length =  length - found.location;
+          found = [environmentVariables rangeOfString: fileExtension 
+                                              options: NSCaseInsensitiveSearch
+                                                range: found];
+        }
+
+      RELEASE(pool);
+
+      return found.location != NSNotFound;
     }
 #else
     {
