X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/9385eb3d10ebe5eb398c52040ec3dbfba9b0cdcf..15de9d6b4ab2de27ae24b13b7b6c4d55fffe4aef:/locale/FreeBSD/wcrtomb.c?ds=sidebyside diff --git a/locale/FreeBSD/wcrtomb.c b/locale/FreeBSD/wcrtomb.c index faf2f09..81b99d4 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,25 @@ */ #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 "xlocale_private.h" -#include -#include -#include -#include #include +#include "mblocal.h" size_t -wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps __unused) +wcrtomb_l(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps, + locale_t loc) { - char *e; - char buf[MB_LEN_MAX]; + NORMALIZE_LOCALE(loc); + if (ps == NULL) + ps = &loc->__mbs_wcrtomb; + return (loc->__lc_ctype->__wcrtomb(s, wc, ps, loc)); +} - 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)); +size_t +wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps) +{ + return wcrtomb_l(s, wc, ps, __current_locale()); }