[3/4] msvcirt: Implement iostream assignment operators.

Iván Matellanes matellanesivan at gmail.com
Tue Aug 9 13:16:04 CDT 2016


Signed-off-by: Iván Matellanes <matellanesivan at gmail.com>
---
 dlls/msvcirt/msvcirt.c       |  7 ++---
 dlls/msvcirt/tests/msvcirt.c | 62 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c
index 305eb9d..6533af0 100644
--- a/dlls/msvcirt/msvcirt.c
+++ b/dlls/msvcirt/msvcirt.c
@@ -3997,7 +3997,9 @@ void __thiscall iostream_dtor(ios *base)
 DEFINE_THISCALL_WRAPPER(iostream_assign_sb, 8)
 iostream* __thiscall iostream_assign_sb(iostream *this, streambuf *sb)
 {
-    FIXME("(%p %p) stub\n", this, sb);
+    TRACE("(%p %p)\n", this, sb);
+    this->base1.count = 0;
+    ostream_assign_sb(&this->base2, sb);
     return this;
 }
 
@@ -4006,8 +4008,7 @@ iostream* __thiscall iostream_assign_sb(iostream *this, streambuf *sb)
 DEFINE_THISCALL_WRAPPER(iostream_assign, 8)
 iostream* __thiscall iostream_assign(iostream *this, const iostream *rhs)
 {
-    FIXME("(%p %p) stub\n", this, rhs);
-    return this;
+    return iostream_assign_sb(this, istream_get_ios(&rhs->base1)->sb);
 }
 
 /* ??_Diostream@@QAEXXZ */
diff --git a/dlls/msvcirt/tests/msvcirt.c b/dlls/msvcirt/tests/msvcirt.c
index c26e906..1b15949 100644
--- a/dlls/msvcirt/tests/msvcirt.c
+++ b/dlls/msvcirt/tests/msvcirt.c
@@ -380,6 +380,8 @@ static iostream* (*__thiscall p_iostream_sb_ctor)(iostream*, streambuf*, BOOL);
 static iostream* (*__thiscall p_iostream_ctor)(iostream*, BOOL);
 static void (*__thiscall p_iostream_dtor)(ios*);
 static void (*__thiscall p_iostream_vbase_dtor)(iostream*);
+static iostream* (*__thiscall p_iostream_assign_sb)(iostream*, streambuf*);
+static iostream* (*__thiscall p_iostream_assign)(iostream*, const iostream*);
 
 /* Emulate a __thiscall */
 #ifdef __i386__
@@ -631,6 +633,8 @@ static BOOL init(void)
         SET(p_iostream_ctor, "??0iostream@@IEAA at XZ");
         SET(p_iostream_dtor, "??1iostream@@UEAA at XZ");
         SET(p_iostream_vbase_dtor, "??_Diostream@@QEAAXXZ");
+        SET(p_iostream_assign_sb, "??4iostream@@IEAAAEAV0 at PEAVstreambuf@@@Z");
+        SET(p_iostream_assign, "??4iostream@@IEAAAEAV0 at AEAV0@@Z");
     } else {
         p_operator_new = (void*)GetProcAddress(msvcrt, "??2 at YAPAXI@Z");
         p_operator_delete = (void*)GetProcAddress(msvcrt, "??3 at YAXPAX@Z");
@@ -804,6 +808,8 @@ static BOOL init(void)
         SET(p_iostream_ctor, "??0iostream@@IAE at XZ");
         SET(p_iostream_dtor, "??1iostream@@UAE at XZ");
         SET(p_iostream_vbase_dtor, "??_Diostream@@QAEXXZ");
+        SET(p_iostream_assign_sb, "??4iostream@@IAEAAV0 at PAVstreambuf@@@Z");
+        SET(p_iostream_assign, "??4iostream@@IAEAAV0 at AAV0@@Z");
     }
     SET(p_ios_static_lock, "?x_lockc at ios@@0U_CRT_CRITICAL_SECTION@@A");
     SET(p_ios_lockc, "?lockc at ios@@KAXXZ");
@@ -5968,6 +5974,62 @@ static void test_iostream(void)
     ok(ios2.base_ios.width == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base_ios.width);
     ok(ios2.base_ios.do_lock == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base_ios.do_lock);
     call_func1(p_iostream_dtor, &ios2.base_ios);
+
+    /* assignment */
+    ios2.base1.extract_delim = ios2.base1.count = 0xcdcdcdcd;
+    ios2.base2.unknown = 0xcdcdcdcd;
+    ios2.base_ios.sb = (streambuf*) 0xcdcdcdcd;
+    ios2.base_ios.state = 0xcdcdcdcd;
+    pios = call_func2(p_iostream_assign_sb, &ios2, &sb);
+    ok(pios == &ios2, "wrong return, expected %p got %p\n", &ios2, pios);
+    ok(ios2.base1.extract_delim == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base1.extract_delim);
+    ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
+    ok(ios2.base2.unknown == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base2.unknown);
+    ok(ios2.base_ios.sb == &sb, "expected %p got %p\n", &sb, ios2.base_ios.sb);
+    ok(ios2.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios2.base_ios.state);
+    ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
+    ok(ios2.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios2.base_ios.tie);
+    ok(ios2.base_ios.flags == 0, "expected 0 got %x\n", ios2.base_ios.flags);
+    ok(ios2.base_ios.precision == 6, "expected 6 got %d\n", ios2.base_ios.precision);
+    ok(ios2.base_ios.fill == ' ', "expected 32 got %d\n", ios2.base_ios.fill);
+    ok(ios2.base_ios.width == 0, "expected 0 got %d\n", ios2.base_ios.width);
+    ok(ios2.base_ios.do_lock == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base_ios.do_lock);
+    ios2.base1.count = 0xcdcdcdcd;
+    memset(&ios2.base_ios, 0xcd, sizeof(ios));
+    ios2.base_ios.delbuf = 0;
+    pios = call_func2(p_iostream_assign_sb, &ios2, NULL);
+    ok(pios == &ios2, "wrong return, expected %p got %p\n", &ios2, pios);
+    ok(ios2.base1.extract_delim == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base1.extract_delim);
+    ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
+    ok(ios2.base2.unknown == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base2.unknown);
+    ok(ios2.base_ios.sb == NULL, "expected %p got %p\n", NULL, ios2.base_ios.sb);
+    ok(ios2.base_ios.state == IOSTATE_badbit, "expected %d got %d\n", IOSTATE_badbit, ios2.base_ios.state);
+    ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
+    ok(ios2.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios2.base_ios.tie);
+    ok(ios2.base_ios.flags == 0, "expected 0 got %x\n", ios2.base_ios.flags);
+    ok(ios2.base_ios.precision == 6, "expected 6 got %d\n", ios2.base_ios.precision);
+    ok(ios2.base_ios.fill == ' ', "expected 32 got %d\n", ios2.base_ios.fill);
+    ok(ios2.base_ios.width == 0, "expected 0 got %d\n", ios2.base_ios.width);
+    ok(ios2.base_ios.do_lock == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base_ios.do_lock);
+    ios2.base1.count = 0xcdcdcdcd;
+    memset(&ios2.base_ios, 0xcd, sizeof(ios));
+    ios2.base_ios.delbuf = 0;
+if (0) /* crashes on native */
+    pios = call_func2(p_iostream_assign, &ios2, NULL);
+    pios = call_func2(p_iostream_assign, &ios2, &ios1);
+    ok(pios == &ios2, "wrong return, expected %p got %p\n", &ios2, pios);
+    ok(ios2.base1.extract_delim == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base1.extract_delim);
+    ok(ios2.base1.count == 0, "expected 0 got %d\n", ios2.base1.count);
+    ok(ios2.base2.unknown == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base2.unknown);
+    ok(ios2.base_ios.sb == &sb, "expected %p got %p\n", &sb, ios2.base_ios.sb);
+    ok(ios2.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, ios2.base_ios.state);
+    ok(ios2.base_ios.delbuf == 0, "expected 0 got %d\n", ios2.base_ios.delbuf);
+    ok(ios2.base_ios.tie == NULL, "expected %p got %p\n", NULL, ios2.base_ios.tie);
+    ok(ios2.base_ios.flags == 0, "expected 0 got %x\n", ios2.base_ios.flags);
+    ok(ios2.base_ios.precision == 6, "expected 6 got %d\n", ios2.base_ios.precision);
+    ok(ios2.base_ios.fill == ' ', "expected 32 got %d\n", ios2.base_ios.fill);
+    ok(ios2.base_ios.width == 0, "expected 0 got %d\n", ios2.base_ios.width);
+    ok(ios2.base_ios.do_lock == 0xcdcdcdcd, "expected %d got %d\n", 0xcdcdcdcd, ios2.base_ios.do_lock);
 }
 
 START_TEST(msvcirt)
-- 
2.7.4




More information about the wine-patches mailing list