diff options
author | Paolo Carlini <pcarlini@unitus.it> | 2002-11-28 18:29:24 +0100 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2002-11-28 17:29:24 +0000 |
commit | dc7291321c8d1040264577d8d6a120dd0de0bd24 (patch) | |
tree | 24358b49e1920e9b3d993fd54c8d5732d11dbcfe | |
parent | 17c04c5eb2a66c74098c0ac0f429078954b16c59 (diff) | |
download | gcc-dc7291321c8d1040264577d8d6a120dd0de0bd24.zip gcc-dc7291321c8d1040264577d8d6a120dd0de0bd24.tar.gz gcc-dc7291321c8d1040264577d8d6a120dd0de0bd24.tar.bz2 |
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
-rw-r--r-- | libstdc++-v3/ChangeLog | 7 | ||||
-rw-r--r-- | libstdc++-v3/src/localename.cc | 30 |
2 files changed, 19 insertions, 18 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c622519..b18948e 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,4 +1,11 @@ 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): Reorder the categories to match that of glibc's setlocale(LC_ALL, "")) diff --git a/libstdc++-v3/src/localename.cc b/libstdc++-v3/src/localename.cc index daed6f1..892a951 100644 --- a/libstdc++-v3/src/localename.cc +++ b/libstdc++-v3/src/localename.cc @@ -141,37 +141,31 @@ namespace std } // Name all the categories. - size_t __len = strlen(__s) + 1; + size_t __len = strlen(__s); if (!strchr(__s, ';')) { for (size_t __i = 0; __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); } } else - { - char* __new; - const char* __save = __s; - char* __next = strpbrk(__save, "=;"); - __save = __next + 1; + { + const char* __beg = __s; 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, "=;"); - __new = new char[__next - __save + 1]; - memcpy(__new, __save, __next - __save); - __new[__next - __save] = '\0'; + __beg = strchr(__beg, '=') + 1; + const char* __end = strchr(__beg, ';'); + if (!__end) + __end = __s + __len; + char* __new = new char[__end - __beg + 1]; + memcpy(__new, __beg, __end - __beg); + __new[__end - __beg] = '\0'; _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. |