cmd: Correct handling of %~0 for batch call.
When a batch label is called, %0 and %~0 should be the label being called, and if you start adding modifiers to it (eg %~d0) then you get details of the batch program containing the label. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=44369 Signed-off-by: Jason Edmeades <us@edmeades.me.uk> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
bc9d68bcbe
commit
987fee3791
|
@ -460,10 +460,19 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
|
|||
}
|
||||
if (lastModifier == firstModifier) return; /* Invalid syntax */
|
||||
|
||||
/* Extract the parameter to play with */
|
||||
if (*lastModifier == '0') {
|
||||
/* So now, firstModifier points to beginning of modifiers, lastModifier
|
||||
points to the variable just after the modifiers. Process modifiers
|
||||
in a specific order, remembering there could be duplicates */
|
||||
modifierLen = lastModifier - firstModifier;
|
||||
finaloutput[0] = 0x00;
|
||||
|
||||
/* Extract the parameter to play with
|
||||
Special case param 0 - With %~0 you get the batch label which was called
|
||||
whereas if you start applying other modifiers to it, you get the filename
|
||||
the batch label is in */
|
||||
if (*lastModifier == '0' && modifierLen > 1) {
|
||||
strcpyW(outputparam, context->batchfileW);
|
||||
} else if ((*lastModifier >= '1' && *lastModifier <= '9')) {
|
||||
} else if ((*lastModifier >= '0' && *lastModifier <= '9')) {
|
||||
strcpyW(outputparam,
|
||||
WCMD_parameter (context -> command,
|
||||
*lastModifier-'0' + context -> shift_count[*lastModifier-'0'],
|
||||
|
@ -473,12 +482,6 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
|
|||
strcpyW(outputparam, forloopcontext.variable[foridx]);
|
||||
}
|
||||
|
||||
/* So now, firstModifier points to beginning of modifiers, lastModifier
|
||||
points to the variable just after the modifiers. Process modifiers
|
||||
in a specific order, remembering there could be duplicates */
|
||||
modifierLen = lastModifier - firstModifier;
|
||||
finaloutput[0] = 0x00;
|
||||
|
||||
/* 1. Handle '~' : Strip surrounding quotes */
|
||||
if (outputparam[0]=='"' &&
|
||||
memchrW(firstModifier, '~', modifierLen) != NULL) {
|
||||
|
@ -728,7 +731,7 @@ void WCMD_call (WCHAR *command) {
|
|||
li.QuadPart = 0;
|
||||
li.u.LowPart = SetFilePointer(context -> h, li.u.LowPart,
|
||||
&li.u.HighPart, FILE_CURRENT);
|
||||
WCMD_batch (param1, command, TRUE, gotoLabel, context->h);
|
||||
WCMD_batch (context->batchfileW, command, TRUE, gotoLabel, context->h);
|
||||
SetFilePointer(context -> h, li.u.LowPart,
|
||||
&li.u.HighPart, FILE_BEGIN);
|
||||
|
||||
|
|
|
@ -687,6 +687,15 @@ echo '%~xs1'
|
|||
goto :eof
|
||||
:endEchoFuns
|
||||
|
||||
echo ------------ Testing parameter zero ------------
|
||||
call :func parm1 parm2
|
||||
goto :endParm0
|
||||
:func
|
||||
echo %~0 %~1
|
||||
echo [%0] [%~d0] [%~p0] [%~n0] [%~x0] [%~s0]
|
||||
goto :EOF
|
||||
:endParm0
|
||||
|
||||
echo ------------ Testing variable delayed expansion ------------
|
||||
rem NT4 doesn't support this
|
||||
echo --- default mode (load-time expansion)
|
||||
|
|
|
@ -578,6 +578,9 @@ N
|
|||
@drive@
|
||||
''
|
||||
'.eh'@or_broken@''
|
||||
------------ Testing parameter zero ------------
|
||||
:func parm1
|
||||
[:func] [@drive@] [@path@] [test] [.cmd] [@drive@@shortpath@test.cmd]
|
||||
------------ Testing variable delayed expansion ------------
|
||||
--- default mode (load-time expansion)
|
||||
foo
|
||||
|
|
Loading…
Reference in New Issue