Iván Matellanes : msvcirt: Implement ios status-testing functions.
Module: wine Branch: master Commit: 8413edb6964e80fa505d90c4f215699b864c378e URL: http://source.winehq.org/git/wine.git/?a=commit;h=8413edb6964e80fa505d90c4f2... Author: Iván Matellanes <matellanesivan(a)gmail.com> Date: Fri Jul 17 16:36:55 2015 +0200 msvcirt: Implement ios status-testing functions. --- dlls/msvcirt/msvcirt.c | 25 ++++++++++++---------- dlls/msvcirt/tests/msvcirt.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 11 deletions(-) diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c index 5bae2c8..1397ccd 100644 --- a/dlls/msvcirt/msvcirt.c +++ b/dlls/msvcirt/msvcirt.c @@ -843,8 +843,8 @@ ios* __thiscall ios_scalar_dtor(ios *this, unsigned int flags) DEFINE_THISCALL_WRAPPER(ios_bad, 4) int __thiscall ios_bad(const ios *this) { - FIXME("(%p) stub\n", this); - return 0; + TRACE("(%p)\n", this); + return (this->state & IOSTATE_badbit); } /* ?bitalloc(a)ios@@SAJXZ */ @@ -859,7 +859,10 @@ LONG __cdecl ios_bitalloc(void) DEFINE_THISCALL_WRAPPER(ios_clear, 8) void __thiscall ios_clear(ios *this, int state) { - FIXME("(%p %d) stub\n", this, state); + TRACE("(%p %d)\n", this, state); + ios_lock(this); + this->state = state; + ios_unlock(this); } /* ?clrlock(a)ios@@QAAXXZ */ @@ -904,8 +907,8 @@ ios* __cdecl ios_dec(ios *this) DEFINE_THISCALL_WRAPPER(ios_eof, 4) int __thiscall ios_eof(const ios *this) { - FIXME("(%p) stub\n", this); - return 0; + TRACE("(%p)\n", this); + return (this->state & IOSTATE_eofbit); } /* ?fail(a)ios@@QBEHXZ */ @@ -913,8 +916,8 @@ int __thiscall ios_eof(const ios *this) DEFINE_THISCALL_WRAPPER(ios_fail, 4) int __thiscall ios_fail(const ios *this) { - FIXME("(%p) stub\n", this); - return 0; + TRACE("(%p)\n", this); + return (this->state & (IOSTATE_failbit|IOSTATE_badbit)); } /* ?fill(a)ios@@QAEDD(a)Z */ @@ -966,8 +969,8 @@ LONG __thiscall ios_flags_get(const ios *this) DEFINE_THISCALL_WRAPPER(ios_good, 4) int __thiscall ios_good(const ios *this) { - FIXME("(%p) stub\n", this); - return 0; + TRACE("(%p)\n", this); + return this->state == IOSTATE_goodbit; } /* ?hex@@YAAAVios@@AAV1@@Z */ @@ -1088,8 +1091,8 @@ streambuf* __thiscall ios_rdbuf(const ios *this) DEFINE_THISCALL_WRAPPER(ios_rdstate, 4) int __thiscall ios_rdstate(const ios *this) { - FIXME("(%p) stub\n", this); - return 0; + TRACE("(%p)\n", this); + return this->state; } /* ?setf(a)ios@@QAEJJ(a)Z */ diff --git a/dlls/msvcirt/tests/msvcirt.c b/dlls/msvcirt/tests/msvcirt.c index 1b730b9..c65d419 100644 --- a/dlls/msvcirt/tests/msvcirt.c +++ b/dlls/msvcirt/tests/msvcirt.c @@ -142,6 +142,11 @@ static LONG (*__thiscall p_ios_flags_get)(const ios*); static LONG (*__thiscall p_ios_setf)(ios*, LONG); static LONG (*__thiscall p_ios_setf_mask)(ios*, LONG, LONG); static LONG (*__thiscall p_ios_unsetf)(ios*, LONG); +static int (*__thiscall p_ios_good)(const ios*); +static int (*__thiscall p_ios_bad)(const ios*); +static int (*__thiscall p_ios_eof)(const ios*); +static int (*__thiscall p_ios_fail)(const ios*); +static void (*__thiscall p_ios_clear)(ios*, int); /* Emulate a __thiscall */ #ifdef __i386__ @@ -255,6 +260,11 @@ static BOOL init(void) SET(p_ios_setf, "?setf(a)ios@@QEAAJJ(a)Z"); SET(p_ios_setf_mask, "?setf(a)ios@@QEAAJJJ(a)Z"); SET(p_ios_unsetf, "?unsetf(a)ios@@QEAAJJ(a)Z"); + SET(p_ios_good, "?good(a)ios@@QEBAHXZ"); + SET(p_ios_bad, "?bad(a)ios@@QEBAHXZ"); + SET(p_ios_eof, "?eof(a)ios@@QEBAHXZ"); + SET(p_ios_fail, "?fail(a)ios@@QEBAHXZ"); + SET(p_ios_clear, "?clear(a)ios@@QEAAXH(a)Z"); } else { p_operator_new = (void*)GetProcAddress(msvcrt, "??2(a)YAPAXI@Z"); @@ -298,6 +308,11 @@ static BOOL init(void) SET(p_ios_setf, "?setf(a)ios@@QAEJJ(a)Z"); SET(p_ios_setf_mask, "?setf(a)ios@@QAEJJJ(a)Z"); SET(p_ios_unsetf, "?unsetf(a)ios@@QAEJJ(a)Z"); + SET(p_ios_good, "?good(a)ios@@QBEHXZ"); + SET(p_ios_bad, "?bad(a)ios@@QBEHXZ"); + SET(p_ios_eof, "?eof(a)ios@@QBEHXZ"); + SET(p_ios_fail, "?fail(a)ios@@QBEHXZ"); + SET(p_ios_clear, "?clear(a)ios@@QAEXH(a)Z"); } SET(p_ios_static_lock, "?x_lockc(a)ios@@0U_CRT_CRITICAL_SECTION@@A"); SET(p_ios_lockc, "?lockc(a)ios@@KAXXZ"); @@ -1033,6 +1048,41 @@ static void test_ios(void) ok(ios_obj.flags == 0x440, "expected %x got %x\n", 0x440, ios_obj.flags); ios_obj.do_lock = -1; + /* state */ + ios_obj.state = 0x8; + ret = (LONG) call_func1(p_ios_good, &ios_obj); + ok(ret == 0, "expected 0 got %d\n", ret); + ios_obj.state = IOSTATE_goodbit; + ret = (LONG) call_func1(p_ios_good, &ios_obj); + ok(ret == 1, "expected 1 got %d\n", ret); + ret = (LONG) call_func1(p_ios_bad, &ios_obj); + ok(ret == 0, "expected 0 got %d\n", ret); + ios_obj.state = (IOSTATE_eofbit|IOSTATE_badbit); + ret = (LONG) call_func1(p_ios_bad, &ios_obj); + ok(ret == IOSTATE_badbit, "expected 4 got %d\n", ret); + ret = (LONG) call_func1(p_ios_eof, &ios_obj); + ok(ret == IOSTATE_eofbit, "expected 1 got %d\n", ret); + ios_obj.state = 0x8; + ret = (LONG) call_func1(p_ios_eof, &ios_obj); + ok(ret == 0, "expected 0 got %d\n", ret); + ret = (LONG) call_func1(p_ios_fail, &ios_obj); + ok(ret == 0, "expected 0 got %d\n", ret); + ios_obj.state = IOSTATE_badbit; + ret = (LONG) call_func1(p_ios_fail, &ios_obj); + ok(ret == IOSTATE_badbit, "expected 4 got %d\n", ret); + ios_obj.state = (IOSTATE_eofbit|IOSTATE_failbit); + ret = (LONG) call_func1(p_ios_fail, &ios_obj); + ok(ret == IOSTATE_failbit, "expected 2 got %d\n", ret); + ios_obj.state = (IOSTATE_eofbit|IOSTATE_failbit|IOSTATE_badbit); + ret = (LONG) call_func1(p_ios_fail, &ios_obj); + ok(ret == (IOSTATE_failbit|IOSTATE_badbit), "expected 6 got %d\n", ret); + ios_obj.do_lock = 0; + call_func2(p_ios_clear, &ios_obj, 0); + ok(ios_obj.state == IOSTATE_goodbit, "expected 0 got %d\n", ios_obj.state); + call_func2(p_ios_clear, &ios_obj, 0x8|IOSTATE_eofbit); + ok(ios_obj.state == (0x8|IOSTATE_eofbit), "expected 9 got %d\n", ios_obj.state); + ios_obj.do_lock = -1; + SetEvent(lock_arg.release[0]); SetEvent(lock_arg.release[1]); SetEvent(lock_arg.release[2]);
participants (1)
-
Alexandre Julliard