From e97578e4071831dcc2380802c1aae2dac2ff8a7c Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Tue, 6 Dec 2011 12:48:46 +0100 Subject: [PATCH] msvcp90: Added _Locinfo constructor implementation. --- dlls/msvcp90/locale.c | 84 ++++++++++++++++++++++++++---------------- dlls/msvcp90/msvcp90.h | 2 +- dlls/msvcp90/string.c | 4 +- 3 files changed, 56 insertions(+), 34 deletions(-) diff --git a/dlls/msvcp90/locale.c b/dlls/msvcp90/locale.c index e928d3e241d..26147245687 100644 --- a/dlls/msvcp90/locale.c +++ b/dlls/msvcp90/locale.c @@ -712,29 +712,35 @@ void* __thiscall _Timevec__Getptr(_Timevec *this) return this->timeptr; } -/* ?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z */ -/* ?_Locinfo_ctor@_Locinfo@std@@SAXPEAV12@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z */ -_Locinfo* __cdecl _Locinfo__Locinfo_ctor_bstr(_Locinfo *locinfo, const basic_string_char *locstr) -{ - FIXME("(%p %p) stub\n", locinfo, locstr); - return NULL; -} - -/* ??0_Locinfo@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */ -/* ??0_Locinfo@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */ -DEFINE_THISCALL_WRAPPER(_Locinfo_ctor_bstr, 8) -_Locinfo* __thiscall _Locinfo_ctor_bstr(_Locinfo *this, const basic_string_char *locstr) -{ - FIXME("(%p %p) stub\n", this, locstr); - return NULL; -} - /* ?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@HPBD@Z */ /* ?_Locinfo_ctor@_Locinfo@std@@SAXPEAV12@HPEBD@Z */ _Locinfo* __cdecl _Locinfo__Locinfo_ctor_cat_cstr(_Locinfo *locinfo, int category, const char *locstr) { - FIXME("(%p %d %s) stub\n", locinfo, category, locstr); - return NULL; + const char *locale = NULL; + + /* This function is probably modifying more global objects */ + FIXME("(%p %d %s) semi-stub\n", locinfo, category, locstr); + + if(!locstr) + throw_exception(EXCEPTION_RUNTIME_ERROR, "bad locale name"); + + _Lockit_ctor_locktype(&locinfo->lock, _LOCK_LOCALE); + MSVCP_basic_string_char_ctor_cstr(&locinfo->days, ""); + MSVCP_basic_string_char_ctor_cstr(&locinfo->months, ""); + MSVCP_basic_string_char_ctor_cstr(&locinfo->oldlocname, setlocale(LC_ALL, NULL)); + + if(category) + locale = setlocale(LC_ALL, locstr); + else + locale = setlocale(LC_ALL, NULL); + + if(locale) + MSVCP_basic_string_char_ctor_cstr(&locinfo->newlocname, locale); + else + MSVCP_basic_string_char_ctor_cstr(&locinfo->newlocname, "*"); + _Lockit_dtor(&locinfo->lock); + + return locinfo; } /* ??0_Locinfo@std@@QAE@HPBD@Z */ @@ -742,16 +748,29 @@ _Locinfo* __cdecl _Locinfo__Locinfo_ctor_cat_cstr(_Locinfo *locinfo, int categor DEFINE_THISCALL_WRAPPER(_Locinfo_ctor_cat_cstr, 12) _Locinfo* __thiscall _Locinfo_ctor_cat_cstr(_Locinfo *this, int category, const char *locstr) { - FIXME("(%p %d %s) stub\n", this, category, locstr); - return NULL; + return _Locinfo__Locinfo_ctor_cat_cstr(this, category, locstr); +} + +/* ?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z */ +/* ?_Locinfo_ctor@_Locinfo@std@@SAXPEAV12@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z */ +_Locinfo* __cdecl _Locinfo__Locinfo_ctor_bstr(_Locinfo *locinfo, const basic_string_char *locstr) +{ + return _Locinfo__Locinfo_ctor_cat_cstr(locinfo, 1/*FIXME*/, MSVCP_basic_string_char_c_str(locstr)); +} + +/* ??0_Locinfo@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */ +/* ??0_Locinfo@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */ +DEFINE_THISCALL_WRAPPER(_Locinfo_ctor_bstr, 8) +_Locinfo* __thiscall _Locinfo_ctor_bstr(_Locinfo *this, const basic_string_char *locstr) +{ + return _Locinfo__Locinfo_ctor_cat_cstr(this, 1/*FIXME*/, MSVCP_basic_string_char_c_str(locstr)); } /* ?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@PBD@Z */ /* ?_Locinfo_ctor@_Locinfo@std@@SAXPEAV12@PEBD@Z */ _Locinfo* __cdecl _Locinfo__Locinfo_ctor_cstr(_Locinfo *locinfo, const char *locstr) { - FIXME("(%p %s) stub\n", locinfo, locstr); - return NULL; + return _Locinfo__Locinfo_ctor_cat_cstr(locinfo, 1/*FIXME*/, locstr); } /* ??0_Locinfo@std@@QAE@PBD@Z */ @@ -759,16 +778,20 @@ _Locinfo* __cdecl _Locinfo__Locinfo_ctor_cstr(_Locinfo *locinfo, const char *loc DEFINE_THISCALL_WRAPPER(_Locinfo_ctor_cstr, 8) _Locinfo* __thiscall _Locinfo_ctor_cstr(_Locinfo *this, const char *locstr) { - FIXME("(%p %s) stub\n", this, locstr); - return NULL; + return _Locinfo__Locinfo_ctor_cat_cstr(this, 1/*FIXME*/, locstr); } /* ?_Locinfo_dtor@_Locinfo@std@@SAXPAV12@@Z */ /* ?_Locinfo_dtor@_Locinfo@std@@SAXPEAV12@@Z */ -_Locinfo* __cdecl _Locinfo__Locinfo_dtor(_Locinfo *locinfo) +void __cdecl _Locinfo__Locinfo_dtor(_Locinfo *locinfo) { - FIXME("(%p) stub\n", locinfo); - return NULL; + TRACE("(%p)\n", locinfo); + + setlocale(LC_ALL, MSVCP_basic_string_char_c_str(&locinfo->oldlocname)); + MSVCP_basic_string_char_dtor(&locinfo->days); + MSVCP_basic_string_char_dtor(&locinfo->months); + MSVCP_basic_string_char_dtor(&locinfo->oldlocname); + MSVCP_basic_string_char_dtor(&locinfo->newlocname); } /* ??_F_Locinfo@std@@QAEXXZ */ @@ -776,8 +799,7 @@ _Locinfo* __cdecl _Locinfo__Locinfo_dtor(_Locinfo *locinfo) DEFINE_THISCALL_WRAPPER(_Locinfo_ctor, 4) _Locinfo* __thiscall _Locinfo_ctor(_Locinfo *this) { - FIXME("(%p) stub\n", this); - return NULL; + return _Locinfo__Locinfo_ctor_cat_cstr(this, 1/*FIXME*/, "C"); } /* ??1_Locinfo@std@@QAE@XZ */ @@ -785,7 +807,7 @@ _Locinfo* __thiscall _Locinfo_ctor(_Locinfo *this) DEFINE_THISCALL_WRAPPER(_Locinfo_dtor, 4) void __thiscall _Locinfo_dtor(_Locinfo *this) { - FIXME("(%p) stub\n", this); + _Locinfo__Locinfo_dtor(this); } /* ?_Locinfo_Addcats@_Locinfo@std@@SAAAV12@PAV12@HPBD@Z */ diff --git a/dlls/msvcp90/msvcp90.h b/dlls/msvcp90/msvcp90.h index 72e5d11a449..ed66d23725b 100644 --- a/dlls/msvcp90/msvcp90.h +++ b/dlls/msvcp90/msvcp90.h @@ -172,7 +172,7 @@ typedef struct _basic_string_char basic_string_char* __stdcall MSVCP_basic_string_char_ctor_cstr(basic_string_char*, const char*); basic_string_char* __stdcall MSVCP_basic_string_char_copy_ctor(basic_string_char*, const basic_string_char*); void __stdcall MSVCP_basic_string_char_dtor(basic_string_char*); -const char* __stdcall MSVCP_basic_string_char_c_str(basic_string_char*); +const char* __stdcall MSVCP_basic_string_char_c_str(const basic_string_char*); #define BUF_SIZE_WCHAR 8 typedef struct _basic_string_wchar diff --git a/dlls/msvcp90/string.c b/dlls/msvcp90/string.c index 19459c1d194..906a99c3f6b 100644 --- a/dlls/msvcp90/string.c +++ b/dlls/msvcp90/string.c @@ -882,7 +882,7 @@ MSVCP_size_t __thiscall basic_string_char_copy(const basic_string_char *this, /* ?data@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ */ /* ?data@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEBDXZ */ DEFINE_THISCALL_WRAPPER(MSVCP_basic_string_char_c_str, 4) -const char* __thiscall MSVCP_basic_string_char_c_str(basic_string_char *this) +const char* __thiscall MSVCP_basic_string_char_c_str(const basic_string_char *this) { TRACE("%p\n", this); return basic_string_char_const_ptr(this); @@ -2724,7 +2724,7 @@ MSVCP_size_t __thiscall basic_string_wchar_copy(const basic_string_wchar *this, /* ?data@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBEPBGXZ */ /* ?data@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEBAPEBGXZ */ DEFINE_THISCALL_WRAPPER(MSVCP_basic_string_wchar_c_str, 4) -const wchar_t* __thiscall MSVCP_basic_string_wchar_c_str(basic_string_wchar *this) +const wchar_t* __thiscall MSVCP_basic_string_wchar_c_str(const basic_string_wchar *this) { TRACE("%p\n", this); return basic_string_wchar_const_ptr(this);