Module: wine
Branch: master
Commit: 3cda870469cc457766f677f51afe352285db437b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3cda870469cc457766f677f51…
Author: Thomas Faller <tfaller1(a)gmx.de>
Date: Wed Jun 24 20:10:04 2015 +0200
cmd: Fix invalid "else if" execution.
---
programs/cmd/builtins.c | 2 +-
programs/cmd/tests/test_builtins.cmd | 40 +++++++++++++++++++++++++++++++-
programs/cmd/tests/test_builtins.cmd.exp | 3 +++
3 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 30b8684..5309bc0 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -1561,7 +1561,7 @@ static void WCMD_part_execute(CMD_LIST **cmdList, const WCHAR *firstcmd,
(*cmdList)->command)) {
/* Swap between if and else processing */
- processThese = !processThese;
+ processThese = !executecmds;
/* Process the ELSE part */
if (processThese) {
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index 16fdd43..5351e9c 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -667,7 +667,45 @@ if /c==/c (
) else (
echo parameter detection seems to be broken
)
-
+SET elseIF=0
+if 1 == 1 (
+ SET /a elseIF=%elseIF%+1
+) else if 1 == 1 (
+ SET /a elseIF=%elseIF%+2
+) else (
+ SET /a elseIF=%elseIF%+2
+)
+if %elseIF% == 1 (
+ echo else if seems to work
+) else (
+ echo else if seems to be broken
+)
+SET elseIF=0
+if 1 == 2 (
+ SET /a elseIF=%elseIF%+2
+) else if 1 == 1 (
+ SET /a elseIF=%elseIF%+1
+) else (
+ SET /a elseIF=%elseIF%+2
+)
+if %elseIF% == 1 (
+ echo else if seems to work
+) else (
+ echo else if seems to be broken
+)
+SET elseIF=0
+if 1 == 2 (
+ SET /a elseIF=%elseIF%+2
+) else if 1 == 2 (
+ SET /a elseIF=%elseIF%+2
+) else (
+ SET /a elseIF=%elseIF%+1
+)
+if %elseIF% == 1 (
+ echo else if seems to work
+) else (
+ echo else if seems to be broken
+)
echo --- case sensitivity with and without /i option
if bar==BAR echo if does not default to case sensitivity
if not bar==BAR echo if seems to default to case sensitivity
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index 828a651..4dddc71 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -438,6 +438,9 @@ Passed: file size check on subdir\a.a [8]@or_broken@Skipping file size check on
if seems to work
else seems to work
if seems not to detect /c as parameter
+else if seems to work
+else if seems to work
+else if seems to work
--- case sensitivity with and without /i option
if seems to default to case sensitivity
if /i seems to work