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 #include <clocale>
00037 #include <langinfo.h>
00038 #include <iconv.h>
00039 #include <libintl.h>
00040
00041 #define _GLIBCPP_C_LOCALE_GNU 1
00042
00043 #define _GLIBCPP_NUM_CATEGORIES 6
00044
00045 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
00046 namespace __gnu_cxx
00047 {
00048 extern "C" __typeof(uselocale) __uselocale;
00049 }
00050 #endif
00051
00052 namespace std
00053 {
00054 typedef __locale_t __c_locale;
00055
00056 template<typename _Tv>
00057 int
00058 __convert_from_v(char* __out, const int __size, const char* __fmt,
00059 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
00060 _Tv __v, const __c_locale& __cloc, int __prec = -1)
00061 {
00062 __c_locale __old = __gnu_cxx::__uselocale(__cloc);
00063 #else
00064 _Tv __v, const __c_locale&, int __prec = -1)
00065 {
00066 char* __old = setlocale(LC_ALL, NULL);
00067 char* __sav = static_cast<char*>(malloc(strlen(__old) + 1));
00068 if (__sav)
00069 strcpy(__sav, __old);
00070 setlocale(LC_ALL, "C");
00071 #endif
00072
00073 int __ret;
00074 #ifdef _GLIBCPP_USE_C99
00075 if (__prec >= 0)
00076 __ret = snprintf(__out, __size, __fmt, __prec, __v);
00077 else
00078 __ret = snprintf(__out, __size, __fmt, __v);
00079 #else
00080 if (__prec >= 0)
00081 __ret = sprintf(__out, __fmt, __prec, __v);
00082 else
00083 __ret = sprintf(__out, __fmt, __v);
00084 #endif
00085
00086 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
00087 __gnu_cxx::__uselocale(__old);
00088 #else
00089 setlocale(LC_ALL, __sav);
00090 free(__sav);
00091 #endif
00092 return __ret;
00093 }
00094 }