Module: wine Branch: master Commit: 14cd4151a93e0656b2caeae6e095b61cbb99bff1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=14cd4151a93e0656b2caeae6e0...
Author: Frédéric Delanoy frederic.delanoy@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@or_broken@NT4 a LEQ B insensitive A LEQ b A LEQ b insensitive -@todo_wine@A EQU A -@todo_wine@B EQU B -@todo_wine@AB EQU AB -@todo_wine@BA EQU BA -@todo_wine@AA EQU AA -@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@B NEQ A @todo_wine@AB NEQ A @todo_wine@BA NEQ A @@ -556,14 +556,14 @@ also in negative form 0 LEQ 9 1 LEQ 9 9 LEQ 9 -@todo_wine@0 EQU 0 -@todo_wine@1 EQU 1 -@todo_wine@10 EQU 10 -@todo_wine@9 EQU 9 -@todo_wine@octal ok -@todo_wine@hexa ok -@todo_wine@string/hexa compare ok -@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@1 NEQ 0 @todo_wine@10 NEQ 0 @todo_wine@9 NEQ 0