Piotr Caban : msvcp90: Added partial collate<wchar_t> implementation.
Alexandre Julliard
julliard at winehq.org
Wed Dec 21 12:38:08 CST 2011
Module: wine
Branch: master
Commit: bb002e27b35bb4d7f5620f97bcebd0745a1b7efe
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bb002e27b35bb4d7f5620f97bcebd0745a1b7efe
Author: Piotr Caban <piotr at codeweavers.com>
Date: Wed Dec 21 15:57:46 2011 +0100
msvcp90: Added partial collate<wchar_t> implementation.
---
dlls/msvcp90/locale.c | 97 ++++++++++++++++++++++++++++++++-------------
dlls/msvcp90/msvcp90.spec | 2 +-
2 files changed, 70 insertions(+), 29 deletions(-)
diff --git a/dlls/msvcp90/locale.c b/dlls/msvcp90/locale.c
index 7b0fa5f..b8c4b11 100644
--- a/dlls/msvcp90/locale.c
+++ b/dlls/msvcp90/locale.c
@@ -833,14 +833,36 @@ extern const vtable_ptr MSVCP_collate_wchar_vtable;
/* ??_7?$collate at G@std@@6B@ */
extern const vtable_ptr MSVCP_collate_short_vtable;
+/* ?_Init@?$collate at _W@std@@IAEXABV_Locinfo at 2@@Z */
+/* ?_Init@?$collate at _W@std@@IEAAXAEBV_Locinfo at 2@@Z */
+/* ?_Init@?$collate at G@std@@IAEXABV_Locinfo at 2@@Z */
+/* ?_Init@?$collate at G@std@@IEAAXAEBV_Locinfo at 2@@Z */
+DEFINE_THISCALL_WRAPPER(collate_wchar__Init, 8)
+void __thiscall collate_wchar__Init(collate *this, const _Locinfo *locinfo)
+{
+ TRACE("(%p %p)\n", this, locinfo);
+ this->coll = _Locinfo__Getcoll(locinfo);
+}
+
/* ??0?$collate at _W@std@@IAE at PBDI@Z */
/* ??0?$collate at _W@std@@IEAA at PEBD_K@Z */
DEFINE_THISCALL_WRAPPER(collate_wchar_ctor_name, 12)
collate* __thiscall collate_wchar_ctor_name(collate *this, const char *name, MSVCP_size_t refs)
{
- FIXME("(%p %s %lu) stub\n", this, name, refs);
+ _Lockit lockit;
+ _Locinfo locinfo;
+
+ TRACE("(%p %s %lu)\n", this, name, refs);
+
+ locale_facet_ctor_refs(&this->facet, refs);
this->facet.vtable = &MSVCP_collate_wchar_vtable;
- return NULL;
+
+ _Lockit_ctor_locktype(&lockit, _LOCK_LOCALE);
+ _Locinfo_ctor_cstr(&locinfo, name);
+ collate_wchar__Init(this, &locinfo);
+ _Locinfo_dtor(&locinfo);
+ _Lockit_dtor(&lockit);
+ return this;
}
/* ??0?$collate at G@std@@IAE at PBDI@Z */
@@ -858,9 +880,12 @@ collate* __thiscall collate_short_ctor_name(collate *this, const char *name, MSV
DEFINE_THISCALL_WRAPPER(collate_wchar_ctor_locinfo, 12)
collate* __thiscall collate_wchar_ctor_locinfo(collate *this, _Locinfo *locinfo, MSVCP_size_t refs)
{
- FIXME("(%p %p %lu) stub\n", this, locinfo, refs);
+ TRACE("(%p %p %lu)\n", this, locinfo, refs);
+
+ locale_facet_ctor_refs(&this->facet, refs);
this->facet.vtable = &MSVCP_collate_wchar_vtable;
- return NULL;
+ collate_wchar__Init(this, locinfo);
+ return this;
}
/* ??0?$collate at G@std@@QAE at ABV_Locinfo@1 at I@Z */
@@ -878,9 +903,7 @@ collate* __thiscall collate_short_ctor_locinfo(collate *this, _Locinfo *locinfo,
DEFINE_THISCALL_WRAPPER(collate_wchar_ctor_refs, 8)
collate* __thiscall collate_wchar_ctor_refs(collate *this, MSVCP_size_t refs)
{
- FIXME("(%p %lu) stub\n", this, refs);
- this->facet.vtable = &MSVCP_collate_wchar_vtable;
- return NULL;
+ return collate_wchar_ctor_name(this, "C", refs);
}
/* ??0?$collate at G@std@@QAE at I@Z */
@@ -900,7 +923,7 @@ collate* __thiscall collate_short_ctor_refs(collate *this, MSVCP_size_t refs)
DEFINE_THISCALL_WRAPPER(collate_wchar_dtor, 4)
void __thiscall collate_wchar_dtor(collate *this)
{
- FIXME("(%p) stub\n", this);
+ TRACE("(%p)\n", this);
}
DEFINE_THISCALL_WRAPPER(MSVCP_collate_wchar_vector_dtor, 8)
@@ -934,9 +957,7 @@ collate* __thiscall MSVCP_collate_short_vector_dtor(collate *this, unsigned int
DEFINE_THISCALL_WRAPPER(collate_wchar_ctor, 4)
collate* __thiscall collate_wchar_ctor(collate *this)
{
- FIXME("(%p) stub\n", this);
- this->facet.vtable = &MSVCP_collate_wchar_vtable;
- return NULL;
+ return collate_wchar_ctor_name(this, "C", 0);
}
/* ??_F?$collate at G@std@@QAEXXZ */
@@ -955,18 +976,28 @@ collate* __thiscall collate_short_ctor(collate *this)
/* ?_Getcat@?$collate at G@std@@SA_KPEAPEBVfacet at locale@2 at PEBV42@@Z */
MSVCP_size_t __cdecl collate_wchar__Getcat(const locale_facet **facet, const locale *loc)
{
- FIXME("(%p %p) stub\n", facet, loc);
- return 0;
+ TRACE("(%p %p)\n", facet, loc);
+
+ if(facet && !*facet) {
+ *facet = MSVCRT_operator_new(sizeof(collate));
+ if(!*facet) {
+ ERR("Out of memory\n");
+ throw_exception(EXCEPTION_BAD_ALLOC, NULL);
+ return 0;
+ }
+ collate_wchar_ctor_name((collate*)*facet,
+ MSVCP_basic_string_char_c_str(&loc->ptr->name), 0);
+ }
+
+ return LC_COLLATE;
}
-/* ?_Init@?$collate at _W@std@@IAEXABV_Locinfo at 2@@Z */
-/* ?_Init@?$collate at _W@std@@IEAAXAEBV_Locinfo at 2@@Z */
-/* ?_Init@?$collate at G@std@@IAEXABV_Locinfo at 2@@Z */
-/* ?_Init@?$collate at G@std@@IEAAXAEBV_Locinfo at 2@@Z */
-DEFINE_THISCALL_WRAPPER(collate_wchar__Init, 8)
-void __thiscall collate_wchar__Init(collate *this, const _Locinfo *locinfo)
+/* _Wcscoll */
+int __cdecl _Wcscoll(const wchar_t *first1, const wchar_t *last1, const wchar_t *first2,
+ const wchar_t *last2, const _Collvec *coll)
{
- FIXME("(%p %p) stub\n", this, locinfo);
+ TRACE("(%s %s)\n", debugstr_wn(first1, last1-first1), debugstr_wn(first2, last2-first2));
+ return CompareStringW(coll->handle, 0, first1, last1-first1, first2, last2-first2)-2;
}
/* ?do_compare@?$collate at _W@std@@MBEHPB_W000 at Z */
@@ -974,11 +1005,14 @@ void __thiscall collate_wchar__Init(collate *this, const _Locinfo *locinfo)
/* ?do_compare@?$collate at G@std@@MBEHPBG000 at Z */
/* ?do_compare@?$collate at G@std@@MEBAHPEBG000 at Z */
DEFINE_THISCALL_WRAPPER(collate_wchar_do_compare, 20)
+#define call_collate_wchar_do_compare(this, first1, last1, first2, last2) CALL_VTBL_FUNC(this, 4, int, \
+ (const collate*, const wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*), \
+ (this, first1, last1, first2, last2))
int __thiscall collate_wchar_do_compare(const collate *this, const wchar_t *first1,
const wchar_t *last1, const wchar_t *first2, const wchar_t *last2)
{
- FIXME("(%p %p %p %p %p) stub\n", this, first1, last1, first2, last2);
- return 0;
+ TRACE("(%p %p %p %p %p)\n", this, first1, last1, first2, last2);
+ return _Wcscoll(first1, last1, first2, last2, &this->coll);
}
/* ?compare@?$collate at _W@std@@QBEHPB_W000 at Z */
@@ -989,8 +1023,8 @@ DEFINE_THISCALL_WRAPPER(collate_wchar_compare, 20)
int __thiscall collate_wchar_compare(const collate *this, const wchar_t *first1,
const wchar_t *last1, const wchar_t *first2, const wchar_t *last2)
{
- FIXME("(%p %p %p %p %p) stub\n", this, first1, last1, first2, last2);
- return 0;
+ TRACE("(%p %p %p %p %p)\n", this, first1, last1, first2, last2);
+ return call_collate_wchar_do_compare(this, first1, last1, first2, last2);
}
/* ?do_hash@?$collate at _W@std@@MBEJPB_W0 at Z */
@@ -998,11 +1032,18 @@ int __thiscall collate_wchar_compare(const collate *this, const wchar_t *first1,
/* ?do_hash@?$collate at G@std@@MBEJPBG0 at Z */
/* ?do_hash@?$collate at G@std@@MEBAJPEBG0 at Z */
DEFINE_THISCALL_WRAPPER(collate_wchar_do_hash, 12)
+#define call_collate_wchar_do_hash(this, first, last) CALL_VTBL_FUNC(this, 12, LONG, \
+ (const collate*, const wchar_t*, const wchar_t*), (this, first, last))
LONG __thiscall collate_wchar_do_hash(const collate *this,
const wchar_t *first, const wchar_t *last)
{
- FIXME("(%p %p %p) stub\n", this, first, last);
- return 0;
+ ULONG ret = 0;
+
+ TRACE("(%p %p %p)\n", this, first, last);
+
+ for(; first<last; first++)
+ ret = (ret<<8 | ret>>24) + *first;
+ return ret;
}
/* ?hash@?$collate at _W@std@@QBEJPB_W0 at Z */
@@ -1013,8 +1054,8 @@ DEFINE_THISCALL_WRAPPER(collate_wchar_hash, 12)
LONG __thiscall collate_wchar_hash(const collate *this,
const wchar_t *first, const wchar_t *last)
{
- FIXME("(%p %p %p) stub\n", this, first, last);
- return 0;
+ TRACE("(%p %p %p)\n", this, first, last);
+ return call_collate_wchar_do_hash(this, first, last);
}
/* ?do_transform@?$collate at _W@std@@MBE?AV?$basic_string at _WU?$char_traits at _W@std@@V?$allocator at _W@2@@2 at PB_W0@Z */
diff --git a/dlls/msvcp90/msvcp90.spec b/dlls/msvcp90/msvcp90.spec
index 687bacc..f53b579 100644
--- a/dlls/msvcp90/msvcp90.spec
+++ b/dlls/msvcp90/msvcp90.spec
@@ -5803,7 +5803,7 @@
@ stub _Towlower
@ stub _Towupper
@ stub _Wcrtomb
-@ stub _Wcscoll
+@ cdecl _Wcscoll(ptr ptr ptr ptr ptr)
@ stub _Wcsxfrm
# extern _Xbig
@ stub __Wcrtomb_lk
More information about the wine-cvs
mailing list