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