Commit in reactos/subsys/system/cmd on MAIN
where.c+25-81.5 -> 1.6
- Fixed the compilation as unicode.    
- Search only for the file name directly if the name contains a known extension.  
- Don't add an extension if the file name contains a known extension.

reactos/subsys/system/cmd
where.c 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- where.c	15 Aug 2004 22:15:23 -0000	1.5
+++ where.c	22 Aug 2004 20:55:15 -0000	1.6
@@ -215,16 +215,11 @@
 	static TCHAR pszDefaultPathExt[] = _T(".COM;.EXE;.BAT;.CMD");
 	LPTSTR pszBuffer = NULL;
 	LPTSTR pCh;
+	LPTSTR pExt;
 	DWORD  dwBuffer;
 #ifdef _DEBUG
 	DebugPrintf (_T("SearchForExecutable: \'%s\'\n"), pFileName);
 #endif
-	/* check the filename directly */
-	if (SearchForExecutableSingle(pFileName, pFullName, NULL))
-	{
-		return TRUE;
-	}
-
 	/* load environment varable PATHEXT */
 	pszBuffer = (LPTSTR)malloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
 	dwBuffer = GetEnvironmentVariable (_T("PATHEXT"), pszBuffer, ENV_BUFFER_SIZE);
@@ -242,7 +237,29 @@
 	DebugPrintf (_T("SearchForExecutable(): Loaded PATHEXT: %s\n"), pszBuffer);
 #endif
 
-	pCh = _tcstok(pszBuffer, ";");
+    	pExt = _tcsrchr(pFileName, _T('.'));
+	if (pExt != NULL)
+	{
+	   	LPTSTR pszBuffer2;
+       		pszBuffer2 = _tcsdup(pszBuffer);
+	   	if (pszBuffer2)
+	   	{
+	      		pCh = _tcstok(pszBuffer2, _T(";"));
+	      		while (pCh)
+		  	{
+             			if (0 == _tcsicmp(pCh, pExt))
+			 	{
+					free(pszBuffer);
+					free(pszBuffer2);
+			    		return SearchForExecutableSingle(pFileName, pFullName, NULL);
+			 	}
+		     		pCh = _tcstok(NULL, _T(";"));
+		  	}
+		  	free(pszBuffer2);
+	   	}
+	}
+
+    	pCh = _tcstok(pszBuffer, _T(";"));
 	while (pCh)
 	{
 		if (SearchForExecutableSingle(pFileName, pFullName, pCh))
@@ -250,7 +267,7 @@
 			free(pszBuffer);
 			return TRUE;
 		}
-		pCh = _tcstok(NULL, ";");
+		pCh = _tcstok(NULL, _T(";"));
 	}
 
 	free(pszBuffer);
CVSspam 0.2.8