=?UTF-8?Q?Fr=C3=A9d=C3=A9ric=20Delanoy=20?=: cmd: Fix IF operands parsing for '==' operator.

Alexandre Julliard julliard at winehq.org
Thu Sep 8 14:52:12 CDT 2011


Module: wine
Branch: master
Commit: 712276c7bf561ae3bf34e851c1d794568cd5b8f7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=712276c7bf561ae3bf34e851c1d794568cd5b8f7

Author: Frédéric Delanoy <frederic.delanoy at gmail.com>
Date:   Tue Sep  6 19:19:44 2011 +0200

cmd: Fix IF operands parsing for '==' operator.

---

 programs/cmd/builtins.c                  |   13 +++++++++++--
 programs/cmd/tests/test_builtins.cmd.exp |    6 +++---
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 9dbeb93..9c4f72a 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -1525,9 +1525,18 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) {
     WCMD_parameter(p, 2+negate, &command, NULL);
   }
   else if ((s = strstrW (p, eqeqW))) {
+    /* We need to get potential surrounding double quotes, so param1/2 can't be used */
+    WCHAR *leftPart, *leftPartEnd, *rightPart, *rightPartEnd;
     s += 2;
-    test = caseInsensitive ? (!lstrcmpiW(condition, WCMD_parameter(s, 0, NULL, NULL)))
-                           : (!lstrcmpW (condition, WCMD_parameter(s, 0, NULL, NULL)));
+    WCMD_parameter(p, 0+negate+caseInsensitive, &leftPart, &leftPartEnd);
+    WCMD_parameter(p, 1+negate+caseInsensitive, &rightPart, &rightPartEnd);
+    test = caseInsensitive
+            ? (CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
+                              leftPart, leftPartEnd-leftPart+1,
+                              rightPart, rightPartEnd-rightPart+1) == CSTR_EQUAL)
+            : (CompareStringW(LOCALE_SYSTEM_DEFAULT, 0,
+                              leftPart, leftPartEnd-leftPart+1,
+                              rightPart, rightPartEnd-rightPart+1) == CSTR_EQUAL);
     WCMD_parameter(s, 1, &command, NULL);
   }
   else {
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index 514a635..90dfb45 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -382,15 +382,15 @@ NUL
 if/else should work with blocks
 if seems to work
 else seems to work
- at todo_wine@if seems not to detect /c as parameter
+if seems not to detect /c as parameter
 Testing case sensitivity with and without /i option
 if seems to default to case sensitivity
 if /i seems to work
 if /I seems to work
 Testing string comparisons
 equal
- at todo_wine@non equal
- at todo_wine@non equal
+non equal
+non equal
 equal
 Testing tabs handling
 doom




More information about the wine-cvs mailing list