From d553a0883f21cc6a990688975d54395e90c8c52a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Iv=C3=A1n=20Matellanes?= Date: Thu, 25 Jun 2015 19:02:17 +0200 Subject: [PATCH] msvcirt: Add implementation of streambuf::stossc. --- dlls/msvcirt/msvcirt.c | 19 +++++++++++++++++++ dlls/msvcirt/msvcirt.spec | 4 ++-- dlls/msvcirt/tests/msvcirt.c | 27 +++++++++++++++++++++++++++ dlls/msvcrt20/msvcrt20.spec | 4 ++-- dlls/msvcrt40/msvcrt40.spec | 4 ++-- 5 files changed, 52 insertions(+), 6 deletions(-) diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c index 808237cc099..66858dee8ca 100644 --- a/dlls/msvcirt/msvcirt.c +++ b/dlls/msvcirt/msvcirt.c @@ -636,6 +636,25 @@ int __thiscall streambuf_sbumpc(streambuf *this) return ret; } +/* ?stossc@streambuf@@QAEXXZ */ +/* ?stossc@streambuf@@QEAAXXZ */ +DEFINE_THISCALL_WRAPPER(streambuf_stossc, 4) +void __thiscall streambuf_stossc(streambuf *this) +{ + TRACE("(%p)\n", this); + if (this->unbuffered) { + if (this->stored_char == EOF) + call_streambuf_underflow(this); + else + this->stored_char = EOF; + } else { + if (this->gptr >= this->egptr) + call_streambuf_underflow(this); + if (this->gptr < this->egptr) + this->gptr++; + } +} + /****************************************************************** * ??1ios@@UAE@XZ (MSVCRTI.@) * class ios & __thiscall ios::-ios<<(void) diff --git a/dlls/msvcirt/msvcirt.spec b/dlls/msvcirt/msvcirt.spec index b3f592de869..913f18607a3 100644 --- a/dlls/msvcirt/msvcirt.spec +++ b/dlls/msvcirt/msvcirt.spec @@ -710,8 +710,8 @@ @ cdecl -arch=win64 ?sputn@streambuf@@QEAAHPEBDH@Z(ptr str long) streambuf_sputn @ stub -arch=win32 ?stdiofile@stdiobuf@@QAEPAU_iobuf@@XZ # struct _iobuf * __thiscall stdiobuf::stdiofile(void) @ stub -arch=win64 ?stdiofile@stdiobuf@@QEAAPEAU_iobuf@@XZ -@ stub -arch=win32 ?stossc@streambuf@@QAEXXZ # void __thiscall streambuf::stossc(void) -@ stub -arch=win64 ?stossc@streambuf@@QEAAXXZ +@ thiscall -arch=win32 ?stossc@streambuf@@QAEXXZ(ptr) streambuf_stossc +@ cdecl -arch=win64 ?stossc@streambuf@@QEAAXXZ(ptr) streambuf_stossc @ stub -arch=win32 ?str@istrstream@@QAEPADXZ # char * __thiscall istrstream::str(void) @ stub -arch=win64 ?str@istrstream@@QEAAPEADXZ @ stub -arch=win32 ?str@ostrstream@@QAEPADXZ # char * __thiscall ostrstream::str(void) diff --git a/dlls/msvcirt/tests/msvcirt.c b/dlls/msvcirt/tests/msvcirt.c index 8ebf045363a..42c0e3aaae1 100644 --- a/dlls/msvcirt/tests/msvcirt.c +++ b/dlls/msvcirt/tests/msvcirt.c @@ -65,6 +65,7 @@ static streambuf* (*__thiscall p_streambuf_setbuf)(streambuf*, char*, int); static int (*__thiscall p_streambuf_sgetc)(streambuf*); static int (*__thiscall p_streambuf_snextc)(streambuf*); static int (*__thiscall p_streambuf_sputc)(streambuf*, int); +static void (*__thiscall p_streambuf_stossc)(streambuf*); static int (*__thiscall p_streambuf_sync)(streambuf*); static void (*__thiscall p_streambuf_unlock)(streambuf*); static int (*__thiscall p_streambuf_xsgetn)(streambuf*, char*, int); @@ -155,6 +156,7 @@ static BOOL init(void) SET(p_streambuf_sgetc, "?sgetc@streambuf@@QEAAHXZ"); SET(p_streambuf_snextc, "?snextc@streambuf@@QEAAHXZ"); SET(p_streambuf_sputc, "?sputc@streambuf@@QEAAHH@Z"); + SET(p_streambuf_stossc, "?stossc@streambuf@@QEAAXXZ"); SET(p_streambuf_sync, "?sync@streambuf@@UEAAHXZ"); SET(p_streambuf_unlock, "?unlock@streambuf@@QEAAXXZ"); SET(p_streambuf_xsgetn, "?xsgetn@streambuf@@UEAAHPEADH@Z"); @@ -176,6 +178,7 @@ static BOOL init(void) SET(p_streambuf_sgetc, "?sgetc@streambuf@@QAEHXZ"); SET(p_streambuf_snextc, "?snextc@streambuf@@QAEHXZ"); SET(p_streambuf_sputc, "?sputc@streambuf@@QAEHH@Z"); + SET(p_streambuf_stossc, "?stossc@streambuf@@QAEXXZ"); SET(p_streambuf_sync, "?sync@streambuf@@UAEHXZ"); SET(p_streambuf_unlock, "?unlock@streambuf@@QAEXXZ"); SET(p_streambuf_xsgetn, "?xsgetn@streambuf@@UAEHPADH@Z"); @@ -662,6 +665,30 @@ static void test_streambuf(void) ok(sb3.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb3.stored_char); ok(underflow_count == 54, "expected call to underflow\n"); + /* stossc */ + call_func1(p_streambuf_stossc, &sb); + ok(sb.gptr == sb.eback + 3, "wrong get pointer, expected %p got %p\n", sb.eback + 3, sb.gptr); + test_this = &sb2; + call_func1(p_streambuf_stossc, &sb2); + ok(sb2.gptr == sb2.egptr, "wrong get pointer, expected %p got %p\n", sb2.egptr, sb2.gptr); + ok(underflow_count == 55, "expected call to underflow\n"); + get_end = 0; + call_func1(p_streambuf_stossc, &sb2); + ok(sb2.gptr == sb2.eback + 1, "wrong get pointer, expected %p got %p\n", sb2.eback + 1, sb2.gptr); + ok(underflow_count == 56, "expected call to underflow\n"); + sb2.gptr = sb2.egptr - 1; + call_func1(p_streambuf_stossc, &sb2); + ok(sb2.gptr == sb2.egptr, "wrong get pointer, expected %p got %p\n", sb2.egptr, sb2.gptr); + ok(underflow_count == 56, "no call to underflow expected\n"); + test_this = &sb3; + call_func1(p_streambuf_stossc, &sb3); + ok(sb3.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb3.stored_char); + ok(underflow_count == 57, "expected call to underflow\n"); + sb3.stored_char = 'a'; + call_func1(p_streambuf_stossc, &sb3); + ok(sb3.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb3.stored_char); + ok(underflow_count == 57, "no call to underflow expected\n"); + SetEvent(lock_arg.test[3]); WaitForSingleObject(thread, INFINITE); diff --git a/dlls/msvcrt20/msvcrt20.spec b/dlls/msvcrt20/msvcrt20.spec index 2e4bc16e261..f37d8761b88 100644 --- a/dlls/msvcrt20/msvcrt20.spec +++ b/dlls/msvcrt20/msvcrt20.spec @@ -698,8 +698,8 @@ @ cdecl -arch=win64 ?sputn@streambuf@@QEAAHPEBDH@Z(ptr str long) msvcirt.?sputn@streambuf@@QEAAHPEBDH@Z @ stub -arch=win32 ?stdiofile@stdiobuf@@QAEPAU_iobuf@@XZ @ stub -arch=win64 ?stdiofile@stdiobuf@@QEAAPEAU_iobuf@@XZ -@ stub -arch=win32 ?stossc@streambuf@@QAEXXZ -@ stub -arch=win64 ?stossc@streambuf@@QEAAXXZ +@ thiscall -arch=win32 ?stossc@streambuf@@QAEXXZ(ptr) msvcirt.?stossc@streambuf@@QAEXXZ +@ cdecl -arch=win64 ?stossc@streambuf@@QEAAXXZ(ptr) msvcirt.?stossc@streambuf@@QEAAXXZ @ stub -arch=win32 ?str@istrstream@@QAEPADXZ @ stub -arch=win64 ?str@istrstream@@QEAAPEADXZ @ stub -arch=win32 ?str@ostrstream@@QAEPADXZ diff --git a/dlls/msvcrt40/msvcrt40.spec b/dlls/msvcrt40/msvcrt40.spec index a3cfbdce131..9173aef3ab2 100644 --- a/dlls/msvcrt40/msvcrt40.spec +++ b/dlls/msvcrt40/msvcrt40.spec @@ -770,8 +770,8 @@ @ cdecl -arch=win64 ?sputn@streambuf@@QEAAHPEBDH@Z(ptr str long) msvcirt.?sputn@streambuf@@QEAAHPEBDH@Z @ stub -arch=win32 ?stdiofile@stdiobuf@@QAEPAU_iobuf@@XZ @ stub -arch=win64 ?stdiofile@stdiobuf@@QEAAPEAU_iobuf@@XZ -@ stub -arch=win32 ?stossc@streambuf@@QAEXXZ -@ stub -arch=win64 ?stossc@streambuf@@QEAAXXZ +@ thiscall -arch=win32 ?stossc@streambuf@@QAEXXZ(ptr) msvcirt.?stossc@streambuf@@QAEXXZ +@ cdecl -arch=win64 ?stossc@streambuf@@QEAAXXZ(ptr) msvcirt.?stossc@streambuf@@QEAAXXZ @ stub -arch=win32 ?str@istrstream@@QAEPADXZ @ stub -arch=win64 ?str@istrstream@@QEAAPEADXZ @ stub -arch=win32 ?str@ostrstream@@QAEPADXZ -- 2.11.4.GIT