From 1f1cf8a68e38c68fbdfbcaaf60d89930fff2dbef Mon Sep 17 00:00:00 2001 From: =?utf8?q?Iv=C3=A1n=20Matellanes?= Date: Tue, 9 Jun 2015 19:40:33 +0200 Subject: [PATCH] msvcirt: Add implementation of streambuf::sync. --- 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 a5b71411ae3..e20fb68c1c7 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@streambuf@@IAEXH@Z */ diff --git a/dlls/msvcirt/tests/msvcirt.c b/dlls/msvcirt/tests/msvcirt.c index 2a45b04980b..057c6c8321d 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@streambuf@@IEAAXPEAD0H@Z"); SET(p_streambuf_setbuf, "?setbuf@streambuf@@UEAAPEAV1@PEADH@Z"); SET(p_streambuf_setlock, "?setlock@streambuf@@QEAAXXZ"); + SET(p_streambuf_sync, "?sync@streambuf@@UEAAHXZ"); SET(p_streambuf_unlock, "?unlock@streambuf@@QEAAXXZ"); } else { SET(p_streambuf_reserve_ctor, "??0streambuf@@IAE@PADH@Z"); @@ -158,6 +160,7 @@ static BOOL init(void) SET(p_streambuf_setb, "?setb@streambuf@@IAEXPAD0H@Z"); SET(p_streambuf_setbuf, "?setbuf@streambuf@@UAEPAV1@PADH@Z"); SET(p_streambuf_setlock, "?setlock@streambuf@@QAEXXZ"); + SET(p_streambuf_sync, "?sync@streambuf@@UAEHXZ"); SET(p_streambuf_unlock, "?unlock@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.11.4.GIT