[3/7] cmd: Add support for EQU comparison operator in if statements
Frédéric Delanoy
frederic.delanoy at gmail.com
Thu Sep 1 06:02:21 CDT 2011
---
programs/cmd/builtins.c | 16 ++++++++++++++++
programs/cmd/tests/test_builtins.cmd | 12 ++++++++++++
programs/cmd/tests/test_builtins.cmd.exp | 9 +++++++++
3 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index edd99ea..f4cab69 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -1487,6 +1487,7 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) {
static const WCHAR eqeqW[] = {'=','=','\0'};
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 zeroW[] = {'0','\0'};
static const WCHAR parmI[] = {'/','I','\0'};
@@ -1555,6 +1556,21 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) {
}
WCMD_parameter (s, 1, &command);
}
+ else if ((s = StrStrIW (p, equW))) {
+ s += 3;
+ a = StrToIntW(condition);
+ b = StrToIntW(WCMD_parameter (s, 0, NULL));
+ if ((a != 0 || lstrcmpW(condition, zeroW) == 0) && (b != 0 || lstrcmpW(WCMD_parameter (s, 0, NULL), zeroW) == 0)) {
+ if (a == b) test = 1;
+ }
+ else if (strstrW (quals, parmI) == NULL) {
+ if (!lstrcmpW (condition, WCMD_parameter (s, 0, NULL))) test = 1;
+ }
+ else {
+ if (!lstrcmpiW (condition, WCMD_parameter (s, 0, NULL))) test = 1;
+ }
+ WCMD_parameter (s, 1, &command);
+ }
else {
WCMD_output (WCMD_LoadMessage(WCMD_SYNTAXERR));
return;
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index 9833eeb..c475f74 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -614,6 +614,11 @@ if a LEQ B (echo a LEQ B) else echo NT4
if /I a LEQ B echo a LEQ B insensitive
if A LEQ b echo A LEQ b
if /I A LEQ b echo A LEQ b insensitive
+for %%i in (%STR_PARMS%) do call :EQUtest %%i A
+for %%i in (%STR_PARMS%) do call :EQUtest %%i B
+for %%i in (%STR_PARMS%) do call :EQUtest %%i AB
+for %%i in (%STR_PARMS%) do call :EQUtest %%i BA
+for %%i in (%STR_PARMS%) do call :EQUtest %%i AA
echo ... comparison operators for numbers
set INT_PARMS=0 1 10 9
for %%i in (%INT_PARMS%) do call :LSStest %%i 0
@@ -624,6 +629,10 @@ for %%i in (%INT_PARMS%) do call :LEQtest %%i 0
for %%i in (%INT_PARMS%) do call :LEQtest %%i 1
for %%i in (%INT_PARMS%) do call :LEQtest %%i 10
for %%i in (%INT_PARMS%) do call :LEQtest %%i 9
+for %%i in (%INT_PARMS%) do call :EQUtest %%i 0
+for %%i in (%INT_PARMS%) do call :EQUtest %%i 1
+for %%i in (%INT_PARMS%) do call :EQUtest %%i 10
+for %%i in (%INT_PARMS%) do call :EQUtest %%i 9
goto :endIfCompOpsSubroutines
rem IF subroutines helpers
@@ -633,6 +642,9 @@ goto :eof
:LEQtest
if %1 LEQ %2 echo %1 LEQ %2
goto :eof
+:EQUtest
+if %1 EQU %2 echo %1 EQU %2
+goto :eof
:endIfCompOpsSubroutines
set STR_PARMS=
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index 315daf1..de2381b 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -432,6 +432,11 @@ a LEQ B at or_broken@NT4
a LEQ B insensitive
A LEQ b
A LEQ b insensitive
+A EQU A
+B EQU B
+AB EQU AB
+BA EQU BA
+AA EQU AA
... comparison operators for numbers
0 LSS 1
0 LSS 10
@@ -449,6 +454,10 @@ A LEQ b insensitive
0 LEQ 9
1 LEQ 9
9 LEQ 9
+0 EQU 0
+1 EQU 1
+10 EQU 10
+9 EQU 9
-----------Testing for -----------
...plain FOR
A
--
1.7.6
More information about the wine-patches
mailing list