aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/stdlib/wcstombs_r.c
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdlib/wcstombs_r.c')
-rw-r--r--newlib/libc/stdlib/wcstombs_r.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/newlib/libc/stdlib/wcstombs_r.c b/newlib/libc/stdlib/wcstombs_r.c
index c6a06a3..2c82a2c 100644
--- a/newlib/libc/stdlib/wcstombs_r.c
+++ b/newlib/libc/stdlib/wcstombs_r.c
@@ -17,14 +17,15 @@ _wcstombs_r (struct _reent *r,
if (s == NULL)
{
size_t num_bytes = 0;
- while (*pwcs != 0)
+ do
{
- bytes = __WCTOMB (r, buff, *pwcs++, state);
+ bytes = __WCTOMB (r, buff, *pwcs, state);
if (bytes == -1)
return -1;
num_bytes += bytes;
}
- return num_bytes;
+ while (*pwcs++ != 0x00);
+ return num_bytes - 1;
}
else
{