msvcirt: Implement ios status-testing functions.

This commit is contained in:
Iván Matellanes 2015-07-17 16:36:55 +02:00 committed by Alexandre Julliard
parent 9abffde3bc
commit 8413edb696
2 changed files with 64 additions and 11 deletions

View File

@ -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@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@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@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@ios@@QAEDD@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@ios@@QAEJJ@Z */

View File

@ -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@ios@@QEAAJJ@Z");
SET(p_ios_setf_mask, "?setf@ios@@QEAAJJJ@Z");
SET(p_ios_unsetf, "?unsetf@ios@@QEAAJJ@Z");
SET(p_ios_good, "?good@ios@@QEBAHXZ");
SET(p_ios_bad, "?bad@ios@@QEBAHXZ");
SET(p_ios_eof, "?eof@ios@@QEBAHXZ");
SET(p_ios_fail, "?fail@ios@@QEBAHXZ");
SET(p_ios_clear, "?clear@ios@@QEAAXH@Z");
} else {
p_operator_new = (void*)GetProcAddress(msvcrt, "??2@YAPAXI@Z");
@ -298,6 +308,11 @@ static BOOL init(void)
SET(p_ios_setf, "?setf@ios@@QAEJJ@Z");
SET(p_ios_setf_mask, "?setf@ios@@QAEJJJ@Z");
SET(p_ios_unsetf, "?unsetf@ios@@QAEJJ@Z");
SET(p_ios_good, "?good@ios@@QBEHXZ");
SET(p_ios_bad, "?bad@ios@@QBEHXZ");
SET(p_ios_eof, "?eof@ios@@QBEHXZ");
SET(p_ios_fail, "?fail@ios@@QBEHXZ");
SET(p_ios_clear, "?clear@ios@@QAEXH@Z");
}
SET(p_ios_static_lock, "?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A");
SET(p_ios_lockc, "?lockc@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]);