unDName: Fix 20 tests from demangle_test() on old Win versions

Michael Stefaniuc mstefani at redhat.de
Sat Feb 18 18:11:26 CST 2006


Hello,

there are still 13 test_demangle() tests that fail on Win{9x,ME,2K} but
that are due to a bug in name back referencing (constructor/desctructor
falsely added to the name reference array) in the old native msvcrt
dlls.

Changelog:
In test_demangle use a custom strcmp that treats multiple spaces as
single space. __unDName() from older msvcrt (including W2K it seems)
emit in some places 2 spaces instead of one. Fixes 20 failing tests on
those old Windows versions.

---

 dlls/msvcrt/tests/cpp.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

ca3452fe016d926814bccd7018568cbfcaff5674
diff --git a/dlls/msvcrt/tests/cpp.c b/dlls/msvcrt/tests/cpp.c
index 1282168..8165ffd 100644
--- a/dlls/msvcrt/tests/cpp.c
+++ b/dlls/msvcrt/tests/cpp.c
@@ -849,6 +849,26 @@ static void test_demangle_datatype(void)
 	      
     }
 }
+
+/* Compare two strings treating multiple spaces (' ', ascii 0x20) in s2 
+   as single space. Needed for test_demangle as __unDName() returns sometimes
+   two spaces instead of one in some older native msvcrt dlls. */
+static int strcmp_space(const char *s1, const char *s2)
+{
+    const char* s2start = s2;
+    do {
+        while (*s1 == *s2 && *s1) {
+            s1++;
+            s2++;
+        }
+        if (*s2 == ' ' && s2 > s2start && *(s2 - 1) == ' ')
+            s2++;
+        else
+            break;
+    } while (*s1 && *s2);
+    return *s1 - *s2;
+}
+
 static void test_demangle(void)
 {
     static struct {const char* in; const char* out;} test[] = {
@@ -959,7 +979,8 @@ static void test_demangle(void)
     for (i = 0; i < num_test; i++)
     {
 	name = p__unDName(0, test[i].in, 0, pmalloc, pfree, 0);
-        ok(name != NULL && !strcmp(name, test[i].out), "Got name \"%s\" for %d\n", name, i);
+        ok(name != NULL && !strcmp_space(test[i].out, name),
+                "Got name \"%s\" for %d\n", name, i);
         pfree(name);
     }
 }
-- 
1.2.1

-- 
Michael Stefaniuc               Tel.: +49-711-96437-199
Sr. Network Engineer            Fax.: +49-711-96437-111
Red Hat GmbH                    Email: mstefani at redhat.com
Hauptstaetterstr. 58            http://www.redhat.de/
D-70178 Stuttgart
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20060219/888888c3/attachment.pgp


More information about the wine-patches mailing list