From e57c9673d1cfa8e0489e6714d000ac9680767e7c Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 17 Nov 2014 15:25:55 +0000 Subject: [PATCH] enhanced types and macros to handle the wchar_t type defined to 1 byte in size --- qse/include/qse/macros.h | 6 +++++- qse/include/qse/types.h | 6 ++++++ qse/lib/cmn/chr.c | 6 +++--- qse/lib/cmn/dll.c | 6 ++++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/qse/include/qse/macros.h b/qse/include/qse/macros.h index 95bf814b..ba2c3892 100644 --- a/qse/include/qse/macros.h +++ b/qse/include/qse/macros.h @@ -251,7 +251,11 @@ * The #QSE_WT macro maps a multi-byte literal string to a wide character * string by prefixing it with @b L. */ -#define QSE_WT(txt) (L ## txt) +#if (QSE_SIZEOF_WCHAR_T == QSE_SIZEOF_MCHAR_T) +# define QSE_WT(txt) (txt) +#else +# define QSE_WT(txt) (L ## txt) +#endif /** @def QSE_T * The #QSE_T macro maps to #QSE_MT if #QSE_CHAR_IS_MCHAR is defined, and to diff --git a/qse/include/qse/types.h b/qse/include/qse/types.h index 482ea666..cda45cb8 100644 --- a/qse/include/qse/types.h +++ b/qse/include/qse/types.h @@ -528,6 +528,12 @@ typedef int qse_mcint_t; #elif defined(__GNUC__) && defined(__WCHAR_TYPE__) && defined(__WINT_TYPE__) typedef __WCHAR_TYPE__ qse_wchar_t; typedef __WINT_TYPE__ qse_wcint_t; + +#elif (QSE_SIZEOF_WCHAR_T == QSE_SIZEOF_MCHAR_T) + /* most likely, there is no support for wchar_t */ + typedef qse_mchar_t qse_wchar_t; + typedef qse_mcint_t qse_wcint_t; + #elif (QSE_SIZEOF_WCHAR_T == 2) || (QSE_SIZEOF_WCHAR_T == 0) typedef unsigned short qse_wchar_t; typedef unsigned short qse_wcint_t; diff --git a/qse/lib/cmn/chr.c b/qse/lib/cmn/chr.c index 0e46888a..368d4fc6 100644 --- a/qse/lib/cmn/chr.c +++ b/qse/lib/cmn/chr.c @@ -156,7 +156,7 @@ int qse_ismctype (qse_mcint_t c, qse_mctype_t type) static int (*f[]) (qse_mcint_t) = { -#if 0 +#if 1 is_malnum, is_malpha, is_mblank, @@ -169,8 +169,7 @@ int qse_ismctype (qse_mcint_t c, qse_mctype_t type) is_mspace, is_mupper, is_mxdigit -#endif - +#else isalnum, isalpha, is_mblank, @@ -183,6 +182,7 @@ int qse_ismctype (qse_mcint_t c, qse_mctype_t type) isspace, isupper, isxdigit +#endif }; QSE_ASSERTX (type >= QSE_WCTYPE_ALNUM && type <= QSE_WCTYPE_XDIGIT, diff --git a/qse/lib/cmn/dll.c b/qse/lib/cmn/dll.c index d2a886eb..dc9d52f9 100644 --- a/qse/lib/cmn/dll.c +++ b/qse/lib/cmn/dll.c @@ -299,8 +299,9 @@ void qse_dll_walk (qse_dll_t* dll, qse_dll_walker_t walker, void* ctx) while (QSE_GDL_ISLINK(&dll->gdl,n)) { - qse_gdl_link_t tmp = *n; + qse_gdl_link_t tmp; + tmp = *n; w = walker (dll, QSE_GDL_CONTAINER (n, qse_dll_node_t, link), ctx); if (w == QSE_DLL_WALK_FORWARD) n = QSE_GDL_NEXT (&tmp); @@ -316,8 +317,9 @@ void qse_dll_rwalk (qse_dll_t* dll, qse_dll_walker_t walker, void* ctx) while (QSE_GDL_ISLINK(&dll->gdl,n)) { - qse_gdl_link_t tmp = *n; + qse_gdl_link_t tmp; + tmp = *n; w = walker (dll, QSE_GDL_CONTAINER (n, qse_dll_node_t, link), ctx); if (w == QSE_DLL_WALK_FORWARD) n = QSE_GDL_NEXT (&tmp);