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

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


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

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

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

---

 programs/cmd/builtins.c                  |    9 ++++
 programs/cmd/tests/test_builtins.cmd.exp |   64 +++++++++++++++---------------
 2 files changed, 41 insertions(+), 32 deletions(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 3a8dfba..e15c7c8 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -2358,6 +2358,7 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
     static const WCHAR lssW[]  = {'l','s','s','\0'};
     static const WCHAR leqW[]  = {'l','e','q','\0'};
     static const WCHAR equW[]  = {'e','q','u','\0'};
+    static const WCHAR neqW[]  = {'n','e','q','\0'};
 
     /* == is a special case, as it always compares strings */
     if (!lstrcmpiW(operator, eqeqW))
@@ -2394,6 +2395,14 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
                                    : lstrcmpW (leftOperand, rightOperand) == 0;
     }
 
+    if (!lstrcmpiW(operator, neqW)) {
+        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 009473e..9adc016 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -487,26 +487,26 @@ AB EQU AB
 BA EQU BA
 AA EQU AA
 A EQU a insensitive
- at todo_wine@B NEQ A
- at todo_wine@AB NEQ A
- at todo_wine@BA NEQ A
- at todo_wine@AA NEQ A
- at todo_wine@A NEQ B
- at todo_wine@AB NEQ B
- at todo_wine@BA NEQ B
- at todo_wine@AA NEQ B
- at todo_wine@A NEQ AB
- at todo_wine@B NEQ AB
- at todo_wine@BA NEQ AB
- at todo_wine@AA NEQ AB
- at todo_wine@A NEQ BA
- at todo_wine@B NEQ BA
- at todo_wine@AB NEQ BA
- at todo_wine@AA NEQ BA
- at todo_wine@A NEQ AA
- at todo_wine@B NEQ AA
- at todo_wine@AB NEQ AA
- at todo_wine@BA NEQ AA
+B NEQ A
+AB NEQ A
+BA NEQ A
+AA NEQ A
+A NEQ B
+AB NEQ B
+BA NEQ B
+AA NEQ B
+A NEQ AB
+B NEQ AB
+BA NEQ AB
+AA NEQ AB
+A NEQ BA
+B NEQ BA
+AB NEQ BA
+AA NEQ BA
+A NEQ AA
+B NEQ AA
+AB NEQ AA
+BA NEQ AA
 @todo_wine at A GEQ A
 @todo_wine at B GEQ A
 @todo_wine at AB GEQ A
@@ -564,18 +564,18 @@ octal ok
 hexa ok
 string/hexa compare ok
 string/hexa compare ok
- at todo_wine@1 NEQ 0
- at todo_wine@10 NEQ 0
- at todo_wine@9 NEQ 0
- at todo_wine@0 NEQ 1
- at todo_wine@10 NEQ 1
- at todo_wine@9 NEQ 1
- at todo_wine@0 NEQ 10
- at todo_wine@1 NEQ 10
- at todo_wine@9 NEQ 10
- at todo_wine@0 NEQ 9
- at todo_wine@1 NEQ 9
- at todo_wine@10 NEQ 9
+1 NEQ 0
+10 NEQ 0
+9 NEQ 0
+0 NEQ 1
+10 NEQ 1
+9 NEQ 1
+0 NEQ 10
+1 NEQ 10
+9 NEQ 10
+0 NEQ 9
+1 NEQ 9
+10 NEQ 9
 @todo_wine at 0 GEQ 0
 @todo_wine at 1 GEQ 0
 @todo_wine at 10 GEQ 0




More information about the wine-cvs mailing list