On 02/18/2010 03:33 PM, Alexandre Julliard wrote:
Paul Vriens<paul.vriens.w...@gmail.com> writes:
In any case the test environment needs to be comparing paths in a
case-insensitive way, it doesn't make sense to require exact case.
So the memcmp needs to change into some strcmp form?
Yes, though you probably need CompareString.
Could you think of a reason we need the extension checking in WCMD_batch() ?
I did some (small) tests and it seems like we could remove those checks
as WCMD_run_program() already seems to figure this out when it calls
WCMD_batch().
The attached patch gets rid of the checks and my tests still pass.
My test was "wine cmd /c test".
Where test.cmd:
==
CALL test1
==
test1.cmd:
==
goto gotoreg
exit
:gotoreg
CALL :callreg
CALL :callreg
CALL test2
exit
:callreg
CALL reg
==
And test2.bat:
==
echo %~dp0
==
--
Cheers,
Paul.
diff --git a/programs/cmd/batch.c b/programs/cmd/batch.c
index 28744d4..9b78d81 100644
--- a/programs/cmd/batch.c
+++ b/programs/cmd/batch.c
@@ -47,35 +47,17 @@ extern DWORD errorlevel;
void WCMD_batch (WCHAR *file, WCHAR *command, int called, WCHAR *startLabel,
HANDLE pgmHandle) {
-#define WCMD_BATCH_EXT_SIZE 5
-
HANDLE h = INVALID_HANDLE_VALUE;
- WCHAR string[MAXSTRING];
- static const WCHAR extension_batch[][WCMD_BATCH_EXT_SIZE] =
{{'.','b','a','t','\0'},
-
{'.','c','m','d','\0'}};
- static const WCHAR extension_exe[WCMD_BATCH_EXT_SIZE] =
{'.','e','x','e','\0'};
- unsigned int i;
BATCH_CONTEXT *prev_context;
+ WINE_TRACE("file : (%s), command : (%s), startLabel : (%s)\n",
wine_dbgstr_w(file), wine_dbgstr_w(command), wine_dbgstr_w(startLabel));
+
if (startLabel == NULL) {
- for(i=0; (i<sizeof(extension_batch)/(WCMD_BATCH_EXT_SIZE * sizeof(WCHAR)))
&&
- (h == INVALID_HANDLE_VALUE); i++) {
- strcpyW (string, file);
- CharLowerW (string);
- if (strstrW (string, extension_batch[i]) == NULL) strcatW (string,
extension_batch[i]);
- h = CreateFileW (string, GENERIC_READ, FILE_SHARE_READ,
- NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- }
+ h = CreateFileW (file, GENERIC_READ, FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) {
- strcpyW (string, file);
- CharLowerW (string);
- if (strstrW (string, extension_exe) == NULL) strcatW (string,
extension_exe);
- if (GetFileAttributesW (string) != INVALID_FILE_ATTRIBUTES) {
- WCMD_run_program (command, 0);
- } else {
- SetLastError (ERROR_FILE_NOT_FOUND);
- WCMD_print_error ();
- }
+ SetLastError (ERROR_FILE_NOT_FOUND);
+ WCMD_print_error ();
return;
}
} else {
@@ -91,7 +73,7 @@ void WCMD_batch (WCHAR *file, WCHAR *command, int called,
WCHAR *startLabel, HAN
prev_context = context;
context = LocalAlloc (LMEM_FIXED, sizeof (BATCH_CONTEXT));
context -> h = h;
- context->batchfileW = WCMD_strdupW(string);
+ context->batchfileW = WCMD_strdupW(file);
context -> command = command;
memset(context -> shift_count, 0x00, sizeof(context -> shift_count));
context -> prev_context = prev_context;