PR libstdc++/28277 (partial: __add_grouping)

2006-10-09  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/28277 (partial: __add_grouping)
	* include/bits/locale_facets.tcc (__add_grouping<>(_CharT*, _CharT,
	const char*, size_t, const _CharT*, const _CharT*)): Rewrite in
	non-recursive form.

From-SVN: r117581
This commit is contained in:
Paolo Carlini 2006-10-09 18:04:18 +00:00 committed by Paolo Carlini
parent a98d4769d5
commit a484326f89
2 changed files with 31 additions and 10 deletions

View File

@ -1,3 +1,10 @@
2006-10-09 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28277 (partial: __add_grouping)
* include/bits/locale_facets.tcc (__add_grouping<>(_CharT*, _CharT,
const char*, size_t, const _CharT*, const _CharT*)): Rewrite in
non-recursive form.
2006-10-09 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28277 (partial: money_put bits)

View File

@ -2590,19 +2590,33 @@ _GLIBCXX_END_LDBL_NAMESPACE
const char* __gbeg, size_t __gsize,
const _CharT* __first, const _CharT* __last)
{
if (__last - __first > *__gbeg
&& static_cast<signed char>(*__gbeg) > 0)
size_t __idx = 0;
size_t __ctr = 0;
while (__last - __first > __gbeg[__idx]
&& static_cast<signed char>(__gbeg[__idx]) > 0)
{
const bool __bump = __gsize != 1;
__s = std::__add_grouping(__s, __sep, __gbeg + __bump,
__gsize - __bump, __first,
__last - *__gbeg);
__first = __last - *__gbeg;
*__s++ = __sep;
__last -= __gbeg[__idx];
__idx < __gsize - 1 ? ++__idx : ++__ctr;
}
do
while (__first != __last)
*__s++ = *__first++;
while (__first != __last);
while (__ctr--)
{
*__s++ = __sep;
for (char __i = __gbeg[__idx]; __i > 0; --__i)
*__s++ = *__first++;
}
while (__idx--)
{
*__s++ = __sep;
for (char __i = __gbeg[__idx]; __i > 0; --__i)
*__s++ = *__first++;
}
return __s;
}