X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/59e0d9fe772464b93d835d2a2964457702469a43..3d9156a7a519a5e3aa1b92e9d9d4b991f1aed7ff:/locale/FreeBSD/wcrtomb.c diff --git a/locale/FreeBSD/wcrtomb.c b/locale/FreeBSD/wcrtomb.c index faf2f09..4d7b115 100644 --- a/locale/FreeBSD/wcrtomb.c +++ b/locale/FreeBSD/wcrtomb.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2002 Tim J. Robbins. + * Copyright (c) 2002-2004 Tim J. Robbins. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -25,28 +25,17 @@ */ #include -__FBSDID("$FreeBSD: src/lib/libc/locale/wcrtomb.c,v 1.4 2003/04/10 09:20:38 tjr Exp $"); +__FBSDID("$FreeBSD: src/lib/libc/locale/wcrtomb.c,v 1.8 2004/05/12 14:09:04 tjr Exp $"); -#include -#include -#include -#include #include +#include "mblocal.h" size_t -wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps __unused) +wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps) { - char *e; - char buf[MB_LEN_MAX]; + static mbstate_t mbs; - if (s == NULL) { - s = buf; - wc = L'\0'; - } - sputrune(wc, s, MB_CUR_MAX, &e); - if (e == NULL) { - errno = EILSEQ; - return ((size_t)-1); - } - return ((size_t)(e - s)); + if (ps == NULL) + ps = &mbs; + return (__wcrtomb(s, wc, ps)); }