enhanced --enable-unicode to accept ucs4 and ucs2 in addition to yes/no.

redefined the moo_uch_t type to follow the enable-unicode value
This commit is contained in:
hyunghwan.chung 2018-02-21 10:11:39 +00:00
parent c16546c3df
commit ae0f559060
38 changed files with 73 additions and 47 deletions

14
moo/configure vendored
View File

@ -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.

View File

@ -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],

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;