+2007-05-11 Paolo Carlini <pcarlini@suse.de>
+
+ * include/ext/pod_char_traits.h (char_traits<>::move):
+ Use __builtin_memmove.
+ * include/bits/locale_classes.h (locale::_Impl::_M_check_same_name,
+ collate_byname(const char*, size_t)): Use __builtin_strcmp.
+ * include/bits/locale_facets.h: Use __builtin_mem* and
+ __builtin_str* everywhere.
+ * include/bits/codecvt.h (codecvt_byname(const char*, size_t)):
+ Use __builtin_strcmp.
+ * include/bits/char_traits.h: Use __builtin_mem* everywhere.
+ * include/bits/fstream.tcc (basic_filebuf<>::underflow, imbue):
+ Use __builtin_memcpy and __builtin_memmove.
+ * include/bits/locale_facets_nonio.h (moneypunct_byname(const char*,
+ size_t __refs)): Use __builtin_strcmp.
+ * include/std/bitset (bitset<>::_M_do_reset): Use __builtin_memset.
+ * config/locale/gnu/c_locale.h: Use __builtin_strlen, __builtin_strcmp,
+ and __builtin_memcpy.
+ * config/locale/gnu/messages_members.h: Likewise.
+ * config/locale/gnu/time_members.h: Likewise.
+ * config/locale/generic/c_locale.h: Likewise.
+ * config/locale/generic/messages_members.h: Likewise.
+ * config/locale/generic/time_members.h: Likewise.
+ * config/os/gnu-linux/ctype_noninline.h: Likewise, avoid strdup.
+ * config/os/tpf/ctype_noninline.h: Likewise.
+ * config/locale/generic/codecvt_members.cc: Include <cstring>.
+ * config/locale/generic/ctype_members.cc: Likewise.
+ * config/locale/generic/collate_members.cc: Likewise.
+ * config/locale/gnu/c++locale_internal.h: Likewise.
+ * config/locale/darwin/ctype_members.cc: Likewise.
+ * src/ctype.cc: Likewise.
+ * testsuite/19_diagnostics/logic_error/what-1.cc: Likewise.
+ * testsuite/19_diagnostics/logic_error/what-2.cc: Likewise.
+ * testsuite/19_diagnostics/runtime_error/what-1.cc: Likewise.
+ * testsuite/19_diagnostics/runtime_error/what-2.cc: Likewise.
+ * testsuite/19_diagnostics/runtime_error/what-3.cc: Likewise.
+ * config/locale/gnu/messages_members.cc: Avoid strdup.
+ * config/locale/gnu/monetary_members.cc: Likewise.
+ * config/locale/gnu/time_members.cc: Likewise.
+ * config/locale/gnu/time_members.cc: Likewise.
+ * config/locale/generic/c_locale.cc: Likewise.
+
2007-05-11 Benjamin Kosnik <bkoz@redhat.com>
- * include/std/stdexcept: Remove extra spacing.
-
- * testsuite/19_diagnostics/stdexceptions.cc: Break into...
- * testsuite/19_diagnostics/bad_exception: ...this. Populate.
- * testsuite/19_diagnostics/logic_error: ... this.
- * testsuite/19_diagnostics/logic_error/what-1.cc: ...this.
- * testsuite/19_diagnostics/logic_error/what-2.cc: ...this.
- * testsuite/19_diagnostics/runtime_error: ...this.
- * testsuite/19_diagnostics/runtime_error/what-1.cc: ...this.
- * testsuite/19_diagnostics/runtime_error/what-2.cc: ...this.
- * testsuite/19_diagnostics/runtime_error/what-3.cc: ...this.
- * testsuite/19_diagnostics/23591_thread-1.c: Move...
- * testsuite/19_diagnostics/bad_exception/23591_thread-1.c: ...here.
+ * include/std/stdexcept: Remove extra spacing.
+
+ * testsuite/19_diagnostics/stdexceptions.cc: Break into...
+ * testsuite/19_diagnostics/bad_exception: ...this. Populate.
+ * testsuite/19_diagnostics/logic_error: ... this.
+ * testsuite/19_diagnostics/logic_error/what-1.cc: ...this.
+ * testsuite/19_diagnostics/logic_error/what-2.cc: ...this.
+ * testsuite/19_diagnostics/runtime_error: ...this.
+ * testsuite/19_diagnostics/runtime_error/what-1.cc: ...this.
+ * testsuite/19_diagnostics/runtime_error/what-2.cc: ...this.
+ * testsuite/19_diagnostics/runtime_error/what-3.cc: ...this.
+ * testsuite/19_diagnostics/23591_thread-1.c: Move...
+ * testsuite/19_diagnostics/bad_exception/23591_thread-1.c: ...here.
2007-05-10 Paolo Carlini <pcarlini@suse.de>
#include <locale>
#include <bits/c++locale_internal.h>
#include <cstdlib>
+#include <cstring>
namespace std
{
#include <cerrno> // For errno
#include <cmath> // For isinf, finite, finitef, fabs
#include <cstdlib> // For strof, strtold
+#include <cstring>
#include <locale>
#include <limits>
+#include <cstddef>
#ifdef _GLIBCXX_HAVE_IEEEFP_H
#include <ieeefp.h>
const __c_locale&)
{
// Assumes __s formatted for "C" locale.
- char* __old = strdup(setlocale(LC_ALL, NULL));
+ char* __old = setlocale(LC_ALL, NULL);
+ const size_t __len = strlen(__old) + 1;
+ char* __sav = new char[__len];
+ memcpy(__sav, __old, __len);
setlocale(LC_ALL, "C");
char* __sanity;
else
__err |= ios_base::failbit;
- setlocale(LC_ALL, __old);
- free(__old);
+ setlocale(LC_ALL, __sav);
+ delete [] __sav;
}
template<>
const __c_locale&)
{
// Assumes __s formatted for "C" locale.
- char* __old = strdup(setlocale(LC_ALL, NULL));
+ char* __old = setlocale(LC_ALL, NULL);
+ const size_t __len = strlen(__old) + 1;
+ char* __sav = new char[__len];
+ memcpy(__sav, __old, __len);
setlocale(LC_ALL, "C");
char* __sanity;
else
__err |= ios_base::failbit;
- setlocale(LC_ALL, __old);
- free(__old);
+ setlocale(LC_ALL, __sav);
+ delete [] __sav;
}
template<>
ios_base::iostate& __err, const __c_locale&)
{
// Assumes __s formatted for "C" locale.
- char* __old = strdup(setlocale(LC_ALL, NULL));
+ char* __old = setlocale(LC_ALL, NULL);
+ const size_t __len = strlen(__old) + 1;
+ char* __sav = new char[__len];
+ memcpy(__sav, __old, __len);
setlocale(LC_ALL, "C");
#if !__LDBL_HAS_INFINITY__
else
__err |= ios_base::failbit;
- setlocale(LC_ALL, __old);
- free(__old);
+ setlocale(LC_ALL, __sav);
+ delete [] __sav;
}
void
// 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 <clocale>
-#include <cstring> // get std::strlen
#include <cstdio> // get std::vsnprintf or std::vsprintf
#include <cstdarg>
+#include <cstddef>
#define _GLIBCXX_NUM_CATEGORIES 0
{
char* __old = std::setlocale(LC_NUMERIC, NULL);
char* __sav = NULL;
- if (std::strcmp(__old, "C"))
+ if (__builtin_strcmp(__old, "C"))
{
- __sav = new char[std::strlen(__old) + 1];
- std::strcpy(__sav, __old);
+ const size_t __len = __builtin_strlen(__old) + 1;
+ __sav = new char[__len];
+ __builtin_memcpy(__sav, __old, __len);
std::setlocale(LC_NUMERIC, "C");
}
#include <locale>
#include <cstdlib> // For MB_CUR_MAX
#include <climits> // For MB_LEN_MAX
+#include <cstring>
_GLIBCXX_BEGIN_NAMESPACE(std)
// std::collate implementation details, generic version -*- C++ -*-
-// Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc.
+// 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
// software; you can redistribute it and/or modify it under the
// Written by Benjamin Kosnik <bkoz@redhat.com>
#include <locale>
+#include <cstring>
_GLIBCXX_BEGIN_NAMESPACE(std)
#include <locale>
#include <cstdlib>
+#include <cstring>
_GLIBCXX_BEGIN_NAMESPACE(std)
// std::messages implementation details, generic version -*- C++ -*-
-// Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc.
+// 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
// software; you can redistribute it and/or modify it under the
messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
: messages<_CharT>(__refs)
{
- if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ if (__builtin_strcmp(__s, "C") != 0
+ && __builtin_strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_messages);
this->_S_create_c_locale(this->_M_c_locale_messages, __s);
#include <locale>
#include <cstdlib>
+#include <cstring>
_GLIBCXX_BEGIN_NAMESPACE(std)
_M_put(char* __s, size_t __maxlen, const char* __format,
const tm* __tm) const
{
- char* __old = strdup(setlocale(LC_ALL, NULL));
+ char* __old = setlocale(LC_ALL, NULL);
+ const size_t __llen = strlen(__old) + 1;
+ char* __sav = new char[__llen];
+ memcpy(__sav, __old, __llen);
setlocale(LC_ALL, _M_name_timepunct);
const size_t __len = strftime(__s, __maxlen, __format, __tm);
- setlocale(LC_ALL, __old);
- free(__old);
+ setlocale(LC_ALL, __sav);
+ delete [] __sav;
// Make sure __s is null terminated.
if (__len == 0)
__s[0] = '\0';
_M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
const tm* __tm) const
{
- char* __old = strdup(setlocale(LC_ALL, NULL));
+ char* __old = setlocale(LC_ALL, NULL);
+ const size_t __llen = strlen(__old) + 1;
+ char* __sav = new char[__llen];
+ memcpy(__sav, __old, __llen);
setlocale(LC_ALL, _M_name_timepunct);
const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
- setlocale(LC_ALL, __old);
- free(__old);
+ setlocale(LC_ALL, __sav);
+ delete [] __sav;
// Make sure __s is null terminated.
if (__len == 0)
__s[0] = L'\0';
// std::time_get, std::time_put implementation, generic version -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+// 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
// software; you can redistribute it and/or modify it under the
size_t __refs)
: facet(__refs), _M_data(NULL)
{
- const size_t __len = std::strlen(__s) + 1;
+ const size_t __len = __builtin_strlen(__s) + 1;
char* __tmp = new char[__len];
- std::memcpy(__tmp, __s, __len);
+ __builtin_memcpy(__tmp, __s, __len);
_M_name_timepunct = __tmp;
try
#include <bits/c++config.h>
#include <clocale>
#include <cstdlib>
+#include <cstring>
+#include <cstddef>
#include <langinfo.h>
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
#pragma GCC system_header
-#include <cstring> // get std::strlen
#include <cstdio> // get std::vsnprintf or std::vsprintf
#include <clocale>
#include <libintl.h> // For messages
#include <cstdarg>
+#include <cstddef>
#define _GLIBCXX_C_LOCALE_GNU 1
__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);
+ const size_t __len = __builtin_strlen(__old) + 1;
+ char* __sav = new char[__len];
+ __builtin_memcpy(__sav, __old, __len);
std::setlocale(LC_ALL, "C");
#endif
__uselocale(__old);
return string(__msg);
#else
- char* __old = strdup(setlocale(LC_ALL, NULL));
+ char* __old = setlocale(LC_ALL, NULL);
+ const size_t __len = strlen(__old) + 1;
+ char* __sav = new char[__len];
+ memcpy(__sav, __old, __len);
setlocale(LC_ALL, _M_name_messages);
const char* __msg = gettext(__dfault.c_str());
- setlocale(LC_ALL, __old);
- free(__old);
+ setlocale(LC_ALL, __sav);
+ delete [] __sav;
return string(__msg);
#endif
}
__uselocale(__old);
return _M_convert_from_char(__msg);
# else
- char* __old = strdup(setlocale(LC_ALL, NULL));
+ char* __old = setlocale(LC_ALL, NULL);
+ const size_t __len = strlen(__old) + 1;
+ char* __sav = new char[__len];
+ memcpy(__sav, __old, __len);
setlocale(LC_ALL, _M_name_messages);
char* __msg = gettext(_M_convert_to_char(__dfault));
- setlocale(LC_ALL, __old);
- free(__old);
+ setlocale(LC_ALL, __sav);
+ delete [] __sav;
return _M_convert_from_char(__msg);
# endif
}
// std::messages implementation details, GNU version -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+// 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
// software; you can redistribute it and/or modify it under the
size_t __refs)
: facet(__refs), _M_c_locale_messages(NULL), _M_name_messages(NULL)
{
- const size_t __len = std::strlen(__s) + 1;
+ const size_t __len = __builtin_strlen(__s) + 1;
char* __tmp = new char[__len];
- std::memcpy(__tmp, __s, __len);
+ __builtin_memcpy(__tmp, __s, __len);
_M_name_messages = __tmp;
// Last to avoid leaking memory if new throws.
{
if (this->_M_name_messages != locale::facet::_S_get_c_name())
delete [] this->_M_name_messages;
- char* __tmp = new char[std::strlen(__s) + 1];
- std::strcpy(__tmp, __s);
+ const size_t __len = __builtin_strlen(__s) + 1;
+ char* __tmp = new char[__len];
+ __builtin_memcpy(__tmp, __s, __len);
this->_M_name_messages = __tmp;
- if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ if (__builtin_strcmp(__s, "C") != 0
+ && __builtin_strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_messages);
this->_S_create_c_locale(this->_M_c_locale_messages, __s);
__c_locale __old = __uselocale(__cloc);
#else
// Switch to named locale so that mbsrtowcs will work.
- char* __old = strdup(setlocale(LC_ALL, NULL));
+ char* __old = setlocale(LC_ALL, NULL);
+ const size_t __llen = strlen(__old) + 1;
+ char* __sav = new char[__llen];
+ memcpy(__sav, __old, __llen);
setlocale(LC_ALL, __name);
#endif
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#else
- setlocale(LC_ALL, __old);
- free(__old);
+ setlocale(LC_ALL, __sav);
+ delete [] __sav;
#endif
__throw_exception_again;
}
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#else
- setlocale(LC_ALL, __old);
- free(__old);
+ setlocale(LC_ALL, __sav);
+ delete [] __sav;
#endif
}
}
__c_locale __old = __uselocale(__cloc);
#else
// Switch to named locale so that mbsrtowcs will work.
- char* __old = strdup(setlocale(LC_ALL, NULL));
+ char* __old = setlocale(LC_ALL, NULL);
+ const size_t __llen = strlen(__old) + 1;
+ char* __sav = new char[__llen];
+ memcpy(__sav, __old, __llen);
setlocale(LC_ALL, __name);
#endif
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#else
- setlocale(LC_ALL, __old);
- free(__old);
+ setlocale(LC_ALL, __sav);
+ delete [] __sav;
#endif
__throw_exception_again;
}
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__uselocale(__old);
#else
- setlocale(LC_ALL, __old);
- free(__old);
+ setlocale(LC_ALL, __sav);
+ delete [] __sav;
#endif
}
}
// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+// 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
// software; you can redistribute it and/or modify it under the
const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
_M_c_locale_timepunct);
#else
- char* __old = strdup(setlocale(LC_ALL, NULL));
+ char* __old = setlocale(LC_ALL, NULL);
+ const size_t __llen = strlen(__old) + 1;
+ char* __sav = new char[__llen];
+ memcpy(__sav, __old, __llen);
setlocale(LC_ALL, _M_name_timepunct);
const size_t __len = strftime(__s, __maxlen, __format, __tm);
- setlocale(LC_ALL, __old);
- free(__old);
+ setlocale(LC_ALL, __sav);
+ delete [] __sav;
#endif
// Make sure __s is null terminated.
if (__len == 0)
const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
_M_c_locale_timepunct);
#else
- char* __old = strdup(setlocale(LC_ALL, NULL));
+ char* __old = setlocale(LC_ALL, NULL);
+ const size_t __llen = strlen(__old) + 1;
+ char* __sav = new char[__llen];
+ memcpy(__sav, __old, __llen);
setlocale(LC_ALL, _M_name_timepunct);
const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
- setlocale(LC_ALL, __old);
- free(__old);
+ setlocale(LC_ALL, __sav);
+ delete [] __sav;
#endif
// Make sure __s is null terminated.
if (__len == 0)
// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+// 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
// software; you can redistribute it and/or modify it under the
: facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
_M_name_timepunct(NULL)
{
- const size_t __len = std::strlen(__s) + 1;
+ const size_t __len = __builtin_strlen(__s) + 1;
char* __tmp = new char[__len];
- std::memcpy(__tmp, __s, __len);
+ __builtin_memcpy(__tmp, __s, __len);
_M_name_timepunct = __tmp;
try
// Locale support -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004
+// Copyright (C) 1997, 1998, 1999, 2000, 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
ctype<char>::classic_table() throw()
{
const ctype_base::mask* __ret;
- char* __old = strdup(setlocale(LC_CTYPE, NULL));
+ char* __old = setlocale(LC_CTYPE, NULL);
+ const size_t __len = __builtin_strlen(__old) + 1;
+ char* __sav = new char[__len];
+ __builtin_memcpy(__sav, __old, __len);
setlocale(LC_CTYPE, "C");
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__ret = *__ctype_b_loc();
#else
__ret = __ctype_b;
#endif
- setlocale(LC_CTYPE, __old);
- free(__old);
+ setlocale(LC_CTYPE, __sav);
+ delete [] __sav;
return __ret;
}
#endif
_M_table(__table ? __table : _M_c_locale_ctype->__ctype_b),
_M_widen_ok(0), _M_narrow_ok(0)
{
- memset(_M_widen, 0, sizeof(_M_widen));
- memset(_M_narrow, 0, sizeof(_M_narrow));
+ __builtin_memset(_M_widen, 0, sizeof(_M_widen));
+ __builtin_memset(_M_narrow, 0, sizeof(_M_narrow));
}
#else
ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
: facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
_M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
{
- char* __old=strdup(setlocale(LC_CTYPE, NULL));
+ char* __old = setlocale(LC_CTYPE, NULL);
+ const size_t __len = __builtin_strlen(__old) + 1;
+ char* __sav = new char[__len];
+ __builtin_memcpy(__sav, __old, __len);
setlocale(LC_CTYPE, "C");
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
_M_toupper = *__ctype_toupper_loc();
_M_tolower = __ctype_tolower;
_M_table = __table ? __table : __ctype_b;
#endif
- setlocale(LC_CTYPE, __old);
- free(__old);
- memset(_M_widen, 0, sizeof(_M_widen));
- memset(_M_narrow, 0, sizeof(_M_narrow));
+ setlocale(LC_CTYPE, __sav);
+ delete [] __sav;
+ __builtin_memset(_M_widen, 0, sizeof(_M_widen));
+ __builtin_memset(_M_narrow, 0, sizeof(_M_narrow));
}
#endif
_M_table(__table ? __table : _M_c_locale_ctype->__ctype_b),
_M_widen_ok(0), _M_narrow_ok(0)
{
- memset(_M_widen, 0, sizeof(_M_widen));
- memset(_M_narrow, 0, sizeof(_M_narrow));
+ __builtin_memset(_M_widen, 0, sizeof(_M_widen));
+ __builtin_memset(_M_narrow, 0, sizeof(_M_narrow));
}
#else
ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
: facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
_M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
{
- char* __old=strdup(setlocale(LC_CTYPE, NULL));
+ char* __old = setlocale(LC_CTYPE, NULL);
+ const size_t __len = __builtin_strlen(__old) + 1;
+ char* __sav = new char[__len];
+ __builtin_memcpy(__sav, __old, __len);
setlocale(LC_CTYPE, "C");
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
_M_toupper = *__ctype_toupper_loc();
_M_tolower = __ctype_tolower;
_M_table = __table ? __table : __ctype_b;
#endif
- setlocale(LC_CTYPE, __old);
- free(__old);
- memset(_M_widen, 0, sizeof(_M_widen));
- memset(_M_narrow, 0, sizeof(_M_narrow));
+ setlocale(LC_CTYPE, __sav);
+ delete [] __sav;
+ __builtin_memset(_M_widen, 0, sizeof(_M_widen));
+ __builtin_memset(_M_narrow, 0, sizeof(_M_narrow));
}
#endif
// Locale support -*- C++ -*-
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005, 2006, 2007 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
ctype<char>::classic_table() throw()
{
const ctype_base::mask* __ret;
- char* __old = strdup(setlocale(LC_CTYPE, NULL));
+ char* __old = setlocale(LC_CTYPE, NULL);
+ const size_t __len = __builtin_strlen(__old) + 1;
+ char* __sav = new char[__len];
+ __builtin_memcpy(__sav, __old, __len);
setlocale(LC_CTYPE, "C");
__ret = *__ctype_b_loc();
- setlocale(LC_CTYPE, __old);
- free(__old);
+ setlocale(LC_CTYPE, __sav);
+ delete [] __sav;
return __ret;
}
size_t __refs)
: facet(__refs), _M_del(__table != 0 && __del)
{
- char* __old=strdup(setlocale(LC_CTYPE, NULL));
+ char* __old = setlocale(LC_CTYPE, NULL);
+ const size_t __len = __builtin_strlen(__old) + 1;
+ char* __sav = new char[__len];
+ __builtin_memcpy(__sav, __old, __len);
setlocale(LC_CTYPE, "C");
_M_toupper = *__ctype_toupper_loc();
_M_tolower = *__ctype_tolower_loc();
_M_table = __table ? __table : *__ctype_b_loc();
- setlocale(LC_CTYPE, __old);
- free(__old);
+ setlocale(LC_CTYPE, __sav);
+ delete [] __sav;
_M_c_locale_ctype = _S_get_c_locale();
}
ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
: facet(__refs), _M_del(__table != 0 && __del)
{
- char* __old=strdup(setlocale(LC_CTYPE, NULL));
+ char* __old = setlocale(LC_CTYPE, NULL);
+ const size_t __len = __builtin_strlen(__old) + 1;
+ char* __sav = new char[__len];
+ __builtin_memcpy(__sav, __old, __len);
setlocale(LC_CTYPE, "C");
_M_toupper = *__ctype_toupper_loc();
_M_tolower = *__ctype_tolower_loc();
_M_table = __table ? __table : *__ctype_b_loc();
- setlocale(LC_CTYPE, __old);
- free(__old);
+ setlocale(LC_CTYPE, __sav);
+ delete [] __sav;
_M_c_locale_ctype = _S_get_c_locale();
}
#pragma GCC system_header
-#include <cstring> // For memmove, memset, memchr
#include <bits/stl_algobase.h> // For copy, fill_n
#include <bits/postypes.h> // For streampos
#include <cstdio> // For EOF
char_traits<_CharT>::
move(char_type* __s1, const char_type* __s2, std::size_t __n)
{
- return static_cast<_CharT*>(std::memmove(__s1, __s2,
- __n * sizeof(char_type)));
+ return static_cast<_CharT*>(__builtin_memmove(__s1, __s2,
+ __n * sizeof(char_type)));
}
template<typename _CharT>
static int
compare(const char_type* __s1, const char_type* __s2, size_t __n)
- { return memcmp(__s1, __s2, __n); }
+ { return __builtin_memcmp(__s1, __s2, __n); }
static size_t
length(const char_type* __s)
- { return strlen(__s); }
+ { return __builtin_strlen(__s); }
static const char_type*
find(const char_type* __s, size_t __n, const char_type& __a)
- { return static_cast<const char_type*>(memchr(__s, __a, __n)); }
+ { return static_cast<const char_type*>(__builtin_memchr(__s, __a, __n)); }
static char_type*
move(char_type* __s1, const char_type* __s2, size_t __n)
- { return static_cast<char_type*>(memmove(__s1, __s2, __n)); }
+ { return static_cast<char_type*>(__builtin_memmove(__s1, __s2, __n)); }
static char_type*
copy(char_type* __s1, const char_type* __s2, size_t __n)
- { return static_cast<char_type*>(memcpy(__s1, __s2, __n)); }
+ { return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n)); }
static char_type*
assign(char_type* __s, size_t __n, char_type __a)
- { return static_cast<char_type*>(memset(__s, __a, __n)); }
+ { return static_cast<char_type*>(__builtin_memset(__s, __a, __n)); }
static char_type
to_char_type(const int_type& __c)
codecvt_byname(const char* __s, size_t __refs = 0)
: codecvt<_InternT, _ExternT, _StateT>(__refs)
{
- if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ if (__builtin_strcmp(__s, "C") != 0
+ && __builtin_strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_codecvt);
this->_S_create_c_locale(this->_M_c_locale_codecvt, __s);
{
char* __buf = new char[__blen];
if (__remainder)
- std::memcpy(__buf, _M_ext_next, __remainder);
+ __builtin_memcpy(__buf, _M_ext_next, __remainder);
delete [] _M_ext_buf;
_M_ext_buf = __buf;
_M_ext_buf_size = __blen;
}
else if (__remainder)
- std::memmove(_M_ext_buf, _M_ext_next, __remainder);
+ __builtin_memmove(_M_ext_buf, _M_ext_next, __remainder);
_M_ext_next = _M_ext_buf;
_M_ext_end = _M_ext_buf + __remainder;
this->gptr() - this->eback());
const streamsize __remainder = _M_ext_end - _M_ext_next;
if (__remainder)
- std::memmove(_M_ext_buf, _M_ext_next, __remainder);
+ __builtin_memmove(_M_ext_buf, _M_ext_next, __remainder);
_M_ext_next = _M_ext_buf;
_M_ext_end = _M_ext_buf + __remainder;
#pragma GCC system_header
#include <bits/localefwd.h>
-#include <cstring> // For strcmp.
#include <string>
#include <ext/atomicity.h>
if (_M_names[1])
// We must actually compare all the _M_names: can be all equal!
for (size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i)
- __ret = std::strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
+ __ret = __builtin_strcmp(_M_names[__i], _M_names[__i + 1]) == 0;
return __ret;
}
collate_byname(const char* __s, size_t __refs = 0)
: collate<_CharT>(__refs)
{
- if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ if (__builtin_strcmp(__s, "C") != 0
+ && __builtin_strcmp(__s, "POSIX") != 0)
{
this->_S_destroy_c_locale(this->_M_c_locale_collate);
this->_S_create_c_locale(this->_M_c_locale_collate, __s);
{
if (_M_widen_ok == 1)
{
- memcpy(__to, __lo, __hi - __lo);
+ __builtin_memcpy(__to, __lo, __hi - __lo);
return __hi;
}
if (!_M_widen_ok)
{
if (__builtin_expect(_M_narrow_ok == 1, true))
{
- memcpy(__to, __lo, __hi - __lo);
+ __builtin_memcpy(__to, __lo, __hi - __lo);
return __hi;
}
if (!_M_narrow_ok)
virtual const char*
do_widen(const char* __lo, const char* __hi, char_type* __dest) const
{
- memcpy(__dest, __lo, __hi - __lo);
+ __builtin_memcpy(__dest, __lo, __hi - __lo);
return __hi;
}
do_narrow(const char_type* __lo, const char_type* __hi,
char, char* __dest) const
{
- memcpy(__dest, __lo, __hi - __lo);
+ __builtin_memcpy(__dest, __lo, __hi - __lo);
return __hi;
}
_M_widen_ok = 1;
// Set _M_widen_ok to 2 if memcpy can't be used.
- if (memcmp(__tmp, _M_widen, sizeof(_M_widen)))
+ if (__builtin_memcmp(__tmp, _M_widen, sizeof(_M_widen)))
_M_widen_ok = 2;
}
do_narrow(__tmp, __tmp + sizeof(__tmp), 0, _M_narrow);
_M_narrow_ok = 1;
- if (memcmp(__tmp, _M_narrow, sizeof(_M_narrow)))
+ if (__builtin_memcmp(__tmp, _M_narrow, sizeof(_M_narrow)))
_M_narrow_ok = 2;
else
{
numpunct_byname(const char* __s, size_t __refs = 0)
: numpunct<_CharT>(__refs)
{
- if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ if (__builtin_strcmp(__s, "C") != 0
+ && __builtin_strcmp(__s, "POSIX") != 0)
{
__c_locale __tmp;
this->_S_create_c_locale(__tmp, __s);
moneypunct_byname(const char* __s, size_t __refs = 0)
: moneypunct<_CharT, _Intl>(__refs)
{
- if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ if (__builtin_strcmp(__s, "C") != 0
+ && __builtin_strcmp(__s, "POSIX") != 0)
{
__c_locale __tmp;
this->_S_create_c_locale(__tmp, __s);
static char_type*
move(char_type* __s1, const char_type* __s2, size_t __n)
{
- return static_cast<char_type*>(std::memmove(__s1, __s2,
- __n * sizeof(char_type)));
+ return static_cast<char_type*>
+ (__builtin_memmove(__s1, __s2, __n * sizeof(char_type)));
}
static char_type*
#pragma GCC system_header
#include <cstddef> // For size_t
-#include <cstring> // For memset
#include <string>
#include <bits/functexcept.h> // For invalid_argument, out_of_range,
// overflow_error
void
_M_do_reset()
- { std::memset(_M_w, 0, _Nw * sizeof(_WordT)); }
+ { __builtin_memset(_M_w, 0, _Nw * sizeof(_WordT)); }
bool
_M_is_equal(const _Base_bitset<_Nw>& __x) const
#include <locale>
#include <cstdlib>
+#include <cstring>
_GLIBCXX_BEGIN_NAMESPACE(std)
// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
+// 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
// software; you can redistribute it and/or modify it under the
#include <string>
#include <stdexcept>
+#include <cstring>
#include <testsuite_hooks.h>
// libstdc++/1972
// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
+// 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
// software; you can redistribute it and/or modify it under the
#include <string>
#include <stdexcept>
+#include <cstring>
#include <testsuite_hooks.h>
// libstdc++/2089
// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
+// 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
// software; you can redistribute it and/or modify it under the
#include <string>
#include <stdexcept>
+#include <cstring>
#include <testsuite_hooks.h>
// libstdc++/1972
// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
+// 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
// software; you can redistribute it and/or modify it under the
#include <string>
#include <stdexcept>
+#include <cstring>
#include <testsuite_hooks.h>
// libstdc++/2089
// 2001-02-26 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+// 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
// software; you can redistribute it and/or modify it under the
#include <string>
#include <stdexcept>
+#include <cstring>
#include <testsuite_hooks.h>
// test copy ctors and assignment operators