diff options
Diffstat (limited to 'contrib/libstdc++/config/locale/generic/c_locale.h')
-rw-r--r-- | contrib/libstdc++/config/locale/generic/c_locale.h | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/contrib/libstdc++/config/locale/generic/c_locale.h b/contrib/libstdc++/config/locale/generic/c_locale.h index 1f2accb..9fadcc4 100644 --- a/contrib/libstdc++/config/locale/generic/c_locale.h +++ b/contrib/libstdc++/config/locale/generic/c_locale.h @@ -1,6 +1,6 @@ // Wrapper for underlying C-language localization -*- C++ -*- -// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -33,14 +33,16 @@ // Written by Benjamin Kosnik <bkoz@redhat.com> -#ifndef _CPP_BITS_C_LOCALE_H -#define _CPP_BITS_C_LOCALE_H 1 +#ifndef _C_LOCALE_H +#define _C_LOCALE_H 1 #pragma GCC system_header #include <clocale> +#include <cstring> // get std::strlen +#include <cstdio> // get std::snprintf or std::sprintf -#define _GLIBCPP_NUM_CATEGORIES 0 +#define _GLIBCXX_NUM_CATEGORIES 0 namespace std { @@ -53,30 +55,29 @@ namespace std template<typename _Tv> int __convert_from_v(char* __out, - const int __attribute__ ((__unused__)) __size, + const int __size __attribute__((__unused__)), 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"); + char* __old = std::setlocale(LC_ALL, NULL); + char* __sav = new char[std::strlen(__old) + 1]; + std::strcpy(__sav, __old); + std::setlocale(LC_ALL, "C"); int __ret; -#ifdef _GLIBCPP_USE_C99 +#ifdef _GLIBCXX_USE_C99 if (__prec >= 0) - __ret = snprintf(__out, __size, __fmt, __prec, __v); + __ret = std::snprintf(__out, __size, __fmt, __prec, __v); else - __ret = snprintf(__out, __size, __fmt, __v); + __ret = std::snprintf(__out, __size, __fmt, __v); #else if (__prec >= 0) - __ret = sprintf(__out, __fmt, __prec, __v); + __ret = std::sprintf(__out, __fmt, __prec, __v); else - __ret = sprintf(__out, __fmt, __v); + __ret = std::sprintf(__out, __fmt, __v); #endif - setlocale(LC_ALL, __sav); - free(__sav); + std::setlocale(LC_ALL, __sav); + delete [] __sav; return __ret; } } |