summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2002-03-09 16:44:34 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2002-03-09 16:44:34 +0000
commit06d1cf8a41d9af0efd2aec145482cf0d9075073b (patch)
tree3e730b8a2766624cc967e8487b7764915665a5e5
parentb6975aaa2974c90d006508f8ff8321ea8a0696cf (diff)
downloadppe42-gcc-06d1cf8a41d9af0efd2aec145482cf0d9075073b.tar.gz
ppe42-gcc-06d1cf8a41d9af0efd2aec145482cf0d9075073b.zip
2002-03-09 Paolo Carlini <pcarlini@unitus.it>
* include/bits/locale_facets.tcc (collate::do_transform): Rewrite to fix problems with long transformed strings. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50500 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog5
-rw-r--r--libstdc++-v3/include/bits/locale_facets.tcc13
2 files changed, 12 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 7da26326f17..73551673226 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,8 @@
+2002-03-09 Paolo Carlini <pcarlini@unitus.it>
+
+ * include/bits/locale_facets.tcc (collate::do_transform):
+ Rewrite to fix problems with long transformed strings.
+
2002-03-08 Benjamin Kosnik <bkoz@redhat.com>
* c_locale_generic.cc: Move to...
diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc
index 3c8fea13024..90bb221c56c 100644
--- a/libstdc++-v3/include/bits/locale_facets.tcc
+++ b/libstdc++-v3/include/bits/locale_facets.tcc
@@ -1854,16 +1854,17 @@ namespace std
collate<_CharT>::
do_transform(const _CharT* __lo, const _CharT* __hi) const
{
- size_t __len = __hi - __lo;
+ size_t __len = (__hi - __lo) * 2;
+ // First try a buffer perhaps big enough.
_CharT* __c = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len));
size_t __res = _M_transform_helper(__c, __lo, __len);
+ // If the buffer was not large enough, try again with the correct size.
if (__res >= __len)
{
- // 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?
+ _CharT* __c2 =
+ static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * (__res + 1)));
+ size_t __res2 = _M_transform_helper(__c2, __lo, __res + 1);
+ return string_type(__c2);
}
return string_type(__c);
}
OpenPOWER on IntegriCloud