summaryrefslogtreecommitdiffstats
path: root/contrib/libstdc++/config/locale/gnu/ctype_members.cc
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libstdc++/config/locale/gnu/ctype_members.cc')
-rw-r--r--contrib/libstdc++/config/locale/gnu/ctype_members.cc23
1 files changed, 17 insertions, 6 deletions
diff --git a/contrib/libstdc++/config/locale/gnu/ctype_members.cc b/contrib/libstdc++/config/locale/gnu/ctype_members.cc
index 090738b..de83683 100644
--- a/contrib/libstdc++/config/locale/gnu/ctype_members.cc
+++ b/contrib/libstdc++/config/locale/gnu/ctype_members.cc
@@ -190,12 +190,23 @@ namespace std
do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
char* __dest) const
{
- mbstate_t __state;
- memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t));
- size_t __len = __hi - __lo;
- size_t __conv = wcsrtombs(__dest, &__lo, __len, &__state);
- if (__conv == __len)
- *__dest = __dfault;
+ size_t __offset = 0;
+ while (true)
+ {
+ const wchar_t* __start = __lo + __offset;
+ size_t __len = __hi - __start;
+
+ mbstate_t __state;
+ memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t));
+ size_t __con = wcsrtombs(__dest + __offset, &__start, __len, &__state);
+ if (__con != __len && __start != 0)
+ {
+ __offset = __start - __lo;
+ __dest[__offset++] = __dfault;
+ }
+ else
+ break;
+ }
return __hi;
}
#endif // _GLIBCPP_USE_WCHAR_T
OpenPOWER on IntegriCloud