mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-01 11:43:37 +00:00
cmd: Fix if/else tab handling.
This commit is contained in:
parent
6d3fd3abcd
commit
eda33f22ff
|
@ -1250,7 +1250,7 @@ static void WCMD_part_execute(CMD_LIST **cmdList, const WCHAR *firstcmd,
|
|||
if (isIF) processThese = conditionTRUE;
|
||||
|
||||
while (*cmdList) {
|
||||
const WCHAR ifElse[] = {'e','l','s','e',' ','\0'};
|
||||
const WCHAR ifElse[] = {'e','l','s','e'};
|
||||
|
||||
/* execute all appropriate commands */
|
||||
curPosition = *cmdList;
|
||||
|
@ -1280,16 +1280,17 @@ static void WCMD_part_execute(CMD_LIST **cmdList, const WCHAR *firstcmd,
|
|||
|
||||
/* End of the command - does 'ELSE ' follow as the next command? */
|
||||
} else {
|
||||
if (isIF && CompareStringW(LOCALE_USER_DEFAULT,
|
||||
NORM_IGNORECASE | SORT_STRINGSORT,
|
||||
(*cmdList)->command, 5, ifElse, -1) == CSTR_EQUAL) {
|
||||
if (isIF
|
||||
&& WCMD_keyword_ws_found(ifElse, sizeof(ifElse)/sizeof(ifElse[0]),
|
||||
(*cmdList)->command)) {
|
||||
|
||||
/* Swap between if and else processing */
|
||||
processThese = !processThese;
|
||||
|
||||
/* Process the ELSE part */
|
||||
if (processThese) {
|
||||
WCHAR *cmd = ((*cmdList)->command) + strlenW(ifElse);
|
||||
const int keyw_len = sizeof(ifElse)/sizeof(ifElse[0]) + 1;
|
||||
WCHAR *cmd = ((*cmdList)->command) + keyw_len;
|
||||
|
||||
/* Skip leading whitespace between condition and the command */
|
||||
while (*cmd && (*cmd==' ' || *cmd=='\t')) cmd++;
|
||||
|
|
|
@ -391,6 +391,13 @@ if /i foo==FOO echo if /i seems to work
|
|||
if /i not foo==FOO echo if /i seems to be broken
|
||||
if /I foo==FOO echo if /I seems to work
|
||||
if /I not foo==FOO echo if /I seems to be broken
|
||||
if@tab@1==1 echo doom
|
||||
if @tab@1==1 echo doom
|
||||
if 1==1 (echo doom) else@tab@echo quake
|
||||
if@tab@not @tab@1==@tab@0 @tab@echo lol
|
||||
if 1==0@tab@(echo doom) else echo quake
|
||||
if 1==0 (echo doom)@tab@else echo quake
|
||||
if 1==0 (echo doom) else@tab@echo quake
|
||||
|
||||
echo -----------Testing for -----------
|
||||
echo ...plain FOR
|
||||
|
|
|
@ -271,6 +271,13 @@ Testing case sensitivity with and without /i option
|
|||
if seems to default to case sensitivity
|
||||
if /i seems to work
|
||||
if /I seems to work
|
||||
doom
|
||||
doom
|
||||
doom
|
||||
lol
|
||||
quake
|
||||
quake
|
||||
quake
|
||||
-----------Testing for -----------
|
||||
...plain FOR
|
||||
A
|
||||
|
|
|
@ -1755,8 +1755,8 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
|
|||
static WCHAR *extraSpace = NULL; /* Deliberately never freed */
|
||||
const WCHAR remCmd[] = {'r','e','m'};
|
||||
const WCHAR forCmd[] = {'f','o','r'};
|
||||
const WCHAR ifCmd[] = {'i','f',' ','\0'};
|
||||
const WCHAR ifElse[] = {'e','l','s','e',' ','\0'};
|
||||
const WCHAR ifCmd[] = {'i','f'};
|
||||
const WCHAR ifElse[] = {'e','l','s','e'};
|
||||
BOOL inRem = FALSE;
|
||||
BOOL inFor = FALSE;
|
||||
BOOL inIn = FALSE;
|
||||
|
@ -1847,24 +1847,23 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
|
|||
} else if (WCMD_keyword_ws_found(forCmd, sizeof(forCmd)/sizeof(forCmd[0]), curPos)) {
|
||||
inFor = TRUE;
|
||||
|
||||
/* If command starts with 'if' or 'else', handle ('s mid line. We should ensure this
|
||||
/* If command starts with 'if ' or 'else ', handle ('s mid line. We should ensure this
|
||||
is only true in the command portion of the IF statement, but this
|
||||
should suffice for now
|
||||
FIXME: Silly syntax like "if 1(==1( (
|
||||
echo they equal
|
||||
)" will be parsed wrong */
|
||||
} else if (CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
|
||||
curPos, 3, ifCmd, -1) == CSTR_EQUAL) {
|
||||
} else if (WCMD_keyword_ws_found(ifCmd, sizeof(ifCmd)/sizeof(ifCmd[0]), curPos)) {
|
||||
inIf = TRUE;
|
||||
|
||||
} else if (CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
|
||||
curPos, 5, ifElse, -1) == CSTR_EQUAL) {
|
||||
} else if (WCMD_keyword_ws_found(ifElse, sizeof(ifElse)/sizeof(ifElse[0]), curPos)) {
|
||||
const int keyw_len = sizeof(ifElse)/sizeof(ifElse[0]) + 1;
|
||||
inElse = TRUE;
|
||||
lastWasElse = TRUE;
|
||||
onlyWhiteSpace = TRUE;
|
||||
memcpy(&curCopyTo[*curLen], curPos, 5*sizeof(WCHAR));
|
||||
(*curLen)+=5;
|
||||
curPos+=5;
|
||||
memcpy(&curCopyTo[*curLen], curPos, keyw_len*sizeof(WCHAR));
|
||||
(*curLen)+=keyw_len;
|
||||
curPos+=keyw_len;
|
||||
continue;
|
||||
|
||||
/* In a for loop, the DO command will follow a close bracket followed by
|
||||
|
|
Loading…
Reference in a new issue