Piotr Caban : msvcrt: Added _get_current_locale implementation.
Alexandre Julliard
julliard at winehq.org
Tue Dec 6 15:46:18 CST 2011
Module: wine
Branch: master
Commit: f84858ac2c2e31bfa0bf90af4b1f7f4df20491b6
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f84858ac2c2e31bfa0bf90af4b1f7f4df20491b6
Author: Piotr Caban <piotr at codeweavers.com>
Date: Tue Dec 6 12:47:54 2011 +0100
msvcrt: Added _get_current_locale implementation.
---
dlls/msvcr100/msvcr100.spec | 2 +-
dlls/msvcr80/msvcr80.spec | 2 +-
dlls/msvcr90/msvcr90.spec | 2 +-
dlls/msvcrt/locale.c | 24 ++++++++++++++++++++++--
dlls/msvcrt/msvcrt.spec | 1 +
5 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index 1760a1a..38ec0e1 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -675,7 +675,7 @@
@ varargs _fwscanf_s_l(ptr wstr ptr) msvcrt._fwscanf_s_l
@ cdecl _gcvt(double long str) msvcrt._gcvt
@ cdecl _gcvt_s(ptr long double long) msvcrt._gcvt_s
-@ stub _get_current_locale
+@ cdecl _get_current_locale() msvcrt._get_current_locale
@ stub _get_daylight
@ cdecl _get_doserrno(ptr) msvcrt._get_doserrno
@ stub _get_dstbias
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index 503864f..a083053 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -517,7 +517,7 @@
@ cdecl _gcvt(double long str) msvcrt._gcvt
@ cdecl _gcvt_s(ptr long double long) msvcrt._gcvt_s
@ stub _get_amblksiz
-@ stub _get_current_locale
+@ cdecl _get_current_locale() msvcrt._get_current_locale
@ stub _get_daylight
@ cdecl _get_doserrno(ptr) msvcrt._get_doserrno
@ stub _get_dstbias
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index 7976a0f..475e3a9 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -512,7 +512,7 @@
@ cdecl _gcvt(double long str) msvcrt._gcvt
@ cdecl _gcvt_s(ptr long double long) msvcrt._gcvt_s
@ stub _get_amblksiz
-@ stub _get_current_locale
+@ cdecl _get_current_locale() msvcrt._get_current_locale
@ stub _get_daylight
@ cdecl _get_doserrno(ptr) msvcrt._get_doserrno
@ stub _get_dstbias
diff --git a/dlls/msvcrt/locale.c b/dlls/msvcrt/locale.c
index 44fdf7c..6bb6162 100644
--- a/dlls/msvcrt/locale.c
+++ b/dlls/msvcrt/locale.c
@@ -603,6 +603,9 @@ void free_locinfo(MSVCRT_pthreadlocinfo locinfo)
if(!locinfo)
return;
+ if(InterlockedDecrement(&locinfo->refcount))
+ return;
+
for(i=MSVCRT_LC_MIN+1; i<=MSVCRT_LC_MAX; i++) {
MSVCRT_free(locinfo->lc_category[i].locale);
MSVCRT_free(locinfo->lc_category[i].refcount);
@@ -640,9 +643,26 @@ void free_mbcinfo(MSVCRT_pthreadmbcinfo mbcinfo)
if(!mbcinfo)
return;
+ if(InterlockedDecrement(&mbcinfo->refcount))
+ return;
+
MSVCRT_free(mbcinfo);
}
+/* _get_current_locale - not exported in native msvcrt */
+MSVCRT__locale_t CDECL MSVCRT__get_current_locale(void)
+{
+ MSVCRT__locale_t loc = MSVCRT_malloc(sizeof(MSVCRT__locale_tstruct));
+ if(!loc)
+ return NULL;
+
+ loc->locinfo = get_locinfo();
+ loc->mbcinfo = get_mbcinfo();
+ InterlockedIncrement(&loc->locinfo->refcount);
+ InterlockedIncrement(&loc->mbcinfo->refcount);
+ return loc;
+}
+
/* _free_locale - not exported in native msvcrt */
void CDECL MSVCRT__free_locale(MSVCRT__locale_t locale)
{
@@ -747,6 +767,8 @@ MSVCRT__locale_t CDECL MSVCRT__create_locale(int category, const char *locale)
}
memset(loc->locinfo, 0, sizeof(MSVCRT_threadlocinfo));
+ loc->locinfo->refcount = 1;
+ loc->mbcinfo->refcount = 1;
loc->locinfo->lconv = MSVCRT_malloc(sizeof(struct MSVCRT_lconv));
if(!loc->locinfo->lconv) {
@@ -762,8 +784,6 @@ MSVCRT__locale_t CDECL MSVCRT__create_locale(int category, const char *locale)
return NULL;
}
- loc->locinfo->refcount = 1;
-
if(lcid[MSVCRT_LC_COLLATE] && (category==MSVCRT_LC_ALL || category==MSVCRT_LC_COLLATE)) {
if(update_threadlocinfo_category(lcid[MSVCRT_LC_COLLATE], loc, MSVCRT_LC_COLLATE)) {
MSVCRT__free_locale(loc);
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index dfd3a07..75a3b35 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -1490,6 +1490,7 @@
@ cdecl -arch=i386 __control87_2(long long ptr ptr)
@ cdecl _configthreadlocale(long)
@ cdecl _create_locale(long str) MSVCRT__create_locale
+@ cdecl _get_current_locale() MSVCRT__get_current_locale
@ cdecl _dupenv_s(ptr ptr str)
@ cdecl _free_locale(ptr) MSVCRT__free_locale
@ cdecl _get_invalid_parameter_handler()
More information about the wine-cvs
mailing list