From a95dad66556aaa197e13ea637d1be5dbcb22dcf3 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 21 Aug 2008 02:24:36 +0000 Subject: [PATCH] --- ase/lib/cmn/chr.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++ ase/lib/cmn/chr.h | 22 +++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 ase/lib/cmn/chr.c create mode 100644 ase/lib/cmn/chr.h diff --git a/ase/lib/cmn/chr.c b/ase/lib/cmn/chr.c new file mode 100644 index 00000000..52521ed6 --- /dev/null +++ b/ase/lib/cmn/chr.c @@ -0,0 +1,80 @@ +/* + * $Id: ctype.c 132 2008-03-17 10:27:02Z baconevi $ + * + * {License} + */ + +#include + +#if defined(ASE_CHAR_IS_MCHAR) + +#include + +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 */ +} + +static ase_cint_t ccls_to (void* data, ase_cint_t c, in type) +{ + 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 (type == ASE_CCLS_UPPER) return toupper(c); + if (type == ASE_CCLS_LOWER) return tolower(c); + return c; +} + +#elif defined(ASE_CHAR_IS_WCHAR) + +#include + +static ase_bool_t ccls_is (void* data, ase_cint_t c, ase_ccls_type_t type) +{ + 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") + }; + + ASE_ASSERTX (type >= ASE_CCLS_UPPER && type <= ASE_CCLS_PUNCT, + "The character type should be one of ase_ccls_type_t values"); + + return iswctype (c, desc[type]); +} + +static ase_cint_t ccls_to (void* data, ase_cint_t c, in type) +{ + static wctype_t desc[] = + { + wctrans("toupper"), + wctrans("tolower") + }; + + ASE_ASSERTX (type >= ASE_CCLS_UPPER && type <= ASE_CCLS_LOWER, + "The character type should be one of ASE_CCLS_UPPER and ASE_CCLS_LOWER"); + + return towctrans (c, desc[type]); +} + +#else + #error unsupported character type +#endif + +static ase_ccls_t ccls = +{ + ccls_is, + ccls_to, + ASE_NULL +}; + +ase_ccls_t* ase_ccls = &ccls; diff --git a/ase/lib/cmn/chr.h b/ase/lib/cmn/chr.h new file mode 100644 index 00000000..ece4d2e3 --- /dev/null +++ b/ase/lib/cmn/chr.h @@ -0,0 +1,22 @@ +/* + * $Id$ + * + * {License} + */ + +#ifndef _ASE_LIB_CMN_CHR_H_ +#define _ASE_LIB_CMN_CHR_H_ + +#include + +#ifdef USE_STDC + +#include + +#else + +#define ASE_ISALPHA(c) ase_isalpha(c) + +#endif + +#endif