00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef _CPP_BITS_C_LOCALE_H
00037 #define _CPP_BITS_C_LOCALE_H 1
00038
00039 #pragma GCC system_header
00040
00041 #include <clocale>
00042 #include <langinfo.h>
00043 #include <iconv.h>
00044 #include <libintl.h>
00045
00046 #define _GLIBCPP_C_LOCALE_GNU 1
00047
00048 #define _GLIBCPP_NUM_CATEGORIES 6
00049
00050 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
00051 namespace __gnu_cxx
00052 {
00053 extern "C" __typeof(uselocale) __uselocale;
00054 }
00055 #endif
00056
00057 namespace std
00058 {
00059 typedef __locale_t __c_locale;
00060
00061
00062
00063
00064
00065 template<typename _Tv>
00066 int
00067 __convert_from_v(char* __out, const int __size, const char* __fmt,
00068 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
00069 _Tv __v, const __c_locale& __cloc, int __prec = -1)
00070 {
00071 __c_locale __old = __gnu_cxx::__uselocale(__cloc);
00072 #else
00073 _Tv __v, const __c_locale&, int __prec = -1)
00074 {
00075 char* __old = setlocale(LC_ALL, NULL);
00076 char* __sav = static_cast<char*>(malloc(strlen(__old) + 1));
00077 if (__sav)
00078 strcpy(__sav, __old);
00079 setlocale(LC_ALL, "C");
00080 #endif
00081
00082 int __ret;
00083 #ifdef _GLIBCPP_USE_C99
00084 if (__prec >= 0)
00085 __ret = snprintf(__out, __size, __fmt, __prec, __v);
00086 else
00087 __ret = snprintf(__out, __size, __fmt, __v);
00088 #else
00089 if (__prec >= 0)
00090 __ret = sprintf(__out, __fmt, __prec, __v);
00091 else
00092 __ret = sprintf(__out, __fmt, __v);
00093 #endif
00094
00095 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
00096 __gnu_cxx::__uselocale(__old);
00097 #else
00098 setlocale(LC_ALL, __sav);
00099 free(__sav);
00100 #endif
00101 return __ret;
00102 }
00103 }
00104
00105 #endif