2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
22 * This function is apparently referenced by parts of ON. It is
23 * not intended for public API usage -- and it is not documented.
25 * The usage appears to be to consume bytes until a character is
26 * gathered, using a supplied function. It reads exactly one
27 * character and returns the number of bytes in the multibyte string
30 * The string "s" is storage for the multibyte string, the
31 * wc will receive the interpreted character, the peek function
32 * obtains the next character (as an int so we can get EOF),
33 * and errorc is stuffed with the character that is responsible
34 * for a parse error, if any.
38 _mbftowc(char *s
, wchar_t *wc
, int (*peek
)(void), int *errorc
)
48 /* No bytes returned? */
55 (void) memset(&mbs
, 0, sizeof (mbs
));
56 cons
= mbrtowc(wc
, start
, s
- start
, &mbs
);
58 /* fully translated character */
61 if (cons
== (size_t)-2) {
62 /* incomplete, recycle */
67 * Parse error, don't consider the first character part
72 *errorc
= c
>= 0 ? c
: 0;