msvcirt: Implement ostream::write.
Signed-off-by: Iván Matellanes <matellanes.ivan@gmail.com> Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e1b3a52902
commit
c4a5730ec3
|
@ -2506,7 +2506,15 @@ streampos __thiscall ostream_tellp(ostream *this)
|
|||
DEFINE_THISCALL_WRAPPER(ostream_write_char, 12)
|
||||
ostream* __thiscall ostream_write_char(ostream *this, const char *str, int count)
|
||||
{
|
||||
FIXME("(%p %s %d) stub\n", this, str, count);
|
||||
ios *base = ostream_get_ios(this);
|
||||
|
||||
TRACE("(%p %p %d)\n", this, str, count);
|
||||
|
||||
if (ostream_opfx(this)) {
|
||||
if (streambuf_sputn(base->sb, str, count) != count)
|
||||
base->state = IOSTATE_badbit | IOSTATE_failbit;
|
||||
ostream_osfx(this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -2515,8 +2523,7 @@ ostream* __thiscall ostream_write_char(ostream *this, const char *str, int count
|
|||
DEFINE_THISCALL_WRAPPER(ostream_write_signed_char, 12)
|
||||
ostream* __thiscall ostream_write_signed_char(ostream *this, const signed char *str, int count)
|
||||
{
|
||||
FIXME("(%p %s %d) stub\n", this, str, count);
|
||||
return this;
|
||||
return ostream_write_char(this, (const char*) str, count);
|
||||
}
|
||||
|
||||
/* ?write@ostream@@QAEAAV1@PBEH@Z */
|
||||
|
@ -2524,8 +2531,7 @@ ostream* __thiscall ostream_write_signed_char(ostream *this, const signed char *
|
|||
DEFINE_THISCALL_WRAPPER(ostream_write_unsigned_char, 12)
|
||||
ostream* __thiscall ostream_write_unsigned_char(ostream *this, const unsigned char *str, int count)
|
||||
{
|
||||
FIXME("(%p %s %d) stub\n", this, str, count);
|
||||
return this;
|
||||
return ostream_write_char(this, (const char*) str, count);
|
||||
}
|
||||
|
||||
/* ?writepad@ostream@@AAEAAV1@PBD0@Z */
|
||||
|
|
|
@ -265,6 +265,7 @@ static ostream* (*__thiscall p_ostream_flush)(ostream*);
|
|||
static int (*__thiscall p_ostream_opfx)(ostream*);
|
||||
static void (*__thiscall p_ostream_osfx)(ostream*);
|
||||
static ostream* (*__thiscall p_ostream_put_char)(ostream*, char);
|
||||
static ostream* (*__thiscall p_ostream_write_char)(ostream*, const char*, int);
|
||||
|
||||
/* Emulate a __thiscall */
|
||||
#ifdef __i386__
|
||||
|
@ -434,6 +435,7 @@ static BOOL init(void)
|
|||
SET(p_ostream_opfx, "?opfx@ostream@@QEAAHXZ");
|
||||
SET(p_ostream_osfx, "?osfx@ostream@@QEAAXXZ");
|
||||
SET(p_ostream_put_char, "?put@ostream@@QEAAAEAV1@D@Z");
|
||||
SET(p_ostream_write_char, "?write@ostream@@QEAAAEAV1@PEBDH@Z");
|
||||
} else {
|
||||
p_operator_new = (void*)GetProcAddress(msvcrt, "??2@YAPAXI@Z");
|
||||
p_operator_delete = (void*)GetProcAddress(msvcrt, "??3@YAXPAX@Z");
|
||||
|
@ -533,6 +535,7 @@ static BOOL init(void)
|
|||
SET(p_ostream_opfx, "?opfx@ostream@@QAEHXZ");
|
||||
SET(p_ostream_osfx, "?osfx@ostream@@QAEXXZ");
|
||||
SET(p_ostream_put_char, "?put@ostream@@QAEAAV1@D@Z");
|
||||
SET(p_ostream_write_char, "?write@ostream@@QAEAAV1@PBDH@Z");
|
||||
}
|
||||
SET(p_ios_static_lock, "?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A");
|
||||
SET(p_ios_lockc, "?lockc@ios@@KAXXZ");
|
||||
|
@ -2781,6 +2784,38 @@ if (0) /* crashes on native */
|
|||
ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
|
||||
fb1.fd = fd;
|
||||
|
||||
/* write */
|
||||
pos = (ostream*) call_func3(p_ostream_write_char, &os1, "Your", 4);
|
||||
ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
|
||||
ok(os1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
|
||||
IOSTATE_badbit|IOSTATE_failbit, os1.base_ios.state);
|
||||
ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
|
||||
ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
|
||||
os1.base_ios.state = IOSTATE_goodbit;
|
||||
os1.base_ios.width = 1;
|
||||
pos = (ostream*) call_func3(p_ostream_write_char, &os1, "heart's", 7);
|
||||
ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
|
||||
ok(os1.base_ios.state == IOSTATE_goodbit, "expected %d got %d\n", IOSTATE_goodbit, os1.base_ios.state);
|
||||
ok(os1.base_ios.width == 0, "expected 0 got %d\n", os1.base_ios.width);
|
||||
ok(fb1.base.pbase == fb1.base.base, "wrong put base, expected %p got %p\n", fb1.base.base, fb1.base.pbase);
|
||||
ok(fb1.base.pptr == fb1.base.base + 7, "wrong put pointer, expected %p got %p\n", fb1.base.base + 7, fb1.base.pptr);
|
||||
os1.base_ios.sb = NULL;
|
||||
if (0) /* crashes on native */
|
||||
pos = (ostream*) call_func3(p_ostream_write_char, &os1, "been", 4);
|
||||
os1.base_ios.sb = (streambuf*) &fb1;
|
||||
os1.base_ios.width = 5;
|
||||
call_func1(p_filebuf_sync, &fb1);
|
||||
fd = fb1.fd;
|
||||
fb1.fd = -1;
|
||||
pos = (ostream*) call_func3(p_ostream_write_char, &os1, "aching,", 7);
|
||||
ok(pos == &os1, "wrong return, expected %p got %p\n", &os1, pos);
|
||||
ok(os1.base_ios.state == (IOSTATE_badbit|IOSTATE_failbit), "expected %d got %d\n",
|
||||
IOSTATE_badbit|IOSTATE_failbit, os1.base_ios.state);
|
||||
ok(os1.base_ios.width == 0, "expected 0 got %d\n", os1.base_ios.width);
|
||||
ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
|
||||
ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
|
||||
fb1.fd = fd;
|
||||
|
||||
call_func1(p_ostream_vbase_dtor, &os1);
|
||||
call_func1(p_ostream_vbase_dtor, &os2);
|
||||
call_func1(p_filebuf_dtor, &fb1);
|
||||
|
|
Loading…
Reference in New Issue