Deleted Added
full compact
mbtowc.c (102879) mbtowc.c (103012)
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/mbtowc.c 102879 2002-09-03 01:09:47Z tjr $");
38__FBSDID("$FreeBSD: head/lib/libc/locale/mbtowc.c 103012 2002-09-06 11:24:06Z tjr $");
39
40#include <errno.h>
41#include <stdlib.h>
42#include <stddef.h>
43#include <rune.h>
44
45int
46mbtowc(pwc, s, n)
39
40#include <errno.h>
41#include <stdlib.h>
42#include <stddef.h>
43#include <rune.h>
44
45int
46mbtowc(pwc, s, n)
47 wchar_t *__restrict pwc;
48 const char *__restrict s;
47 wchar_t * __restrict pwc;
48 const char * __restrict s;
49 size_t n;
50{
51 char const *e;
52 rune_t r;
53
54 if (s == 0 || *s == 0)
55 return (0); /* No support for state dependent encodings. */
56
57 if ((r = sgetrune(s, n, &e)) == _INVALID_RUNE) {
58 errno = EILSEQ;
59 return (s - e);
60 }
61 if (pwc)
62 *pwc = r;
63 return (e - s);
64}
49 size_t n;
50{
51 char const *e;
52 rune_t r;
53
54 if (s == 0 || *s == 0)
55 return (0); /* No support for state dependent encodings. */
56
57 if ((r = sgetrune(s, n, &e)) == _INVALID_RUNE) {
58 errno = EILSEQ;
59 return (s - e);
60 }
61 if (pwc)
62 *pwc = r;
63 return (e - s);
64}