=?UTF-8?Q?Fr=C3=A9d=C3=A9ric=20Delanoy=20?=: cmd: Add support for EQU comparison operator in if statements.

Alexandre Julliard julliard at winehq.org
Fri Oct 26 11:36:21 CDT 2012


Module: wine
Branch: master
Commit: 14cd4151a93e0656b2caeae6e095b61cbb99bff1
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=14cd4151a93e0656b2caeae6e095b61cbb99bff1

Author: Frédéric Delanoy <frederic.delanoy at gmail.com>
Date:   Thu Oct 25 23:48:04 2012 +0200

cmd: Add support for EQU comparison operator in if statements.

---

 programs/cmd/builtins.c                  |    9 +++++++++
 programs/cmd/tests/test_builtins.cmd.exp |   28 ++++++++++++++--------------
 2 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 3505817..3a8dfba 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -2357,6 +2357,7 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
     BOOL int_operands;
     static const WCHAR lssW[]  = {'l','s','s','\0'};
     static const WCHAR leqW[]  = {'l','e','q','\0'};
+    static const WCHAR equW[]  = {'e','q','u','\0'};
 
     /* == is a special case, as it always compares strings */
     if (!lstrcmpiW(operator, eqeqW))
@@ -2385,6 +2386,14 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
                                    : lstrcmpW (leftOperand, rightOperand) <= 0;
     }
 
+    if (!lstrcmpiW(operator, equW)) {
+        if (int_operands)
+            return leftOperand_int == rightOperand_int;
+        else
+            return caseInsensitive ? lstrcmpiW(leftOperand, rightOperand) == 0
+                                   : lstrcmpW (leftOperand, rightOperand) == 0;
+    }
+
     return -1;
 }
 
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index ec85db6..009473e 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -481,12 +481,12 @@ a LEQ B at or_broken@NT4
 a LEQ B insensitive
 A LEQ b
 A LEQ b insensitive
- at todo_wine@A EQU A
- at todo_wine@B EQU B
- at todo_wine@AB EQU AB
- at todo_wine@BA EQU BA
- at todo_wine@AA EQU AA
- at todo_wine@A EQU a insensitive
+A EQU A
+B EQU B
+AB EQU AB
+BA EQU BA
+AA EQU AA
+A EQU a insensitive
 @todo_wine at B NEQ A
 @todo_wine at AB NEQ A
 @todo_wine at BA NEQ A
@@ -556,14 +556,14 @@ also in negative form
 0 LEQ 9
 1 LEQ 9
 9 LEQ 9
- at todo_wine@0 EQU 0
- at todo_wine@1 EQU 1
- at todo_wine@10 EQU 10
- at todo_wine@9 EQU 9
- at todo_wine@octal ok
- at todo_wine@hexa ok
- at todo_wine@string/hexa compare ok
- at todo_wine@string/hexa compare ok
+0 EQU 0
+1 EQU 1
+10 EQU 10
+9 EQU 9
+octal ok
+hexa ok
+string/hexa compare ok
+string/hexa compare ok
 @todo_wine at 1 NEQ 0
 @todo_wine at 10 NEQ 0
 @todo_wine at 9 NEQ 0




More information about the wine-cvs mailing list