Commit dd139544 authored by Frédéric Delanoy's avatar Frédéric Delanoy Committed by Alexandre Julliard

cmd: Move common error reporting code in WCMD_if.

parent cee1652e
...@@ -2346,9 +2346,8 @@ void WCMD_popd (void) { ...@@ -2346,9 +2346,8 @@ void WCMD_popd (void) {
* *
* FIXME: Much more syntax checking needed! * FIXME: Much more syntax checking needed!
*/ */
void WCMD_if (WCHAR *p, CMD_LIST **cmdList)
void WCMD_if (WCHAR *p, CMD_LIST **cmdList) { {
int negate; /* Negate condition */ int negate; /* Negate condition */
int test; /* Condition evaluation result */ int test; /* Condition evaluation result */
WCHAR condition[MAX_PATH], *command, *s; WCHAR condition[MAX_PATH], *command, *s;
...@@ -2368,10 +2367,7 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) { ...@@ -2368,10 +2367,7 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) {
WCHAR *param = WCMD_parameter(p, 1+negate, NULL, FALSE, FALSE); WCHAR *param = WCMD_parameter(p, 1+negate, NULL, FALSE, FALSE);
WCHAR *endptr; WCHAR *endptr;
long int param_int = strtolW(param, &endptr, 10); long int param_int = strtolW(param, &endptr, 10);
if (*endptr) { if (*endptr) goto syntax_err;
WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
return;
}
test = ((long int)errorlevel >= param_int); test = ((long int)errorlevel >= param_int);
WCMD_parameter(p, 2+negate, &command, FALSE, FALSE); WCMD_parameter(p, 2+negate, &command, FALSE, FALSE);
} }
...@@ -2401,14 +2397,15 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) { ...@@ -2401,14 +2397,15 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) {
rightPart, rightPartLen) == CSTR_EQUAL); rightPart, rightPartLen) == CSTR_EQUAL);
WCMD_parameter(s, 1, &command, FALSE, FALSE); WCMD_parameter(s, 1, &command, FALSE, FALSE);
} }
else { else goto syntax_err;
WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
return;
}
/* Process rest of IF statement which is on the same line /* Process rest of IF statement which is on the same line
Note: This may process all or some of the cmdList (eg a GOTO) */ Note: This may process all or some of the cmdList (eg a GOTO) */
WCMD_part_execute(cmdList, command, NULL, NULL, TRUE, (test != negate)); WCMD_part_execute(cmdList, command, NULL, NULL, TRUE, (test != negate));
return;
syntax_err:
WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
} }
/**************************************************************************** /****************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment