diff options
Diffstat (limited to 'libstdc++-v3/config/locale/generic/c_locale.h')
-rw-r--r-- | libstdc++-v3/config/locale/generic/c_locale.h | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/libstdc++-v3/config/locale/generic/c_locale.h b/libstdc++-v3/config/locale/generic/c_locale.h index 0fc9a250c02..9627d8646af 100644 --- a/libstdc++-v3/config/locale/generic/c_locale.h +++ b/libstdc++-v3/config/locale/generic/c_locale.h @@ -1,6 +1,6 @@ // Wrapper for underlying C-language localization -*- 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 @@ -35,7 +35,37 @@ #include <clocale> +#define _GLIBCPP_NUM_CATEGORIES 0 + namespace std { typedef int* __c_locale; + + template<typename _Tv> + int + __convert_from_v(char* __out, const int __size, const char* __fmt, + _Tv __v, const __c_locale&, int __prec = -1) + { + char* __old = setlocale(LC_ALL, NULL); + char* __sav = static_cast<char*>(malloc(strlen(__old) + 1)); + if (__sav) + strcpy(__sav, __old); + setlocale(LC_ALL, "C"); + + int __ret; +#ifdef _GLIBCPP_USE_C99 + if (__prec >= 0) + __ret = snprintf(__out, __size, __fmt, __prec, __v); + else + __ret = snprintf(__out, __size, __fmt, __v); +#else + if (__prec >= 0) + __ret = sprintf(__out, __fmt, __prec, __v); + else + __ret = sprintf(__out, __fmt, __v); +#endif + setlocale(LC_ALL, __sav); + free(__sav); + return __ret; + } } |