Piotr Caban : msvcp90: Added basic_ios::narrow implementation.

Alexandre Julliard julliard at winehq.org
Fri Jun 15 13:34:39 CDT 2012


Module: wine
Branch: master
Commit: 65a364a2f30b9fb16949008f325a03381eaf4d15
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=65a364a2f30b9fb16949008f325a03381eaf4d15

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Fri Jun 15 11:09:04 2012 +0200

msvcp90: Added basic_ios::narrow implementation.

---

 dlls/msvcp90/ios.c     |    8 ++++----
 dlls/msvcp90/locale.c  |   37 ++++++++++++++++++++++++++-----------
 dlls/msvcp90/msvcp90.h |   16 ++++++++++++++++
 3 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c
index 6a628dd..c69b5c5 100644
--- a/dlls/msvcp90/ios.c
+++ b/dlls/msvcp90/ios.c
@@ -3186,8 +3186,8 @@ locale *__thiscall basic_ios_char_imbue(basic_ios_char *this, locale *ret, const
 DEFINE_THISCALL_WRAPPER(basic_ios_char_narrow, 12)
 char __thiscall basic_ios_char_narrow(basic_ios_char *this, char ch, char def)
 {
-    FIXME("(%p %c %c) stub\n", this, ch, def);
-    return def;
+    TRACE("(%p %c %c)\n", this, ch, def);
+    return ctype_char_narrow_ch(ctype_char_use_facet(this->strbuf->loc), ch, def);
 }
 
 /* ?rdbuf@?$basic_ios at DU?$char_traits at D@std@@@std@@QAEPAV?$basic_streambuf at DU?$char_traits at D@std@@@2 at PAV32@@Z */
@@ -3452,8 +3452,8 @@ locale *__thiscall basic_ios_wchar_imbue(basic_ios_wchar *this, locale *ret, con
 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_narrow, 12)
 char __thiscall basic_ios_wchar_narrow(basic_ios_wchar *this, wchar_t ch, char def)
 {
-    FIXME("(%p %c %c) stub\n", this, ch, def);
-    return def;
+    TRACE("(%p %c %c)\n", this, ch, def);
+    return ctype_wchar_narrow_ch(ctype_wchar_use_facet(this->strbuf->loc), ch, def);
 }
 
 /* ?rdbuf@?$basic_ios at _WU?$char_traits at _W@std@@@std@@QAEPAV?$basic_streambuf at _WU?$char_traits at _W@std@@@2 at PAV32@@Z */
diff --git a/dlls/msvcp90/locale.c b/dlls/msvcp90/locale.c
index 304c510..57eac2b 100644
--- a/dlls/msvcp90/locale.c
+++ b/dlls/msvcp90/locale.c
@@ -74,22 +74,11 @@ typedef struct {
 } _Collvec;
 
 typedef struct {
-    LCID handle;
-    unsigned page;
-} _Cvtvec;
-
-typedef struct {
     locale_facet facet;
     _Collvec coll;
 } collate;
 
 typedef struct {
-    ctype_base base;
-    _Ctypevec ctype;
-    _Cvtvec cvt;
-} ctype_wchar;
-
-typedef struct {
     locale_facet facet;
     const char *grouping;
     char dp;
@@ -2235,6 +2224,32 @@ wchar_t __cdecl _Towlower(wchar_t ch, const _Ctypevec *ctype)
     return tolowerW(ch);
 }
 
+ctype_wchar* ctype_wchar_use_facet(const locale *loc)
+{
+    static ctype_wchar *obj = NULL;
+
+    _Lockit lock;
+    const locale_facet *fac;
+
+    _Lockit_ctor_locktype(&lock, _LOCK_LOCALE);
+    fac = locale__Getfacet(loc, ctype_wchar_id.id);
+    if(fac) {
+        _Lockit_dtor(&lock);
+        return (ctype_wchar*)fac;
+    }
+
+    if(obj)
+        return obj;
+
+    ctype_wchar__Getcat(&fac, loc);
+    obj = (ctype_wchar*)fac;
+    locale_facet__Incref(&obj->base.facet);
+    locale_facet_register(&obj->base.facet);
+    _Lockit_dtor(&lock);
+
+    return obj;
+}
+
 /* ?do_tolower@?$ctype at _W@std@@MBE_W_W at Z */
 /* ?do_tolower@?$ctype at _W@std@@MEBA_W_W at Z */
 /* ?do_tolower@?$ctype at G@std@@MBEGG at Z */
diff --git a/dlls/msvcp90/msvcp90.h b/dlls/msvcp90/msvcp90.h
index 45adcc9..8550ad8 100644
--- a/dlls/msvcp90/msvcp90.h
+++ b/dlls/msvcp90/msvcp90.h
@@ -331,6 +331,21 @@ typedef struct {
 } ctype_char;
 
 MSVCP_bool __thiscall ctype_char_is_ch(const ctype_char*, short, char);
+char __thiscall ctype_char_narrow_ch(const ctype_char*, char, char);
+
+typedef struct {
+    LCID handle;
+    unsigned page;
+} _Cvtvec;
+
+/* class ctype<wchar> */
+typedef struct {
+    ctype_base base;
+    _Ctypevec ctype;
+    _Cvtvec cvt;
+} ctype_wchar;
+
+char __thiscall ctype_wchar_narrow_ch(const ctype_wchar*, wchar_t, char);
 
 /* class locale */
 typedef struct
@@ -345,6 +360,7 @@ void __thiscall locale_dtor(locale*);
 void free_locale(void);
 codecvt_char* codecvt_char_use_facet(const locale*);
 ctype_char* ctype_char_use_facet(const locale*);
+ctype_wchar* ctype_wchar_use_facet(const locale*);
 
 /* class _Lockit */
 typedef struct {




More information about the wine-cvs mailing list