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

Frédéric Delanoy frederic.delanoy at gmail.com
Sat Sep 17 03:54:43 CDT 2011


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

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index bf369ce..ca3378f 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -1511,6 +1511,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 parmI[]   = {'/','I','\0'};
   int caseInsensitive = (strstrW(quals, parmI) != NULL);
 
@@ -1608,6 +1609,13 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) {
         test = caseInsensitive ? (lstrcmpiW(left, right) >= 0)
                                : (lstrcmpW (left, right) >= 0);
     }
+    else if (!lstrcmpiW(compOp, gtrW)) {
+      if (bothInts)
+        test = (a > b);
+      else
+        test = caseInsensitive ? (lstrcmpiW(left, right) > 0)
+                               : (lstrcmpW (left, right) > 0);
+    }
     else {
       HeapFree(GetProcessHeap(), 0, left);
       HeapFree(GetProcessHeap(), 0, compOp);
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index 414cde5..a339b3c 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -647,6 +647,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 ...... for numbers ......
 if -1 LSS 1 (echo foo) else echo bar
 if 11 LSS 101 (echo riri) else echo fifi
@@ -676,6 +681,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
@@ -694,6 +703,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 b878d0a..59c35f1 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -484,6 +484,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
 ...... for numbers ......
 foo
 riri
@@ -534,6 +544,12 @@ hexa ok
 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.3




More information about the wine-patches mailing list