[1/3] msvcirt: Add implementation of streambuf::sync

Iván Matellanes matellanesivan at gmail.com
Tue Jun 9 12:40:33 CDT 2015


---
 dlls/msvcirt/msvcirt.c       |  4 ++--
 dlls/msvcirt/tests/msvcirt.c | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c
index a5b7141..e20fb68 100644
--- a/dlls/msvcirt/msvcirt.c
+++ b/dlls/msvcirt/msvcirt.c
@@ -437,8 +437,8 @@ void __thiscall streambuf_setp(streambuf *this, char *pb, char *ep)
 DEFINE_THISCALL_WRAPPER(streambuf_sync, 4)
 int __thiscall streambuf_sync(streambuf *this)
 {
-    FIXME("(%p): stub\n", this);
-    return EOF;
+    TRACE("(%p)\n", this);
+    return (this->gptr == this->egptr && this->pbase == this->pptr) ? 0 : EOF;
 }
 
 /* ?unbuffered at streambuf@@IAEXH at Z */
diff --git a/dlls/msvcirt/tests/msvcirt.c b/dlls/msvcirt/tests/msvcirt.c
index 2a45b04..057c6c8 100644
--- a/dlls/msvcirt/tests/msvcirt.c
+++ b/dlls/msvcirt/tests/msvcirt.c
@@ -61,6 +61,7 @@ static void (*__thiscall p_streambuf_pbump)(streambuf*, int);
 static void (*__thiscall p_streambuf_setb)(streambuf*, char*, char*, int);
 static void (*__thiscall p_streambuf_setlock)(streambuf*);
 static streambuf* (*__thiscall p_streambuf_setbuf)(streambuf*, char*, int);
+static int (*__thiscall p_streambuf_sync)(streambuf*);
 static void (*__thiscall p_streambuf_unlock)(streambuf*);
 
 /* Emulate a __thiscall */
@@ -144,6 +145,7 @@ static BOOL init(void)
         SET(p_streambuf_setb, "?setb at streambuf@@IEAAXPEAD0H at Z");
         SET(p_streambuf_setbuf, "?setbuf at streambuf@@UEAAPEAV1 at PEADH@Z");
         SET(p_streambuf_setlock, "?setlock at streambuf@@QEAAXXZ");
+        SET(p_streambuf_sync, "?sync at streambuf@@UEAAHXZ");
         SET(p_streambuf_unlock, "?unlock at streambuf@@QEAAXXZ");
     } else {
         SET(p_streambuf_reserve_ctor, "??0streambuf@@IAE at PADH@Z");
@@ -158,6 +160,7 @@ static BOOL init(void)
         SET(p_streambuf_setb, "?setb at streambuf@@IAEXPAD0H at Z");
         SET(p_streambuf_setbuf, "?setbuf at streambuf@@UAEPAV1 at PADH@Z");
         SET(p_streambuf_setlock, "?setlock at streambuf@@QAEXXZ");
+        SET(p_streambuf_sync, "?sync at streambuf@@UAEHXZ");
         SET(p_streambuf_unlock, "?unlock at streambuf@@QAEXXZ");
     }
 
@@ -341,6 +344,18 @@ static void test_streambuf(void)
     call_func2(p_streambuf_pbump, &sb, 20);
     ok(sb.pptr == sb.pbase + 18, "advance put pointer failed, expected %p got %p\n", sb.pbase + 18, sb.pptr);
 
+    /* sync */
+    ret = (int) call_func1(p_streambuf_sync, &sb);
+    ok(ret == EOF, "sync failed, expected EOF got %d\n", ret);
+    sb.gptr = sb.egptr;
+    ret = (int) call_func1(p_streambuf_sync, &sb);
+    ok(ret == EOF, "sync failed, expected EOF got %d\n", ret);
+    sb.pptr = sb.pbase;
+    ret = (int) call_func1(p_streambuf_sync, &sb);
+    ok(ret == 0, "sync failed, expected 0 got %d\n", ret);
+    ret = (int) call_func1(p_streambuf_sync, &sb2);
+    ok(ret == 0, "sync failed, expected 0 got %d\n", ret);
+
     SetEvent(lock_arg.test[3]);
     WaitForSingleObject(thread, INFINITE);
 
-- 
2.1.4




More information about the wine-patches mailing list