Commit 89671b70 by Jakub Jelinek

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<wchar_t>.
	* config/locale/gnu/messages_members.h: Remove generic definition
	of do_get.

From-SVN: r56837
parent 60179904
2002-09-05 Jakub Jelinek <jakub@redhat.com>
* 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 <bkoz@redhat.com>
* include/bits/locale_facets.h: Add declaration of specialization
here.
* config/locale/gnu/messages_members.cc: Add specialization for
messages<wchar_t>.
* config/locale/gnu/messages_members.h: Remove generic definition
of do_get.
2002-09-04 Richard Henderson <rth@redhat.com>
* include/std/std_limits.h (__glibcpp_f32_infinity_bytes,
......
......@@ -1128,6 +1128,12 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
AC_TRY_RUN([
#define _GNU_SOURCE 1
#include <locale.h>
#include <string.h>
#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)
])
......
......@@ -1143,6 +1143,12 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
AC_TRY_RUN([
#define _GNU_SOURCE 1
#include <locale.h>
#include <string.h>
#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)
])
......
// 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)
// 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 <jakub@redhat.com>
#include <clocale>
#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
......@@ -36,6 +36,7 @@
#include <locale>
#include <stdexcept>
#include <langinfo.h>
#include "c++locale_internal.h"
namespace std
{
......
// 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 <bkoz@redhat.com>
#include <locale>
#include "c++locale_internal.h"
namespace std
{
......
......@@ -34,6 +34,7 @@
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include "c++locale_internal.h"
namespace std
{
......
......@@ -34,6 +34,7 @@
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#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<wchar_t>::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
}
......@@ -55,26 +55,6 @@
}
template<typename _CharT>
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<typename _CharT>
void
messages<_CharT>::do_close(catalog) const
{ }
......@@ -34,6 +34,7 @@
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include "c++locale_internal.h"
namespace std
{
......
......@@ -34,6 +34,7 @@
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#include "c++locale_internal.h"
namespace std
{
......
......@@ -35,6 +35,7 @@
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
#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";
......
......@@ -2971,6 +2971,12 @@ else
#define _GNU_SOURCE 1
#include <locale.h>
#include <string.h>
#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 <<EOF
ac_sources="$BASIC_FILE_CC $CLOCALE_CC $CCOLLATE_CC $CCTYPE_CC $CMESSAGES_CC $CMONEY_CC $CNUMERIC_CC $CTIME_CC $LINKER_MAP"
ac_dests="src/basic_file.cc src/c++locale.cc src/collate.cc src/ctype.cc src/messages.cc src/monetary.cc src/numeric.cc src/time.cc src/linker.map"
ac_sources="$BASIC_FILE_CC $CLOCALE_CC $CCOLLATE_CC $CCTYPE_CC $CMESSAGES_CC $CMONEY_CC $CNUMERIC_CC $CTIME_CC $CLOCALE_INTERNAL_H $LINKER_MAP"
ac_dests="src/basic_file.cc src/c++locale.cc src/collate.cc src/ctype.cc src/messages.cc src/monetary.cc src/numeric.cc src/time.cc src/c++locale_internal.h src/linker.map"
EOF
cat >> $CONFIG_STATUS <<\EOF
......
......@@ -1739,6 +1739,12 @@ namespace std
string
messages<char>::do_get(catalog, int, int, const string&) const;
#ifdef _GLIBCPP_USE_WCHAR_T
template<>
wstring
messages<wchar_t>::do_get(catalog, int, int, const wstring&) const;
#endif
// Include host and configuration specific messages virtual functions.
#include <bits/messages_members.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment