Piotr Caban : msvcp90: Added _Getctype implementation.
Alexandre Julliard
julliard at winehq.org
Tue Dec 6 15:46:18 CST 2011
Module: wine
Branch: master
Commit: c56c74331c337e7ec2ba0142d328b577b274375c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c56c74331c337e7ec2ba0142d328b577b274375c
Author: Piotr Caban <piotr at codeweavers.com>
Date: Tue Dec 6 12:49:52 2011 +0100
msvcp90: Added _Getctype implementation.
---
dlls/msvcp90/locale.c | 27 +++++++++++++++++++++++----
dlls/msvcp90/msvcp90.spec | 2 +-
dlls/msvcp90/tests/misc.c | 37 ++++++++++++++++++++++++++++++++++++-
3 files changed, 60 insertions(+), 6 deletions(-)
diff --git a/dlls/msvcp90/locale.c b/dlls/msvcp90/locale.c
index a319d12..2fd3bd1 100644
--- a/dlls/msvcp90/locale.c
+++ b/dlls/msvcp90/locale.c
@@ -68,7 +68,7 @@ typedef struct {
typedef struct {
LCID handle;
unsigned page;
- const short *table;
+ short *table;
int delfl;
} _Ctypevec;
@@ -868,14 +868,33 @@ _Collvec __thiscall _Locinfo__Getcoll(const _Locinfo *this)
return _Getcoll();
}
+/* _Getctype */
+_Ctypevec __cdecl _Getctype(void)
+{
+ _Ctypevec ret;
+ _locale_t locale = _get_current_locale();
+
+ TRACE("\n");
+
+ ret.page = locale->locinfo->lc_codepage;
+ ret.handle = locale->locinfo->lc_handle[LC_COLLATE];
+ ret.delfl = TRUE;
+ ret.table = malloc(sizeof(short[256]));
+ if(!ret.table) {
+ _free_locale(locale);
+ throw_exception(EXCEPTION_BAD_ALLOC, NULL);
+ }
+ memcpy(ret.table, locale->locinfo->pctype, sizeof(short[256]));
+ _free_locale(locale);
+ return ret;
+}
+
/* ?_Getctype at _Locinfo@std@@QBE?AU_Ctypevec@@XZ */
/* ?_Getctype at _Locinfo@std@@QEBA?AU_Ctypevec@@XZ */
DEFINE_THISCALL_WRAPPER_RETPTR(_Locinfo__Getctype, 4)
_Ctypevec __thiscall _Locinfo__Getctype(const _Locinfo *this)
{
- _Ctypevec ret = { 0 }; /* FIXME */
- FIXME("(%p) stub\n", this);
- return ret;
+ return _Getctype();
}
/* ?_Getcvt at _Locinfo@std@@QBE?AU_Cvtvec@@XZ */
diff --git a/dlls/msvcp90/msvcp90.spec b/dlls/msvcp90/msvcp90.spec
index 2464328..bcaaa1c 100644
--- a/dlls/msvcp90/msvcp90.spec
+++ b/dlls/msvcp90/msvcp90.spec
@@ -5751,7 +5751,7 @@
@ extern _FSnan
# extern _FXbig
@ cdecl _Getcoll()
-@ stub _Getctype
+@ cdecl _Getctype()
@ stub _Getcvt
@ stub _Getdateorder
@ stub _Getwctype
diff --git a/dlls/msvcp90/tests/misc.c b/dlls/msvcp90/tests/misc.c
index 069c935..221edf1 100644
--- a/dlls/msvcp90/tests/misc.c
+++ b/dlls/msvcp90/tests/misc.c
@@ -17,12 +17,22 @@
*/
#include <stdio.h>
+#include <locale.h>
#include <windef.h>
#include <winbase.h>
#include "wine/test.h"
+typedef struct {
+ LCID handle;
+ unsigned page;
+ short *table;
+ int delfl;
+} MSVCP__Ctypevec;
+
static void* (__cdecl *p_set_invalid_parameter_handler)(void*);
+static _locale_t (__cdecl *p__get_current_locale)(void);
+static void (__cdecl *p_free)(void*);
static void (__cdecl *p_char_assign)(void*, const void*);
static void (__cdecl *p_wchar_assign)(void*, const void*);
@@ -35,6 +45,7 @@ static BYTE (__cdecl *p_short_eq)(const void*, const void*);
static char* (__cdecl *p_Copy_s)(char*, size_t, const char*, size_t);
static unsigned short (__cdecl *p_wctype)(const char*);
+static MSVCP__Ctypevec (__cdecl *p__Getctype)(void);
#ifdef __i386__
#define __thiscall __stdcall
@@ -119,7 +130,9 @@ static BOOL init(void)
}
p_set_invalid_parameter_handler = (void*)GetProcAddress(msvcr, "_set_invalid_parameter_handler");
- if(!p_set_invalid_parameter_handler) {
+ p__get_current_locale = (void*)GetProcAddress(msvcr, "_get_current_locale");
+ p_free = (void*)GetProcAddress(msvcr, "free");
+ if(!p_set_invalid_parameter_handler || !p__get_current_locale || !p_free) {
win_skip("Error setting tests environment\n");
return FALSE;
}
@@ -127,6 +140,7 @@ static BOOL init(void)
p_set_invalid_parameter_handler(test_invalid_parameter_handler);
SET(p_wctype, "wctype");
+ SET(p__Getctype, "_Getctype");
if(sizeof(void*) == 8) { /* 64-bit initialization */
SET(p_char_assign, "?assign@?$char_traits at D@std@@SAXAEADAEBD at Z");
SET(p_wchar_assign, "?assign@?$char_traits at _W@std@@SAXAEA_WAEB_W at Z");
@@ -291,6 +305,26 @@ static void test_wctype(void)
}
}
+static void test__Getctype(void)
+{
+ MSVCP__Ctypevec ret;
+
+ ret = p__Getctype();
+ ok(ret.handle == 0, "ret.handle = %d\n", ret.handle);
+ ok(ret.page == 0, "ret.page = %d\n", ret.page);
+ ok(ret.delfl == 1, "ret.delfl = %d\n", ret.delfl);
+ ok(ret.table[0] == 32, "ret.table[0] = %d\n", ret.table[0]);
+ p_free(ret.table);
+
+ p__get_current_locale()->locinfo->lc_handle[LC_COLLATE] = 1;
+ ret = p__Getctype();
+ ok(ret.handle == 1, "ret.handle = %d\n", ret.handle);
+ ok(ret.page == 0, "ret.page = %d\n", ret.page);
+ ok(ret.delfl == 1, "ret.delfl = %d\n", ret.delfl);
+ ok(ret.table[0] == 32, "ret.table[0] = %d\n", ret.table[0]);
+ p_free(ret.table);
+}
+
static void test_allocator_char(void)
{
void *allocator = (void*)0xdeadbeef;
@@ -331,6 +365,7 @@ START_TEST(misc)
test_equal();
test_Copy_s();
test_wctype();
+ test__Getctype();
test_allocator_char();
More information about the wine-cvs
mailing list