diff --git a/moo/configure b/moo/configure index 8abe074..0ad318f 100755 --- a/moo/configure +++ b/moo/configure @@ -1504,7 +1504,8 @@ Optional Features: --enable-ltdl-install install libltdl --enable-debug build the library in the debug mode (default. no) --enable-unicode Use the unicode character type as the default - character type (default. yes) + character type. one of yes, no, ucs2, ucs4 (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) @@ -22521,7 +22522,6 @@ $as_echo "#define MOO_BUILD_RELEASE 1" >>confdefs.h fi - # Check whether --enable-unicode was given. if test "${enable_unicode+set}" = set; then : enableval=$enable_unicode; enable_unicode=$enableval @@ -22535,6 +22535,16 @@ then $as_echo "#define MOO_ENABLE_UNICODE 1" >>confdefs.h +elif test "${enable_unicode}" = "ucs2" +then + +$as_echo "#define MOO_ENABLE_UNICODE 2" >>confdefs.h + +elif test "${enable_unicode}" = "ucs4" +then + +$as_echo "#define MOO_ENABLE_UNICODE 4" >>confdefs.h + fi # Check whether --enable-cxx was given. diff --git a/moo/configure.ac b/moo/configure.ac index 1fd2036..e101640 100644 --- a/moo/configure.ac +++ b/moo/configure.ac @@ -645,15 +645,20 @@ else AC_SUBST(BUILD_MODE, "release") fi - AC_ARG_ENABLE([unicode], - [AS_HELP_STRING([--enable-unicode],[Use the unicode character type as the default character type (default. yes)])], + [AS_HELP_STRING([--enable-unicode],[Use the unicode character type as the default character type. one of yes, no, ucs2, ucs4 (default. yes)])], enable_unicode=$enableval, enable_unicode=yes ) if test "${enable_unicode}" = "yes" then AC_DEFINE([MOO_ENABLE_UNICODE],[1],[Use the unicode character type as the default character type]) +elif test "${enable_unicode}" = "ucs2" +then + AC_DEFINE([MOO_ENABLE_UNICODE],[2],[Use the unicode character type as the default character type]) +elif test "${enable_unicode}" = "ucs4" +then + AC_DEFINE([MOO_ENABLE_UNICODE],[4],[Use the unicode character type as the default character type]) fi AC_ARG_ENABLE([cxx], diff --git a/moo/lib/bigint.c b/moo/lib/bigint.c index 3e6c2f1..e458b0a 100644 --- a/moo/lib/bigint.c +++ b/moo/lib/bigint.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/comp.c b/moo/lib/comp.c index 11bcc4d..e6bc29b 100644 --- a/moo/lib/comp.c +++ b/moo/lib/comp.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/debug.c b/moo/lib/debug.c index 697d33f..de89233 100644 --- a/moo/lib/debug.c +++ b/moo/lib/debug.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/decode.c b/moo/lib/decode.c index a011179..11fd0f1 100644 --- a/moo/lib/decode.c +++ b/moo/lib/decode.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/dic.c b/moo/lib/dic.c index e325a54..56367fe 100644 --- a/moo/lib/dic.c +++ b/moo/lib/dic.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/err.c b/moo/lib/err.c index 1348bd6..fc38cc3 100644 --- a/moo/lib/err.c +++ b/moo/lib/err.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/exec.c b/moo/lib/exec.c index bf83077..cce37e9 100644 --- a/moo/lib/exec.c +++ b/moo/lib/exec.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/gc.c b/moo/lib/gc.c index dbff985..b6e1216 100644 --- a/moo/lib/gc.c +++ b/moo/lib/gc.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/heap.c b/moo/lib/heap.c index aebecfb..30ab517 100644 --- a/moo/lib/heap.c +++ b/moo/lib/heap.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/logfmt.c b/moo/lib/logfmt.c index 03f3681..51aa087 100644 --- a/moo/lib/logfmt.c +++ b/moo/lib/logfmt.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/logfmtv.h b/moo/lib/logfmtv.h index 37fa633..13e223b 100644 --- a/moo/lib/logfmtv.h +++ b/moo/lib/logfmtv.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/main.c b/moo/lib/main.c index c7cd7ff..e35c88a 100644 --- a/moo/lib/main.c +++ b/moo/lib/main.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/moo-cmn.h b/moo/lib/moo-cmn.h index 06c11df..092e5c8 100644 --- a/moo/lib/moo-cmn.h +++ b/moo/lib/moo-cmn.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -280,15 +280,26 @@ typedef unsigned char moo_bchu_t; /* unsigned version of moo_bch_t for #define MOO_SIZEOF_BCH_T MOO_SIZEOF_CHAR #define MOO_SIZEOF_BCI_T MOO_SIZEOF_INT -#if defined(__GNUC__) && defined(__CHAR16_TYPE__) -/* TODO ... wchar_t???, char16_t? char32_t? */ -typedef __CHAR16_TYPE__ moo_uch_t; +#if defined(MOO_ENABLE_UNICODE) && (MOO_ENABLE_UNICODE == 4) +# if defined(__GNUC__) && defined(__CHAR32_TYPE__) + typedef __CHAR32_TYPE__ moo_uch_t; +# else + typedef moo_uint32_t moo_uch_t; +# endif + typedef moo_uint32_t moo_uchu_t; /* same as moo_uch_t as it is already unsigned */ +# define MOO_SIZEOF_UCH_T 4 + +#elif defined(__GNUC__) && defined(__CHAR16_TYPE__) + typedef __CHAR16_TYPE__ moo_uch_t; + typedef moo_uint16_t moo_uchu_t; /* same as moo_uch_t as it is already unsigned */ +# define MOO_SIZEOF_UCH_T 2 #else -typedef moo_uint16_t moo_uch_t; + typedef moo_uint16_t moo_uch_t; + typedef moo_uint16_t moo_uchu_t; /* same as moo_uch_t as it is already unsigned */ +# define MOO_SIZEOF_UCH_T 2 #endif + typedef moo_int32_t moo_uci_t; -typedef moo_uint16_t moo_uchu_t; /* same as moo_uch_t as it is already unsigned */ -#define MOO_SIZEOF_UCH_T 2 #define MOO_SIZEOF_UCI_T 4 typedef moo_uint8_t moo_oob_t; diff --git a/moo/lib/moo-opt.h b/moo/lib/moo-opt.h index 1680894..e1c16de 100644 --- a/moo/lib/moo-opt.h +++ b/moo/lib/moo-opt.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/moo-prv.h b/moo/lib/moo-prv.h index 9f09a11..f4f6b1f 100644 --- a/moo/lib/moo-prv.h +++ b/moo/lib/moo-prv.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/moo-rbt.h b/moo/lib/moo-rbt.h index 142b633..6b37c80 100644 --- a/moo/lib/moo-rbt.h +++ b/moo/lib/moo-rbt.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/moo-utl.h b/moo/lib/moo-utl.h index 7a2378b..9765b10 100644 --- a/moo/lib/moo-utl.h +++ b/moo/lib/moo-utl.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/moo.c b/moo/lib/moo.c index fbe9b08..440647b 100644 --- a/moo/lib/moo.c +++ b/moo/lib/moo.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/moo.h b/moo/lib/moo.h index db54bf5..9997d85 100644 --- a/moo/lib/moo.h +++ b/moo/lib/moo.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/obj.c b/moo/lib/obj.c index 0d2fbe6..ff805b2 100644 --- a/moo/lib/obj.c +++ b/moo/lib/obj.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/opt-impl.h b/moo/lib/opt-impl.h index 19e2d1b..c398227 100644 --- a/moo/lib/opt-impl.h +++ b/moo/lib/opt-impl.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/opt.c b/moo/lib/opt.c index d2e2d64..f8497f4 100644 --- a/moo/lib/opt.c +++ b/moo/lib/opt.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/pack1.h b/moo/lib/pack1.h index cbad10a..36f82f0 100644 --- a/moo/lib/pack1.h +++ b/moo/lib/pack1.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/pf-basic.c b/moo/lib/pf-basic.c index 10e3354..e7a386c 100644 --- a/moo/lib/pf-basic.c +++ b/moo/lib/pf-basic.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/rbt.c b/moo/lib/rbt.c index f724a10..83ae026 100644 --- a/moo/lib/rbt.c +++ b/moo/lib/rbt.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/sym.c b/moo/lib/sym.c index c459e46..52245b7 100644 --- a/moo/lib/sym.c +++ b/moo/lib/sym.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/unpack.h b/moo/lib/unpack.h index 5947c15..a87361b 100644 --- a/moo/lib/unpack.h +++ b/moo/lib/unpack.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/utf8.c b/moo/lib/utf8.c index ef1ecfb..f962e8a 100644 --- a/moo/lib/utf8.c +++ b/moo/lib/utf8.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/lib/utl.c b/moo/lib/utl.c index 3c7631b..0eb3381 100644 --- a/moo/lib/utl.c +++ b/moo/lib/utl.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/mod/_sck.h b/moo/mod/_sck.h index 90275af..84f73ea 100644 --- a/moo/mod/_sck.h +++ b/moo/mod/_sck.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/mod/_x11.h b/moo/mod/_x11.h index 10f811b..6db8769 100644 --- a/moo/mod/_x11.h +++ b/moo/mod/_x11.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/mod/ffi.c b/moo/mod/ffi.c index dcf048c..9b80d82 100644 --- a/moo/mod/ffi.c +++ b/moo/mod/ffi.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/mod/sck-addr.c b/moo/mod/sck-addr.c index 1d8ce80..9e56b25 100644 --- a/moo/mod/sck-addr.c +++ b/moo/mod/sck-addr.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/mod/sck.c b/moo/mod/sck.c index 7a94803..3ffdf95 100644 --- a/moo/mod/sck.c +++ b/moo/mod/sck.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/mod/stdio.c b/moo/mod/stdio.c index 8e82226..0d97427 100644 --- a/moo/mod/stdio.c +++ b/moo/mod/stdio.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/moo/mod/x11.c b/moo/mod/x11.c index c97d0f3..ff949a5 100644 --- a/moo/mod/x11.c +++ b/moo/mod/x11.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2014-2017 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2014-2018 Chung, Hyung-Hwan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -55,7 +55,7 @@ static XChar2b* uchars_to_xchar2bstr (moo_t* moo, const moo_uch_t* inptr, moo_oo uch = *inptr++; #if (MOO_SIZEOF_UCH_T > 2) - if (uch > 0xFFFF) uc = 0xFFFD; /* unicode replacement character */ + if (uch > 0xFFFF) uch = 0xFFFD; /* unicode replacement character */ #endif outptr->byte1 = (uch >> 8) & 0xFF;