OSDN Git Service

2001-10-25 Benjamin Kosnik <bkoz@redhat.com>
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 25 Oct 2001 22:56:07 +0000 (22:56 +0000)
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 25 Oct 2001 22:56:07 +0000 (22:56 +0000)
* include/bits/locale_facets.tcc (collate::do_transform): Fix.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@46500 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/locale_facets.tcc

index ce05b96..b64f570 100644 (file)
@@ -1,3 +1,7 @@
+2001-10-25  Benjamin Kosnik  <bkoz@redhat.com>
+
+       * include/bits/locale_facets.tcc (collate::do_transform): Fix.
+
 2001-10-25  Phil Edwards  <pme@gcc.gnu.org>
 
        * docs/html/documentation.html:  Fix typo.
index 7072c0b..e574db0 100644 (file)
@@ -1879,19 +1879,18 @@ namespace std
     collate<_CharT>::
     do_transform(const _CharT* __lo, const _CharT* __hi) const
     {
-      string_type __orig(__lo, __hi);
-      string_type __trans(__orig.size(), char_type());
-      size_t __res = _M_transform_helper(__trans.begin().base(), 
-                                        __orig.c_str(), __trans.size());
-      while (__res >= __trans.size())
+      size_t __len = __hi - __lo;
+      _CharT* __c = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len));
+      size_t __res = _M_transform_helper(__c, __lo, __len);
+      if (__res >= __len)
        {
-         // Increment size of translated string.
-         typename string_type::size_type __newsize = __trans.size() * 2;
-         __trans.resize(__newsize);
-         __res = _M_transform_helper(__trans.begin().base(), __orig.c_str(), 
-                                     __trans.size());
+         // Try to increment size of translated string.
+         size_t __len2 = __len * 2;
+         _CharT* __c2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len2));
+         __res = _M_transform_helper(__c2, __lo, __len);
+         // XXX Throw exception if still indeterminate?
        }
-      return __trans;
+      return string_type(__c);
     }
 
  template<typename _CharT>