Commit dc729132 by Paolo Carlini Committed by Paolo Carlini

localename.cc (locale::_Impl::_Impl(const char*, size_t)): Improve previous fix…

localename.cc (locale::_Impl::_Impl(const char*, size_t)): Improve previous fix for the strtok vs MT issue.

2002-11-28  Paolo Carlini  <pcarlini@unitus.it>
	    Nathan Myers  <ncm@cantrip.org>

	* src/localename.cc
	(locale::_Impl::_Impl(const char*, size_t)):
	Improve previous fix for the strtok vs MT issue.

Co-Authored-By: Nathan Myers <ncm@cantrip.org>

From-SVN: r59609
parent 17c04c5e
2002-11-28 Paolo Carlini <pcarlini@unitus.it> 2002-11-28 Paolo Carlini <pcarlini@unitus.it>
Nathan Myers <ncm@cantrip.org>
* src/localename.cc
(locale::_Impl::_Impl(const char*, size_t)):
Improve previous fix for the strtok vs MT issue.
2002-11-28 Paolo Carlini <pcarlini@unitus.it>
* config/locale/gnu/c_locale.cc (locale::_S_categories): * config/locale/gnu/c_locale.cc (locale::_S_categories):
Reorder the categories to match that of glibc's setlocale(LC_ALL, "")) Reorder the categories to match that of glibc's setlocale(LC_ALL, ""))
......
...@@ -141,37 +141,31 @@ namespace std ...@@ -141,37 +141,31 @@ namespace std
} }
// Name all the categories. // Name all the categories.
size_t __len = strlen(__s) + 1; size_t __len = strlen(__s);
if (!strchr(__s, ';')) if (!strchr(__s, ';'))
{ {
for (size_t __i = 0; for (size_t __i = 0;
__i < _S_categories_size + _S_extra_categories_size; ++__i) __i < _S_categories_size + _S_extra_categories_size; ++__i)
{ {
_M_names[__i] = new char[__len]; _M_names[__i] = new char[__len + 1];
strcpy(_M_names[__i], __s); strcpy(_M_names[__i], __s);
} }
} }
else else
{ {
char* __new; const char* __beg = __s;
const char* __save = __s;
char* __next = strpbrk(__save, "=;");
__save = __next + 1;
for (size_t __i = 0; for (size_t __i = 0;
__i < _S_categories_size + _S_extra_categories_size - 1; ++__i) __i < _S_categories_size + _S_extra_categories_size; ++__i)
{ {
__next = strpbrk(__save, "=;"); __beg = strchr(__beg, '=') + 1;
__new = new char[__next - __save + 1]; const char* __end = strchr(__beg, ';');
memcpy(__new, __save, __next - __save); if (!__end)
__new[__next - __save] = '\0'; __end = __s + __len;
char* __new = new char[__end - __beg + 1];
memcpy(__new, __beg, __end - __beg);
__new[__end - __beg] = '\0';
_M_names[__i] = __new; _M_names[__i] = __new;
__save = __next + 1;
__next = strpbrk(__save, "=;");
__save = __next + 1;
} }
__new = new char[__s + __len - __save];
memcpy(__new, __save, __s + __len - __save);
_M_names[_S_categories_size + _S_extra_categories_size - 1] = __new;
} }
// Construct all standard facets and add them to _M_facets. // Construct all standard facets and add them to _M_facets.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment