[PATCH] CMD: Only search for supplied command as-is if it includes
an extension
Jason Edmeades
us at edmeades.me.uk
Sat Mar 31 15:57:06 CDT 2007
Files with no extensions cannot be run as-is. This enables a directory
with 'fred' and 'fred.bat' to correctly run fred.bat if just fred is
executed
Note: Patch also removes 2 whitespaces from the file
---
programs/cmd/wcmdmain.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index b760223..ecdc476 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -34,7 +34,7 @@ const char * const inbuilt[] = {"ATTRIB", "CALL", "CD", "CHDIR", "CLS", "COPY",
"DATE", "DEL", "DIR", "ECHO", "ERASE", "FOR", "GOTO",
"HELP", "IF", "LABEL", "MD", "MKDIR", "MOVE", "PATH", "PAUSE",
"PROMPT", "REM", "REN", "RENAME", "RD", "RMDIR", "SET", "SHIFT",
- "TIME", "TITLE", "TYPE", "VERIFY", "VER", "VOL",
+ "TIME", "TITLE", "TYPE", "VERIFY", "VER", "VOL",
"ENDLOCAL", "SETLOCAL", "PUSHD", "POPD", "ASSOC", "COLOR", "FTYPE",
"EXIT" };
@@ -874,13 +874,15 @@ void WCMD_run_program (char *command, int called) {
strcpy(temp, thisDir);
GetFullPathName(temp, MAX_PATH, thisDir, NULL);
- /* 1. If extension supplied, see if that file exists */
strcat(thisDir, "\\");
strcat(thisDir, stemofsearch);
pos = &thisDir[strlen(thisDir)]; /* Pos = end of name */
- if (GetFileAttributes(thisDir) != INVALID_FILE_ATTRIBUTES) {
- found = TRUE;
+ /* 1. If extension supplied, see if that file exists */
+ if (extensionsupplied) {
+ if (GetFileAttributes(thisDir) != INVALID_FILE_ATTRIBUTES) {
+ found = TRUE;
+ }
}
/* 2. Any .* matches? */
@@ -1258,7 +1260,7 @@ void WCMD_output_asis (const char *message) {
if (paged_mode) {
do {
if ((ptr = strchr(message, '\n')) != NULL) ptr++;
- WriteFile (GetStdHandle(STD_OUTPUT_HANDLE), message,
+ WriteFile (GetStdHandle(STD_OUTPUT_HANDLE), message,
(ptr) ? ptr - message : lstrlen(message), &count, NULL);
if (ptr) {
if (++line_count >= max_height - 1) {
--
1.5.0
More information about the wine-patches
mailing list