[3/8] msvcirt: Implement ostream::operator<< for strings

Iván Matellanes matellanesivan at gmail.com
Tue Jun 21 04:54:22 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 f19d6bd..df6f514 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 63f41c7..11f680b 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,9 +3016,10 @@ static void test_ostream_print(void)
     int i;
 
     struct ostream_print_test {
-        enum { CHAR } type;
+        enum { CHAR, STR } type;
         union {
             char c;
+            const char *str;
         } param;
         ios_io_state state;
         ios_flags flags;
@@ -3036,7 +3040,18 @@ static void test_ostream_print(void)
         {CHAR, {.c = 'a'}, IOSTATE_goodbit, FLAGS_internal|FLAGS_hex|FLAGS_showbase, 6, ' ', 4, "   a", IOSTATE_goodbit},
         {CHAR, {.c = '9'}, IOSTATE_goodbit, FLAGS_oct|FLAGS_showbase|FLAGS_uppercase, 6, 'i', 2, "i9", IOSTATE_goodbit},
         {CHAR, {.c = '9'}, IOSTATE_goodbit, FLAGS_showpos|FLAGS_scientific, 0, 'i', 2, "i9", IOSTATE_goodbit},
-        {CHAR, {.c = 'e'}, IOSTATE_goodbit, FLAGS_left|FLAGS_right|FLAGS_uppercase, 0, '*', 8, "e*******", IOSTATE_goodbit}
+        {CHAR, {.c = 'e'}, IOSTATE_goodbit, FLAGS_left|FLAGS_right|FLAGS_uppercase, 0, '*', 8, "e*******", IOSTATE_goodbit},
+        /* const char* */
+        {STR, {.str = "Test"}, IOSTATE_badbit, 0, 6, ' ', 0, "", IOSTATE_badbit|IOSTATE_failbit},
+        {STR, {.str = "Test"}, IOSTATE_eofbit, 0, 6, ' ', 0, "", IOSTATE_eofbit|IOSTATE_failbit},
+        {STR, {.str = "Test"}, IOSTATE_goodbit, 0, 6, ' ', 0, "Test", IOSTATE_goodbit},
+        {STR, {.str = "Test"}, IOSTATE_goodbit, 0, 6, ' ', 6, "  Test", IOSTATE_goodbit},
+        {STR, {.str = "Test"}, IOSTATE_goodbit, FLAGS_internal, 6, 'x', 6, "xxTest", IOSTATE_goodbit},
+        {STR, {.str = "Test"}, IOSTATE_goodbit, FLAGS_left, 6, ' ', 5, "Test ", IOSTATE_goodbit},
+        {STR, {.str = "Test"}, IOSTATE_goodbit, FLAGS_left|FLAGS_hex|FLAGS_showpoint, 6, '?', 6, "Test??", IOSTATE_goodbit},
+        {STR, {.str = "800"}, IOSTATE_goodbit, FLAGS_showbase|FLAGS_showpos, 6, ' ', 4, " 800", IOSTATE_goodbit},
+        {STR, {.str = "3.14159"}, IOSTATE_goodbit, FLAGS_scientific, 2, 'x', 2, "3.14159", IOSTATE_goodbit},
+        {STR, {.str = " Test"}, IOSTATE_goodbit, FLAGS_skipws, 6, 'x', 2, " Test", IOSTATE_goodbit}
     };
 
     pssb = (strstreambuf*) call_func1(p_strstreambuf_ctor, &ssb);
@@ -3055,6 +3070,8 @@ static void test_ostream_print(void)
         switch (tests[i].type) {
         case CHAR:
             pos = (ostream*) call_func2(p_ostream_print_char, &os, (int) tests[i].param.c); break;
+        case STR:
+            pos = (ostream*) call_func2(p_ostream_print_str, &os, tests[i].param.str); break;
         }
 
         length = ssb.base.pptr - ssb.base.pbase;
-- 
2.7.4




More information about the wine-patches mailing list