From d274fdb029ed7bfeee9d5bdd0d28ca9c61641659 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Sat, 4 Oct 2014 17:32:20 +0200 Subject: [PATCH] msvcp90: Added locale_ctor_locale_cstr implementation. --- dlls/msvcp60/locale.c | 24 ++++++++++++++++++++++-- dlls/msvcp90/locale.c | 24 ++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/dlls/msvcp60/locale.c b/dlls/msvcp60/locale.c index 326a51a3954..4828dd3f5db 100644 --- a/dlls/msvcp60/locale.c +++ b/dlls/msvcp60/locale.c @@ -8218,8 +8218,28 @@ locale* __thiscall locale_copy_ctor(locale *this, const locale *copy) DEFINE_THISCALL_WRAPPER(locale_ctor_locale_cstr, 16) locale* __thiscall locale_ctor_locale_cstr(locale *this, const locale *loc, const char *locname, category cat) { - FIXME("(%p %p %s %d) stub\n", this, loc, locname, cat); - return NULL; + _Locinfo locinfo; + + TRACE("(%p %p %s %d)\n", this, loc, locname, cat); + + _Locinfo_ctor_cat_cstr(&locinfo, cat, locname); + if(!memcmp(basic_string_char_c_str(&locinfo.newlocname), "*", 2)) { + _Locinfo_dtor(&locinfo); + MSVCRT_operator_delete(this->ptr); + throw_exception(EXCEPTION_RUNTIME_ERROR, "bad locale name"); + } + + this->ptr = MSVCRT_operator_new(sizeof(locale__Locimp)); + if(!this->ptr) { + ERR("Out of memory\n"); + _Locinfo_dtor(&locinfo); + throw_exception(EXCEPTION_BAD_ALLOC, NULL); + } + locale__Locimp_copy_ctor(this->ptr, loc->ptr); + + locale__Locimp__Makeloc(&locinfo, cat, this->ptr, NULL); + _Locinfo_dtor(&locinfo); + return this; } /* ??0locale@std@@QAE@PBDH@Z */ diff --git a/dlls/msvcp90/locale.c b/dlls/msvcp90/locale.c index 587aca65d6e..551a924d927 100644 --- a/dlls/msvcp90/locale.c +++ b/dlls/msvcp90/locale.c @@ -9958,8 +9958,28 @@ locale* __thiscall locale_copy_ctor(locale *this, const locale *copy) DEFINE_THISCALL_WRAPPER(locale_ctor_locale_cstr, 16) locale* __thiscall locale_ctor_locale_cstr(locale *this, const locale *loc, const char *locname, category cat) { - FIXME("(%p %p %s %d) stub\n", this, loc, locname, cat); - return NULL; + _Locinfo locinfo; + + TRACE("(%p %p %s %d)\n", this, loc, locname, cat); + + _Locinfo_ctor_cat_cstr(&locinfo, cat, locname); + if(!memcmp(locale_string_char_c_str(&locinfo.newlocname), "*", 2)) { + _Locinfo_dtor(&locinfo); + MSVCRT_operator_delete(this->ptr); + throw_exception(EXCEPTION_RUNTIME_ERROR, "bad locale name"); + } + + this->ptr = MSVCRT_operator_new(sizeof(locale__Locimp)); + if(!this->ptr) { + ERR("Out of memory\n"); + _Locinfo_dtor(&locinfo); + throw_exception(EXCEPTION_BAD_ALLOC, NULL); + } + locale__Locimp_copy_ctor(this->ptr, loc->ptr); + + locale__Locimp__Makeloc(&locinfo, cat, this->ptr, NULL); + _Locinfo_dtor(&locinfo); + return this; } /* ??0locale@std@@QAE@PBDH@Z */