corrected faults in character handling functions and macros

This commit is contained in:
2011-03-25 22:52:47 +00:00
parent c3f6340f9e
commit 895570a771
7 changed files with 90 additions and 47 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h 343 2010-08-05 07:31:17Z hyunghwan.chung $
* $Id: awk.h 414 2011-03-25 04:52:47Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -21,7 +21,6 @@
#ifndef _QSE_LIB_AWK_AWK_H_
#define _QSE_LIB_AWK_AWK_H_
#define USE_STDC
#include "../cmn/mem.h"
#include <qse/cmn/chr.h>
#include <qse/cmn/str.h>

View File

@ -73,11 +73,11 @@ am__installdirs = "$(DESTDIR)$(libdir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
libqsecmn_la_DEPENDENCIES =
am_libqsecmn_la_OBJECTS = mem.lo xma.lo fma.lo chr.lo chr_cnv.lo \
rex.lo str_bas.lo str_cmp.lo str_cnv.lo str_cpy.lo str_dyn.lo
str_fcpy.lo str_pbrk.lo str_put.lo str_spn.lo str_utl.lo lda.lo oht.lo \
htb.lo rbt.lo sll.lo gdl.lo dll.lo opt.lo tio.lo tio_get.lo \
tio_put.lo fio.lo pio.lo sio.lo alg_search.lo alg_sort.lo \
time.lo misc.lo assert.lo main.lo stdio.lo
rex.lo str_bas.lo str_cnv.lo str_cmp.lo str_cpy.lo str_dyn.lo \
str_fcpy.lo str_pbrk.lo str_put.lo str_spn.lo str_utl.lo \
lda.lo oht.lo htb.lo rbt.lo sll.lo gdl.lo dll.lo opt.lo tio.lo \
tio_get.lo tio_put.lo fio.lo pio.lo sio.lo alg_search.lo \
alg_sort.lo time.lo misc.lo assert.lo main.lo stdio.lo
libqsecmn_la_OBJECTS = $(am_libqsecmn_la_OBJECTS)
libqsecmn_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
@ -265,7 +265,7 @@ lib_LTLIBRARIES = libqsecmn.la $(am__append_1)
libqsecmn_la_SOURCES = \
syscall.h mem.h \
mem.c xma.c fma.c chr.c chr_cnv.c rex.c \
str_bas.c str_cmp.c str_cnv.c str_cpy.c str_dyn.c str_fcpy.c \
str_bas.c str_cnv.c str_cmp.c str_cpy.c str_dyn.c str_fcpy.c \
str_pbrk.c str_put.c str_spn.c str_utl.c \
lda.c oht.c htb.c rbt.c sll.c gdl.c dll.c opt.c \
tio.c tio_get.c tio_put.c \

View File

@ -1,5 +1,5 @@
/*
* $Id: chr.c 413 2011-03-25 04:36:43Z hyunghwan.chung $
* $Id: chr.c 414 2011-03-25 04:52:47Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -35,6 +35,18 @@ static qse_bool_t is_mgraph (qse_mcint_t c) { return isgraph(c); }
static qse_bool_t is_mcntrl (qse_mcint_t c) { return iscntrl(c); }
static qse_bool_t is_mpunct (qse_mcint_t c) { return ispunct(c); }
static qse_bool_t is_wupper (qse_wcint_t c) { return iswupper(c); }
static qse_bool_t is_wlower (qse_wcint_t c) { return iswlower(c); }
static qse_bool_t is_walpha (qse_wcint_t c) { return iswalpha(c); }
static qse_bool_t is_wdigit (qse_wcint_t c) { return iswdigit(c); }
static qse_bool_t is_wxdigit (qse_wcint_t c) { return iswxdigit(c); }
static qse_bool_t is_walnum (qse_wcint_t c) { return iswalnum(c); }
static qse_bool_t is_wspace (qse_wcint_t c) { return iswspace(c); }
static qse_bool_t is_wprint (qse_wcint_t c) { return iswprint(c); }
static qse_bool_t is_wgraph (qse_wcint_t c) { return iswgraph(c); }
static qse_bool_t is_wcntrl (qse_wcint_t c) { return iswcntrl(c); }
static qse_bool_t is_wpunct (qse_wcint_t c) { return iswpunct(c); }
qse_bool_t qse_mccls_is (qse_mcint_t c, qse_mccls_id_t type)
{
/* TODO: use GetStringTypeW/A for WIN32 to implement these */
@ -54,23 +66,25 @@ qse_bool_t qse_mccls_is (qse_mcint_t c, qse_mccls_id_t type)
is_mpunct
};
QSE_ASSERTX (type >= QSE_CCLS_UPPER && type <= QSE_CCLS_PUNCT,
QSE_ASSERTX (type >= QSE_MCCLS_UPPER && type <= QSE_MCCLS_PUNCT,
"The character type should be one of qse_mccls_id_t values");
return f[type] (c);
}
qse_mcint_t qse_mccls_to (qse_mcint_t c, qse_mccls_id_t type)
{
QSE_ASSERTX (type >= QSE_CCLS_UPPER && type <= QSE_CCLS_LOWER,
"The character type should be one of QSE_CCLS_UPPER and QSE_CCLS_LOWER");
QSE_ASSERTX (type >= QSE_MCCLS_UPPER && type <= QSE_MCCLS_LOWER,
"The character type should be one of QSE_MCCLS_UPPER and QSE_MCCLS_LOWER");
if (type == QSE_CCLS_UPPER) return toupper(c);
if (type == QSE_CCLS_LOWER) return tolower(c);
if (type == QSE_MCCLS_UPPER) return toupper(c);
if (type == QSE_MCCLS_LOWER) return tolower(c);
return c;
}
qse_bool_t qse_wccls_is (qse_wcint_t c, qse_wccls_id_t type)
{
/*
#ifdef HAVE_WCTYPE
static const char* name[] =
{
"upper",
@ -106,10 +120,34 @@ qse_bool_t qse_wccls_is (qse_wcint_t c, qse_wccls_id_t type)
if (desc[type] == (wctype_t)0) desc[type] = wctype(name[type]);
return iswctype (c, desc[type]);
#else
*/
static qse_bool_t (*f[]) (qse_wcint_t) =
{
is_wupper,
is_wlower,
is_walpha,
is_wdigit,
is_wxdigit,
is_walnum,
is_wspace,
is_wprint,
is_wgraph,
is_wcntrl,
is_wpunct
};
QSE_ASSERTX (type >= QSE_WCCLS_UPPER && type <= QSE_WCCLS_PUNCT,
"The character type should be one of qse_wccls_id_t values");
return f[type] (c);
/*
#endif
*/
}
qse_wcint_t qse_wccls_to (qse_wcint_t c, qse_wccls_id_t type)
{
/*
#ifdef HAVE_WCTRANS
static const char* name[] =
{
@ -123,15 +161,18 @@ qse_wcint_t qse_wccls_to (qse_wcint_t c, qse_wccls_id_t type)
(wctrans_t)0
};
QSE_ASSERTX (type >= QSE_CCLS_UPPER && type <= QSE_CCLS_LOWER,
"The type should be one of QSE_CCLS_UPPER and QSE_CCLS_LOWER");
QSE_ASSERTX (type >= QSE_WCCLS_UPPER && type <= QSE_WCCLS_LOWER,
"The type should be one of QSE_WCCLS_UPPER and QSE_WCCLS_LOWER");
if (desc[type] == (wctrans_t)0) desc[type] = wctrans(name[type]);
return towctrans (c, desc[type]);
#else
QSE_ASSERTX (type >= QSE_CCLS_UPPER && type <= QSE_CCLS_LOWER,
"The type should be one of QSE_CCLS_UPPER and QSE_CCLS_LOWER");
*/
QSE_ASSERTX (type >= QSE_WCCLS_UPPER && type <= QSE_WCCLS_LOWER,
"The type should be one of QSE_WCCLS_UPPER and QSE_WCCLS_LOWER");
return (type == QSE_CCLS_UPPER)? towupper(c): towlower(c);
/*
#endif
*/
}