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

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

39
40#include <errno.h>
41#include <stdlib.h>
42#include <limits.h>
43#include <stddef.h>
44#include <rune.h>
45
46int
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

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

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}