cmd: Make 'if errorlevel' only recognize integer values.

oldstable
Frédéric Delanoy 2011-10-26 16:57:52 +02:00 committed by Alexandre Julliard
parent 171183c77b
commit 45c1dff552
3 changed files with 16 additions and 1 deletions

View File

@ -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)) {

View File

@ -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

View File

@ -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