From cfdc22ee6021fc5fec4144cc510458266ac1d055 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 21 Feb 2018 07:37:10 +0000 Subject: [PATCH] added --enable-unicode to configure.ac cleaned up unnecessary code --- Makefile.in | 6 ++- configure | 131 +++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 43 ++++++++++++++++ lib/Makefile.in | 2 + lib/exec.c | 4 +- lib/gc.c | 1 - lib/hcl-cfg.h.in | 12 +++++ lib/hcl-cmn.h | 14 +++-- lib/hcl.h | 1 - lib/logfmtv.h | 4 +- lib/obj.c | 11 +--- mod/Makefile.in | 2 + 12 files changed, 205 insertions(+), 26 deletions(-) diff --git a/Makefile.in b/Makefile.in index 2f69e58..80c25ce 100644 --- a/Makefile.in +++ b/Makefile.in @@ -165,8 +165,8 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/ar-lib \ $(top_srcdir)/ac/compile $(top_srcdir)/ac/config.guess \ $(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \ $(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing ac/ar-lib \ - ac/compile ac/config.guess ac/config.sub ac/install-sh \ - ac/ltmain.sh ac/missing + ac/compile ac/config.guess ac/config.sub ac/depcomp \ + ac/install-sh ac/ltmain.sh ac/missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -245,6 +245,8 @@ HAVE_CXX = @HAVE_CXX@ HCL_PROJECT_AUTHOR = @HCL_PROJECT_AUTHOR@ HCL_PROJECT_URL = @HCL_PROJECT_URL@ HCL_SIZEOF_CHAR = @HCL_SIZEOF_CHAR@ +HCL_SIZEOF_CHAR16_T = @HCL_SIZEOF_CHAR16_T@ +HCL_SIZEOF_CHAR32_T = @HCL_SIZEOF_CHAR32_T@ HCL_SIZEOF_DOUBLE = @HCL_SIZEOF_DOUBLE@ HCL_SIZEOF_FLOAT = @HCL_SIZEOF_FLOAT@ HCL_SIZEOF_INT = @HCL_SIZEOF_INT@ diff --git a/configure b/configure index 3f03d15..960b76b 100755 --- a/configure +++ b/configure @@ -648,6 +648,8 @@ HCL_SIZEOF_SHORT HCL_SIZEOF_INT HCL_SIZEOF_LONG HCL_SIZEOF_LONG_LONG +HCL_SIZEOF_CHAR32_T +HCL_SIZEOF_CHAR16_T HCL_SIZEOF_WCHAR_T ENABLE_STATIC_MODULE_FALSE ENABLE_STATIC_MODULE_TRUE @@ -801,6 +803,8 @@ with_gnu_ld with_sysroot enable_libtool_lock enable_debug +enable_override_uch +enable_unicode enable_cxx enable_dynamic_module enable_static_module @@ -1449,6 +1453,10 @@ Optional Features: optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --enable-debug build the library in the debug mode (default. no) + --enable-override-uch Use the specified unicode character type (default. + no) + --enable-unicode Use the unicode character type as the default + character type (default. yes) --enable-cxx build the library for C++ if a C++ compiler is available (default. yes) --enable-dynamic-module enable dynamic module capability(default. yes) @@ -18604,6 +18612,72 @@ cat >>confdefs.h <<_ACEOF _ACEOF +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char16_t" >&5 +$as_echo_n "checking size of char16_t... " >&6; } +if ${ac_cv_sizeof_char16_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char16_t))" "ac_cv_sizeof_char16_t" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_char16_t" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (char16_t) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_char16_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char16_t" >&5 +$as_echo "$ac_cv_sizeof_char16_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_CHAR16_T $ac_cv_sizeof_char16_t +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char32_t" >&5 +$as_echo_n "checking size of char32_t... " >&6; } +if ${ac_cv_sizeof_char32_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char32_t))" "ac_cv_sizeof_char32_t" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_char32_t" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (char32_t) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_char32_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char32_t" >&5 +$as_echo "$ac_cv_sizeof_char32_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_CHAR32_T $ac_cv_sizeof_char32_t +_ACEOF + + # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. @@ -19337,6 +19411,59 @@ else fi + +# Check whether --enable-override-uch was given. +if test "${enable_override_uch+set}" = set; then : + enableval=$enable_override_uch; enable_override_uch=$enableval +else + enable_override_uch=no + +fi + +if test "${enable_override_uch}" = "wchar_t" +then + test "${ac_cv_sizeof_wchar_t}" = "0" && enable_override_uch=no + test "${ac_cv_sizeof_wchar_t}" = "1" && enable_override_uch=no +elif test "${enable_override_uch}" = "char16_t" +then + test "${ac_cv_sizeof_char16_t}" = "0" && enable_override_uch=no +elif test "${enable_override_uch}" = "char32_t" +then + test "${ac_cv_sizeof_char32_t}" = "0" && enable_override_uch=no +fi + +if test "${enable_override_uch}" = "wchar_t" +then + +$as_echo "#define HCL_OVERRIDE_UCH_TYPE wchar_t" >>confdefs.h + +elif test "${enable_override_uch}" = "char16_t" +then + +$as_echo "#define HCL_OVERRIDE_UCH_TYPE char16_t" >>confdefs.h + +elif test "${enable_override_uch}" = "char32_t" +then + +$as_echo "#define HCL_OVERRIDE_UCH_TYPE char32_t" >>confdefs.h + +fi + +# Check whether --enable-unicode was given. +if test "${enable_unicode+set}" = set; then : + enableval=$enable_unicode; enable_unicode=$enableval +else + enable_unicode=yes + +fi + +if test "${enable_unicode}" = "yes" +then + +$as_echo "#define HCL_ENABLE_UNICODE /**/" >>confdefs.h + +fi + # Check whether --enable-cxx was given. if test "${enable_cxx+set}" = set; then : enableval=$enable_cxx; enable_cxx_is=$enableval @@ -19411,6 +19538,10 @@ fi HCL_SIZEOF_WCHAR_T=$ac_cv_sizeof_wchar_t +HCL_SIZEOF_CHAR16_T=$ac_cv_sizeof_char16_t + +HCL_SIZEOF_CHAR32_T=$ac_cv_sizeof_char32_t + HCL_SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long HCL_SIZEOF_LONG=$ac_cv_sizeof_long diff --git a/configure.ac b/configure.ac index fd6a584..d505e58 100644 --- a/configure.ac +++ b/configure.ac @@ -234,6 +234,8 @@ AC_CHECK_SIZEOF(long double,,[[]]) AC_CHECK_SIZEOF(__float128,,[[]]) AC_CHECK_SIZEOF(wchar_t) +AC_CHECK_SIZEOF(char16_t) +AC_CHECK_SIZEOF(char32_t) AC_CHECK_SIZEOF(off_t) AC_CHECK_SIZEOF(off64_t) @@ -404,6 +406,45 @@ else AC_SUBST(BUILD_MODE, "release") fi + +AC_ARG_ENABLE([override-uch], + [AS_HELP_STRING([--enable-override-uch],[Use the specified unicode character type (default. no)])], + enable_override_uch=$enableval, + enable_override_uch=no +) +if test "${enable_override_uch}" = "wchar_t" +then + test "${ac_cv_sizeof_wchar_t}" = "0" && enable_override_uch=no + test "${ac_cv_sizeof_wchar_t}" = "1" && enable_override_uch=no +elif test "${enable_override_uch}" = "char16_t" +then + test "${ac_cv_sizeof_char16_t}" = "0" && enable_override_uch=no +elif test "${enable_override_uch}" = "char32_t" +then + test "${ac_cv_sizeof_char32_t}" = "0" && enable_override_uch=no +fi + +if test "${enable_override_uch}" = "wchar_t" +then + AC_DEFINE([HCL_OVERRIDE_UCH_TYPE],[wchar_t],[unicode character type]) +elif test "${enable_override_uch}" = "char16_t" +then + AC_DEFINE([HCL_OVERRIDE_UCH_TYPE],[char16_t],[unicode character type]) +elif test "${enable_override_uch}" = "char32_t" +then + AC_DEFINE([HCL_OVERRIDE_UCH_TYPE],[char32_t],[unicode character type]) +fi + +AC_ARG_ENABLE([unicode], + [AS_HELP_STRING([--enable-unicode],[Use the unicode character type as the default character type (default. yes)])], + enable_unicode=$enableval, + enable_unicode=yes +) +if test "${enable_unicode}" = "yes" +then + AC_DEFINE([HCL_ENABLE_UNICODE],[],[Use the unicode character type as the default character type]) +fi + AC_ARG_ENABLE([cxx], [AS_HELP_STRING([--enable-cxx],[build the library for C++ if a C++ compiler is available (default. yes)])], enable_cxx_is=$enableval, @@ -447,6 +488,8 @@ fi AM_CONDITIONAL(ENABLE_STATIC_MODULE, test "${enable_static_module_is}" = "yes") AC_SUBST(HCL_SIZEOF_WCHAR_T, $ac_cv_sizeof_wchar_t) +AC_SUBST(HCL_SIZEOF_CHAR16_T, $ac_cv_sizeof_char16_t) +AC_SUBST(HCL_SIZEOF_CHAR32_T, $ac_cv_sizeof_char32_t) AC_SUBST(HCL_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long) AC_SUBST(HCL_SIZEOF_LONG, $ac_cv_sizeof_long) AC_SUBST(HCL_SIZEOF_INT, $ac_cv_sizeof_int) diff --git a/lib/Makefile.in b/lib/Makefile.in index 8c2ccc0..7950239 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -267,6 +267,8 @@ HAVE_CXX = @HAVE_CXX@ HCL_PROJECT_AUTHOR = @HCL_PROJECT_AUTHOR@ HCL_PROJECT_URL = @HCL_PROJECT_URL@ HCL_SIZEOF_CHAR = @HCL_SIZEOF_CHAR@ +HCL_SIZEOF_CHAR16_T = @HCL_SIZEOF_CHAR16_T@ +HCL_SIZEOF_CHAR32_T = @HCL_SIZEOF_CHAR32_T@ HCL_SIZEOF_DOUBLE = @HCL_SIZEOF_DOUBLE@ HCL_SIZEOF_FLOAT = @HCL_SIZEOF_FLOAT@ HCL_SIZEOF_INT = @HCL_SIZEOF_INT@ diff --git a/lib/exec.c b/lib/exec.c index a720f7e..f4f5c43 100644 --- a/lib/exec.c +++ b/lib/exec.c @@ -2099,11 +2099,11 @@ static int execute (hcl_t* hcl) /* it emulates thisContext blockCopy: nargs ofTmprCount: ntmprs */ HCL_ASSERT (hcl, hcl->sp >= 2); - HCL_ASSERT (hcl, HCL_CLASSOF(hcl, HCL_STACK_GETTOP(hcl)) == hcl->_small_integer); + HCL_ASSERT (hcl, HCL_OOP_IS_SMOOI(HCL_STACK_GETTOP(hcl))); ntmprs = HCL_OOP_TO_SMOOI(HCL_STACK_GETTOP(hcl)); HCL_STACK_POP (hcl); - HCL_ASSERT (hcl, HCL_CLASSOF(hcl, HCL_STACK_GETTOP(hcl)) == hcl->_small_integer); + HCL_ASSERT (hcl, HCL_OOP_IS_SMOOI(HCL_STACK_GETTOP(hcl))); nargs = HCL_OOP_TO_SMOOI(HCL_STACK_GETTOP(hcl)); HCL_STACK_POP (hcl); diff --git a/lib/gc.c b/lib/gc.c index 53cc1d8..be8269a 100644 --- a/lib/gc.c +++ b/lib/gc.c @@ -321,7 +321,6 @@ void hcl_gc (hcl_t* hcl) *(hcl_oop_t*)((hcl_uint8_t*)hcl + syminfo[i].offset) = tmp; } - hcl->_class = hcl_moveoop (hcl, hcl->_class); hcl->_character = hcl_moveoop (hcl, hcl->_character); hcl->_small_integer = hcl_moveoop (hcl, hcl->_small_integer); hcl->_large_positive_integer = hcl_moveoop (hcl, hcl->_large_positive_integer); diff --git a/lib/hcl-cfg.h.in b/lib/hcl-cfg.h.in index e7d7a8d..806b1b3 100644 --- a/lib/hcl-cfg.h.in +++ b/lib/hcl-cfg.h.in @@ -222,6 +222,9 @@ /* link modules statically into the main library */ #undef HCL_ENABLE_STATIC_MODULE +/* Use the unicode character type as the default character type */ +#undef HCL_ENABLE_UNICODE + /* Big Endian */ #undef HCL_ENDIAN_BIG @@ -234,6 +237,9 @@ /* MB_LEN_MAX */ #undef HCL_MBLEN_MAX +/* unicode character type */ +#undef HCL_OVERRIDE_UCH_TYPE + /* Author */ #undef HCL_PACKAGE_AUTHOR @@ -348,6 +354,12 @@ /* The size of `char', as computed by sizeof. */ #undef SIZEOF_CHAR +/* The size of `char16_t', as computed by sizeof. */ +#undef SIZEOF_CHAR16_T + +/* The size of `char32_t', as computed by sizeof. */ +#undef SIZEOF_CHAR32_T + /* The size of `double', as computed by sizeof. */ #undef SIZEOF_DOUBLE diff --git a/lib/hcl-cmn.h b/lib/hcl-cmn.h index 154630c..a839f77 100644 --- a/lib/hcl-cmn.h +++ b/lib/hcl-cmn.h @@ -318,20 +318,18 @@ struct hcl_bcs_t }; typedef struct hcl_bcs_t hcl_bcs_t; - -#if 0 - typedef hcl_bch_t hcl_ooch_t; - typedef hcl_bci_t hcl_ooci_t; - typedef hcl_bcs_t hcl_oocs_t; -# define HCL_OOCH_IS_BCH -#else +#if defined(HCL_ENABLE_UNICODE) typedef hcl_uch_t hcl_ooch_t; typedef hcl_uci_t hcl_ooci_t; typedef hcl_ucs_t hcl_oocs_t; # define HCL_OOCH_IS_UCH +#else + typedef hcl_bch_t hcl_ooch_t; + typedef hcl_bci_t hcl_ooci_t; + typedef hcl_bcs_t hcl_oocs_t; +# define HCL_OOCH_IS_BCH #endif - /* ========================================================================= * TIME-RELATED TYPES * =========================================================================*/ diff --git a/lib/hcl.h b/lib/hcl.h index 3b2fb38..0e2d1b2 100644 --- a/lib/hcl.h +++ b/lib/hcl.h @@ -1006,7 +1006,6 @@ struct hcl_t /* == NEVER CHANGE THE ORDER OF FIELDS BELOW == */ /* hcl_ignite() assumes this order. make sure to update symnames in ignite_3() */ - hcl_oop_t _class; /* Class */ hcl_oop_t _character; hcl_oop_t _small_integer; /* SmallInteger */ hcl_oop_t _large_positive_integer; /* LargePositiveInteger */ diff --git a/lib/logfmtv.h b/lib/logfmtv.h index cd09dc3..9cc9f1a 100644 --- a/lib/logfmtv.h +++ b/lib/logfmtv.h @@ -436,7 +436,7 @@ reswitch: /* get the length */ for (bslen = 0; bsp[bslen]; bslen++); - if (hcl_convbtooochars (hcl, bsp, &bslen, HCL_NULL, &slen) <= -1) goto oops; + if (hcl_convbtooochars(hcl, bsp, &bslen, HCL_NULL, &slen) <= -1) goto oops; /* slen holds the length after conversion */ n = slen; @@ -505,7 +505,7 @@ reswitch: /* get the length */ for (uslen = 0; usp[uslen]; uslen++); - if (hcl_convutooochars (hcl, usp, &uslen, HCL_NULL, &slen) <= -1) goto oops; + if (hcl_convutooochars(hcl, usp, &uslen, HCL_NULL, &slen) <= -1) goto oops; /* slen holds the length after conversion */ n = slen; diff --git a/lib/obj.c b/lib/obj.c index 9fa39be..9c169e5 100644 --- a/lib/obj.c +++ b/lib/obj.c @@ -468,31 +468,22 @@ int hcl_equalobjs (hcl_t* hcl, hcl_oop_t rcv, hcl_oop_t arg) case HCL_OOP_TAG_SMOOI: return HCL_OOP_TO_SMOOI(rcv) == HCL_OOP_TO_SMOOI(arg)? 1: 0; -#if 0 case HCL_OOP_TAG_SMPTR: return HCL_OOP_TO_SMPTR(rcv) == HCL_OOP_TO_SMPTR(arg)? 1: 0; -#endif case HCL_OOP_TAG_CHAR: return HCL_OOP_TO_CHAR(rcv) == HCL_OOP_TO_CHAR(arg)? 1: 0; -#if 0 case HCL_OOP_TAG_ERROR: return HCL_OOP_TO_ERROR(rcv) == HCL_OOP_TO_ERROR(arg)? 1: 0; -#endif default: { HCL_ASSERT (hcl, HCL_OOP_IS_POINTER(rcv)); - if (HCL_OBJ_GET_CLASS(rcv) != HCL_OBJ_GET_CLASS(arg)) return 0; /* different class, not equal */ + if (HCL_OBJ_GET_FLAGS_BRAND(rcv) != HCL_OBJ_GET_FLAGS_BRAND(arg)) return 0; /* different class, not equal */ HCL_ASSERT (hcl, HCL_OBJ_GET_FLAGS_TYPE(rcv) == HCL_OBJ_GET_FLAGS_TYPE(arg)); - if (HCL_OBJ_GET_CLASS(rcv) == hcl->_class && rcv != arg) - { - /* a class object are supposed to be unique */ - return 0; - } if (HCL_OBJ_GET_SIZE(rcv) != HCL_OBJ_GET_SIZE(arg)) return 0; /* different size, not equal */ switch (HCL_OBJ_GET_FLAGS_TYPE(rcv)) diff --git a/mod/Makefile.in b/mod/Makefile.in index 716cedd..4937a76 100644 --- a/mod/Makefile.in +++ b/mod/Makefile.in @@ -268,6 +268,8 @@ HAVE_CXX = @HAVE_CXX@ HCL_PROJECT_AUTHOR = @HCL_PROJECT_AUTHOR@ HCL_PROJECT_URL = @HCL_PROJECT_URL@ HCL_SIZEOF_CHAR = @HCL_SIZEOF_CHAR@ +HCL_SIZEOF_CHAR16_T = @HCL_SIZEOF_CHAR16_T@ +HCL_SIZEOF_CHAR32_T = @HCL_SIZEOF_CHAR32_T@ HCL_SIZEOF_DOUBLE = @HCL_SIZEOF_DOUBLE@ HCL_SIZEOF_FLOAT = @HCL_SIZEOF_FLOAT@ HCL_SIZEOF_INT = @HCL_SIZEOF_INT@