[6/7] cmd: Add support for GTR comparison operator in if statements

Frédéric Delanoy frederic.delanoy at gmail.com
Thu Sep 1 06:02:24 CDT 2011


---
 programs/cmd/builtins.c                  |   16 ++++++++++++++++
 programs/cmd/tests/test_builtins.cmd     |   12 ++++++++++++
 programs/cmd/tests/test_builtins.cmd.exp |   16 ++++++++++++++++
 3 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index e490711..a2c747d 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -1490,6 +1490,7 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) {
   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'};
   static const WCHAR zeroW[]   = {'0','\0'};
   static const WCHAR parmI[]   = {'/','I','\0'};
 
@@ -1603,6 +1604,21 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) {
     }
     WCMD_parameter (s, 1, &command);
   }
+  else if ((s = StrStrIW (p, gtrW))) {
+    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)) > 0) test = 1;
+    }
+    else {
+        if (lstrcmpiW (condition, WCMD_parameter (s, 0, NULL)) > 0) 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 7170e37..38aa555 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -629,6 +629,11 @@ for %%i in (%STR_PARMS%) do call :GEQtest %%i B
 for %%i in (%STR_PARMS%) do call :GEQtest %%i AB
 for %%i in (%STR_PARMS%) do call :GEQtest %%i BA
 for %%i in (%STR_PARMS%) do call :GEQtest %%i AA
+for %%i in (%STR_PARMS%) do call :GTRtest %%i A
+for %%i in (%STR_PARMS%) do call :GTRtest %%i B
+for %%i in (%STR_PARMS%) do call :GTRtest %%i AB
+for %%i in (%STR_PARMS%) do call :GTRtest %%i BA
+for %%i in (%STR_PARMS%) do call :GTRtest %%i AA
 echo ... comparison operators for numbers
 set INT_PARMS=0 1 10 9
 for %%i in (%INT_PARMS%) do call :LSStest %%i 0
@@ -651,6 +656,10 @@ for %%i in (%INT_PARMS%) do call :GEQtest %%i 0
 for %%i in (%INT_PARMS%) do call :GEQtest %%i 1
 for %%i in (%INT_PARMS%) do call :GEQtest %%i 10
 for %%i in (%INT_PARMS%) do call :GEQtest %%i 9
+for %%i in (%INT_PARMS%) do call :GTRtest %%i 0
+for %%i in (%INT_PARMS%) do call :GTRtest %%i 1
+for %%i in (%INT_PARMS%) do call :GTRtest %%i 10
+for %%i in (%INT_PARMS%) do call :GTRtest %%i 9
 goto :endIfCompOpsSubroutines
 
 rem IF subroutines helpers
@@ -669,6 +678,9 @@ goto :eof
 :GEQtest
 if %1 GEQ %2 echo %1 GEQ %2
 goto :eof
+:GTRtest
+if %1 GTR %2 echo %1 GTR %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 eda4aaa..20104aa 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -472,6 +472,16 @@ B GEQ AA
 AB GEQ AA
 BA GEQ AA
 AA GEQ 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
 ... comparison operators for numbers
 0 LSS 1
 0 LSS 10
@@ -515,6 +525,12 @@ AA GEQ AA
 10 GEQ 10
 10 GEQ 9
 9 GEQ 9
+1 GTR 0
+10 GTR 0
+9 GTR 0
+10 GTR 1
+9 GTR 1
+10 GTR 9
 -----------Testing for -----------
 ...plain FOR
 A
-- 
1.7.6




More information about the wine-patches mailing list