Added test whether wchar_t is signed or not. A signed wchar_t is not usable as internal unicode type base for Py_UNICODE since the unicode implementation assumes an unsigned type.

This commit is contained in:
Marc-André Lemburg 2003-09-22 11:14:40 +00:00
parent 7e74384af5
commit d7160f8845
3 changed files with 2349 additions and 3103 deletions

View File

@ -12,6 +12,10 @@ What's New in Python 2.4 alpha 1?
Core and builtins Core and builtins
----------------- -----------------
- Added test whether wchar_t is signed or not. A signed wchar_t is not
usable as internal unicode type base for Py_UNICODE since the
unicode implementation assumes an unsigned type.
- Fixed a bug in the cache of length-one Unicode strings that could - Fixed a bug in the cache of length-one Unicode strings that could
lead to a seg fault. The specific problem occurred when an earlier, lead to a seg fault. The specific problem occurred when an earlier,
non-fatal error left an uninitialized Unicode object in the non-fatal error left an uninitialized Unicode object in the

5422
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -2689,6 +2689,25 @@ AC_TRY_COMPILE([
]) ])
AC_MSG_RESULT($have_ucs4_tcl) AC_MSG_RESULT($have_ucs4_tcl)
# check whether wchar_t is signed or not
if test "$wchar_h" = yes
then
# check whether wchar_t is signed or not
AC_MSG_CHECKING(whether wchar_t is signed)
AC_CACHE_VAL(ac_cv_wchar_t_signed, [
AC_TRY_RUN([
#include <wchar.h>
int main()
{
exit((((wchar_t) -1) < ((wchar_t) 0)) ? 1 : 0);
}
],
ac_cv_wchar_t_signed=yes,
ac_cv_wchar_t_signed=no,
ac_cv_wchar_t_signed=yes)])
AC_MSG_RESULT($ac_cv_wchar_t_signed)
fi
AC_MSG_CHECKING(what type to use for unicode) AC_MSG_CHECKING(what type to use for unicode)
dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
AC_ARG_ENABLE(unicode, AC_ARG_ENABLE(unicode,
@ -2730,12 +2749,15 @@ else
UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o" UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
AC_DEFINE(Py_USING_UNICODE, 1, AC_DEFINE(Py_USING_UNICODE, 1,
[Define if you want to have a Unicode type.]) [Define if you want to have a Unicode type.])
if test "$unicode_size" = "$ac_cv_sizeof_wchar_t"
# wchar_t is only usable if it maps to an unsigned type
if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
-a "$ac_cv_wchar_t_signed" == "no"
then then
PY_UNICODE_TYPE="wchar_t" PY_UNICODE_TYPE="wchar_t"
AC_DEFINE(HAVE_USABLE_WCHAR_T, 1, AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
[Define if you have a useable wchar_t type defined in wchar.h; useable [Define if you have a useable wchar_t type defined in wchar.h; useable
means wchar_t must be 16-bit unsigned type. (see means wchar_t must be an unsigned type with at least 16 bits. (see
Include/unicodeobject.h).]) Include/unicodeobject.h).])
AC_DEFINE(PY_UNICODE_TYPE,wchar_t) AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
elif test "$ac_cv_sizeof_short" = "$unicode_size" elif test "$ac_cv_sizeof_short" = "$unicode_size"