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

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


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

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

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

---

 programs/cmd/builtins.c                  |    9 ++++
 programs/cmd/tests/test_builtins.cmd.exp |   62 +++++++++++++++---------------
 2 files changed, 40 insertions(+), 31 deletions(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 95419a1..3505817 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -2356,6 +2356,7 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
     long int leftOperand_int, rightOperand_int;
     BOOL int_operands;
     static const WCHAR lssW[]  = {'l','s','s','\0'};
+    static const WCHAR leqW[]  = {'l','e','q','\0'};
 
     /* == is a special case, as it always compares strings */
     if (!lstrcmpiW(operator, eqeqW))
@@ -2376,6 +2377,14 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
                                    : lstrcmpW (leftOperand, rightOperand) < 0;
     }
 
+    if (!lstrcmpiW(operator, leqW)) {
+        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 b25eb9e..ec85db6 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -460,27 +460,27 @@ a LSS B at or_broken@NT4
 a LSS B insensitive
 A LSS b
 A LSS b insensitive
- at todo_wine@A LEQ A
- at todo_wine@A LEQ B
- at todo_wine@B LEQ B
- at todo_wine@AB LEQ B
- at todo_wine@AA LEQ B
- at todo_wine@A LEQ AB
- at todo_wine@AB LEQ AB
- at todo_wine@AA LEQ AB
- at todo_wine@A LEQ BA
- at todo_wine@B LEQ BA
- at todo_wine@AB LEQ BA
- at todo_wine@BA LEQ BA
- at todo_wine@AA LEQ BA
- at todo_wine@A LEQ AA
- at todo_wine@AA LEQ AA
- at todo_wine@b LEQ B at or_broken@NT4
- at todo_wine@b LEQ B insensitive
- at todo_wine@a LEQ B at or_broken@NT4
- at todo_wine@a LEQ B insensitive
- at todo_wine@A LEQ b
- at todo_wine@A LEQ b insensitive
+A LEQ A
+A LEQ B
+B LEQ B
+AB LEQ B
+AA LEQ B
+A LEQ AB
+AB LEQ AB
+AA LEQ AB
+A LEQ BA
+B LEQ BA
+AB LEQ BA
+BA LEQ BA
+AA LEQ BA
+A LEQ AA
+AA LEQ AA
+b LEQ B at or_broken@NT4
+b LEQ B insensitive
+a LEQ B at or_broken@NT4
+a LEQ B insensitive
+A LEQ b
+A LEQ b insensitive
 @todo_wine at A EQU A
 @todo_wine at B EQU B
 @todo_wine at AB EQU AB
@@ -546,16 +546,16 @@ also in negative form
 9 LSS 10
 0 LSS 9
 1 LSS 9
- at todo_wine@0 LEQ 0
- at todo_wine@0 LEQ 1
- at todo_wine@1 LEQ 1
- at todo_wine@0 LEQ 10
- at todo_wine@1 LEQ 10
- at todo_wine@10 LEQ 10
- at todo_wine@9 LEQ 10
- at todo_wine@0 LEQ 9
- at todo_wine@1 LEQ 9
- at todo_wine@9 LEQ 9
+0 LEQ 0
+0 LEQ 1
+1 LEQ 1
+0 LEQ 10
+1 LEQ 10
+10 LEQ 10
+9 LEQ 10
+0 LEQ 9
+1 LEQ 9
+9 LEQ 9
 @todo_wine at 0 EQU 0
 @todo_wine at 1 EQU 1
 @todo_wine at 10 EQU 10




More information about the wine-cvs mailing list