mblen.c (7438fc3aa8a196e1af28f4b09418a6733af0d69a) | mblen.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 <stddef.h> 42#include <rune.h> 43 44int 45mblen(s, n) 46 const char *s; 47 size_t n; 48{ 49 char const *e; 50 51 if (s == 0 || *s == 0) 52 return (0); /* No support for state dependent encodings. */ 53 | 41#include <stdlib.h> 42#include <stddef.h> 43#include <rune.h> 44 45int 46mblen(s, n) 47 const char *s; 48 size_t n; 49{ 50 char const *e; 51 52 if (s == 0 || *s == 0) 53 return (0); /* No support for state dependent encodings. */ 54 |
54 if (sgetrune(s, n, &e) == _INVALID_RUNE) | 55 if (sgetrune(s, n, &e) == _INVALID_RUNE) { 56 errno = EILSEQ; |
55 return (s - e); | 57 return (s - e); |
58 } |
|
56 return (e - s); 57} | 59 return (e - s); 60} |