1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-12 09:58:36 +00:00

Use an internal buffer for the result when the first argument is NULL.

This commit is contained in:
Tim J. Robbins 2002-10-25 13:24:45 +00:00
parent ddc4f28155
commit 583efa1268
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=105932

View File

@ -28,6 +28,7 @@
__FBSDID("$FreeBSD$");
#include <errno.h>
#include <limits.h>
#include <rune.h>
#include <stdlib.h>
#include <wchar.h>
@ -36,7 +37,10 @@ size_t
wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps __unused)
{
char *e;
char buf[MB_LEN_MAX];
if (s == NULL)
s = buf;
sputrune(wc, s, MB_CUR_MAX, &e);
if (e == NULL) {
errno = EILSEQ;