[v2 2/7] msvcirt: Implement ostream::operator<< for strings
Iván Matellanes
matellanesivan at gmail.com
Wed Jun 22 04:53:03 CDT 2016
Signed-off-by: Iván Matellanes <matellanes.ivan at gmail.com>
---
dlls/msvcirt/msvcirt.c | 9 ++++++---
dlls/msvcirt/tests/msvcirt.c | 21 +++++++++++++++++++--
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c
index a09b4d6..9ec61c3 100644
--- a/dlls/msvcirt/msvcirt.c
+++ b/dlls/msvcirt/msvcirt.c
@@ -2625,7 +2625,11 @@ ostream* __thiscall ostream_print_unsigned_char(ostream *this, unsigned char c)
DEFINE_THISCALL_WRAPPER(ostream_print_str, 8)
ostream* __thiscall ostream_print_str(ostream *this, const char *str)
{
- FIXME("(%p %s) stub\n", this, str);
+ TRACE("(%p %s)\n", this, str);
+ if (ostream_opfx(this)) {
+ ostream_writepad(this, "", str);
+ ostream_osfx(this);
+ }
return this;
}
@@ -2634,8 +2638,7 @@ ostream* __thiscall ostream_print_str(ostream *this, const char *str)
DEFINE_THISCALL_WRAPPER(ostream_print_unsigned_str, 8)
ostream* __thiscall ostream_print_unsigned_str(ostream *this, const unsigned char *str)
{
- FIXME("(%p %s) stub\n", this, str);
- return this;
+ return ostream_print_str(this, (const char*) str);
}
/* ??6ostream@@QAEAAV0 at F@Z */
diff --git a/dlls/msvcirt/tests/msvcirt.c b/dlls/msvcirt/tests/msvcirt.c
index c126807..46d2e97 100644
--- a/dlls/msvcirt/tests/msvcirt.c
+++ b/dlls/msvcirt/tests/msvcirt.c
@@ -271,6 +271,7 @@ static ostream* (*__thiscall p_ostream_seekp)(ostream*, streampos);
static streampos (*__thiscall p_ostream_tellp)(ostream*);
static ostream* (*__thiscall p_ostream_writepad)(ostream*, const char*, const char*);
static ostream* (*__thiscall p_ostream_print_char)(ostream*, char);
+static ostream* (*__thiscall p_ostream_print_str)(ostream*, const char*);
/* Emulate a __thiscall */
#ifdef __i386__
@@ -446,6 +447,7 @@ static BOOL init(void)
SET(p_ostream_tellp, "?tellp at ostream@@QEAAJXZ");
SET(p_ostream_writepad, "?writepad at ostream@@AEAAAEAV1 at PEBD0@Z");
SET(p_ostream_print_char, "??6ostream@@QEAAAEAV0 at D@Z");
+ SET(p_ostream_print_str, "??6ostream@@QEAAAEAV0 at PEBD@Z");
} else {
p_operator_new = (void*)GetProcAddress(msvcrt, "??2 at YAPAXI@Z");
p_operator_delete = (void*)GetProcAddress(msvcrt, "??3 at YAXPAX@Z");
@@ -551,6 +553,7 @@ static BOOL init(void)
SET(p_ostream_tellp, "?tellp at ostream@@QAEJXZ");
SET(p_ostream_writepad, "?writepad at ostream@@AAEAAV1 at PBD0@Z");
SET(p_ostream_print_char, "??6ostream@@QAEAAV0 at D@Z");
+ SET(p_ostream_print_str, "??6ostream@@QAEAAV0 at PBD@Z");
}
SET(p_ios_static_lock, "?x_lockc at ios@@0U_CRT_CRITICAL_SECTION@@A");
SET(p_ios_lockc, "?lockc at ios@@KAXXZ");
@@ -3013,8 +3016,9 @@ static void test_ostream_print(void)
int i;
char param_char[] = {'a', '9', 'e'};
+ const char* param_str[] = {"Test", "800", "3.14159", " Test"};
struct ostream_print_test {
- enum { CHAR } type;
+ enum { CHAR, STR } type;
int param_index;
ios_io_state state;
ios_flags flags;
@@ -3035,7 +3039,18 @@ static void test_ostream_print(void)
{CHAR, /* 'a' */ 0, IOSTATE_goodbit, FLAGS_internal|FLAGS_hex|FLAGS_showbase, 6, ' ', 4, " a", IOSTATE_goodbit},
{CHAR, /* '9' */ 1, IOSTATE_goodbit, FLAGS_oct|FLAGS_showbase|FLAGS_uppercase, 6, 'i', 2, "i9", IOSTATE_goodbit},
{CHAR, /* '9' */ 1, IOSTATE_goodbit, FLAGS_showpos|FLAGS_scientific, 0, 'i', 2, "i9", IOSTATE_goodbit},
- {CHAR, /* 'e' */ 2, IOSTATE_goodbit, FLAGS_left|FLAGS_right|FLAGS_uppercase, 0, '*', 8, "e*******", IOSTATE_goodbit}
+ {CHAR, /* 'e' */ 2, IOSTATE_goodbit, FLAGS_left|FLAGS_right|FLAGS_uppercase, 0, '*', 8, "e*******", IOSTATE_goodbit},
+ /* const char* */
+ {STR, /* "Test" */ 0, IOSTATE_badbit, 0, 6, ' ', 0, "", IOSTATE_badbit|IOSTATE_failbit},
+ {STR, /* "Test" */ 0, IOSTATE_eofbit, 0, 6, ' ', 0, "", IOSTATE_eofbit|IOSTATE_failbit},
+ {STR, /* "Test" */ 0, IOSTATE_goodbit, 0, 6, ' ', 0, "Test", IOSTATE_goodbit},
+ {STR, /* "Test" */ 0, IOSTATE_goodbit, 0, 6, ' ', 6, " Test", IOSTATE_goodbit},
+ {STR, /* "Test" */ 0, IOSTATE_goodbit, FLAGS_internal, 6, 'x', 6, "xxTest", IOSTATE_goodbit},
+ {STR, /* "Test" */ 0, IOSTATE_goodbit, FLAGS_left, 6, ' ', 5, "Test ", IOSTATE_goodbit},
+ {STR, /* "Test" */ 0, IOSTATE_goodbit, FLAGS_left|FLAGS_hex|FLAGS_showpoint, 6, '?', 6, "Test??", IOSTATE_goodbit},
+ {STR, /* "800" */ 1, IOSTATE_goodbit, FLAGS_showbase|FLAGS_showpos, 6, ' ', 4, " 800", IOSTATE_goodbit},
+ {STR, /* "3.14159" */ 2, IOSTATE_goodbit, FLAGS_scientific, 2, 'x', 2, "3.14159", IOSTATE_goodbit},
+ {STR, /* " Test" */ 3, IOSTATE_goodbit, FLAGS_skipws, 6, 'x', 2, " Test", IOSTATE_goodbit}
};
pssb = call_func1(p_strstreambuf_ctor, &ssb);
@@ -3054,6 +3069,8 @@ static void test_ostream_print(void)
switch (tests[i].type) {
case CHAR:
pos = call_func2(p_ostream_print_char, &os, (int) param_char[tests[i].param_index]); break;
+ case STR:
+ pos = call_func2(p_ostream_print_str, &os, param_str[tests[i].param_index]); break;
}
length = ssb.base.pptr - ssb.base.pbase;
--
2.7.4
More information about the wine-patches
mailing list