// Wrapper for underlying C-language localization -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
#pragma GCC system_header
-#include <cstring> // get std::strlen
-#include <cstdio> // get std::vsnprintf or std::vsprintf
#include <clocale>
-#include <langinfo.h> // For codecvt
-#include <iconv.h> // For codecvt using iconv, iconv_t
-#include <libintl.h> // For messages
-#include <cstdarg>
+#include <cstddef>
#define _GLIBCXX_C_LOCALE_GNU 1
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __old = __gnu_cxx::__uselocale(__cloc);
#else
- char* __old = std::setlocale(LC_ALL, NULL);
- char* __sav = new char[std::strlen(__old) + 1];
- std::strcpy(__sav, __old);
- std::setlocale(LC_ALL, "C");
+ char* __old = std::setlocale(LC_NUMERIC, NULL);
+ char* __sav = NULL;
+ if (__builtin_strcmp(__old, "C"))
+ {
+ const size_t __len = __builtin_strlen(__old) + 1;
+ char* __sav = new char[__len];
+ __builtin_memcpy(__sav, __old, __len);
+ std::setlocale(LC_NUMERIC, "C");
+ }
#endif
- va_list __args;
- va_start(__args, __fmt);
+ __builtin_va_list __args;
+ __builtin_va_start(__args, __fmt);
#ifdef _GLIBCXX_USE_C99
- const int __ret = std::vsnprintf(__out, __size, __fmt, __args);
+ const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
#else
- const int __ret = std::vsprintf(__out, __fmt, __args);
+ const int __ret = __builtin_vsprintf(__out, __fmt, __args);
#endif
- va_end(__args);
+ __builtin_va_end(__args);
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__gnu_cxx::__uselocale(__old);
#else
- std::setlocale(LC_ALL, __sav);
- delete [] __sav;
+ if (__sav)
+ {
+ std::setlocale(LC_NUMERIC, __sav);
+ delete [] __sav;
+ }
#endif
return __ret;
}