Tree @eac25d56-607b-4915-bf3d-4351797ca0c0/main (Download .tar.gz)
- ..
- glthread
- malloc
- uniwidth
- _Noreturn.h
- alloca.in.h
- arg-nonnull.h
- argz.c
- argz.in.h
- asnprintf.c
- asprintf.c
- attribute.h
- basename-lgpl.c
- basename-lgpl.h
- btowc.c
- c++defs.h
- cdefs.h
- cloexec.c
- cloexec.h
- close.c
- dup2.c
- dynarray.h
- errno.in.h
- error.c
- error.h
- exitfail.c
- exitfail.h
- fcntl.c
- fcntl.in.h
- fd-hook.c
- fd-hook.h
- filename.h
- float+.h
- float.c
- float.in.h
- fstat.c
- getdtablesize.c
- getopt-cdefs.in.h
- getopt-core.h
- getopt-ext.h
- getopt-pfx-core.h
- getopt-pfx-ext.h
- getopt.c
- getopt.in.h
- getopt1.c
- getopt_int.h
- getprogname.c
- getprogname.h
- gettext.h
- hard-locale.c
- hard-locale.h
- intprops.h
- inttypes.in.h
- iswblank.c
- iswdigit.c
- iswxdigit.c
- itold.c
- langinfo.in.h
- lc-charset-dispatch.c
- lc-charset-dispatch.h
- libc-config.h
- limits.in.h
- localcharset.c
- localcharset.h
- locale.in.h
- localeconv.c
- Makefile.am
- Makefile.in
- malloc.c
- malloca.c
- malloca.h
- mbchar.c
- mbchar.h
- mbiter.c
- mbiter.h
- mbrtowc-impl-utf8.h
- mbrtowc-impl.h
- mbrtowc.c
- mbscasecmp.c
- mbschr.c
- mbsinit.c
- mbslen.c
- mbsncasecmp.c
- mbsstr.c
- mbswidth.c
- mbswidth.h
- mbtowc-impl.h
- mbtowc-lock.c
- mbtowc-lock.h
- mbtowc.c
- mbuiter.c
- mbuiter.h
- memchr.c
- memchr.valgrind
- mempcpy.c
- memrchr.c
- msvc-inval.c
- msvc-inval.h
- msvc-nothrow.c
- msvc-nothrow.h
- nl_langinfo-lock.c
- nl_langinfo.c
- open.c
- pathmax.h
- printf-args.c
- printf-args.h
- printf-parse.c
- printf-parse.h
- regcomp.c
- regex.c
- regex.h
- regex_internal.c
- regex_internal.h
- regexec.c
- setlocale-lock.c
- setlocale_null.c
- setlocale_null.h
- size_max.h
- stat-time.c
- stat-time.h
- stat-w32.c
- stat-w32.h
- stat.c
- stdarg.in.h
- stdbool.in.h
- stddef.in.h
- stdint.in.h
- stdio.in.h
- stdlib.in.h
- stpcpy.c
- str-kmp.h
- str-two-way.h
- strcasecmp.c
- strcasestr.c
- strdup.c
- streq.h
- strerror-override.c
- strerror-override.h
- strerror.c
- string.in.h
- strings.in.h
- strncasecmp.c
- strndup.c
- strnlen.c
- strnlen1.c
- strnlen1.h
- strstr.c
- sys_stat.in.h
- sys_types.in.h
- time.in.h
- unistd.c
- unistd.in.h
- unitypes.in.h
- uniwidth.in.h
- vasnprintf.c
- vasnprintf.h
- vasprintf.c
- verify.h
- warn-on-use.h
- wchar.in.h
- wcrtomb.c
- wctype-h.c
- wctype.in.h
- wcwidth.c
- windows-initguard.h
- windows-mutex.c
- windows-mutex.h
- windows-once.c
- windows-once.h
- windows-recmutex.c
- windows-recmutex.h
- windows-rwlock.c
- windows-rwlock.h
- xalloc-die.c
- xalloc-oversized.h
- xalloc.h
- xmalloc.c
- xsize.c
- xsize.h
mbrtowc-impl-utf8.h @eac25d56-607b-4915-bf3d-4351797ca0c0/main — raw · history · blame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | /* Convert multibyte character to wide character. Copyright (C) 1999-2002, 2005-2021 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* Written by Bruno Haible <bruno@clisp.org>, 2008. */ /* This file contains the part of the body of the mbrtowc and mbrtoc32 functions that handles the special case of the UTF-8 encoding. */ /* Cf. unistr/u8-mbtouc.c. */ unsigned char c = (unsigned char) p[0]; if (c < 0x80) { if (pwc != NULL) *pwc = c; res = (c == 0 ? 0 : 1); goto success; } if (c >= 0xc2) { if (c < 0xe0) { if (m == 1) goto incomplete; else /* m >= 2 */ { unsigned char c2 = (unsigned char) p[1]; if ((c2 ^ 0x80) < 0x40) { if (pwc != NULL) *pwc = ((unsigned int) (c & 0x1f) << 6) | (unsigned int) (c2 ^ 0x80); res = 2; goto success; } } } else if (c < 0xf0) { if (m == 1) goto incomplete; else { unsigned char c2 = (unsigned char) p[1]; if ((c2 ^ 0x80) < 0x40 && (c >= 0xe1 || c2 >= 0xa0) && (c != 0xed || c2 < 0xa0)) { if (m == 2) goto incomplete; else /* m >= 3 */ { unsigned char c3 = (unsigned char) p[2]; if ((c3 ^ 0x80) < 0x40) { unsigned int wc = (((unsigned int) (c & 0x0f) << 12) | ((unsigned int) (c2 ^ 0x80) << 6) | (unsigned int) (c3 ^ 0x80)); if (FITS_IN_CHAR_TYPE (wc)) { if (pwc != NULL) *pwc = wc; res = 3; goto success; } } } } } } else if (c <= 0xf4) { if (m == 1) goto incomplete; else { unsigned char c2 = (unsigned char) p[1]; if ((c2 ^ 0x80) < 0x40 && (c >= 0xf1 || c2 >= 0x90) && (c < 0xf4 || (c == 0xf4 && c2 < 0x90))) { if (m == 2) goto incomplete; else { unsigned char c3 = (unsigned char) p[2]; if ((c3 ^ 0x80) < 0x40) { if (m == 3) goto incomplete; else /* m >= 4 */ { unsigned char c4 = (unsigned char) p[3]; if ((c4 ^ 0x80) < 0x40) { unsigned int wc = (((unsigned int) (c & 0x07) << 18) | ((unsigned int) (c2 ^ 0x80) << 12) | ((unsigned int) (c3 ^ 0x80) << 6) | (unsigned int) (c4 ^ 0x80)); if (FITS_IN_CHAR_TYPE (wc)) { if (pwc != NULL) *pwc = wc; res = 4; goto success; } } } } } } } } } goto invalid; |