Deleted Added
full compact
wctomb.c (102879) wctomb.c (106032)
1/*-
2 * Copyright (c) 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Paul Borman at Krystal Technologies.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 21 unchanged lines hidden (view full) ---

30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Paul Borman at Krystal Technologies.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 21 unchanged lines hidden (view full) ---

30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/lib/libc/locale/wctomb.c 102879 2002-09-03 01:09:47Z tjr $");
38__FBSDID("$FreeBSD: head/lib/libc/locale/wctomb.c 106032 2002-10-27 10:41:21Z tjr $");
39
40#include <errno.h>
41#include <stdlib.h>
42#include <limits.h>
43#include <stddef.h>
44#include <rune.h>
45
46int
39
40#include <errno.h>
41#include <stdlib.h>
42#include <limits.h>
43#include <stddef.h>
44#include <rune.h>
45
46int
47wctomb(s, wchar)
48 char *s;
49 wchar_t wchar;
47wctomb(char *s, wchar_t wchar)
50{
51 char *e;
52
48{
49 char *e;
50
53 if (s == 0)
54 return (0); /* No support for state dependent encodings. */
51 if (s == NULL)
52 /* No support for state dependent encodings. */
53 return (0);
55
54
56 if (wchar == 0) {
57 *s = 0;
55 if (wchar == L'\0') {
56 *s = '\0';
58 return (1);
59 }
60
61 sputrune(wchar, s, MB_CUR_MAX, &e);
62 if (e == NULL) {
63 errno = EILSEQ;
64 return (-1);
65 }
66 return (e - s);
67}
57 return (1);
58 }
59
60 sputrune(wchar, s, MB_CUR_MAX, &e);
61 if (e == NULL) {
62 errno = EILSEQ;
63 return (-1);
64 }
65 return (e - s);
66}