[2/3] msvcirt: Add implementation of streambuf::sbumpc
Iván Matellanes
matellanesivan at gmail.com
Thu Jun 25 12:02:11 CDT 2015
---
dlls/msvcirt/msvcirt.c | 21 +++++++++++++++++++++
dlls/msvcirt/msvcirt.spec | 4 ++--
dlls/msvcirt/tests/msvcirt.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
dlls/msvcrt20/msvcrt20.spec | 4 ++--
dlls/msvcrt40/msvcrt40.spec | 4 ++--
5 files changed, 71 insertions(+), 6 deletions(-)
diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c
index 77dc089..808237c 100644
--- a/dlls/msvcirt/msvcirt.c
+++ b/dlls/msvcirt/msvcirt.c
@@ -615,6 +615,27 @@ int __thiscall streambuf_snextc(streambuf *this)
}
}
+/* ?sbumpc at streambuf@@QAEHXZ */
+/* ?sbumpc at 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 at XZ (MSVCRTI.@)
* class ios & __thiscall ios::-ios<<(void)
diff --git a/dlls/msvcirt/msvcirt.spec b/dlls/msvcirt/msvcirt.spec
index e49fd53..b3f592d 100644
--- a/dlls/msvcirt/msvcirt.spec
+++ b/dlls/msvcirt/msvcirt.spec
@@ -637,8 +637,8 @@
@ stub -arch=win64 ?read at istream@@QEAAAEAV1 at PEADH@Z
@ stub -arch=win32 ?read at istream@@QAEAAV1 at PAEH@Z # class istream & __thiscall istream::read(unsigned char *,int)
@ stub -arch=win64 ?read at istream@@QEAAAEAV1 at PEAEH@Z
-@ stub -arch=win32 ?sbumpc at streambuf@@QAEHXZ # int __thiscall streambuf::sbumpc(void)
-@ stub -arch=win64 ?sbumpc at streambuf@@QEAAHXZ
+@ thiscall -arch=win32 ?sbumpc at streambuf@@QAEHXZ(ptr) streambuf_sbumpc
+@ cdecl -arch=win64 ?sbumpc at streambuf@@QEAAHXZ(ptr) streambuf_sbumpc
@ stub -arch=win32 ?seekg at istream@@QAEAAV1 at J@Z # class istream & __thiscall istream::seekg(long)
@ stub -arch=win64 ?seekg at istream@@QEAAAEAV1 at J@Z
@ stub -arch=win32 ?seekg at istream@@QAEAAV1 at JW4seek_dir@ios@@@Z # class istream & __thiscall istream::seekg(long,enum ios::seek_dir)
diff --git a/dlls/msvcirt/tests/msvcirt.c b/dlls/msvcirt/tests/msvcirt.c
index 3d6e6ad..8ebf045 100644
--- a/dlls/msvcirt/tests/msvcirt.c
+++ b/dlls/msvcirt/tests/msvcirt.c
@@ -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 at streambuf@@IEAAXH at Z");
SET(p_streambuf_lock, "?lock at streambuf@@QEAAXXZ");
SET(p_streambuf_pbump, "?pbump at streambuf@@IEAAXH at Z");
+ SET(p_streambuf_sbumpc, "?sbumpc at streambuf@@QEAAHXZ");
SET(p_streambuf_setb, "?setb at streambuf@@IEAAXPEAD0H at Z");
SET(p_streambuf_setbuf, "?setbuf at streambuf@@UEAAPEAV1 at PEADH@Z");
SET(p_streambuf_setlock, "?setlock at streambuf@@QEAAXXZ");
@@ -167,6 +169,7 @@ static BOOL init(void)
SET(p_streambuf_gbump, "?gbump at streambuf@@IAEXH at Z");
SET(p_streambuf_lock, "?lock at streambuf@@QAEXXZ");
SET(p_streambuf_pbump, "?pbump at streambuf@@IAEXH at Z");
+ SET(p_streambuf_sbumpc, "?sbumpc at streambuf@@QAEHXZ");
SET(p_streambuf_setb, "?setb at streambuf@@IAEXPAD0H at Z");
SET(p_streambuf_setbuf, "?setbuf at streambuf@@UAEPAV1 at PADH@Z");
SET(p_streambuf_setlock, "?setlock at 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);
diff --git a/dlls/msvcrt20/msvcrt20.spec b/dlls/msvcrt20/msvcrt20.spec
index 5786fc4..2e4bc16 100644
--- a/dlls/msvcrt20/msvcrt20.spec
+++ b/dlls/msvcrt20/msvcrt20.spec
@@ -623,8 +623,8 @@
@ stub -arch=win64 ?read at istream@@QEAAAEAV1 at PEADH@Z
@ stub -arch=win32 ?read at istream@@QAEAAV1 at PAEH@Z
@ stub -arch=win64 ?read at istream@@QEAAAEAV1 at PEAEH@Z
-@ stub -arch=win32 ?sbumpc at streambuf@@QAEHXZ
-@ stub -arch=win64 ?sbumpc at streambuf@@QEAAHXZ
+@ thiscall -arch=win32 ?sbumpc at streambuf@@QAEHXZ(ptr) msvcirt.?sbumpc at streambuf@@QAEHXZ
+@ cdecl -arch=win64 ?sbumpc at streambuf@@QEAAHXZ(ptr) msvcirt.?sbumpc at streambuf@@QEAAHXZ
@ stub -arch=win32 ?seekg at istream@@QAEAAV1 at J@Z
@ stub -arch=win64 ?seekg at istream@@QEAAAEAV1 at J@Z
@ stub -arch=win32 ?seekg at istream@@QAEAAV1 at JW4seek_dir@ios@@@Z
diff --git a/dlls/msvcrt40/msvcrt40.spec b/dlls/msvcrt40/msvcrt40.spec
index de6364a..a3cfbdc 100644
--- a/dlls/msvcrt40/msvcrt40.spec
+++ b/dlls/msvcrt40/msvcrt40.spec
@@ -694,8 +694,8 @@
@ stub -arch=win64 ?read at istream@@QEAAAEAV1 at PEADH@Z
@ stub -arch=win32 ?read at istream@@QAEAAV1 at PAEH@Z
@ stub -arch=win64 ?read at istream@@QEAAAEAV1 at PEAEH@Z
-@ stub -arch=win32 ?sbumpc at streambuf@@QAEHXZ
-@ stub -arch=win64 ?sbumpc at streambuf@@QEAAHXZ
+@ thiscall -arch=win32 ?sbumpc at streambuf@@QAEHXZ(ptr) msvcirt.?sbumpc at streambuf@@QAEHXZ
+@ cdecl -arch=win64 ?sbumpc at streambuf@@QEAAHXZ(ptr) msvcirt.?sbumpc at streambuf@@QEAAHXZ
@ stub -arch=win32 ?seekg at istream@@QAEAAV1 at J@Z
@ stub -arch=win64 ?seekg at istream@@QEAAAEAV1 at J@Z
@ stub -arch=win32 ?seekg at istream@@QAEAAV1 at JW4seek_dir@ios@@@Z
--
2.1.4
More information about the wine-patches
mailing list