wctomb.c (7438fc3aa8a196e1af28f4b09418a6733af0d69a) wctomb.c (f0c6c306f91a839c0ad2e84a3e1b84aa81b26c8f)
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

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

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$");
39
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

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

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$");
39
40#include <errno.h>
40#include <stdlib.h>
41#include <limits.h>
42#include <stddef.h>
43#include <rune.h>
44
45int
46wctomb(s, wchar)
47 char *s;

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

53 return (0); /* No support for state dependent encodings. */
54
55 if (wchar == 0) {
56 *s = 0;
57 return (1);
58 }
59
60 sputrune(wchar, s, MB_CUR_MAX, &e);
41#include <stdlib.h>
42#include <limits.h>
43#include <stddef.h>
44#include <rune.h>
45
46int
47wctomb(s, wchar)
48 char *s;

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

54 return (0); /* No support for state dependent encodings. */
55
56 if (wchar == 0) {
57 *s = 0;
58 return (1);
59 }
60
61 sputrune(wchar, s, MB_CUR_MAX, &e);
61 return (e ? e - s : -1);
62 if (e == NULL) {
63 errno = EILSEQ;
64 return (-1);
65 }
66 return (e - s);
62}
67}