Commit 346a8e1c authored by Iván Matellanes's avatar Iván Matellanes Committed by Alexandre Julliard

msvcirt: Add implementation of streambuf::sbumpc.

parent fac4fdb5
......@@ -615,6 +615,27 @@ int __thiscall streambuf_snextc(streambuf *this)
}
}
/* ?sbumpc@streambuf@@QAEHXZ */
/* ?sbumpc@streambuf@@QEAAHXZ */
DEFINE_THISCALL_WRAPPER(streambuf_sbumpc, 4)
int __thiscall streambuf_sbumpc(streambuf *this)
{
int ret;
TRACE("(%p)\n", this);
if (this->unbuffered) {
ret = this->stored_char;
this->stored_char = EOF;
if (ret == EOF)
ret = call_streambuf_underflow(this);
} else {
ret = (this->gptr < this->egptr) ? *this->gptr : call_streambuf_underflow(this);
this->gptr++;
}
return ret;
}
/******************************************************************
* ??1ios@@UAE@XZ (MSVCRTI.@)
* class ios & __thiscall ios::-ios<<(void)
......
......@@ -637,8 +637,8 @@
@ stub -arch=win64 ?read@istream@@QEAAAEAV1@PEADH@Z
@ stub -arch=win32 ?read@istream@@QAEAAV1@PAEH@Z # class istream & __thiscall istream::read(unsigned char *,int)
@ stub -arch=win64 ?read@istream@@QEAAAEAV1@PEAEH@Z
@ stub -arch=win32 ?sbumpc@streambuf@@QAEHXZ # int __thiscall streambuf::sbumpc(void)
@ stub -arch=win64 ?sbumpc@streambuf@@QEAAHXZ
@ thiscall -arch=win32 ?sbumpc@streambuf@@QAEHXZ(ptr) streambuf_sbumpc
@ cdecl -arch=win64 ?sbumpc@streambuf@@QEAAHXZ(ptr) streambuf_sbumpc
@ stub -arch=win32 ?seekg@istream@@QAEAAV1@J@Z # class istream & __thiscall istream::seekg(long)
@ stub -arch=win64 ?seekg@istream@@QEAAAEAV1@J@Z
@ stub -arch=win32 ?seekg@istream@@QAEAAV1@JW4seek_dir@ios@@@Z # class istream & __thiscall istream::seekg(long,enum ios::seek_dir)
......
......@@ -58,6 +58,7 @@ static int (*__thiscall p_streambuf_doallocate)(streambuf*);
static void (*__thiscall p_streambuf_gbump)(streambuf*, int);
static void (*__thiscall p_streambuf_lock)(streambuf*);
static void (*__thiscall p_streambuf_pbump)(streambuf*, int);
static int (*__thiscall p_streambuf_sbumpc)(streambuf*);
static void (*__thiscall p_streambuf_setb)(streambuf*, char*, char*, int);
static void (*__thiscall p_streambuf_setlock)(streambuf*);
static streambuf* (*__thiscall p_streambuf_setbuf)(streambuf*, char*, int);
......@@ -147,6 +148,7 @@ static BOOL init(void)
SET(p_streambuf_gbump, "?gbump@streambuf@@IEAAXH@Z");
SET(p_streambuf_lock, "?lock@streambuf@@QEAAXXZ");
SET(p_streambuf_pbump, "?pbump@streambuf@@IEAAXH@Z");
SET(p_streambuf_sbumpc, "?sbumpc@streambuf@@QEAAHXZ");
SET(p_streambuf_setb, "?setb@streambuf@@IEAAXPEAD0H@Z");
SET(p_streambuf_setbuf, "?setbuf@streambuf@@UEAAPEAV1@PEADH@Z");
SET(p_streambuf_setlock, "?setlock@streambuf@@QEAAXXZ");
......@@ -167,6 +169,7 @@ static BOOL init(void)
SET(p_streambuf_gbump, "?gbump@streambuf@@IAEXH@Z");
SET(p_streambuf_lock, "?lock@streambuf@@QAEXXZ");
SET(p_streambuf_pbump, "?pbump@streambuf@@IAEXH@Z");
SET(p_streambuf_sbumpc, "?sbumpc@streambuf@@QAEHXZ");
SET(p_streambuf_setb, "?setb@streambuf@@IAEXPAD0H@Z");
SET(p_streambuf_setbuf, "?setbuf@streambuf@@UAEPAV1@PADH@Z");
SET(p_streambuf_setlock, "?setlock@streambuf@@QAEXXZ");
......@@ -618,6 +621,47 @@ static void test_streambuf(void)
ok(sb3.stored_char == 'p', "wrong stored character, expected 'p' got %c\n", sb3.stored_char);
ok(underflow_count == 49, "expected 2 calls to underflow, got %d\n", underflow_count - 47);
/* sbumpc */
ret = (int) call_func1(p_streambuf_sbumpc, &sb);
ok(ret == 'e', "expected 'e' got '%c'\n", ret);
ok(sb.gptr == sb.eback + 2, "wrong get pointer, expected %p got %p\n", sb.eback + 2, sb.gptr);
test_this = &sb2;
ret = (int) call_func1(p_streambuf_sbumpc, &sb2);
ok(ret == 'W', "expected 'W' got '%c'\n", ret);
ok(sb2.gptr == sb2.eback + 1, "wrong get pointer, expected %p got %p\n", sb2.eback + 1, sb2.gptr);
ok(underflow_count == 50, "expected call to underflow\n");
sb2.gptr = sb2.egptr - 1;
*sb2.gptr = 't';
ret = (int) call_func1(p_streambuf_sbumpc, &sb2);
ok(ret == 't', "expected 't' got '%c'\n", ret);
ok(sb2.gptr == sb2.egptr, "wrong get pointer, expected %p got %p\n", sb2.egptr, sb2.gptr);
ok(underflow_count == 50, "no call to underflow expected\n");
get_end = 1;
ret = (int) call_func1(p_streambuf_sbumpc, &sb2);
ok(ret == EOF, "expected EOF got '%c'\n", ret);
ok(sb2.gptr == sb2.egptr + 1, "wrong get pointer, expected %p got %p\n", sb2.egptr + 1, sb2.gptr);
ok(underflow_count == 51, "expected call to underflow\n");
sb2.gptr = sb2.egptr;
test_this = &sb3;
ret = (int) call_func1(p_streambuf_sbumpc, &sb3);
ok(ret == 'p', "expected 'p' got '%c'\n", ret);
ok(sb3.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb3.stored_char);
ok(underflow_count == 51, "no call to underflow expected\n");
ret = (int) call_func1(p_streambuf_sbumpc, &sb3);
ok(ret == 'u', "expected 'u' got '%c'\n", ret);
ok(sb3.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb3.stored_char);
ok(underflow_count == 52, "expected call to underflow\n");
buffer_pos = 23;
ret = (int) call_func1(p_streambuf_sbumpc, &sb3);
ok(ret == EOF, "expected EOF got '%c'\n", ret);
ok(sb3.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb3.stored_char);
ok(underflow_count == 53, "expected call to underflow\n");
buffer_pos = 0;
ret = (int) call_func1(p_streambuf_sbumpc, &sb3);
ok(ret == 'C', "expected 'C' got '%c'\n", ret);
ok(sb3.stored_char == EOF, "wrong stored character, expected EOF got %c\n", sb3.stored_char);
ok(underflow_count == 54, "expected call to underflow\n");
SetEvent(lock_arg.test[3]);
WaitForSingleObject(thread, INFINITE);
......
......@@ -623,8 +623,8 @@
@ stub -arch=win64 ?read@istream@@QEAAAEAV1@PEADH@Z
@ stub -arch=win32 ?read@istream@@QAEAAV1@PAEH@Z
@ stub -arch=win64 ?read@istream@@QEAAAEAV1@PEAEH@Z
@ stub -arch=win32 ?sbumpc@streambuf@@QAEHXZ
@ stub -arch=win64 ?sbumpc@streambuf@@QEAAHXZ
@ thiscall -arch=win32 ?sbumpc@streambuf@@QAEHXZ(ptr) msvcirt.?sbumpc@streambuf@@QAEHXZ
@ cdecl -arch=win64 ?sbumpc@streambuf@@QEAAHXZ(ptr) msvcirt.?sbumpc@streambuf@@QEAAHXZ
@ stub -arch=win32 ?seekg@istream@@QAEAAV1@J@Z
@ stub -arch=win64 ?seekg@istream@@QEAAAEAV1@J@Z
@ stub -arch=win32 ?seekg@istream@@QAEAAV1@JW4seek_dir@ios@@@Z
......
......@@ -694,8 +694,8 @@
@ stub -arch=win64 ?read@istream@@QEAAAEAV1@PEADH@Z
@ stub -arch=win32 ?read@istream@@QAEAAV1@PAEH@Z
@ stub -arch=win64 ?read@istream@@QEAAAEAV1@PEAEH@Z
@ stub -arch=win32 ?sbumpc@streambuf@@QAEHXZ
@ stub -arch=win64 ?sbumpc@streambuf@@QEAAHXZ
@ thiscall -arch=win32 ?sbumpc@streambuf@@QAEHXZ(ptr) msvcirt.?sbumpc@streambuf@@QAEHXZ
@ cdecl -arch=win64 ?sbumpc@streambuf@@QEAAHXZ(ptr) msvcirt.?sbumpc@streambuf@@QEAAHXZ
@ stub -arch=win32 ?seekg@istream@@QAEAAV1@J@Z
@ stub -arch=win64 ?seekg@istream@@QEAAAEAV1@J@Z
@ stub -arch=win32 ?seekg@istream@@QAEAAV1@JW4seek_dir@ios@@@Z
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment