From 6b82a9c6b49d16e701f096891550c93661a58bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= Date: Tue, 29 Dec 2020 11:08:33 +0100 Subject: [PATCH] libstdc++: implement locale support for POSIX 2008 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The implementation is based on dragonfly one. It also adds support for AIX with a few tweaks. As of now, a few locale functions are missing on AIX. For strftime_l, localeconv_l, mbstowcs_l and wcsftime_l, uselocale must be set prior to use the version without _l. For strtof_l, strtod_l, strtold_l, a wrapper simply calls the default version. libstdc++-v3/ChangeLog: 2021-01-12 Clément Chigot * acinclude.m4: Add ieee_1003.1-2008 locale model. * configure: Regenerate. * config/os/aix/ctype_configure_char.cc: Enable locale support. * testsuite/lib/libstdc++.exp (check_v3_target_namedlocale): Handle AIX locale names. * testsuite/util/testsuite_hooks.h: Likewise. * config/locale/dragonfly/c_locale.cc: Removed. * config/locale/dragonfly/c_locale.h: Removed. * config/locale/dragonfly/codecvt_members.cc: Removed. * config/locale/dragonfly/collate_members.cc: Removed. * config/locale/dragonfly/ctype_members.cc: Removed. * config/locale/dragonfly/monetary_members.cc: Removed. * config/locale/dragonfly/numeric_members.cc: Removed. * config/locale/dragonfly/time_members.cc: Removed. * config/locale/dragonfly/time_members.h: Removed. * config/locale/ieee_1003.1-2008/c_locale.cc: New file. * config/locale/ieee_1003.1-2008/c_locale.h: New file. * config/locale/ieee_1003.1-2008/codecvt_members.cc: New file. * config/locale/ieee_1003.1-2008/collate_members.cc: New file. * config/locale/ieee_1003.1-2008/ctype_members.cc: New file. * config/locale/ieee_1003.1-2008/monetary_members.cc: New file. * config/locale/ieee_1003.1-2008/numeric_members.cc: New file. * config/locale/ieee_1003.1-2008/time_members.cc: New file. * config/locale/ieee_1003.1-2008/time_members.h: New file. --- libstdc++-v3/acinclude.m4 | 360 +++++++++++++++++- libstdc++-v3/config.h.in | 45 +++ .../c_locale.cc | 3 + .../c_locale.h | 45 +++ .../codecvt_members.cc | 0 .../collate_members.cc | 35 +- .../ctype_members.cc | 156 +++++++- .../monetary_members.cc | 39 +- .../numeric_members.cc | 25 ++ .../time_members.cc | 31 +- .../time_members.h | 0 .../config/os/aix/ctype_configure_char.cc | 10 +- .../os/gnu-linux/ctype_configure_char.cc | 4 +- .../22_locale/codecvt/in/wchar_t/2.cc | 1 + .../22_locale/codecvt/in/wchar_t/3.cc | 1 + .../22_locale/codecvt/in/wchar_t/4.cc | 1 + .../22_locale/codecvt/in/wchar_t/7.cc | 1 + .../22_locale/codecvt/in/wchar_t/8.cc | 1 + .../22_locale/codecvt/in/wchar_t/9.cc | 1 + .../22_locale/codecvt/length/wchar_t/4.cc | 1 + .../22_locale/codecvt/out/wchar_t/4.cc | 1 + .../22_locale/codecvt/unshift/wchar_t/4.cc | 1 + .../basic_filebuf/overflow/wchar_t/11305-1.cc | 1 + .../basic_filebuf/overflow/wchar_t/11305-2.cc | 1 + .../basic_filebuf/overflow/wchar_t/11305-3.cc | 1 + .../basic_filebuf/overflow/wchar_t/11305-4.cc | 1 + libstdc++-v3/testsuite/lib/libstdc++.exp | 5 + libstdc++-v3/testsuite/util/testsuite_hooks.h | 3 + 28 files changed, 727 insertions(+), 47 deletions(-) rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/c_locale.cc (99%) rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/c_locale.h (72%) rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/codecvt_members.cc (100%) rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/collate_members.cc (71%) rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/ctype_members.cc (57%) rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/monetary_members.cc (96%) rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/numeric_members.cc (92%) rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/time_members.cc (93%) rename libstdc++-v3/config/locale/{dragonfly => ieee_1003.1-2008}/time_members.h (100%) diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index e4175ea3e64..e1d705309d7 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -2421,7 +2421,7 @@ dnl AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [ GLIBCXX_ENABLE(clocale,auto,[[[=MODEL]]], [use MODEL for target locale package], - [permit generic|gnu|ieee_1003.1-2001|newlib|yes|no|auto]) + [permit generic|gnu|ieee_1003.1-2001|ieee_1003.1-2008|newlib|yes|no|auto]) # Deal with gettext issues. Default to not using it (=no) until we detect # support for it later. Let the user turn it off via --e/d, but let that @@ -2448,8 +2448,8 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [ darwin*) enable_clocale_flag=darwin ;; - dragonfly* | freebsd*) - enable_clocale_flag=dragonfly + aix* | dragonfly* | freebsd*) + enable_clocale_flag=ieee_1003.1-2008 ;; openbsd*) enable_clocale_flag=newlib @@ -2543,23 +2543,6 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [ CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h ;; - dragonfly) - AC_MSG_RESULT(dragonfly or freebsd) - - CLOCALE_H=config/locale/dragonfly/c_locale.h - CLOCALE_CC=config/locale/dragonfly/c_locale.cc - CCODECVT_CC=config/locale/dragonfly/codecvt_members.cc - CCOLLATE_CC=config/locale/dragonfly/collate_members.cc - CCTYPE_CC=config/locale/dragonfly/ctype_members.cc - CMESSAGES_H=config/locale/generic/messages_members.h - CMESSAGES_CC=config/locale/generic/messages_members.cc - CMONEY_CC=config/locale/dragonfly/monetary_members.cc - CNUMERIC_CC=config/locale/dragonfly/numeric_members.cc - CTIME_H=config/locale/dragonfly/time_members.h - CTIME_CC=config/locale/dragonfly/time_members.cc - CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h - ;; - gnu) AC_MSG_RESULT(gnu) @@ -2610,6 +2593,24 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [ CTIME_CC=config/locale/generic/time_members.cc CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h ;; + + ieee_1003.1-2008) + AC_MSG_RESULT(ieee_1003.1-2008) + + CLOCALE_H=config/locale/ieee_1003.1-2008/c_locale.h + CLOCALE_CC=config/locale/ieee_1003.1-2008/c_locale.cc + CCODECVT_CC=config/locale/ieee_1003.1-2008/codecvt_members.cc + CCOLLATE_CC=config/locale/ieee_1003.1-2008/collate_members.cc + CCTYPE_CC=config/locale/ieee_1003.1-2008/ctype_members.cc + CMESSAGES_H=config/locale/generic/messages_members.h + CMESSAGES_CC=config/locale/generic/messages_members.cc + CMONEY_CC=config/locale/ieee_1003.1-2008/monetary_members.cc + CNUMERIC_CC=config/locale/ieee_1003.1-2008/numeric_members.cc + CTIME_H=config/locale/ieee_1003.1-2008/time_members.h + CTIME_CC=config/locale/ieee_1003.1-2008/time_members.cc + CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h + ;; + newlib) AC_MSG_RESULT(newlib) @@ -2656,6 +2657,325 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [ AC_SUBST(CTIME_CC) AC_SUBST(CLOCALE_CC) AC_SUBST(CLOCALE_INTERNAL_H) + + if test $enable_clocale_flag = ieee_1003.1-2008; then + case ${target_os} in + dragonfly* | freebsd*) AC_DEFINE(_GLIBCXX_NEED_XLOCALE_H, 1, + [Define if must be included for locale support.]);; + esac + + # Set it to scream when it hurts. + ac_save_CFLAGS="$CFLAGS" + CFLAGS="-Wimplicit-function-declaration -Werror" + + # Use strtof_l if available. + AC_MSG_CHECKING([for strtof_l]) + AC_CACHE_VAL(glibcxx_cv_strtof_l, [ + AC_TRY_COMPILE( + [ + #include + #ifdef _GLIBCXX_NEED_XLOCALE_H + #include + #endif + ], + [strtof_l(0,0,0)], + [glibcxx_cv_strtof_l=yes], + [glibcxx_cv_strtof_l=no]) + ]) + if test $glibcxx_cv_strtof_l = yes; then + AC_DEFINE(HAVE_STRTOF_L, 1, + [Define if strtof_l is available in .]) + fi + AC_MSG_RESULT($glibcxx_cv_strtof_l) + + # Use strtod_l if available. + AC_MSG_CHECKING([for strtod_l]) + AC_CACHE_VAL(glibcxx_cv_strtod_l, [ + AC_TRY_COMPILE( + [ + #include + #ifdef _GLIBCXX_NEED_XLOCALE_H + #include + #endif + ], + [strtod_l(0,0,0)], + [glibcxx_cv_strtod_l=yes], + [glibcxx_cv_strtod_l=no]) + ]) + if test $glibcxx_cv_strtod_l = yes; then + AC_DEFINE(HAVE_STRTOD_L, 1, + [Define if strtod_l is available in .]) + fi + AC_MSG_RESULT($glibcxx_cv_strtod_l) + + # Use strtold_l if available. + AC_MSG_CHECKING([for strtold_l]) + AC_CACHE_VAL(glibcxx_cv_strtold_l, [ + AC_TRY_COMPILE( + [ + #include + #ifdef _GLIBCXX_NEED_XLOCALE_H + #include + #endif + ], + [strtold_l(0,0,0)], + [glibcxx_cv_strtold_l=yes], + [glibcxx_cv_strtold_l=no]) + ]) + if test $glibcxx_cv_strtold_l = yes; then + AC_DEFINE(HAVE_STRTOLD_L, 1, + [Define if strtold_l is available in .]) + fi + AC_MSG_RESULT($glibcxx_cv_strtold_l) + + # Use localeconv_l if available. + AC_MSG_CHECKING([for localeconv_l]) + AC_CACHE_VAL(glibcxx_cv_localeconv_l, [ + AC_TRY_COMPILE( + [ + #include + #ifdef _GLIBCXX_NEED_XLOCALE_H + #include + #endif + ], + [localeconv_l(0)], + [glibcxx_cv_localeconv_l=yes], + [glibcxx_cv_localeconv_l=no]) + ]) + if test $glibcxx_cv_localeconv_l = yes; then + AC_DEFINE(HAVE_LOCALECONV_L, 1, + [Define if localeconv_l is available in .]) + fi + AC_MSG_RESULT($glibcxx_cv_localeconv_l) + + # Use mbstowcs_l if available. + AC_MSG_CHECKING([for mbstowcs_l]) + AC_CACHE_VAL(glibcxx_cv_mbstowcs_l, [ + AC_TRY_COMPILE( + [ + #include + #ifdef _GLIBCXX_NEED_XLOCALE_H + #include + #endif + ], + [mbstowcs_l(0,0,0,0)], + [glibcxx_cv_mbstowcs_l=yes], + [glibcxx_cv_mbstowcs_l=no]) + ]) + if test $glibcxx_cv_mbstowcs_l = yes; then + AC_DEFINE(HAVE_MBSTOWCS_L, 1, + [Define if mbstowcs_l is available in .]) + fi + AC_MSG_RESULT($glibcxx_cv_mbstowcs_l) + + # Use wcsftime_l if available. + AC_MSG_CHECKING([for wcsftime_l]) + AC_CACHE_VAL(glibcxx_cv_wcsftime_l, [ + AC_TRY_COMPILE( + [ + #include + #ifdef _GLIBCXX_NEED_XLOCALE_H + #include + #endif + ], + [wcsftime_l(0,0,0,0,0)], + [glibcxx_cv_wcsftime_l=yes], + [glibcxx_cv_wcsftime_l=no]) + ]) + if test $glibcxx_cv_wcsftime_l = yes; then + AC_DEFINE(HAVE_WCSFTIME_L, 1, + [Define if wcsftime_l is available in .]) + fi + AC_MSG_RESULT($glibcxx_cv_wcsftime_l) + + # Use iswctype_l if available. + AC_MSG_CHECKING([for iswctype_l]) + AC_CACHE_VAL(glibcxx_cv_iswctype_l, [ + AC_TRY_COMPILE( + [ + #include + #include + #ifdef _GLIBCXX_NEED_XLOCALE_H + #include + #endif + ], + [iswctype_l(0,0,0)], + [glibcxx_cv_iswctype_l=yes], + [glibcxx_cv_iswctype_l=no]) + ]) + if test $glibcxx_cv_iswctype_l = yes; then + AC_DEFINE(HAVE_ISWCTYPE_L, 1, + [Define if iswctype_l is available in or .]) + fi + AC_MSG_RESULT($glibcxx_cv_iswctype_l) + + # Use wctype_l if available. + AC_MSG_CHECKING([for wctype_l]) + AC_CACHE_VAL(glibcxx_cv_wctype_l, [ + AC_TRY_COMPILE( + [ + #include + #include + #ifdef _GLIBCXX_NEED_XLOCALE_H + #include + #endif + ], + [wctype_l(0,0)], + [glibcxx_cv_wctype_l=yes], + [glibcxx_cv_wctype_l=no]) + ]) + if test $glibcxx_cv_wctype_l = yes; then + AC_DEFINE(HAVE_WCTYPE_L, 1, + [Define if wctype_l is available in or .]) + fi + AC_MSG_RESULT($glibcxx_cv_wctype_l) + + # Use strcoll_l if available. + AC_MSG_CHECKING([for strcoll_l]) + AC_CACHE_VAL(glibcxx_cv_strcoll_l, [ + AC_TRY_COMPILE( + [ + #include + #ifdef _GLIBCXX_NEED_XLOCALE_H + #include + #endif + ], + [strcoll_l(0,0,0)], + [glibcxx_cv_strcoll_l=yes], + [glibcxx_cv_strcoll_l=no]) + ]) + if test $glibcxx_cv_strcoll_l = yes; then + AC_DEFINE(HAVE_STRCOLL_L, 1, + [Define if strcoll_l is available in .]) + fi + AC_MSG_RESULT($glibcxx_cv_strcoll_l) + + # Use strxfrm_l if available. + AC_MSG_CHECKING([for strxfrm_l]) + AC_CACHE_VAL(glibcxx_cv_strxfrm_l, [ + AC_TRY_COMPILE( + [ + #include + #ifdef _GLIBCXX_NEED_XLOCALE_H + #include + #endif + ], + [strxfrm_l(0,0,0,0)], + [glibcxx_cv_strxfrm_l=yes], + [glibcxx_cv_strxfrm_l=no]) + ]) + if test $glibcxx_cv_strxfrm_l = yes; then + AC_DEFINE(HAVE_STRXFRM_L, 1, + [Define if strxfrm_l is available in .]) + fi + AC_MSG_RESULT($glibcxx_cv_strxfrm_l) + + # Use wcscoll_l if available. + AC_MSG_CHECKING([for wcscoll_l]) + AC_CACHE_VAL(glibcxx_cv_wcscoll_l, [ + AC_TRY_COMPILE( + [ + #include + #include + #ifdef _GLIBCXX_NEED_XLOCALE_H + #include + #endif + ], + [wcscoll_l(0,0,0)], + [glibcxx_cv_wcscoll_l=yes], + [glibcxx_cv_wcscoll_l=no]) + ]) + if test $glibcxx_cv_wcscoll_l = yes; then + AC_DEFINE(HAVE_WCSCOLL_L, 1, + [Define if wcscoll_l is available in or .]) + fi + AC_MSG_RESULT($glibcxx_cv_wcscoll_l) + + # Use wcsxfrm_l if available. + AC_MSG_CHECKING([for wcsxfrm_l]) + AC_CACHE_VAL(glibcxx_cv_wcsxfrm_l, [ + AC_TRY_COMPILE( + [ + #include + #include + #ifdef _GLIBCXX_NEED_XLOCALE_H + #include + #endif + ], + [wcsxfrm_l(0,0,0,0)], + [glibcxx_cv_wcsxfrm_l=yes], + [glibcxx_cv_wcsxfrm_l=no]) + ]) + if test $glibcxx_cv_wcsxfrm_l = yes; then + AC_DEFINE(HAVE_WCSXFRM_L, 1, + [Define if wcsxfrm_l is available in or .]) + fi + AC_MSG_RESULT($glibcxx_cv_wcsxfrm_l) + + # Use towlower_l if available. + AC_MSG_CHECKING([for towlower_l]) + AC_CACHE_VAL(glibcxx_cv_towlower_l, [ + AC_TRY_COMPILE( + [ + #include + #include + #ifdef _GLIBCXX_NEED_XLOCALE_H + #include + #endif + ], + [towlower_l(0,0)], + [glibcxx_cv_towlower_l=yes], + [glibcxx_cv_towlower_l=no]) + ]) + if test $glibcxx_cv_towlower_l = yes; then + AC_DEFINE(HAVE_TOWLOWER_L, 1, + [Define if towlower_l is available in or .]) + fi + AC_MSG_RESULT($glibcxx_cv_towlower_l) + + # Use towupper_l if available. + AC_MSG_CHECKING([for towupper_l]) + AC_CACHE_VAL(glibcxx_cv_towupper_l, [ + AC_TRY_COMPILE( + [ + #include + #include + #ifdef _GLIBCXX_NEED_XLOCALE_H + #include + #endif + ], + [towupper_l(0,0)], + [glibcxx_cv_towupper_l=yes], + [glibcxx_cv_towupper_l=no]) + ]) + if test $glibcxx_cv_towupper_l = yes; then + AC_DEFINE(HAVE_TOWUPPER_L, 1, + [Define if towupper_l is available in or .]) + fi + AC_MSG_RESULT($glibcxx_cv_towupper_l) + + # Use strftime_l if available. + AC_MSG_CHECKING([for strftime_l]) + AC_CACHE_VAL(glibcxx_cv_strftime_l, [ + AC_TRY_COMPILE( + [ + #include + #ifdef _GLIBCXX_NEED_XLOCALE_H + #include + #endif + ], + [strftime_l(0,0,0,0,0)], + [glibcxx_cv_strftime_l=yes], + [glibcxx_cv_strftime_l=no]) + ]) + if test $glibcxx_cv_strftime_l = yes; then + AC_DEFINE(HAVE_STRFTIME_L, 1, + [Define if strftime_l is available in .]) + fi + AC_MSG_RESULT($glibcxx_cv_strftime_l) + + CFLAGS="$ac_save_CFLAGS" + fi ]) diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index d36ca2620b4..b02bf922364 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -186,6 +186,9 @@ /* Defined if iswblank exists. */ #undef HAVE_ISWBLANK +/* Define if iswctype_l is available in or . */ +#undef HAVE_ISWCTYPE_L + /* Define if LC_MESSAGES is available in . */ #undef HAVE_LC_MESSAGES @@ -225,6 +228,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_TYPES_H +/* Define if localeconv_l is available in . */ +#undef HAVE_LOCALECONV_L + /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H @@ -249,6 +255,9 @@ /* Define if mbstate_t exists in wchar.h. */ #undef HAVE_MBSTATE_T +/* Define if mbstowcs_l is available in . */ +#undef HAVE_MBSTOWCS_L + /* Define to 1 if you have the `memalign' function. */ #undef HAVE_MEMALIGN @@ -354,24 +363,39 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H +/* Define if strcoll_l is available in . */ +#undef HAVE_STRCOLL_L + /* Define if strerror_l is available in . */ #undef HAVE_STRERROR_L /* Define if strerror_r is available in . */ #undef HAVE_STRERROR_R +/* Define if strftime_l is available in . */ +#undef HAVE_STRFTIME_L + /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H +/* Define if strtod_l is available in . */ +#undef HAVE_STRTOD_L + /* Define to 1 if you have the `strtof' function. */ #undef HAVE_STRTOF +/* Define if strtof_l is available in . */ +#undef HAVE_STRTOF_L + /* Define to 1 if you have the `strtold' function. */ #undef HAVE_STRTOLD +/* Define if strtold_l is available in . */ +#undef HAVE_STRTOLD_L + /* Define to 1 if `d_type' is a member of `struct dirent'. */ #undef HAVE_STRUCT_DIRENT_D_TYPE @@ -460,6 +484,12 @@ /* Define to 1 if the target supports thread-local storage. */ #undef HAVE_TLS +/* Define if towlower_l is available in or . */ +#undef HAVE_TOWLOWER_L + +/* Define if towupper_l is available in or . */ +#undef HAVE_TOWUPPER_L + /* Define if truncate is available in . */ #undef HAVE_TRUNCATE @@ -490,12 +520,24 @@ /* Define to 1 if you have the header file. */ #undef HAVE_WCHAR_H +/* Define if wcscoll_l is available in or . */ +#undef HAVE_WCSCOLL_L + +/* Define if wcsftime_l is available in . */ +#undef HAVE_WCSFTIME_L + /* Defined if wcstof exists. */ #undef HAVE_WCSTOF +/* Define if wcsxfrm_l is available in or . */ +#undef HAVE_WCSXFRM_L + /* Define to 1 if you have the header file. */ #undef HAVE_WCTYPE_H +/* Define if wctype_l is available in or . */ +#undef HAVE_WCTYPE_L + /* Defined if Sleep exists. */ #undef HAVE_WIN32_SLEEP @@ -835,6 +877,9 @@ /* Define to the letter to which size_t is mangled. */ #undef _GLIBCXX_MANGLE_SIZE_T +/* Define if must be included for locale support. */ +#undef _GLIBCXX_NEED_XLOCALE_H + /* Define if C99 llrint and llround functions are missing from . */ #undef _GLIBCXX_NO_C99_ROUNDING_FUNCS diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.cc similarity index 99% rename from libstdc++-v3/config/locale/dragonfly/c_locale.cc rename to libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.cc index 02df4605bb5..ea1531f5691 100644 --- a/libstdc++-v3/config/locale/dragonfly/c_locale.cc +++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.cc @@ -33,8 +33,11 @@ #include #include #include + #include +#ifdef _GLIBCXX_NEED_XLOCALE_H #include +#endif namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.h b/libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.h similarity index 72% rename from libstdc++-v3/config/locale/dragonfly/c_locale.h rename to libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.h index cf4281cebbf..31c9aab6712 100644 --- a/libstdc++-v3/config/locale/dragonfly/c_locale.h +++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/c_locale.h @@ -40,7 +40,48 @@ #pragma GCC system_header #include +#include +#ifdef _GLIBCXX_NEED_XLOCALE_H #include +#endif + +#define _GLIBCXX_C_LOCALE_IEEE_2008 1 + +#ifndef _GLIBCXX_HAVE_STRTOF_L +extern "C" inline +float strtof_l (const char *__nptr, char **__endptr, + locale_t locale) +{ + locale_t __old = uselocale(locale); + float __res = strtof(__nptr, __endptr); + uselocale(__old); + return __res; +} +#endif + +#ifndef _GLIBCXX_HAVE_STRTOD_L +extern "C" inline +double strtod_l (const char *__nptr, char **__endptr, + locale_t locale) +{ + locale_t __old = uselocale(locale); + double __res = strtod(__nptr, __endptr); + uselocale(__old); + return __res; +} +#endif + +#ifndef _GLIBCXX_HAVE_STRTOLD_L +extern "C" inline +long double strtold_l (const char *__nptr, char **__endptr, + locale_t locale) +{ + locale_t __old = uselocale(locale); + long double __res = strtold(__nptr, __endptr); + uselocale(__old); + return __res; +} +#endif #define _GLIBCXX_NUM_CATEGORIES 0 @@ -48,7 +89,11 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION +#if defined(__DragonFly__) || defined(__FreeBSD__) typedef int* __c_locale; +#else + typedef locale_t __c_locale; +#endif // Convert numeric value of type double and long double to string and // return length of string. If vsnprintf is available use it, otherwise diff --git a/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/codecvt_members.cc similarity index 100% rename from libstdc++-v3/config/locale/dragonfly/codecvt_members.cc rename to libstdc++-v3/config/locale/ieee_1003.1-2008/codecvt_members.cc diff --git a/libstdc++-v3/config/locale/dragonfly/collate_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/collate_members.cc similarity index 71% rename from libstdc++-v3/config/locale/dragonfly/collate_members.cc rename to libstdc++-v3/config/locale/ieee_1003.1-2008/collate_members.cc index 64c7d864a61..6ecf29bfc65 100644 --- a/libstdc++-v3/config/locale/dragonfly/collate_members.cc +++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/collate_members.cc @@ -43,7 +43,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION collate::_M_compare(const char* __one, const char* __two) const throw() { +#ifdef _GLIBCXX_HAVE_STRCOLL_L int __cmp = strcoll_l(__one, __two, (locale_t)_M_c_locale_collate); +#else + __c_locale __old = uselocale((locale_t)_M_c_locale_collate); + int __cmp = strcoll(__one, __two); + uselocale(__old); +#endif return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0); } @@ -51,7 +57,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION size_t collate::_M_transform(char* __to, const char* __from, size_t __n) const throw() - { return strxfrm_l(__to, __from, __n, (locale_t)_M_c_locale_collate); } + { +#ifdef _GLIBCXX_HAVE_STRXFRM_L + return strxfrm_l(__to, __from, __n, (locale_t)_M_c_locale_collate); +#else + __c_locale __old = uselocale((locale_t)_M_c_locale_collate); + size_t __res = strxfrm(__to, __from, __n); + uselocale(__old); + return __res; +#endif + } #ifdef _GLIBCXX_USE_WCHAR_T template<> @@ -59,7 +74,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION collate::_M_compare(const wchar_t* __one, const wchar_t* __two) const throw() { +#ifdef _GLIBCXX_HAVE_WCSCOLL_L int __cmp = wcscoll_l(__one, __two, (locale_t)_M_c_locale_collate); +#else + __c_locale __old = uselocale((locale_t)_M_c_locale_collate); + int __cmp = wcscoll(__one, __two); + uselocale(__old); +#endif + return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0); } @@ -67,7 +89,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION size_t collate::_M_transform(wchar_t* __to, const wchar_t* __from, size_t __n) const throw() - { return wcsxfrm_l(__to, __from, __n, (locale_t)_M_c_locale_collate); } + { +#ifdef _GLIBCXX_HAVE_WCSXFRM_L + return wcsxfrm_l(__to, __from, __n, (locale_t)_M_c_locale_collate); +#else + __c_locale __old = uselocale((locale_t)_M_c_locale_collate); + size_t __res = wcsxfrm(__to, __from, __n); + uselocale(__old); + return __res; +#endif + } #endif _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/config/locale/dragonfly/ctype_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/ctype_members.cc similarity index 57% rename from libstdc++-v3/config/locale/dragonfly/ctype_members.cc rename to libstdc++-v3/config/locale/ieee_1003.1-2008/ctype_members.cc index 420cb51e07a..e37e9fb3b83 100644 --- a/libstdc++-v3/config/locale/dragonfly/ctype_members.cc +++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/ctype_members.cc @@ -34,7 +34,11 @@ #include #ifndef _ISbit +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #define _ISbit(bit) ((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8)) +#else +#define _ISbit(bit) (1 << bit) +#endif #endif namespace std _GLIBCXX_VISIBILITY(default) @@ -56,85 +60,209 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ctype_byname::~ctype_byname() { } +#ifdef _GLIBCXX_HAVE_WCTYPE_L +#define WCTYPE_L(PROP, LOCALE) wctype_l(PROP, LOCALE) +#else + // "uselocale" must be called before using this macro. +#define WCTYPE_L(PROP, LOCALE) wctype(PROP) +#endif + #ifdef _GLIBCXX_USE_WCHAR_T ctype::__wmask_type ctype::_M_convert_to_wmask(const mask __m) const throw() { +#ifndef _GLIBCXX_HAVE_WCTYPE_L + __c_locale __old = uselocale((locale_t)_M_c_locale_ctype); +#endif __wmask_type __ret; switch (__m) { case space: - __ret = wctype_l("space", (locale_t)_M_c_locale_ctype); + __ret = WCTYPE_L("space", (locale_t)_M_c_locale_ctype); break; case print: - __ret = wctype_l("print", (locale_t)_M_c_locale_ctype); + __ret = WCTYPE_L("print", (locale_t)_M_c_locale_ctype); break; case cntrl: - __ret = wctype_l("cntrl", (locale_t)_M_c_locale_ctype); + __ret = WCTYPE_L("cntrl", (locale_t)_M_c_locale_ctype); break; case upper: - __ret = wctype_l("upper", (locale_t)_M_c_locale_ctype); + __ret = WCTYPE_L("upper", (locale_t)_M_c_locale_ctype); break; case lower: - __ret = wctype_l("lower", (locale_t)_M_c_locale_ctype); + __ret = WCTYPE_L("lower", (locale_t)_M_c_locale_ctype); break; case alpha: - __ret = wctype_l("alpha", (locale_t)_M_c_locale_ctype); + __ret = WCTYPE_L("alpha", (locale_t)_M_c_locale_ctype); break; case digit: - __ret = wctype_l("digit", (locale_t)_M_c_locale_ctype); + __ret = WCTYPE_L("digit", (locale_t)_M_c_locale_ctype); break; case punct: - __ret = wctype_l("punct", (locale_t)_M_c_locale_ctype); + __ret = WCTYPE_L("punct", (locale_t)_M_c_locale_ctype); break; case xdigit: - __ret = wctype_l("xdigit", (locale_t)_M_c_locale_ctype); + __ret = WCTYPE_L("xdigit", (locale_t)_M_c_locale_ctype); break; case alnum: - __ret = wctype_l("alnum", (locale_t)_M_c_locale_ctype); + __ret = WCTYPE_L("alnum", (locale_t)_M_c_locale_ctype); break; case graph: - __ret = wctype_l("graph", (locale_t)_M_c_locale_ctype); + __ret = WCTYPE_L("graph", (locale_t)_M_c_locale_ctype); break; case blank: - __ret = wctype_l("blank", (locale_t)_M_c_locale_ctype); + __ret = WCTYPE_L("blank", (locale_t)_M_c_locale_ctype); break; default: __ret = __wmask_type(); } +#ifndef _GLIBCXX_HAVE_WCTYPE_L + uselocale(__old); +#endif return __ret; } wchar_t ctype::do_toupper(wchar_t __c) const - { return towupper_l(__c, (locale_t)_M_c_locale_ctype); } + { +#ifdef _GLIBCXX_HAVE_TOWUPPER_L + return towupper_l(__c, (locale_t)_M_c_locale_ctype); +#else + __c_locale __old = uselocale((locale_t)_M_c_locale_ctype); + wchar_t __res = towupper(__c); + uselocale(__old); + return __res; +#endif + } const wchar_t* ctype::do_toupper(wchar_t* __lo, const wchar_t* __hi) const { +#ifndef _GLIBCXX_HAVE_TOWUPPER_L + __c_locale __old = uselocale((locale_t)_M_c_locale_ctype); +#endif while (__lo < __hi) { +#ifdef _GLIBCXX_HAVE_TOWUPPER_L *__lo = towupper_l(*__lo, (locale_t)_M_c_locale_ctype); +#else + *__lo = towupper(*__lo); +#endif ++__lo; } +#ifndef _GLIBCXX_HAVE_TOWUPPER_L + uselocale(__old); +#endif return __hi; } wchar_t ctype::do_tolower(wchar_t __c) const - { return towlower_l(__c, (locale_t)_M_c_locale_ctype); } + { +#ifdef _GLIBCXX_HAVE_TOWLOWER_L + return towlower_l(__c, (locale_t)_M_c_locale_ctype); +#else + __c_locale __old = uselocale((locale_t)_M_c_locale_ctype); + wchar_t __res = towlower(__c); + uselocale(__old); + return __res; +#endif + } const wchar_t* ctype::do_tolower(wchar_t* __lo, const wchar_t* __hi) const { +#ifndef _GLIBCXX_HAVE_TOWLOWER_L + __c_locale __old = uselocale((locale_t)_M_c_locale_ctype); +#endif while (__lo < __hi) { +#ifdef _GLIBCXX_HAVE_TOWLOWER_L *__lo = towlower_l(*__lo, (locale_t)_M_c_locale_ctype); +#else + *__lo = towlower(*__lo); +#endif ++__lo; } +#ifndef _GLIBCXX_HAVE_TOWLOWER_L + uselocale(__old); +#endif + return __hi; + } + +#if !defined(__DragonFly__) && !defined(__FreeBSD__) + bool + ctype:: + do_is(mask __m, char_type __c) const + { + bool __ret = false; + const size_t __bitmasksize = 11; +#ifndef _GLIBCXX_HAVE_ISWCTYPE_L + __c_locale __old = uselocale((locale_t)_M_c_locale_ctype); +#endif + for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur) + if (__m & _M_bit[__bitcur] +#ifdef _GLIBCXX_HAVE_ISWCTYPE_L + && iswctype_l(__c, _M_wmask[__bitcur], (locale_t)_M_c_locale_ctype) +#else + && iswctype(__c, _M_wmask[__bitcur]) +#endif + ) + { + __ret = true; + break; + } +#ifndef _GLIBCXX_HAVE_ISWCTYPE_L + uselocale(__old); +#endif + return __ret; + } + + const wchar_t* + ctype:: + do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const + { +#ifndef _GLIBCXX_HAVE_ISWCTYPE_L + __c_locale __old = uselocale((locale_t)_M_c_locale_ctype); +#endif + for (;__lo < __hi; ++__vec, ++__lo) + { + const size_t __bitmasksize = 11; + mask __m = 0; + for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur) +#ifdef _GLIBCXX_HAVE_ISWCTYPE_L + if (iswctype_l(*__lo, _M_wmask[__bitcur], (locale_t)_M_c_locale_ctype)) +#else + if (iswctype(*__lo, _M_wmask[__bitcur])) +#endif + __m |= _M_bit[__bitcur]; + *__vec = __m; + } +#ifndef _GLIBCXX_HAVE_ISWCTYPE_L + uselocale(__old); +#endif return __hi; } + const wchar_t* + ctype:: + do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const + { + while (__lo < __hi && !this->do_is(__m, *__lo)) + ++__lo; + return __lo; + } + + const wchar_t* + ctype:: + do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const + { + while (__lo < __hi && this->do_is(__m, *__lo) != 0) + ++__lo; + return __lo; + } +#endif + wchar_t ctype:: do_widen(char __c) const diff --git a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/monetary_members.cc similarity index 96% rename from libstdc++-v3/config/locale/dragonfly/monetary_members.cc rename to libstdc++-v3/config/locale/ieee_1003.1-2008/monetary_members.cc index e1decc61cbf..700098c5562 100644 --- a/libstdc++-v3/config/locale/dragonfly/monetary_members.cc +++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/monetary_members.cc @@ -31,7 +31,10 @@ #include #include + +#ifdef _GLIBCXX_NEED_XLOCALE_H #include +#endif namespace std _GLIBCXX_VISIBILITY(default) { @@ -241,7 +244,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION else { // Named locale. +#ifdef _GLIBCXX_HAVE_LOCALECONV_L lconv* lc = localeconv_l((locale_t) __cloc); +#else + __c_locale __old = uselocale(__cloc); + lconv* lc = localeconv(); +#endif // Check for NULL, which implies no fractional digits. if (lc->mon_decimal_point == NULL || @@ -348,6 +356,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION delete [] __group; delete [] __ps; delete [] __ns; +#ifndef _GLIBCXX_HAVE_LOCALECONV_L + uselocale(__old); +#endif __throw_exception_again; } @@ -360,6 +371,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION char __nspace = lc->int_n_sep_by_space; _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); +#ifndef _GLIBCXX_HAVE_LOCALECONV_L + uselocale(__old); +#endif } } @@ -395,7 +409,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION else { // Named locale. +#ifdef _GLIBCXX_HAVE_LOCALECONV_L lconv* lc = localeconv_l((locale_t) __cloc); +#else + __c_locale __old = uselocale(__cloc); + lconv* lc = localeconv(); +#endif // Check for NULL, which implies no fractional digits. if (lc->mon_decimal_point == NULL || @@ -502,6 +521,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION delete [] __group; delete [] __ps; delete [] __ns; +#ifndef _GLIBCXX_HAVE_LOCALECONV_L + uselocale(__old); +#endif __throw_exception_again; } @@ -514,6 +536,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION char __nspace = lc->n_sep_by_space; _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); +#ifndef _GLIBCXX_HAVE_LOCALECONV_L + uselocale(__old); +#endif } } @@ -581,9 +606,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } else { - __c_locale __old = (__c_locale)uselocale((locale_t)__cloc); // Named locale. + // uselocale is needed for mbsrtowcs. + __c_locale __old = (__c_locale)uselocale((locale_t)__cloc); +#ifdef _GLIBCXX_HAVE_LOCALECONV_L lconv* lc = localeconv_l((locale_t) __cloc); +#else + lconv* lc = localeconv(); +#endif // Check for NULL, which implies no fractional digits. if (lc->mon_decimal_point == NULL || @@ -741,9 +771,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } else { - __c_locale __old = (__c_locale)uselocale((locale_t)__cloc); // Named locale. + // uselocale is needed for mbsrtowcs. + __c_locale __old = (__c_locale)uselocale((locale_t)__cloc); +#ifdef _GLIBCXX_HAVE_LOCALECONV_L lconv* lc = localeconv_l((locale_t) __cloc); +#else + lconv* lc = localeconv(); +#endif // Check for NULL, which implies no fractional digits. if (lc->mon_decimal_point == NULL || diff --git a/libstdc++-v3/config/locale/dragonfly/numeric_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/numeric_members.cc similarity index 92% rename from libstdc++-v3/config/locale/dragonfly/numeric_members.cc rename to libstdc++-v3/config/locale/ieee_1003.1-2008/numeric_members.cc index cac6fe8c710..196f2952218 100644 --- a/libstdc++-v3/config/locale/dragonfly/numeric_members.cc +++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/numeric_members.cc @@ -31,7 +31,10 @@ #include #include + +#ifdef _GLIBCXX_NEED_XLOCALE_H #include +#endif namespace std _GLIBCXX_VISIBILITY(default) { @@ -63,7 +66,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION else { // Named locale. +#ifdef _GLIBCXX_HAVE_LOCALECONV_L lconv* lc = localeconv_l((locale_t) __cloc); +#else + __c_locale __old = uselocale(__cloc); + lconv* lc = localeconv(); +#endif // Decimal point should always be defined, but check null anyway if (lc->decimal_point == NULL) @@ -103,6 +111,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { delete _M_data; _M_data = 0; +#ifndef _GLIBCXX_HAVE_LOCALECONV_L + uselocale(__old); +#endif __throw_exception_again; } } @@ -113,6 +124,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } _M_data->_M_grouping_size = __len; } +#ifndef _GLIBCXX_HAVE_LOCALECONV_L + uselocale(__old); +#endif } // NB: There is no way to extact this info from posix locales. @@ -162,7 +176,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION else { // Named locale. +#ifdef _GLIBCXX_HAVE_LOCALECONV_L lconv* lc = localeconv_l((locale_t) __cloc); +#else + __c_locale __old = uselocale(__cloc); + lconv* lc = localeconv(); +#endif // Decimal point should always be defined, but check null anyway if (lc->decimal_point == NULL) @@ -201,6 +220,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { delete _M_data; _M_data = 0; +#ifndef _GLIBCXX_HAVE_LOCALECONV_L + uselocale(__old); +#endif __throw_exception_again; } } @@ -211,6 +233,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } _M_data->_M_grouping_size = __len; } +#ifndef _GLIBCXX_HAVE_LOCALECONV_L + uselocale(__old); +#endif } // NB: There is no way to extact this info from posix locales. diff --git a/libstdc++-v3/config/locale/dragonfly/time_members.cc b/libstdc++-v3/config/locale/ieee_1003.1-2008/time_members.cc similarity index 93% rename from libstdc++-v3/config/locale/dragonfly/time_members.cc rename to libstdc++-v3/config/locale/ieee_1003.1-2008/time_members.cc index c8b621a323f..926cc5269b2 100644 --- a/libstdc++-v3/config/locale/dragonfly/time_members.cc +++ b/libstdc++-v3/config/locale/ieee_1003.1-2008/time_members.cc @@ -35,7 +35,10 @@ #include #include #include + +#ifdef _GLIBCXX_NEED_XLOCALE_H #include +#endif namespace std _GLIBCXX_VISIBILITY(default) { @@ -47,8 +50,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_put(char* __s, size_t __maxlen, const char* __format, const tm* __tm) const throw() { +#ifdef _GLIBCXX_HAVE_STRFTIME_L const size_t __len = strftime_l(__s, __maxlen, __format, __tm, (locale_t)_M_c_locale_timepunct); +#else + __c_locale __old = uselocale(_M_c_locale_timepunct); + const size_t __len = strftime(__s, __maxlen, __format, __tm); + uselocale(__old); +#endif // Make sure __s is null terminated. if (__len == 0) __s[0] = '\0'; @@ -196,15 +205,29 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format, const tm* __tm) const throw() { +#ifdef _GLIBCXX_HAVE_WCSFTIME_L const size_t __len = wcsftime_l(__s, __maxlen, __format, __tm, (locale_t)_M_c_locale_timepunct); +#else + __c_locale __old = uselocale(_M_c_locale_timepunct); + const size_t __len = wcsftime(__s, __maxlen, __format, __tm); + uselocale(__old); +#endif // Make sure __s is null terminated. if (__len == 0) __s[0] = L'\0'; } +#ifdef _GLIBCXX_HAVE_MBSTOWCS_L +#define MBSTOWCS_L(WCSTRING, STRING, NUMBER, LOCALE) \ + mbstowcs_l (WCSTRING, STRING, NUMBER, LOCALE); +#else + // "uselocale" must be called before using this macro. +#define MBSTOWCS_L(WCSTRING, STRING, NUMBER, LOCALE) \ + mbstowcs (WCSTRING, STRING, NUMBER); +#endif #define WIDE_LANGINFO(M,FMT) \ - fmtlen = mbstowcs_l (holder, nl_langinfo_l(FMT, (locale_t)__cloc), \ + fmtlen = MBSTOWCS_L (holder, nl_langinfo_l(FMT, (locale_t)__cloc), \ 128, (locale_t)__cloc); \ langstring = new wchar_t[fmtlen + 1]; \ wcsncpy (langstring, holder, fmtlen); \ @@ -281,6 +304,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } else { +#ifndef _GLIBCXX_HAVE_MBSTOWCS_L + __c_locale __old = uselocale(__cloc); +#endif wchar_t *langstring = 0; wchar_t holder[128]; size_t fmtlen; @@ -342,6 +368,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION WIDE_LANGINFO(_M_amonth10, ABMON_10) WIDE_LANGINFO(_M_amonth11, ABMON_11) WIDE_LANGINFO(_M_amonth12, ABMON_12) +#ifndef _GLIBCXX_HAVE_MBSTOWCS_L + uselocale(__old); +#endif } } diff --git a/libstdc++-v3/config/locale/dragonfly/time_members.h b/libstdc++-v3/config/locale/ieee_1003.1-2008/time_members.h similarity index 100% rename from libstdc++-v3/config/locale/dragonfly/time_members.h rename to libstdc++-v3/config/locale/ieee_1003.1-2008/time_members.h diff --git a/libstdc++-v3/config/os/aix/ctype_configure_char.cc b/libstdc++-v3/config/os/aix/ctype_configure_char.cc index b12c0bd435c..38f9308893b 100644 --- a/libstdc++-v3/config/os/aix/ctype_configure_char.cc +++ b/libstdc++-v3/config/os/aix/ctype_configure_char.cc @@ -46,23 +46,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION size_t __refs) : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), - _M_table(__table ? __table : classic_table()) + _M_table(__table ? __table : classic_table()), + _M_widen_ok(0), _M_narrow_ok(0) { memset(_M_widen, 0, sizeof(_M_widen)); - _M_widen_ok = 0; memset(_M_narrow, 0, sizeof(_M_narrow)); - _M_narrow_ok = 0; } ctype::ctype(const mask* __table, bool __del, size_t __refs) : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), - _M_table(__table ? __table : classic_table()) + _M_table(__table ? __table : classic_table()), + _M_widen_ok(0), _M_narrow_ok(0) { memset(_M_widen, 0, sizeof(_M_widen)); - _M_widen_ok = 0; memset(_M_narrow, 0, sizeof(_M_narrow)); - _M_narrow_ok = 0; } char diff --git a/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc b/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc index d6ab73175b8..9cf21500271 100644 --- a/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc +++ b/libstdc++-v3/config/os/gnu-linux/ctype_configure_char.cc @@ -38,7 +38,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Information as gleaned from /usr/include/ctype.h -#if _GLIBCXX_C_LOCALE_GNU +#if _GLIBCXX_C_LOCALE_GNU || _GLIBCXX_C_LOCALE_IEEE_2008 const ctype_base::mask* ctype::classic_table() throw() { return _S_get_c_locale()->__ctype_b; } @@ -70,7 +70,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #endif -#if _GLIBCXX_C_LOCALE_GNU +#if _GLIBCXX_C_LOCALE_GNU || _GLIBCXX_C_LOCALE_IEEE_2008 ctype::ctype(__c_locale __cloc, const mask* __table, bool __del, size_t __refs) : facet(__refs), _M_c_locale_ctype(_S_clone_c_locale(__cloc)), diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc index ea0c43a20fc..71e198843d2 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/2.cc @@ -1,4 +1,5 @@ // { dg-require-namedlocale "en_US.ISO8859-1" } +// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } } // 2003-02-06 Petur Runolfsson diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc index 54206f8000a..ffde94108a1 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc @@ -1,4 +1,5 @@ // { dg-require-namedlocale "en_US.ISO-8859-15" } +// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } } // 2003-02-06 Petur Runolfsson diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc index f27d667daf5..9193b598162 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/4.cc @@ -1,4 +1,5 @@ // { dg-require-namedlocale "en_US.UTF-8" } +// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } } // 2003-02-06 Petur Runolfsson diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc index b5383af657c..e4b428c9fc6 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/7.cc @@ -1,4 +1,5 @@ // { dg-require-namedlocale "en_US.UTF-8" } +// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } } // 2003-02-06 Petur Runolfsson diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc index 1d40a1723a4..ffbd856640b 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/8.cc @@ -1,4 +1,5 @@ // { dg-require-namedlocale "en_US.UTF-8" } +// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } } // 2003-02-06 Petur Runolfsson diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc index 9801e085683..5e42a373547 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/9.cc @@ -1,4 +1,5 @@ // { dg-require-namedlocale "en_US.UTF-8" } +// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } } // 2003-02-06 Petur Runolfsson diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc index f70d0fc6c58..01bf1a57917 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt/length/wchar_t/4.cc @@ -1,4 +1,5 @@ // { dg-require-namedlocale "en_US.UTF-8" } +// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } } // 2003-02-06 Petur Runolfsson diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc index 5cde0b66331..25dfa02b99d 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/4.cc @@ -1,4 +1,5 @@ // { dg-require-namedlocale "en_US.UTF-8" } +// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } } // 2003-02-06 Petur Runolfsson diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc b/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc index 1e4ce5a8e3e..5d00a62c9a9 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt/unshift/wchar_t/4.cc @@ -1,4 +1,5 @@ // { dg-require-namedlocale "en_US.UTF-8" } +// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } } // 2003-02-06 Petur Runolfsson diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc index c747f7bfb02..46713cca118 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-1.cc @@ -1,4 +1,5 @@ // { dg-require-namedlocale "en_US.UTF-8" } +// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } } // Copyright (C) 2003-2021 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc index 76a387768fe..a3a4bbf5833 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-2.cc @@ -1,4 +1,5 @@ // { dg-require-namedlocale "en_US.UTF-8" } +// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } } // Copyright (C) 2003-2021 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc index 24d192921cb..2a314589714 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-3.cc @@ -1,4 +1,5 @@ // { dg-require-namedlocale "en_US.UTF-8" } +// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } } // Copyright (C) 2003-2021 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc index 2c0a2ab61db..71393bbd255 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/overflow/wchar_t/11305-4.cc @@ -1,4 +1,5 @@ // { dg-require-namedlocale "en_US.UTF-8" } +// { dg-excess-errors "wchar_t overflow" { xfail { wchar_t_char16_t_compatible } } } // Copyright (C) 2003-2021 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 30a4345b14f..200602d003e 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -904,6 +904,11 @@ proc check_v3_target_namedlocale { args } { puts $f " strcpy(result, name);" puts $f "#if defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__" puts $f " /* fall-through */" + puts $f "#elif defined _AIX" + puts $f " char *p = strstr(result, \"ISO8859-15\");" + puts $f " if (p) {" + puts $f " strcpy(p, \"8859-15\");" + puts $f " }" puts $f "#else" puts $f " if (strstr(result, \"ISO8859-15\")) {" puts $f " strcat(result, \"@euro\");" diff --git a/libstdc++-v3/testsuite/util/testsuite_hooks.h b/libstdc++-v3/testsuite/util/testsuite_hooks.h index b5e0767211a..a632f5f31f8 100644 --- a/libstdc++-v3/testsuite/util/testsuite_hooks.h +++ b/libstdc++-v3/testsuite/util/testsuite_hooks.h @@ -77,6 +77,9 @@ #if defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__ # define ISO_8859(part,langTERR) #langTERR ".ISO8859-" #part +#elif defined _AIX +# define ISO_8859(part,langTERR) ((part) == 15 ?\ + #langTERR ".8859-" #part : #langTERR ".ISO8859-" #part) #else # define ISO_8859(part,langTERR) ((part) == 15 ?\ #langTERR ".ISO8859-" #part "@euro" : #langTERR ".ISO8859-" #part) -- 2.25.0