From: Paolo Carlini Date: Mon, 9 Oct 2006 18:04:18 +0000 (+0000) Subject: PR libstdc++/28277 (partial: __add_grouping) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a484326f89cb7e5b71f67959d86a9de69309839a;p=gcc.git PR libstdc++/28277 (partial: __add_grouping) 2006-10-09 Paolo Carlini 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 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index aceb26e7d27..f9123f136f1 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2006-10-09 Paolo Carlini + + 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 PR libstdc++/28277 (partial: money_put bits) diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc index 43051a1a71a..49c64a11add 100644 --- a/libstdc++-v3/include/bits/locale_facets.tcc +++ b/libstdc++-v3/include/bits/locale_facets.tcc @@ -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(*__gbeg) > 0) + size_t __idx = 0; + size_t __ctr = 0; + + while (__last - __first > __gbeg[__idx] + && static_cast(__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; }