From: Jakub Jelinek Date: Thu, 5 Sep 2002 07:46:17 +0000 (+0200) Subject: c++locale_internal.h: New header. X-Git-Tag: releases/gcc-3.3.0~3021 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=89671b70677af6d2f66c48cd9e2f703fc8e0444b;p=thirdparty%2Fgcc.git c++locale_internal.h: New header. * config/locale/generic/c++locale_internal.h: New header. * config/locale/gnu/c++locale_internal.h: New header. * config/locale/gnu/c_locale.cc: Include it. * config/locale/gnu/collate_members.cc: Include it. * config/locale/gnu/ctype_members.cc: Include it. * config/locale/gnu/messages_members.cc: Include it. * config/locale/gnu/monetary_members.cc: Include it. * config/locale/gnu/numeric_members.cc: Include it. * config/locale/gnu/time_members.cc: Include it. (_M_put): Reorder __strftime_l and __wcsftime_l arguments to match glibc. (_M_initialize_timepunct): Initialize _M_c_locale_timepunct for C locale. * acinclude.m4: Include string.h when testing strcoll_l. For glibc 2.3 provide __-prefixed prototypes. (CLOCALE_INTERNAL_H): Set, add AC_LINK_FILES line. * aclocal.m4, configure: Rebuilt. * include/bits/locale_facets.h: Add declaration of specialization here. * config/locale/gnu/messages_members.cc: Add specialization for messages. * config/locale/gnu/messages_members.h: Remove generic definition of do_get. From-SVN: r56837 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 702cb67041ed..f3dd059d9293 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,32 @@ +2002-09-05 Jakub Jelinek + + * config/locale/generic/c++locale_internal.h: New header. + * config/locale/gnu/c++locale_internal.h: New header. + * config/locale/gnu/c_locale.cc: Include it. + * config/locale/gnu/collate_members.cc: Include it. + * config/locale/gnu/ctype_members.cc: Include it. + * config/locale/gnu/messages_members.cc: Include it. + * config/locale/gnu/monetary_members.cc: Include it. + * config/locale/gnu/numeric_members.cc: Include it. + * config/locale/gnu/time_members.cc: Include it. + (_M_put): Reorder __strftime_l and __wcsftime_l arguments to match + glibc. + (_M_initialize_timepunct): Initialize _M_c_locale_timepunct for + C locale. + * acinclude.m4: Include string.h when testing strcoll_l. + For glibc 2.3 provide __-prefixed prototypes. + (CLOCALE_INTERNAL_H): Set, add AC_LINK_FILES line. + * aclocal.m4, configure: Rebuilt. + +2002-09-05 Benjamin Kosnik + + * include/bits/locale_facets.h: Add declaration of specialization + here. + * config/locale/gnu/messages_members.cc: Add specialization for + messages. + * config/locale/gnu/messages_members.h: Remove generic definition + of do_get. + 2002-09-04 Richard Henderson * include/std/std_limits.h (__glibcpp_f32_infinity_bytes, diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 7fcb0770c3e4..3011d5a4961e 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -1128,6 +1128,12 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [ AC_TRY_RUN([ #define _GNU_SOURCE 1 #include + #include + #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + extern __typeof(newlocale) __newlocale; + extern __typeof(duplocale) __duplocale; + extern __typeof(strcoll_l) __strcoll_l; + #endif int main() { const char __one[] = "Äuglein Augmen"; @@ -1176,6 +1182,7 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [ CMONEY_CC=config/locale/generic/monetary_members.cc CNUMERIC_CC=config/locale/generic/numeric_members.cc CTIME_CC=config/locale/generic/time_members.cc + CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h ;; xgnu) AC_MSG_RESULT(gnu) @@ -1208,6 +1215,7 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [ CMONEY_CC=config/locale/gnu/monetary_members.cc CNUMERIC_CC=config/locale/gnu/numeric_members.cc CTIME_CC=config/locale/gnu/time_members.cc + CLOCALE_INTERNAL_H=config/locale/gnu/c++locale_internal.h ;; xieee_1003.1-2001) AC_MSG_RESULT(generic) @@ -1222,6 +1230,7 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [ CMONEY_CC=config/locale/generic/monetary_members.cc CNUMERIC_CC=config/locale/generic/numeric_members.cc CTIME_CC=config/locale/generic/time_members.cc + CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h ;; *) echo "$enable_clocale is an unknown locale package" 1>&2 @@ -1245,6 +1254,7 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [ AC_LINK_FILES($CMONEY_CC, src/monetary.cc) AC_LINK_FILES($CNUMERIC_CC, src/numeric.cc) AC_LINK_FILES($CTIME_CC, src/time.cc) + AC_LINK_FILES($CLOCALE_INTERNAL_H, src/c++locale_internal.h) ]) diff --git a/libstdc++-v3/aclocal.m4 b/libstdc++-v3/aclocal.m4 index dae93c1c8a3c..cc7afacbbd89 100644 --- a/libstdc++-v3/aclocal.m4 +++ b/libstdc++-v3/aclocal.m4 @@ -1143,6 +1143,12 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [ AC_TRY_RUN([ #define _GNU_SOURCE 1 #include + #include + #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + extern __typeof(newlocale) __newlocale; + extern __typeof(duplocale) __duplocale; + extern __typeof(strcoll_l) __strcoll_l; + #endif int main() { const char __one[] = "Äuglein Augmen"; @@ -1191,6 +1197,7 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [ CMONEY_CC=config/locale/generic/monetary_members.cc CNUMERIC_CC=config/locale/generic/numeric_members.cc CTIME_CC=config/locale/generic/time_members.cc + CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h ;; xgnu) AC_MSG_RESULT(gnu) @@ -1223,6 +1230,7 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [ CMONEY_CC=config/locale/gnu/monetary_members.cc CNUMERIC_CC=config/locale/gnu/numeric_members.cc CTIME_CC=config/locale/gnu/time_members.cc + CLOCALE_INTERNAL_H=config/locale/gnu/c++locale_internal.h ;; xieee_1003.1-2001) AC_MSG_RESULT(generic) @@ -1237,6 +1245,7 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [ CMONEY_CC=config/locale/generic/monetary_members.cc CNUMERIC_CC=config/locale/generic/numeric_members.cc CTIME_CC=config/locale/generic/time_members.cc + CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h ;; *) echo "$enable_clocale is an unknown locale package" 1>&2 @@ -1260,6 +1269,7 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [ AC_LINK_FILES($CMONEY_CC, src/monetary.cc) AC_LINK_FILES($CNUMERIC_CC, src/numeric.cc) AC_LINK_FILES($CTIME_CC, src/time.cc) + AC_LINK_FILES($CLOCALE_INTERNAL_H, src/c++locale_internal.h) ]) diff --git a/libstdc++-v3/config/locale/generic/c++locale_internal.h b/libstdc++-v3/config/locale/generic/c++locale_internal.h new file mode 100644 index 000000000000..fb263528bb0d --- /dev/null +++ b/libstdc++-v3/config/locale/generic/c++locale_internal.h @@ -0,0 +1,30 @@ +// Locale internal implementation header -*- C++ -*- + +// Copyright (C) 2002 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// The generic locale code doesn't need to do anything here (yet) diff --git a/libstdc++-v3/config/locale/gnu/c++locale_internal.h b/libstdc++-v3/config/locale/gnu/c++locale_internal.h new file mode 100644 index 000000000000..cfb89b5dd707 --- /dev/null +++ b/libstdc++-v3/config/locale/gnu/c++locale_internal.h @@ -0,0 +1,59 @@ +// Prototypes for GLIBC thread locale __-prefixed functions -*- C++ -*- + +// Copyright (C) 2002 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// Written by Jakub Jelinek + +#include + +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + +extern "C" __typeof(iswctype_l) __iswctype_l; +extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l; +extern "C" __typeof(strcoll_l) __strcoll_l; +extern "C" __typeof(strftime_l) __strftime_l; +extern "C" __typeof(strtod_l) __strtod_l; +extern "C" __typeof(strtof_l) __strtof_l; +extern "C" __typeof(strtold_l) __strtold_l; +extern "C" __typeof(strtol_l) __strtol_l; +extern "C" __typeof(strtoll_l) __strtoll_l; +extern "C" __typeof(strtoul_l) __strtoul_l; +extern "C" __typeof(strtoull_l) __strtoull_l; +extern "C" __typeof(strxfrm_l) __strxfrm_l; +extern "C" __typeof(towlower_l) __towlower_l; +extern "C" __typeof(towupper_l) __towupper_l; +extern "C" __typeof(wcscoll_l) __wcscoll_l; +extern "C" __typeof(wcsftime_l) __wcsftime_l; +extern "C" __typeof(wcsxfrm_l) __wcsxfrm_l; +extern "C" __typeof(wctype_l) __wctype_l; +extern "C" __typeof(newlocale) __newlocale; +extern "C" __typeof(freelocale) __freelocale; +extern "C" __typeof(duplocale) __duplocale; +extern "C" __typeof(uselocale) __uselocale; + +#endif // GLIBC 2.3 and later diff --git a/libstdc++-v3/config/locale/gnu/c_locale.cc b/libstdc++-v3/config/locale/gnu/c_locale.cc index 60ec54d76dbd..3982a65ceb6b 100644 --- a/libstdc++-v3/config/locale/gnu/c_locale.cc +++ b/libstdc++-v3/config/locale/gnu/c_locale.cc @@ -36,6 +36,7 @@ #include #include #include +#include "c++locale_internal.h" namespace std { diff --git a/libstdc++-v3/config/locale/gnu/collate_members.cc b/libstdc++-v3/config/locale/gnu/collate_members.cc index 3b55f6985c6d..97ff0c557b01 100644 --- a/libstdc++-v3/config/locale/gnu/collate_members.cc +++ b/libstdc++-v3/config/locale/gnu/collate_members.cc @@ -1,6 +1,6 @@ // std::collate implementation details, GNU version -*- C++ -*- -// Copyright (C) 2001 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -34,6 +34,7 @@ // Written by Benjamin Kosnik #include +#include "c++locale_internal.h" namespace std { diff --git a/libstdc++-v3/config/locale/gnu/ctype_members.cc b/libstdc++-v3/config/locale/gnu/ctype_members.cc index de83683934a5..18c3a8250942 100644 --- a/libstdc++-v3/config/locale/gnu/ctype_members.cc +++ b/libstdc++-v3/config/locale/gnu/ctype_members.cc @@ -34,6 +34,7 @@ // Written by Benjamin Kosnik #include +#include "c++locale_internal.h" namespace std { diff --git a/libstdc++-v3/config/locale/gnu/messages_members.cc b/libstdc++-v3/config/locale/gnu/messages_members.cc index 2717c6b55e10..54a3c8fa9f64 100644 --- a/libstdc++-v3/config/locale/gnu/messages_members.cc +++ b/libstdc++-v3/config/locale/gnu/messages_members.cc @@ -34,6 +34,7 @@ // Written by Benjamin Kosnik #include +#include "c++locale_internal.h" namespace std { @@ -56,4 +57,25 @@ namespace std return string(__msg); #endif } + +#ifdef _GLIBCPP_USE_WCHAR_T + template<> + wstring + messages::do_get(catalog, int, int, const wstring& __dfault) const + { +# if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + __c_locale __old = __uselocale(_M_c_locale_messages); + char* __msg = gettext(_M_convert_to_char(__dfault)); + __uselocale(__old); + return _M_convert_from_char(__msg); +# else + char* __old = strdup(setlocale(LC_ALL, NULL)); + setlocale(LC_ALL, _M_name_messages); + char* __msg = gettext(_M_convert_to_char(__dfault)); + setlocale(LC_ALL, __old); + free(__old); + return _M_convert_from_char(__msg); +# endif + } +#endif } diff --git a/libstdc++-v3/config/locale/gnu/messages_members.h b/libstdc++-v3/config/locale/gnu/messages_members.h index 11bfcb504407..68a2ea395318 100644 --- a/libstdc++-v3/config/locale/gnu/messages_members.h +++ b/libstdc++-v3/config/locale/gnu/messages_members.h @@ -54,26 +54,6 @@ return 0; } - template - typename messages<_CharT>::string_type - messages<_CharT>::do_get(catalog, int, int, - const string_type& __dfault) const - { -#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) - __c_locale __old = __uselocale(_M_c_locale_messages); - char* __msg = gettext(_M_convert_to_char(__dfault)); - __uselocale(__old); - return _M_convert_from_char(__msg); -#else - char* __old = strdup(setlocale(LC_ALL, NULL)); - setlocale(LC_ALL, _M_name_messages); - char* __msg = gettext(_M_convert_to_char(__dfault)); - setlocale(LC_ALL, __old); - free(__old); - return _M_convert_from_char(__msg); -#endif - } - template void messages<_CharT>::do_close(catalog) const diff --git a/libstdc++-v3/config/locale/gnu/monetary_members.cc b/libstdc++-v3/config/locale/gnu/monetary_members.cc index 6a797ffbc25f..bc915af0b15f 100644 --- a/libstdc++-v3/config/locale/gnu/monetary_members.cc +++ b/libstdc++-v3/config/locale/gnu/monetary_members.cc @@ -34,6 +34,7 @@ // Written by Benjamin Kosnik #include +#include "c++locale_internal.h" namespace std { diff --git a/libstdc++-v3/config/locale/gnu/numeric_members.cc b/libstdc++-v3/config/locale/gnu/numeric_members.cc index 4806435a50fb..b71374c4b8e5 100644 --- a/libstdc++-v3/config/locale/gnu/numeric_members.cc +++ b/libstdc++-v3/config/locale/gnu/numeric_members.cc @@ -34,6 +34,7 @@ // Written by Benjamin Kosnik #include +#include "c++locale_internal.h" namespace std { diff --git a/libstdc++-v3/config/locale/gnu/time_members.cc b/libstdc++-v3/config/locale/gnu/time_members.cc index ad71931056a4..ce3d9bf01066 100644 --- a/libstdc++-v3/config/locale/gnu/time_members.cc +++ b/libstdc++-v3/config/locale/gnu/time_members.cc @@ -35,6 +35,7 @@ // Written by Benjamin Kosnik #include +#include "c++locale_internal.h" namespace std { @@ -52,7 +53,7 @@ namespace std const tm* __tm) const { #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) - __strftime_l(__s, __maxlen, _M_c_locale_timepunct, __format, __tm); + __strftime_l(__s, __maxlen, __format, __tm, _M_c_locale_timepunct); #else char* __old = strdup(setlocale(LC_ALL, NULL)); setlocale(LC_ALL, _M_name_timepunct); @@ -69,6 +70,9 @@ namespace std if (__cloc == _S_c_locale) { // "C" locale + + _M_c_locale_timepunct = _S_c_locale; + _M_date_format = "%m/%d/%y"; _M_date_era_format = "%m/%d/%y"; _M_time_format = "%H:%M:%S"; @@ -202,7 +206,7 @@ namespace std const tm* __tm) const { #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) - __wcsftime_l(__s, __maxlen, _M_c_locale_timepunct, __format, __tm); + __wcsftime_l(__s, __maxlen, __format, __tm, _M_c_locale_timepunct); #else char* __old = strdup(setlocale(LC_ALL, NULL)); setlocale(LC_ALL, _M_name_timepunct); @@ -219,6 +223,9 @@ namespace std if (__cloc == _S_c_locale) { // "C" locale + + _M_c_locale_timepunct = _S_c_locale; + _M_date_format = L"%m/%d/%y"; _M_date_era_format = L"%m/%d/%y"; _M_time_format = L"%H:%M:%S"; diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 18e363958fcb..cf9f09b96996 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -2971,6 +2971,12 @@ else #define _GNU_SOURCE 1 #include + #include + #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + extern __typeof(newlocale) __newlocale; + extern __typeof(duplocale) __duplocale; + extern __typeof(strcoll_l) __strcoll_l; + #endif int main() { const char __one[] = "Äuglein Augmen"; @@ -3033,6 +3039,7 @@ fi CMONEY_CC=config/locale/generic/monetary_members.cc CNUMERIC_CC=config/locale/generic/numeric_members.cc CTIME_CC=config/locale/generic/time_members.cc + CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h ;; xgnu) echo "$ac_t""gnu" 1>&6 @@ -3094,6 +3101,7 @@ fi CMONEY_CC=config/locale/gnu/monetary_members.cc CNUMERIC_CC=config/locale/gnu/numeric_members.cc CTIME_CC=config/locale/gnu/time_members.cc + CLOCALE_INTERNAL_H=config/locale/gnu/c++locale_internal.h ;; xieee_1003.1-2001) echo "$ac_t""generic" 1>&6 @@ -3108,6 +3116,7 @@ fi CMONEY_CC=config/locale/generic/monetary_members.cc CNUMERIC_CC=config/locale/generic/numeric_members.cc CTIME_CC=config/locale/generic/time_members.cc + CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h ;; *) echo "$enable_clocale is an unknown locale package" 1>&2 @@ -22856,8 +22865,8 @@ fi; done EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h index 159cecccdcb1..9a4b994a5ad0 100644 --- a/libstdc++-v3/include/bits/locale_facets.h +++ b/libstdc++-v3/include/bits/locale_facets.h @@ -1739,6 +1739,12 @@ namespace std string messages::do_get(catalog, int, int, const string&) const; +#ifdef _GLIBCPP_USE_WCHAR_T + template<> + wstring + messages::do_get(catalog, int, int, const wstring&) const; +#endif + // Include host and configuration specific messages virtual functions. #include