cmd: Make 'if errorlevel' only recognize integer values.
This commit is contained in:
parent
171183c77b
commit
45c1dff552
|
@ -1513,7 +1513,14 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) {
|
|||
WINE_TRACE("Condition: %s\n", wine_dbgstr_w(condition));
|
||||
|
||||
if (!lstrcmpiW (condition, errlvlW)) {
|
||||
test = (errorlevel >= atoiW(WCMD_parameter(p, 1+negate, NULL, NULL)));
|
||||
WCHAR *param = WCMD_parameter(p, 1+negate, NULL, NULL);
|
||||
WCHAR *endptr;
|
||||
long int param_int = strtolW(param, &endptr, 10);
|
||||
if (*endptr) {
|
||||
WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
|
||||
return;
|
||||
}
|
||||
test = ((long int)errorlevel >= param_int);
|
||||
WCMD_parameter(p, 2+negate, &command, NULL);
|
||||
}
|
||||
else if (!lstrcmpiW (condition, existW)) {
|
||||
|
|
|
@ -1485,10 +1485,16 @@ call :setError 1
|
|||
echo %ErrorLevel%
|
||||
if errorlevel 2 echo errorlevel too high, bad
|
||||
if errorlevel 1 echo errorlevel just right, good
|
||||
if errorlevel 01 echo errorlevel with leading zero just right, good
|
||||
if errorlevel -1 echo errorlevel with negative number OK
|
||||
if errorlevel 0x1 echo hexa should not be recognized!
|
||||
if errorlevel 1a echo invalid error level recognized!
|
||||
call :setError 0
|
||||
echo abc%ErrorLevel%def
|
||||
if errorlevel 1 echo errorlevel nonzero, bad
|
||||
if not errorlevel 1 echo errorlevel zero, good
|
||||
if not errorlevel 0x1 echo hexa should not be recognized!
|
||||
if not errorlevel 1a echo invalid error level recognized!
|
||||
rem Now verify that setting a real variable hides its magic variable
|
||||
set errorlevel=7
|
||||
echo %ErrorLevel% should be 7
|
||||
|
|
|
@ -792,6 +792,8 @@ localval
|
|||
9009
|
||||
1
|
||||
errorlevel just right, good
|
||||
errorlevel with leading zero just right, good
|
||||
errorlevel with negative number OK
|
||||
abc0def@or_broken@abc1def
|
||||
errorlevel zero, good@or_broken@errorlevel nonzero, bad
|
||||
7 should be 7
|
||||
|
|
Loading…
Reference in New Issue