From 01dd1ad7653d81e796a7d166befd4f367d3a8d0a Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 21 Aug 2008 03:58:42 +0000 Subject: [PATCH] --- ase/lib/awk/awk.c | 4 ++-- ase/lib/awk/awk.h | 6 ++--- ase/lib/cmn/chr.c | 56 +++++++++++++++++++++++++++++++++-------------- ase/lib/cmn/dll.c | 2 +- ase/lib/cmn/sll.c | 2 +- ase/lib/tgp/tgp.c | 10 ++++----- 6 files changed, 52 insertions(+), 28 deletions(-) diff --git a/ase/lib/awk/awk.c b/ase/lib/awk/awk.c index f4e1d7d0..092bb2eb 100644 --- a/ase/lib/awk/awk.c +++ b/ase/lib/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c 337 2008-08-20 09:17:25Z baconevi $ + * $Id: awk.c 339 2008-08-20 09:58:42Z baconevi $ * * {License} */ @@ -40,7 +40,7 @@ ase_awk_t* ase_awk_open ( if (mmgr == ASE_NULL) return ASE_NULL; } - awk = ASE_ALLOC (mmgr, ASE_SIZEOF(ase_awk_t) + extension); + awk = ASE_MMGR_ALLOC (mmgr, ASE_SIZEOF(ase_awk_t) + extension); if (awk == ASE_NULL) return ASE_NULL; ASE_MEMSET (awk, 0, ASE_SIZEOF(ase_awk_t) + extension); diff --git a/ase/lib/awk/awk.h b/ase/lib/awk/awk.h index 90f6fdd5..91d8477c 100644 --- a/ase/lib/awk/awk.h +++ b/ase/lib/awk/awk.h @@ -34,9 +34,9 @@ typedef struct ase_awk_tree_t ase_awk_tree_t; #define ASE_AWK_MAX_LOCALS 9999 #define ASE_AWK_MAX_PARAMS 9999 -#define ASE_AWK_ALLOC(awk,size) ASE_ALLOC((awk)->mmgr,size) -#define ASE_AWK_REALLOC(awk,ptr,size) ASE_REALLOC((awk)->mmgr,ptr,size) -#define ASE_AWK_FREE(awk,ptr) ASE_FREE((awk)->mmgr,ptr) +#define ASE_AWK_ALLOC(awk,size) ASE_MMGR_ALLOC((awk)->mmgr,size) +#define ASE_AWK_REALLOC(awk,ptr,size) ASE_MMGR_REALLOC((awk)->mmgr,ptr,size) +#define ASE_AWK_FREE(awk,ptr) ASE_MMGR_FREE((awk)->mmgr,ptr) #define ASE_AWK_ISUPPER(awk,c) ASE_CCLS_ISUPPER((awk)->ccls,c) #define ASE_AWK_ISLOWER(awk,c) ASE_CCLS_ISLOWER((awk)->ccls,c) diff --git a/ase/lib/cmn/chr.c b/ase/lib/cmn/chr.c index 52521ed6..7505ea7b 100644 --- a/ase/lib/cmn/chr.c +++ b/ase/lib/cmn/chr.c @@ -13,6 +13,7 @@ static ase_bool_t ccls_is (void* data, ase_cint_t c, ase_ccls_type_t type) { /* TODO: use GetStringTypeW/A for WIN32 to implement these */ +#error NOT IMPLEMENTED YET. } static ase_cint_t ccls_to (void* data, ase_cint_t c, in type) @@ -29,40 +30,63 @@ static ase_cint_t ccls_to (void* data, ase_cint_t c, in type) #include -static ase_bool_t ccls_is (void* data, ase_cint_t c, ase_ccls_type_t type) +static ase_bool_t ccls_is (void* data, ase_cint_t c, int type) { + static const char* name[] = + { + "upper", + "lower", + "alpha", + "digit", + "xdigit", + "alnum", + "space", + "print", + "graph", + "cntrl", + "punct" + }; + static wctype_t desc[] = { - wctype("upper"), - wctype("lower"), - wctype("alpha"), - wctype("digit"), - wctype("xdigit"), - wctype("alnum"), - wctype("space"), - wctype("print"), - wctype("graph"), - wctype("cntrl"), - wctype("punct") + (wctype_t)0, + (wctype_t)0, + (wctype_t)0, + (wctype_t)0, + (wctype_t)0, + (wctype_t)0, + (wctype_t)0, + (wctype_t)0, + (wctype_t)0, + (wctype_t)0, + (wctype_t)0 }; ASE_ASSERTX (type >= ASE_CCLS_UPPER && type <= ASE_CCLS_PUNCT, "The character type should be one of ase_ccls_type_t values"); + if (desc[type] == (wctype_t)0) desc[type] = wctype(name[type]); return iswctype (c, desc[type]); } -static ase_cint_t ccls_to (void* data, ase_cint_t c, in type) +static ase_cint_t ccls_to (void* data, ase_cint_t c, int type) { - static wctype_t desc[] = + static const char* name[] = { - wctrans("toupper"), - wctrans("tolower") + "upper", + "lower" + }; + + static wctrans_t desc[] = + { + (wctrans_t)0, + (wctrans_t)0 }; ASE_ASSERTX (type >= ASE_CCLS_UPPER && type <= ASE_CCLS_LOWER, "The character type should be one of ASE_CCLS_UPPER and ASE_CCLS_LOWER"); + if (desc[type] == (wctrans_t)0) desc[type] = wctrans(name[type]); return towctrans (c, desc[type]); } diff --git a/ase/lib/cmn/dll.c b/ase/lib/cmn/dll.c index 14e15f20..e39a2b7b 100644 --- a/ase/lib/cmn/dll.c +++ b/ase/lib/cmn/dll.c @@ -29,7 +29,7 @@ ase_dll_t* ase_dll_open ( if (mmgr == ASE_NULL) return ASE_NULL; } - dll = ASE_MALLOC (mmgr, ASE_SIZEOF(ase_dll_t) + extension); + dll = ASE_MMGR_ALLOC (mmgr, ASE_SIZEOF(ase_dll_t) + extension); if (dll == ASE_NULL) return ASE_NULL; ASE_MEMSET (dll, 0, ASE_SIZEOF(ase_dll_t) + extension); diff --git a/ase/lib/cmn/sll.c b/ase/lib/cmn/sll.c index 0701bcfb..9aaf2ea6 100644 --- a/ase/lib/cmn/sll.c +++ b/ase/lib/cmn/sll.c @@ -29,7 +29,7 @@ ase_sll_t* ase_sll_open ( if (mmgr == ASE_NULL) return ASE_NULL; } - sll = ASE_MALLOC (mmgr, ASE_SIZEOF(ase_sll_t) + extension); + sll = ASE_MMGR_ALLOC (mmgr, ASE_SIZEOF(ase_sll_t) + extension); if (sll == ASE_NULL) return ASE_NULL; ASE_MEMSET (sll, 0, ASE_SIZEOF(ase_sll_t) + extension); diff --git a/ase/lib/tgp/tgp.c b/ase/lib/tgp/tgp.c index cac46dd8..e1c65f95 100644 --- a/ase/lib/tgp/tgp.c +++ b/ase/lib/tgp/tgp.c @@ -3,7 +3,7 @@ */ #include -#include +#include "../cmn/mem.h" struct ase_tgp_t { @@ -67,18 +67,18 @@ ase_tgp_t* ase_tgp_open (ase_mmgr_t* mmgr) } */ - tgp = ASE_MALLOC (mmgr, ASE_SIZEOF(*tgp)); + tgp = ASE_MMGR_ALLOC (mmgr, ASE_SIZEOF(*tgp)); if (tgp == ASE_NULL) return ASE_NULL; - ase_memset (tgp, 0, ASE_SIZEOF(*tgp)); - ase_memcpy (&tgp->mmgr, mmgr, ASE_SIZEOF(*mmgr)); + ASE_MEMSET (tgp, 0, ASE_SIZEOF(*tgp)); + ASE_MEMCPY (&tgp->mmgr, mmgr, ASE_SIZEOF(*mmgr)); return tgp; } void ase_tgp_close (ase_tgp_t* tgp) { - ASE_FREE (&tgp->mmgr, tgp); + ASE_MMGR_FREE (&tgp->mmgr, tgp); } void ase_tgp_setassocdata (ase_tgp_t* tgp, void* data)