msvcirt: Implement filebuf::overflow.
This commit is contained in:
parent
5ebf8cfc40
commit
ed5f60e46f
|
@ -983,8 +983,19 @@ filebuf* __thiscall filebuf_open(filebuf *this, const char *name, ios_open_mode
|
||||||
DEFINE_THISCALL_WRAPPER(filebuf_overflow, 8)
|
DEFINE_THISCALL_WRAPPER(filebuf_overflow, 8)
|
||||||
int __thiscall filebuf_overflow(filebuf *this, int c)
|
int __thiscall filebuf_overflow(filebuf *this, int c)
|
||||||
{
|
{
|
||||||
FIXME("(%p %d) stub\n", this, c);
|
TRACE("(%p %d)\n", this, c);
|
||||||
|
if (call_streambuf_sync(&this->base) == EOF)
|
||||||
return EOF;
|
return EOF;
|
||||||
|
if (this->base.unbuffered)
|
||||||
|
return (c == EOF) ? 1 : _write(this->fd, &c, 1);
|
||||||
|
if (streambuf_allocate(&this->base) == EOF)
|
||||||
|
return EOF;
|
||||||
|
|
||||||
|
this->base.pbase = this->base.pptr = this->base.base;
|
||||||
|
this->base.epptr = this->base.ebuf;
|
||||||
|
if (c != EOF)
|
||||||
|
*this->base.pptr++ = c;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ?seekoff@filebuf@@UAEJJW4seek_dir@ios@@H@Z */
|
/* ?seekoff@filebuf@@UAEJJW4seek_dir@ios@@H@Z */
|
||||||
|
|
|
@ -160,6 +160,7 @@ static filebuf* (*__thiscall p_filebuf_close)(filebuf*);
|
||||||
static int (*__thiscall p_filebuf_setmode)(filebuf*, int);
|
static int (*__thiscall p_filebuf_setmode)(filebuf*, int);
|
||||||
static streambuf* (*__thiscall p_filebuf_setbuf)(filebuf*, char*, int);
|
static streambuf* (*__thiscall p_filebuf_setbuf)(filebuf*, char*, int);
|
||||||
static int (*__thiscall p_filebuf_sync)(filebuf*);
|
static int (*__thiscall p_filebuf_sync)(filebuf*);
|
||||||
|
static int (*__thiscall p_filebuf_overflow)(filebuf*, int);
|
||||||
|
|
||||||
/* ios */
|
/* ios */
|
||||||
static ios* (*__thiscall p_ios_copy_ctor)(ios*, const ios*);
|
static ios* (*__thiscall p_ios_copy_ctor)(ios*, const ios*);
|
||||||
|
@ -301,6 +302,7 @@ static BOOL init(void)
|
||||||
SET(p_filebuf_setmode, "?setmode@filebuf@@QEAAHH@Z");
|
SET(p_filebuf_setmode, "?setmode@filebuf@@QEAAHH@Z");
|
||||||
SET(p_filebuf_setbuf, "?setbuf@filebuf@@UEAAPEAVstreambuf@@PEADH@Z");
|
SET(p_filebuf_setbuf, "?setbuf@filebuf@@UEAAPEAVstreambuf@@PEADH@Z");
|
||||||
SET(p_filebuf_sync, "?sync@filebuf@@UEAAHXZ");
|
SET(p_filebuf_sync, "?sync@filebuf@@UEAAHXZ");
|
||||||
|
SET(p_filebuf_overflow, "?overflow@filebuf@@UEAAHH@Z");
|
||||||
|
|
||||||
SET(p_ios_copy_ctor, "??0ios@@IEAA@AEBV0@@Z");
|
SET(p_ios_copy_ctor, "??0ios@@IEAA@AEBV0@@Z");
|
||||||
SET(p_ios_ctor, "??0ios@@IEAA@XZ");
|
SET(p_ios_ctor, "??0ios@@IEAA@XZ");
|
||||||
|
@ -362,6 +364,7 @@ static BOOL init(void)
|
||||||
SET(p_filebuf_setmode, "?setmode@filebuf@@QAEHH@Z");
|
SET(p_filebuf_setmode, "?setmode@filebuf@@QAEHH@Z");
|
||||||
SET(p_filebuf_setbuf, "?setbuf@filebuf@@UAEPAVstreambuf@@PADH@Z");
|
SET(p_filebuf_setbuf, "?setbuf@filebuf@@UAEPAVstreambuf@@PADH@Z");
|
||||||
SET(p_filebuf_sync, "?sync@filebuf@@UAEHXZ");
|
SET(p_filebuf_sync, "?sync@filebuf@@UAEHXZ");
|
||||||
|
SET(p_filebuf_overflow, "?overflow@filebuf@@UAEHH@Z");
|
||||||
|
|
||||||
SET(p_ios_copy_ctor, "??0ios@@IAE@ABV0@@Z");
|
SET(p_ios_copy_ctor, "??0ios@@IAE@ABV0@@Z");
|
||||||
SET(p_ios_ctor, "??0ios@@IAE@XZ");
|
SET(p_ios_ctor, "??0ios@@IAE@XZ");
|
||||||
|
@ -1225,6 +1228,44 @@ static void test_filebuf(void)
|
||||||
fb3.base.eback = fb3.base.gptr = fb3.base.egptr = NULL;
|
fb3.base.eback = fb3.base.gptr = fb3.base.egptr = NULL;
|
||||||
fb3.base.pbase = fb3.base.pptr = fb3.base.epptr = NULL;
|
fb3.base.pbase = fb3.base.pptr = fb3.base.epptr = NULL;
|
||||||
|
|
||||||
|
/* overflow */
|
||||||
|
ret = (int) call_func2(p_filebuf_overflow, &fb1, EOF);
|
||||||
|
ok(ret == 1, "wrong return, expected 1 got %d\n", ret);
|
||||||
|
fb1.base.pbase = fb1.base.pptr = fb1.base.epptr = NULL;
|
||||||
|
fb1.base.eback = fb1.base.gptr = fb1.base.base;
|
||||||
|
fb1.base.egptr = fb1.base.ebuf;
|
||||||
|
ret = (int) call_func2(p_filebuf_overflow, &fb1, 'a');
|
||||||
|
ok(ret == EOF, "wrong return, expected EOF got %d\n", ret);
|
||||||
|
fb1.base.gptr = fb1.base.egptr = fb1.base.pbase = fb1.base.pptr = fb1.base.base + 256;
|
||||||
|
fb1.base.epptr = fb1.base.ebuf;
|
||||||
|
ret = (int) call_func3(p_streambuf_xsputn, &fb1.base, "I just want to tell you how I'm feeling", 39);
|
||||||
|
ok(ret == 39, "wrong return, expected 39 got %d\n", ret);
|
||||||
|
ret = (int) call_func2(p_filebuf_overflow, &fb1, '\n');
|
||||||
|
ok(ret == 1, "wrong return, expected 1 got %d\n", ret);
|
||||||
|
ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
|
||||||
|
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 + 1, "wrong put pointer, expected %p got %p\n", fb1.base.base + 1, fb1.base.pptr);
|
||||||
|
ok(fb1.base.epptr == fb1.base.ebuf, "wrong put end pointer, expected %p got %p\n", fb1.base.ebuf, fb1.base.epptr);
|
||||||
|
ok(*fb1.base.pbase == '\n', "wrong character, expected '\\n' got '%c'\n", *fb1.base.pbase);
|
||||||
|
ret = (int) call_func2(p_filebuf_overflow, &fb1, EOF);
|
||||||
|
ok(ret == 1, "wrong return, expected 1 got %d\n", ret);
|
||||||
|
ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
|
||||||
|
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, "wrong put pointer, expected %p got %p\n", fb1.base.base, fb1.base.pptr);
|
||||||
|
ok(fb1.base.epptr == fb1.base.ebuf, "wrong put end pointer, expected %p got %p\n", fb1.base.ebuf, fb1.base.epptr);
|
||||||
|
ret = (int) call_func2(p_filebuf_overflow, &fb2, EOF);
|
||||||
|
ok(ret == EOF, "wrong return, expected EOF got %d\n", ret);
|
||||||
|
fb2.base.do_lock = 0;
|
||||||
|
pret = (filebuf*) call_func4(p_filebuf_open, &fb2, filename2, OPENMODE_in|OPENMODE_out, filebuf_openprot);
|
||||||
|
ok(pret == &fb2, "wrong return, expected %p got %p\n", &fb2, pret);
|
||||||
|
fb2.base.do_lock = -1;
|
||||||
|
ret = (int) call_func2(p_filebuf_overflow, &fb2, EOF);
|
||||||
|
ok(ret == 1, "wrong return, expected 1 got %d\n", ret);
|
||||||
|
fb2.base.do_lock = 0;
|
||||||
|
pret = (filebuf*) call_func1(p_filebuf_close, &fb2);
|
||||||
|
ok(pret == &fb2, "wrong return, expected %p got %p\n", &fb2, pret);
|
||||||
|
fb2.base.do_lock = -1;
|
||||||
|
|
||||||
/* close */
|
/* close */
|
||||||
pret = (filebuf*) call_func1(p_filebuf_close, &fb2);
|
pret = (filebuf*) call_func1(p_filebuf_close, &fb2);
|
||||||
ok(pret == NULL, "wrong return, expected %p got %p\n", NULL, pret);
|
ok(pret == NULL, "wrong return, expected %p got %p\n", NULL, pret);
|
||||||
|
|
Loading…
Reference in New Issue