corrected faults in character handling functions and macros

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

2
qse/configure vendored
View File

@ -15370,7 +15370,7 @@ _ACEOF
fi
done
for ac_func in wctrans towctrans
for ac_func in wctype wctrans towctrans
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"

View File

@ -93,7 +93,7 @@ dnl check functions
AC_CHECK_FUNCS([uselocale])
AC_CHECK_FUNCS([mbrlen mbrtowc wcrtomb])
AC_CHECK_FUNCS([mbsnrtowcs mbsrtowcs wcsnrtombs wcsrtombs])
AC_CHECK_FUNCS([wctrans towctrans])
AC_CHECK_FUNCS([wctype wctrans towctrans])
AC_CHECK_FUNCS([lseek64 stat64 fstat64 ftruncate64])
AC_CHECK_FUNCS([timegm timelocal])
AC_CHECK_FUNCS([utime utimes])

View File

@ -1,5 +1,5 @@
/*
* $Id: chr.h 413 2011-03-25 04:36:43Z hyunghwan.chung $
* $Id: chr.h 414 2011-03-25 04:52:47Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -73,33 +73,33 @@ typedef qse_ccls_id_t qse_wccls_id_t;
# include <ctype.h>
# include <wctype.h>
#
# define QSE_ISUPPER(c) isupper(c)
# define QSE_ISLOWER(c) islower(c)
# define QSE_ISALPHA(c) isalpha(c)
# define QSE_ISDIGIT(c) isdigit(c)
# define QSE_ISXDIGIT(c) isxdigit(c)
# define QSE_ISALNUM(c) isalnum(c)
# define QSE_ISSPACE(c) isspace(c)
# define QSE_ISPRINT(c) isprint(c)
# define QSE_ISGRAPH(c) isgraph(c)
# define QSE_ISCNTRL(c) iscntrl(c)
# define QSE_ISPUNCT(c) ispunct(c)
# define QSE_TOUPPER(c) toupper(c)
# define QSE_TOLOWER(c) tolower(c)
# define QSE_ISMUPPER(c) isupper(c)
# define QSE_ISMLOWER(c) islower(c)
# define QSE_ISMALPHA(c) isalpha(c)
# define QSE_ISMDIGIT(c) isdigit(c)
# define QSE_ISMXDIGIT(c) isxdigit(c)
# define QSE_ISMALNUM(c) isalnum(c)
# define QSE_ISMSPACE(c) isspace(c)
# define QSE_ISMPRINT(c) isprint(c)
# define QSE_ISMGRAPH(c) isgraph(c)
# define QSE_ISMCNTRL(c) iscntrl(c)
# define QSE_ISMPUNCT(c) ispunct(c)
# define QSE_TOMUPPER(c) toupper(c)
# define QSE_TOMLOWER(c) tolower(c)
#
# define QSE_ISUPPER(c) iswupper(c)
# define QSE_ISLOWER(c) iswlower(c)
# define QSE_ISALPHA(c) iswalpha(c)
# define QSE_ISDIGIT(c) iswdigit(c)
# define QSE_ISXDIGIT(c) iswxdigit(c)
# define QSE_ISALNUM(c) iswalnum(c)
# define QSE_ISSPACE(c) iswspace(c)
# define QSE_ISPRINT(c) iswprint(c)
# define QSE_ISGRAPH(c) iswgraph(c)
# define QSE_ISCNTRL(c) iswcntrl(c)
# define QSE_ISPUNCT(c) iswpunct(c)
# define QSE_TOUPPER(c) towupper(c)
# define QSE_TOLOWER(c) towlower(c)
# define QSE_ISWUPPER(c) iswupper(c)
# define QSE_ISWLOWER(c) iswlower(c)
# define QSE_ISWALPHA(c) iswalpha(c)
# define QSE_ISWDIGIT(c) iswdigit(c)
# define QSE_ISWXDIGIT(c) iswxdigit(c)
# define QSE_ISWALNUM(c) iswalnum(c)
# define QSE_ISWSPACE(c) iswspace(c)
# define QSE_ISWPRINT(c) iswprint(c)
# define QSE_ISWGRAPH(c) iswgraph(c)
# define QSE_ISWCNTRL(c) iswcntrl(c)
# define QSE_ISWPUNCT(c) iswpunct(c)
# define QSE_TOWUPPER(c) towupper(c)
# define QSE_TOWLOWER(c) towlower(c)
#else
# define QSE_ISMUPPER(c) (qse_mccls_is(c,QSE_CCLS_UPPER))
# define QSE_ISMLOWER(c) (qse_mccls_is(c,QSE_CCLS_LOWER))

View File

@ -210,6 +210,9 @@
/* Define to 1 if you have the `wctrans' function. */
#undef HAVE_WCTRANS
/* Define to 1 if you have the `wctype' function. */
#undef HAVE_WCTYPE
/* Define to 1 if you have the <wctype.h> header file. */
#undef HAVE_WCTYPE_H

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
*/
}