2007-10-23 Jeff Johnston <jjohnstn@redhat.com>

* libc/stdlib/wcstombs_r.c: Add SUSV2 support for calculating
        size if output buffer is NULL.
This commit is contained in:
Jeff Johnston 2007-10-23 19:50:29 +00:00
parent 09ecdc8504
commit 2a3a02a687
2 changed files with 28 additions and 14 deletions

View File

@ -1,3 +1,8 @@
2007-10-23 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdlib/wcstombs_r.c: Add SUSV2 support for calculating
size if output buffer is NULL.
2007-10-17 Jeff Johnston <jjohnstn@redhat.com> 2007-10-17 Jeff Johnston <jjohnstn@redhat.com>
* libm/mathfp/s_logarithm.c: Fix error introduced by previous * libm/mathfp/s_logarithm.c: Fix error introduced by previous

View File

@ -14,6 +14,15 @@ _DEFUN (_wcstombs_r, (reent, s, pwcs, n, state),
char buff[8]; char buff[8];
int i, num_to_copy; int i, num_to_copy;
if (s == NULL)
{
size_t num_bytes = 0;
while (*pwcs != 0)
num_bytes += _wctomb_r (r, buff, *pwcs++, state);
return num_bytes;
}
else
{
while (n > 0) while (n > 0)
{ {
int bytes = _wctomb_r (r, buff, *pwcs, state); int bytes = _wctomb_r (r, buff, *pwcs, state);
@ -28,6 +37,6 @@ _DEFUN (_wcstombs_r, (reent, s, pwcs, n, state),
++pwcs; ++pwcs;
n -= num_to_copy; n -= num_to_copy;
} }
return max; return max;
}
} }