=?UTF-8?Q?Fr=C3=A9d=C3=A9ric=20Delanoy=20?=: cmd: Add support for GTR comparison operator in if statements.
Alexandre Julliard
julliard at winehq.org
Fri Oct 26 11:36:21 CDT 2012
Module: wine
Branch: master
Commit: 90c6f57fa9d9c9caf1b469ae82ed13bccb9625ef
URL: http://source.winehq.org/git/wine.git/?a=commit;h=90c6f57fa9d9c9caf1b469ae82ed13bccb9625ef
Author: Frédéric Delanoy <frederic.delanoy at gmail.com>
Date: Thu Oct 25 23:48:07 2012 +0200
cmd: Add support for GTR comparison operator in if statements.
---
programs/cmd/builtins.c | 9 ++++++++
programs/cmd/tests/test_builtins.cmd.exp | 32 +++++++++++++++---------------
2 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 112d678..855040e 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -2360,6 +2360,7 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
static const WCHAR equW[] = {'e','q','u','\0'};
static const WCHAR neqW[] = {'n','e','q','\0'};
static const WCHAR geqW[] = {'g','e','q','\0'};
+ static const WCHAR gtrW[] = {'g','t','r','\0'};
/* == is a special case, as it always compares strings */
if (!lstrcmpiW(operator, eqeqW))
@@ -2412,6 +2413,14 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
: lstrcmpW (leftOperand, rightOperand) >= 0;
}
+ if (!lstrcmpiW(operator, gtrW)) {
+ 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 c451c70..aeaa14d 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -522,16 +522,16 @@ B GEQ AA
AB GEQ AA
BA GEQ AA
AA GEQ AA
- at todo_wine@B GTR A
- at todo_wine@AB GTR A
- at todo_wine@BA GTR A
- at todo_wine@AA GTR A
- at todo_wine@BA GTR B
- at todo_wine@B GTR AB
- at todo_wine@BA GTR AB
- at todo_wine@B GTR AA
- at todo_wine@AB GTR AA
- at todo_wine@BA GTR AA
+B GTR A
+AB GTR A
+BA GTR A
+AA GTR A
+BA GTR B
+B GTR AB
+BA GTR AB
+B GTR AA
+AB GTR AA
+BA GTR AA
------ for numbers
negative numbers handled
negative numbers handled
@@ -586,12 +586,12 @@ string/hexa compare ok
10 GEQ 10
10 GEQ 9
9 GEQ 9
- at todo_wine@1 GTR 0
- at todo_wine@10 GTR 0
- at todo_wine@9 GTR 0
- at todo_wine@10 GTR 1
- at todo_wine@9 GTR 1
- at todo_wine@10 GTR 9
+1 GTR 0
+10 GTR 0
+9 GTR 0
+10 GTR 1
+9 GTR 1
+10 GTR 9
------ for numbers and stringified numbers
strings and integers not equal
strings and integers not equal
More information about the wine-cvs
mailing list