[06/10] msvcirt: Implement strstreambuf::setbuf (resend)
Iván Matellanes
matellanesivan at gmail.com
Thu Sep 17 04:06:51 CDT 2015
---
dlls/msvcirt/msvcirt.c | 6 ++++--
dlls/msvcirt/tests/msvcirt.c | 19 +++++++++++++++++++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c
index d2c39eb..0ea4030 100644
--- a/dlls/msvcirt/msvcirt.c
+++ b/dlls/msvcirt/msvcirt.c
@@ -1350,8 +1350,10 @@ streampos __thiscall strstreambuf_seekoff(strstreambuf *this, streamoff offset,
DEFINE_THISCALL_WRAPPER(strstreambuf_setbuf, 12)
streambuf* __thiscall strstreambuf_setbuf(strstreambuf *this, char *buffer, int length)
{
- FIXME("(%p %p %d) stub\n", this, buffer, length);
- return NULL;
+ TRACE("(%p %p %d)\n", this, buffer, length);
+ if (length)
+ this->increase = length;
+ return &this->base;
}
/* ?str at strstreambuf@@QAEPADXZ */
diff --git a/dlls/msvcirt/tests/msvcirt.c b/dlls/msvcirt/tests/msvcirt.c
index c7398d6..978665f 100644
--- a/dlls/msvcirt/tests/msvcirt.c
+++ b/dlls/msvcirt/tests/msvcirt.c
@@ -195,6 +195,7 @@ static strstreambuf* (*__thiscall p_strstreambuf_ctor)(strstreambuf*);
static void (*__thiscall p_strstreambuf_dtor)(strstreambuf*);
static int (*__thiscall p_strstreambuf_doallocate)(strstreambuf*);
static void (*__thiscall p_strstreambuf_freeze)(strstreambuf*, int);
+static streambuf* (*__thiscall p_strstreambuf_setbuf)(strstreambuf*, char*, int);
/* ios */
static ios* (*__thiscall p_ios_copy_ctor)(ios*, const ios*);
@@ -349,6 +350,7 @@ static BOOL init(void)
SET(p_strstreambuf_dtor, "??1strstreambuf@@UEAA at XZ");
SET(p_strstreambuf_doallocate, "?doallocate at strstreambuf@@MEAAHXZ");
SET(p_strstreambuf_freeze, "?freeze at strstreambuf@@QEAAXH at Z");
+ SET(p_strstreambuf_setbuf, "?setbuf at strstreambuf@@UEAAPEAVstreambuf@@PEADH at Z");
SET(p_ios_copy_ctor, "??0ios@@IEAA at AEBV0@@Z");
SET(p_ios_ctor, "??0ios@@IEAA at XZ");
@@ -423,6 +425,7 @@ static BOOL init(void)
SET(p_strstreambuf_dtor, "??1strstreambuf@@UAE at XZ");
SET(p_strstreambuf_doallocate, "?doallocate at strstreambuf@@MAEHXZ");
SET(p_strstreambuf_freeze, "?freeze at strstreambuf@@QAEXH at Z");
+ SET(p_strstreambuf_setbuf, "?setbuf at strstreambuf@@UAEPAVstreambuf@@PADH at Z");
SET(p_ios_copy_ctor, "??0ios@@IAE at ABV0@@Z");
SET(p_ios_ctor, "??0ios@@IAE at XZ");
@@ -1422,6 +1425,7 @@ static void test_filebuf(void)
static void test_strstreambuf(void)
{
strstreambuf ssb1, ssb2;
+ streambuf *pret;
char buffer[64];
int ret;
@@ -1577,6 +1581,21 @@ static void test_strstreambuf(void)
ok(!strncmp(ssb2.base.base, "Check", 5), "strings are not equal\n");
ssb2.dynamic = 1;
+ /* setbuf */
+ pret = (streambuf*) call_func3(p_strstreambuf_setbuf, &ssb1, buffer + 16, 16);
+ ok(pret == &ssb1.base, "expected %p got %p\n", &ssb1.base, pret);
+ ok(ssb1.base.base == buffer, "wrong buffer, expected %p got %p\n", buffer, ssb1.base.base);
+ ok(ssb1.increase == 16, "expected 16, got %d\n", ssb1.increase);
+ pret = (streambuf*) call_func3(p_strstreambuf_setbuf, &ssb2, NULL, 2);
+ ok(pret == &ssb2.base, "expected %p got %p\n", &ssb2.base, pret);
+ ok(ssb2.increase == 2, "expected 2, got %d\n", ssb2.increase);
+ pret = (streambuf*) call_func3(p_strstreambuf_setbuf, &ssb2, buffer, 0);
+ ok(pret == &ssb2.base, "expected %p got %p\n", &ssb2.base, pret);
+ ok(ssb2.increase == 2, "expected 2, got %d\n", ssb2.increase);
+ pret = (streambuf*) call_func3(p_strstreambuf_setbuf, &ssb2, NULL, -2);
+ ok(pret == &ssb2.base, "expected %p got %p\n", &ssb2.base, pret);
+ ok(ssb2.increase == -2, "expected -2, got %d\n", ssb2.increase);
+
call_func1(p_strstreambuf_dtor, &ssb1);
call_func1(p_strstreambuf_dtor, &ssb2);
}
--
2.1.4
More information about the wine-patches
mailing list