Piotr Caban : msvcp90: Use codecvt<char>:: is in basic_istream_char__Ipfx function.

Alexandre Julliard julliard at winehq.org
Thu Jun 14 15:31:30 CDT 2012


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

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Thu Jun 14 15:37:13 2012 +0200

msvcp90: Use codecvt<char>::is in basic_istream_char__Ipfx function.

---

 dlls/msvcp90/ios.c     |    4 ++--
 dlls/msvcp90/locale.c  |   42 ++++++++++++++++++++++++++----------------
 dlls/msvcp90/msvcp90.h |   21 +++++++++++++++++++++
 3 files changed, 49 insertions(+), 18 deletions(-)

diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c
index 43a951d..7102639 100644
--- a/dlls/msvcp90/ios.c
+++ b/dlls/msvcp90/ios.c
@@ -4061,6 +4061,7 @@ MSVCP_bool __thiscall basic_istream_char__Ipfx(basic_istream_char *this, MSVCP_b
 
     if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
+        const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
         int ch;
 
         for(ch = basic_streambuf_char_sgetc(strbuf); ;
@@ -4070,8 +4071,7 @@ MSVCP_bool __thiscall basic_istream_char__Ipfx(basic_istream_char *this, MSVCP_b
                 return FALSE;
             }
 
-            /* TODO: use locale class instead of isspace */
-            if(!isspace(ch))
+            if(!ctype_char_is_ch(ctype, _SPACE|_BLANK, ch))
                 break;
         }
     }
diff --git a/dlls/msvcp90/locale.c b/dlls/msvcp90/locale.c
index 4ad37e8..304c510 100644
--- a/dlls/msvcp90/locale.c
+++ b/dlls/msvcp90/locale.c
@@ -76,13 +76,6 @@ typedef struct {
 typedef struct {
     LCID handle;
     unsigned page;
-    const short *table;
-    int delfl;
-} _Ctypevec;
-
-typedef struct {
-    LCID handle;
-    unsigned page;
 } _Cvtvec;
 
 typedef struct {
@@ -91,15 +84,6 @@ typedef struct {
 } collate;
 
 typedef struct {
-    locale_facet facet;
-} ctype_base;
-
-typedef struct {
-    ctype_base base;
-    _Ctypevec ctype;
-} ctype_char;
-
-typedef struct {
     ctype_base base;
     _Ctypevec ctype;
     _Cvtvec cvt;
@@ -1496,6 +1480,32 @@ MSVCP_size_t __cdecl ctype_char__Getcat(const locale_facet **facet, const locale
     return LC_CTYPE;
 }
 
+ctype_char* ctype_char_use_facet(const locale *loc)
+{
+    static ctype_char *obj = NULL;
+
+    _Lockit lock;
+    const locale_facet *fac;
+
+    _Lockit_ctor_locktype(&lock, _LOCK_LOCALE);
+    fac = locale__Getfacet(loc, ctype_char_id.id);
+    if(fac) {
+        _Lockit_dtor(&lock);
+        return (ctype_char*)fac;
+    }
+
+    if(obj)
+        return obj;
+
+    ctype_char__Getcat(&fac, loc);
+    obj = (ctype_char*)fac;
+    locale_facet__Incref(&obj->base.facet);
+    locale_facet_register(&obj->base.facet);
+    _Lockit_dtor(&lock);
+
+    return obj;
+}
+
 /* _Tolower */
 int __cdecl _Tolower(int ch, const _Ctypevec *ctype)
 {
diff --git a/dlls/msvcp90/msvcp90.h b/dlls/msvcp90/msvcp90.h
index c7260c2..4523845 100644
--- a/dlls/msvcp90/msvcp90.h
+++ b/dlls/msvcp90/msvcp90.h
@@ -311,6 +311,26 @@ int __thiscall codecvt_char_in(const codecvt_char*, int*, const char*,
         const char*, const char**, char*, char*, char**);
 int __thiscall codecvt_base_max_length(const codecvt_base*);
 
+typedef struct {
+    LCID handle;
+    unsigned page;
+    const short *table;
+    int delfl;
+} _Ctypevec;
+
+/* class ctype_base */
+typedef struct {
+    locale_facet facet;
+} ctype_base;
+
+/* class ctype<char> */
+typedef struct {
+    ctype_base base;
+    _Ctypevec ctype;
+} ctype_char;
+
+MSVCP_bool __thiscall ctype_char_is_ch(const ctype_char*, short, char);
+
 /* class locale */
 typedef struct
 {
@@ -323,6 +343,7 @@ locale* __thiscall locale_operator_assign(locale*, const locale*);
 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*);
 
 /* class _Lockit */
 typedef struct {




More information about the wine-cvs mailing list