├── .gitmodules ├── LICENSE.txt ├── README.md └── src ├── musl-ctype ├── alpha.h ├── iswalnum.c ├── iswalpha.c ├── iswblank.c ├── iswcntrl.c ├── iswctype.c ├── iswdigit.c ├── iswgraph.c ├── iswlower.c ├── iswprint.c ├── iswpunct.c ├── iswspace.c ├── iswupper.c ├── iswxdigit.c ├── nonspacing.h ├── punct.h ├── towctrans.c ├── wcswidth.c └── wctrans.c └── musl-multibyte ├── internal.c ├── internal.h ├── libc.h ├── mblen.c ├── mbsnrtowcs.c └── mbsrtowcs.c /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "src/musl-ctype/wcwidth"] 2 | path = src/musl-ctype/wcwidth 3 | url = https://github.com/termux/wcwidth 4 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2016 The Android Open Source Project 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | ================================================================================ 16 | 17 | musl as a whole is licensed under the following standard MIT license: 18 | 19 | ---------------------------------------------------------------------- 20 | Copyright © 2005-2014 Rich Felker, et al. 21 | 22 | Permission is hereby granted, free of charge, to any person obtaining 23 | a copy of this software and associated documentation files (the 24 | "Software"), to deal in the Software without restriction, including 25 | without limitation the rights to use, copy, modify, merge, publish, 26 | distribute, sublicense, and/or sell copies of the Software, and to 27 | permit persons to whom the Software is furnished to do so, subject to 28 | the following conditions: 29 | 30 | The above copyright notice and this permission notice shall be 31 | included in all copies or substantial portions of the Software. 32 | 33 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 34 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 35 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 36 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 37 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 38 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 39 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 40 | ---------------------------------------------------------------------- 41 | 42 | Authors/contributors include: 43 | 44 | Alexander Monakov 45 | Anthony G. Basile 46 | Arvid Picciani 47 | Bobby Bingham 48 | Boris Brezillon 49 | Brent Cook 50 | Chris Spiegel 51 | Clément Vasseur 52 | Denys Vlasenko 53 | Emil Renner Berthing 54 | Felix Fietkau 55 | Felix Janda 56 | Gianluca Anzolin 57 | Hiltjo Posthuma 58 | Isaac Dunham 59 | Jens Gustedt 60 | Jeremy Huntwork 61 | Joakim Sindholt 62 | John Spencer 63 | Josiah Worcester 64 | Justin Cormack 65 | Luca Barbato 66 | Luka Perkov 67 | M Farkas-Dyck (Strake) 68 | Michael Forney 69 | Nicholas J. Kain 70 | orc 71 | Pascal Cuoq 72 | Pierre Carrier 73 | Rich Felker 74 | Richard Pennington 75 | sin 76 | Solar Designer 77 | Stefan Kristiansson 78 | Szabolcs Nagy 79 | Timo Teräs 80 | Trutz Behn 81 | Valentin Ochs 82 | William Haddon 83 | 84 | Portions of this software are derived from third-party works licensed 85 | under terms compatible with the above MIT license: 86 | 87 | The TRE regular expression implementation (src/regex/reg* and 88 | src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed 89 | under a 2-clause BSD license (license text in the source files). The 90 | included version has been heavily modified by Rich Felker in 2012, in 91 | the interests of size, simplicity, and namespace cleanliness. 92 | 93 | Much of the math library code (src/math/* and src/complex/*) is 94 | Copyright © 1993,2004 Sun Microsystems or 95 | Copyright © 2003-2011 David Schultz or 96 | Copyright © 2003-2009 Steven G. Kargl or 97 | Copyright © 2003-2009 Bruce D. Evans or 98 | Copyright © 2008 Stephen L. Moshier 99 | and labelled as such in comments in the individual source files. All 100 | have been licensed under extremely permissive terms. 101 | 102 | The ARM memcpy code (src/string/armel/memcpy.s) is Copyright © 2008 103 | The Android Open Source Project and is licensed under a two-clause BSD 104 | license. It was taken from Bionic libc, used on Android. 105 | 106 | The implementation of DES for crypt (src/misc/crypt_des.c) is 107 | Copyright © 1994 David Burren. It is licensed under a BSD license. 108 | 109 | The implementation of blowfish crypt (src/misc/crypt_blowfish.c) was 110 | originally written by Solar Designer and placed into the public 111 | domain. The code also comes with a fallback permissive license for use 112 | in jurisdictions that may not recognize the public domain. 113 | 114 | The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011 115 | Valentin Ochs and is licensed under an MIT-style license. 116 | 117 | The BSD PRNG implementation (src/prng/random.c) and XSI search API 118 | (src/search/*.c) functions are Copyright © 2011 Szabolcs Nagy and 119 | licensed under following terms: "Permission to use, copy, modify, 120 | and/or distribute this code for any purpose with or without fee is 121 | hereby granted. There is no warranty." 122 | 123 | The x86_64 port was written by Nicholas J. Kain. Several files (crt) 124 | were released into the public domain; others are licensed under the 125 | standard MIT license terms at the top of this file. See individual 126 | files for their copyright status. 127 | 128 | The mips and microblaze ports were originally written by Richard 129 | Pennington for use in the ellcc project. The original code was adapted 130 | by Rich Felker for build system and code conventions during upstream 131 | integration. It is licensed under the standard MIT terms. 132 | 133 | The powerpc port was also originally written by Richard Pennington, 134 | and later supplemented and integrated by John Spencer. It is licensed 135 | under the standard MIT terms. 136 | 137 | All other files which have no copyright comments are original works 138 | produced specifically for use as part of this library, written either 139 | by Rich Felker, the main author of the library, or by one or more 140 | contibutors listed above. Details on authorship of individual files 141 | can be found in the git version control history of the project. The 142 | omission of copyright and license comments in each file is in the 143 | interest of source tree size. 144 | 145 | All public header files (include/* and arch/*/bits/*) should be 146 | treated as Public Domain as they intentionally contain no content 147 | which can be covered by copyright. Some source modules may fall in 148 | this category as well. If you believe that a file is so trivial that 149 | it should be in the Public Domain, please contact the authors and 150 | request an explicit statement releasing it from copyright. 151 | 152 | The following files are trivial, believed not to be copyrightable in 153 | the first place, and hereby explicitly released to the Public Domain: 154 | 155 | All public headers: include/*, arch/*/bits/* 156 | Startup files: crt/* 157 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | libandroid-support 2 | ------------------ 3 | A copy of libandroid-support as built from NDK r14 in Termux. 4 | 5 | The purpose of `libandroid-support` in Termux is to add functionality missing 6 | the system libc to ease building packages. 7 | 8 | What is still necessary? 9 | ------------------------ 10 | Some functionality can probably be removed in favour of functionality in bionic: 11 | 12 | - [bionic in Android 5.0](https://android.googlesource.com/platform/bionic.git/+/lollipop-release/libc/bionic/) 13 | - [bionic in Android 6.0](https://android.googlesource.com/platform/bionic.git/+/marshmallow-release/libc/bionic/) 14 | - [bionic in Android 7.0](https://android.googlesource.com/platform/bionic.git/+/nougat-release/libc/bionic/) 15 | 16 | Test cases 17 | ---------- 18 | - Findutils: `touch åäö && find . -name åäö`. 19 | -------------------------------------------------------------------------------- /src/musl-ctype/alpha.h: -------------------------------------------------------------------------------- 1 | 18,17,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,17,34,35,36,17,37,38,39,40, 2 | 41,42,43,44,17,45,46,47,16,16,48,16,16,16,16,16,16,16,49,50,51,16,52,53,16,16, 3 | 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,54, 4 | 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, 5 | 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, 6 | 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, 7 | 17,17,17,55,17,17,17,17,56,17,57,58,59,60,61,62,17,17,17,17,17,17,17,17,17,17, 8 | 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, 9 | 17,17,17,17,17,17,17,63,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 10 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,64,65,17,66,67,68,69,70,71,72, 11 | 73,16,16,16,74,75,76,77,78,16,16,16,79,80,16,16,16,16,81,16,16,16,16,16,16,16, 12 | 16,16,17,17,17,82,83,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,84,16,16,16, 13 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 14 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,85,16, 15 | 16,16,16,86,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 17 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,87,16,16,16,16,16,16,16,16,16, 18 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 19 | 88,89,90,91,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 20 | 92,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,0,0,0,0,0,0,0,0,0,0,0,0, 21 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255, 22 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 23 | 255,255,255,255,0,0,0,0,0,0,0,0,254,255,255,7,254,255,255,7,0,0,0,0,0,4,32,4, 24 | 255,255,127,255,255,255,127,255,255,255,255,255,255,255,255,255,255,255,255, 25 | 255,255,255,255,255,255,255,255,255,255,255,255,255,195,255,3,0,31,80,0,0,0,0, 26 | 0,0,0,0,0,0,32,0,0,0,0,0,223,60,64,215,255,255,251,255,255,255,255,255,255, 27 | 255,255,255,191,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 28 | 255,255,3,252,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 29 | 255,255,255,0,254,255,255,255,127,2,254,255,255,255,255,0,0,0,0,0,255,191,182, 30 | 0,255,255,255,7,7,0,0,0,255,7,255,255,255,255,255,255,255,254,255,195,255,255, 31 | 255,255,255,255,255,255,255,255,255,255,239,31,254,225,255,159,0,0,255,255, 32 | 255,255,255,255,0,224,255,255,255,255,255,255,255,255,255,255,255,255,3,0,255, 33 | 255,255,255,255,7,48,4,255,255,255,252,255,31,0,0,255,255,255,1,0,0,0,0,0,0,0, 34 | 0,253,31,0,0,0,0,0,0,240,3,255,127,255,255,255,255,255,255,255,239,255,223, 35 | 225,255,207,255,254,254,238,159,249,255,255,253,197,227,159,89,128,176,207, 36 | 255,3,0,238,135,249,255,255,253,109,195,135,25,2,94,192,255,63,0,238,191,251, 37 | 255,255,253,237,227,191,27,1,0,207,255,0,0,238,159,249,255,255,253,237,227, 38 | 159,25,192,176,207,255,2,0,236,199,61,214,24,199,255,195,199,29,129,0,192,255, 39 | 0,0,238,223,253,255,255,253,239,227,223,29,96,3,207,255,0,0,236,223,253,255, 40 | 255,253,239,227,223,29,96,64,207,255,6,0,236,223,253,255,255,255,255,231,223, 41 | 93,128,0,207,255,0,252,236,255,127,252,255,255,251,47,127,128,95,255,0,0,12,0, 42 | 254,255,255,255,255,127,255,7,63,32,255,3,0,0,0,0,150,37,240,254,174,236,255, 43 | 59,95,32,255,243,0,0,0,0,1,0,0,0,255,3,0,0,255,254,255,255,255,31,254,255,3, 44 | 255,255,254,255,255,255,31,0,0,0,0,0,0,0,0,255,255,255,255,255,255,127,249, 45 | 255,3,255,255,231,193,255,255,127,64,255,51,255,255,255,255,191,32,255,255, 46 | 255,255,255,247,255,255,255,255,255,255,255,255,255,61,127,61,255,255,255,255, 47 | 255,61,255,255,255,255,61,127,61,255,127,255,255,255,255,255,255,255,61,255, 48 | 255,255,255,255,255,255,255,135,0,0,0,0,255,255,0,0,255,255,255,255,255,255, 49 | 255,255,255,255,31,0,254,255,255,255,255,255,255,255,255,255,255,255,255,255, 50 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 51 | 255,255,255,255,255,255,255,255,255,255,255,255,159,255,255,254,255,255,7,255, 52 | 255,255,255,255,255,255,255,255,199,1,0,255,223,15,0,255,255,15,0,255,255,15, 53 | 0,255,223,13,0,255,255,255,255,255,255,207,255,255,1,128,16,255,3,0,0,0,0,255, 54 | 3,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,7,255,255, 55 | 255,255,255,255,255,255,63,0,255,255,255,31,255,15,255,1,192,255,255,255,255, 56 | 63,31,0,255,255,255,255,255,15,255,255,255,3,255,3,0,0,0,0,255,255,255,15,255, 57 | 255,255,255,255,255,255,127,254,255,31,0,255,3,255,3,128,0,0,0,0,0,0,0,0,0,0, 58 | 0,255,255,255,255,255,255,239,255,239,15,255,3,0,0,0,0,255,255,255,255,255, 59 | 243,255,255,255,255,255,255,191,255,3,0,255,255,255,255,255,255,63,0,255,227, 60 | 255,255,255,255,255,63,0,0,0,0,0,0,0,0,0,0,0,0,0,222,111,0,255,255,255,255, 61 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 62 | 255,0,0,0,0,0,0,0,0,255,255,63,63,255,255,255,255,63,63,255,170,255,255,255, 63 | 63,255,255,255,255,255,255,223,95,220,31,207,15,255,31,220,31,0,0,0,0,0,0,0,0, 64 | 0,0,0,0,0,0,2,128,0,0,255,31,0,0,0,0,0,0,0,0,0,0,0,0,132,252,47,62,80,189,255, 65 | 243,224,67,0,0,255,255,255,255,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 66 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,255,255,255,255,255,255,3,0,0,255,255,255, 67 | 255,255,127,255,255,255,255,255,127,255,255,255,255,255,255,255,255,255,255, 68 | 255,255,255,255,255,255,31,120,12,0,255,255,255,255,191,32,255,255,255,255, 69 | 255,255,255,128,0,0,255,255,127,0,127,127,127,127,127,127,127,127,255,255,255, 70 | 255,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,224,0,0, 71 | 0,254,3,62,31,254,255,255,255,255,255,255,255,255,255,127,224,254,255,255,255, 72 | 255,255,255,255,255,255,255,247,224,255,255,255,255,63,254,255,255,255,255, 73 | 255,255,255,255,255,255,127,0,0,255,255,255,7,0,0,0,0,0,0,255,255,255,255,255, 74 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 75 | 63,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 76 | 255,255,255,255,255,255,255,255,255,255,255,31,0,0,0,0,0,0,255,255,255,255, 77 | 255,255,255,255,255,255,255,255,255,255,255,255,255,31,0,0,0,0,0,0,0,0,255, 78 | 255,255,255,255,63,255,31,255,255,255,15,0,0,255,255,255,255,255,127,240,143, 79 | 255,255,255,128,255,255,255,255,255,255,255,255,255,255,0,0,0,0,128,255,252, 80 | 255,255,255,255,255,255,255,255,255,255,255,255,121,15,0,255,7,0,0,0,0,0,0,0, 81 | 0,0,255,187,247,255,255,255,0,0,0,255,255,255,255,255,255,15,0,255,255,255, 82 | 255,255,255,255,255,15,0,255,3,0,0,252,8,255,255,255,255,255,7,255,255,255, 83 | 255,7,0,255,255,255,31,255,255,255,255,255,255,247,255,0,128,255,3,0,0,0,0, 84 | 255,255,255,255,255,255,127,0,255,63,255,3,255,255,127,4,255,255,255,255,255, 85 | 255,255,127,5,0,0,56,255,255,60,0,126,126,126,0,127,127,0,0,0,0,0,0,0,0,0,0,0, 86 | 0,0,0,0,0,0,0,255,255,255,255,255,7,255,3,255,255,255,255,255,255,255,255,255, 87 | 255,255,255,255,255,255,255,255,255,255,255,15,0,255,255,127,248,255,255,255, 88 | 255,255,15,255,255,255,255,255,255,255,255,255,255,255,255,255,63,255,255,255, 89 | 255,255,255,255,255,255,255,255,255,255,3,0,0,0,0,127,0,248,224,255,253,127, 90 | 95,219,255,255,255,255,255,255,255,255,255,255,255,255,255,3,0,0,0,248,255, 91 | 255,255,255,255,255,255,255,255,255,255,255,63,0,0,255,255,255,255,255,255, 92 | 255,255,252,255,255,255,255,255,255,0,0,0,0,0,255,15,0,0,0,0,0,0,0,0,0,0,0,0, 93 | 0,0,223,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,31,0, 94 | 0,255,3,254,255,255,7,254,255,255,7,192,255,255,255,255,255,255,255,255,255, 95 | 255,127,252,252,252,28,0,0,0,0,255,239,255,255,127,255,255,183,255,63,255,63, 96 | 0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,7,0,0,0,0, 97 | 0,0,0,0,255,255,255,255,255,255,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 98 | 0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,31,255,255,255,255,255,255,1,0,0,0,0,0, 99 | 255,255,255,127,0,0,255,255,255,7,0,0,0,0,0,0,255,255,255,63,255,255,255,255, 100 | 15,255,62,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 101 | 255,255,255,255,255,63,255,3,0,0,0,0,0,0,0,0,0,0,63,253,255,255,255,255,191, 102 | 145,255,255,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,63,0,255,255, 103 | 255,3,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,192,0,0,0,0,0,0,0,0,111,240, 104 | 239,254,255,255,15,0,0,0,0,0,255,255,255,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 105 | 255,255,255,255,255,255,63,0,255,255,63,0,255,255,7,0,0,0,0,0,0,0,0,0,0,0,0,0, 106 | 0,0,0,0,255,255,255,255,255,255,255,255,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 107 | 0,0,0,0,0,0,255,255,255,255,255,255,255,255,63,0,0,0,192,255,0,0,252,255,255, 108 | 255,255,255,255,1,0,0,255,255,255,1,255,3,255,255,255,255,255,255,199,255,0,0, 109 | 0,0,0,0,0,0,255,255,255,255,255,255,255,255,30,0,255,3,0,0,0,0,0,0,0,0,0,0,0, 110 | 0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,63,0,255,3,0,0,0,0,0,0,255,255,255, 111 | 255,255,255,255,255,255,255,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 112 | 0,255,255,255,255,255,255,255,255,255,255,255,255,7,0,0,0,0,0,0,0,0,0,0,0,0,0, 113 | 0,0,0,0,0,0,255,255,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 114 | 0,0,0,0,0,255,255,255,255,255,255,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 115 | 0,0,0,0,0,255,255,255,255,255,255,255,255,31,0,255,255,255,255,255,127,0,0, 116 | 248,255,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 117 | 0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,223,255,255,255,255, 118 | 255,255,255,255,223,100,222,255,235,239,255,255,255,255,255,255,255,191,231, 119 | 223,223,255,255,255,123,95,252,253,255,255,255,255,255,255,255,255,255,255, 120 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 121 | 255,255,255,255,255,255,255,255,255,255,255,255,63,255,255,255,253,255,255, 122 | 247,255,255,255,247,255,255,223,255,255,255,223,255,255,127,255,255,255,127, 123 | 255,255,255,253,255,255,255,253,255,255,247,207,255,255,255,255,255,255,239, 124 | 255,255,255,150,254,247,10,132,234,150,170,150,247,247,94,255,251,255,15,238, 125 | 251,255,15,0,0,0,0,0,0,0,0, 126 | -------------------------------------------------------------------------------- /src/musl-ctype/iswalnum.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int iswalnum(wint_t wc) 5 | { 6 | return iswdigit(wc) || iswalpha(wc); 7 | } 8 | -------------------------------------------------------------------------------- /src/musl-ctype/iswalpha.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static const unsigned char table[] = { 4 | #include "alpha.h" 5 | }; 6 | 7 | int iswalpha(wint_t wc) 8 | { 9 | if (wc<0x20000U) 10 | return (table[table[wc>>8]*32+((wc&255)>>3)]>>(wc&7))&1; 11 | if (wc<0x2fffeU) 12 | return 1; 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /src/musl-ctype/iswblank.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int iswblank(wint_t wc) 6 | { 7 | return isblank(wc); 8 | } 9 | -------------------------------------------------------------------------------- /src/musl-ctype/iswcntrl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int iswcntrl(wint_t wc) 5 | { 6 | return (unsigned)wc < 32 7 | || (unsigned)(wc-0x7f) < 33 8 | || (unsigned)(wc-0x2028) < 2 9 | || (unsigned)(wc-0xfff9) < 3; 10 | } 11 | -------------------------------------------------------------------------------- /src/musl-ctype/iswctype.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define WCTYPE_ALNUM 1 6 | #define WCTYPE_ALPHA 2 7 | #define WCTYPE_BLANK 3 8 | #define WCTYPE_CNTRL 4 9 | #define WCTYPE_DIGIT 5 10 | #define WCTYPE_GRAPH 6 11 | #define WCTYPE_LOWER 7 12 | #define WCTYPE_PRINT 8 13 | #define WCTYPE_PUNCT 9 14 | #define WCTYPE_SPACE 10 15 | #define WCTYPE_UPPER 11 16 | #define WCTYPE_XDIGIT 12 17 | 18 | int iswctype(wint_t wc, wctype_t type) 19 | { 20 | switch (type) { 21 | case WCTYPE_ALNUM: 22 | return iswalnum(wc); 23 | case WCTYPE_ALPHA: 24 | return iswalpha(wc); 25 | case WCTYPE_BLANK: 26 | return iswblank(wc); 27 | case WCTYPE_CNTRL: 28 | return iswcntrl(wc); 29 | case WCTYPE_DIGIT: 30 | return iswdigit(wc); 31 | case WCTYPE_GRAPH: 32 | return iswgraph(wc); 33 | case WCTYPE_LOWER: 34 | return iswlower(wc); 35 | case WCTYPE_PRINT: 36 | return iswprint(wc); 37 | case WCTYPE_PUNCT: 38 | return iswpunct(wc); 39 | case WCTYPE_SPACE: 40 | return iswspace(wc); 41 | case WCTYPE_UPPER: 42 | return iswupper(wc); 43 | case WCTYPE_XDIGIT: 44 | return iswxdigit(wc); 45 | } 46 | return 0; 47 | } 48 | 49 | wctype_t wctype(const char *s) 50 | { 51 | int i; 52 | const char *p; 53 | /* order must match! */ 54 | static const char names[] = 55 | "alnum\0" "alpha\0" "blank\0" 56 | "cntrl\0" "digit\0" "graph\0" 57 | "lower\0" "print\0" "punct\0" 58 | "space\0" "upper\0" "xdigit"; 59 | for (i=1, p=names; *p; i++, p+=6) 60 | if (*s == *p && !strcmp(s, p)) 61 | return i; 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /src/musl-ctype/iswdigit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #undef iswdigit 5 | 6 | int iswdigit(wint_t wc) 7 | { 8 | return (unsigned)wc-'0' < 10; 9 | } 10 | -------------------------------------------------------------------------------- /src/musl-ctype/iswgraph.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int iswgraph(wint_t wc) 4 | { 5 | /* ISO C defines this function as: */ 6 | return !iswspace(wc) && iswprint(wc); 7 | } 8 | -------------------------------------------------------------------------------- /src/musl-ctype/iswlower.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int iswlower(wint_t wc) 4 | { 5 | return towupper(wc) != wc || wc == 0xdf; 6 | } 7 | -------------------------------------------------------------------------------- /src/musl-ctype/iswprint.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* Consider all legal codepoints as printable except for: 4 | * - C0 and C1 control characters 5 | * - U+2028 and U+2029 (line/para break) 6 | * - U+FFF9 through U+FFFB (interlinear annotation controls) 7 | * The following code is optimized heavily to make hot paths for the 8 | * expected printable characters. */ 9 | 10 | int iswprint(wint_t wc) 11 | { 12 | if (wc < 0xffU) 13 | return (wc+1 & 0x7f) >= 0x21; 14 | if (wc < 0x2028U || wc-0x202aU < 0xd800-0x202a || wc-0xe000U < 0xfff9-0xe000) 15 | return 1; 16 | if (wc-0xfffcU > 0x10ffff-0xfffc || (wc&0xfffe)==0xfffe) 17 | return 0; 18 | return 1; 19 | } 20 | -------------------------------------------------------------------------------- /src/musl-ctype/iswpunct.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static const unsigned char table[] = { 4 | #include "punct.h" 5 | }; 6 | 7 | int iswpunct(wint_t wc) 8 | { 9 | if (wc<0x20000U) 10 | return (table[table[wc>>8]*32+((wc&255)>>3)]>>(wc&7))&1; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /src/musl-ctype/iswspace.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* Our definition of whitespace is the Unicode White_Space property, 6 | * minus non-breaking spaces (U+00A0, U+2007, and U+202F) and script- 7 | * specific characters with non-blank glyphs (U+1680 and U+180E). */ 8 | 9 | int iswspace(wint_t wc) 10 | { 11 | static const wchar_t spaces[] = { 12 | ' ', '\t', '\n', '\r', 11, 12, 0x0085, 13 | 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 14 | 0x2006, 0x2008, 0x2009, 0x200a, 15 | 0x2028, 0x2029, 0x205f, 0x3000, 0 16 | }; 17 | return wc && wcschr(spaces, wc); 18 | } 19 | -------------------------------------------------------------------------------- /src/musl-ctype/iswupper.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int iswupper(wint_t wc) 4 | { 5 | return towlower(wc) != wc; 6 | } 7 | -------------------------------------------------------------------------------- /src/musl-ctype/iswxdigit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int iswxdigit(wint_t wc) 5 | { 6 | return (unsigned)(wc-'0') < 10 || (unsigned)((wc|32)-'a') < 6; 7 | } 8 | -------------------------------------------------------------------------------- /src/musl-ctype/nonspacing.h: -------------------------------------------------------------------------------- 1 | 16,16,16,18,19,20,21,22,23,24,25,26,27,28,29,30,31,16,16,32,16,16,16,33,34,35, 2 | 36,37,38,39,16,16,40,16,16,16,16,16,16,16,16,16,16,16,41,42,16,16,43,16,16,16, 3 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 4 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 5 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 6 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 7 | 16,16,16,16,16,16,16,16,16,16,44,16,45,46,47,48,16,16,16,16,16,16,16,16,16,16, 8 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 9 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 10 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,49,16,16,50,51,16,52,16,16, 11 | 16,16,16,16,16,16,53,16,16,16,16,16,54,55,16,16,16,16,56,16,16,16,16,16,16,16, 12 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 13 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 14 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 15 | 16,16,16,57,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 17 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 18 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,58,59,16, 19 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 20 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,0,0,0,0,0,0,0,0,0,0,0,0, 21 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255, 22 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 23 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0, 24 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,3,0,0,0,0,0, 25 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,255,255,255,255,191, 26 | 182,0,0,0,0,0,0,0,31,0,255,7,0,0,0,0,0,248,255,255,0,0,1,0,0,0,0,0,0,0,0,0,0, 27 | 0,192,191,159,61,0,0,0,128,2,0,0,0,255,255,255,7,0,0,0,0,0,0,0,0,0,0,192,255, 28 | 1,0,0,0,0,0,0,248,15,0,0,0,192,251,239,62,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0, 29 | 0,0,0,0,0,240,255,255,127,7,0,0,0,0,0,0,20,254,33,254,0,12,0,0,0,2,0,0,0,0,0, 30 | 0,16,30,32,0,0,12,0,0,0,6,0,0,0,0,0,0,16,134,57,2,0,0,0,35,0,6,0,0,0,0,0,0,16, 31 | 190,33,0,0,12,0,0,0,2,0,0,0,0,0,0,144,30,32,64,0,12,0,0,0,4,0,0,0,0,0,0,0,1, 32 | 32,0,0,0,0,0,0,0,0,0,0,0,0,0,192,193,61,96,0,12,0,0,0,0,0,0,0,0,0,0,144,64,48, 33 | 0,0,12,0,0,0,0,0,0,0,0,0,0,0,30,32,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,4,92,0,0,0, 34 | 0,0,0,0,0,0,0,0,242,7,128,127,0,0,0,0,0,0,0,0,0,0,0,0,242,27,0,63,0,0,0,0,0,0, 35 | 0,0,0,3,0,0,160,2,0,0,0,0,0,0,254,127,223,224,255,254,255,255,255,31,64,0,0,0, 36 | 0,0,0,0,0,0,0,0,0,224,253,102,0,0,0,195,1,0,30,0,100,32,0,32,0,0,0,0,0,0,0,0, 37 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 38 | 28,0,0,0,28,0,0,0,12,0,0,0,12,0,0,0,0,0,0,0,176,63,64,254,15,32,0,0,0,0,0,56, 39 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135,1,4, 40 | 14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,1,0,0,0,0,0,0,64, 41 | 127,229,31,248,159,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,0,208,23,4,0,0, 42 | 0,0,248,15,0,3,0,0,0,60,11,0,0,0,0,0,0,64,163,3,0,0,0,0,0,0,240,207,0,0,0,0,0, 43 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,247,255,253,33,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 44 | 0,0,0,0,0,0,0,0,0,255,255,255,255,127,0,0,240,0,248,0,0,0,124,0,0,0,0,0,0,31, 45 | 252,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 46 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0, 47 | 0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,0,60,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0, 48 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,247,63,0,0,0,128,0,0,0,0,0, 49 | 0,0,0,0,0,3,0,68,8,0,0,96,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,255, 50 | 255,3,0,0,0,0,0,192,63,0,0,128,255,3,0,0,0,0,0,7,0,0,0,0,0,200,19,0,0,0,0,0,0, 51 | 0,0,0,0,0,0,0,126,102,0,8,16,0,0,0,0,0,0,0,0,0,0,0,0,157,193,2,0,0,0,0,48,64, 52 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,33,0,0,0,0,0,64, 53 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,0,0,127,0,0,0, 54 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 55 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 56 | 0,0,0,0,0,0,0,0,0,0,0,32,110,240,0,0,0,0,0,135,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 57 | 0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,255,127,0,0,0,0,0,0,0,3,0,0,0,0,0,120,38,0,0, 58 | 0,0,0,0,0,0,7,0,0,0,128,239,31,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,192,127,0,0,0,0, 59 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,191,0,0,0,0,0,0,0,0,0,0, 60 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 61 | 0,0,0,0,0,128,3,248,255,231,15,0,0,0,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 62 | 28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 63 | -------------------------------------------------------------------------------- /src/musl-ctype/punct.h: -------------------------------------------------------------------------------- 1 | 18,16,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,16,16,34,35,16,36,37,38,39, 2 | 40,41,42,43,16,44,45,46,17,47,48,17,17,49,17,17,17,50,51,52,53,54,55,56,57,17, 3 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,58, 4 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 5 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 6 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 7 | 16,16,16,16,16,16,16,16,59,16,60,61,62,63,64,65,16,16,16,16,16,16,16,16,16,16, 8 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 9 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,66,16,16,16,16,16,16,16,16,16, 10 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,67,16,16,68,16,69,70,71,16,72,16,73, 11 | 16,16,16,16,74,75,76,77,16,16,78,16,79,80,16,16,16,16,81,16,16,16,16,16,16,16, 12 | 16,16,16,16,16,16,82,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 13 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 14 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 15 | 16,16,16,83,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 17 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 18 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,84,85,86,87, 19 | 16,16,88,89,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 20 | 90,16,91,92,93,94,95,96,97,98,16,16,16,16,16,16,16,16,0,0,0,0,0,0,0,0,0,0,0,0, 21 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255, 22 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 23 | 255,255,255,255,0,0,0,0,254,255,0,252,1,0,0,248,1,0,0,120,0,0,0,0,255,251,223, 24 | 251,0,0,128,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,60,0, 25 | 252,255,224,175,255,255,255,255,255,255,255,255,255,255,223,255,255,255,255, 26 | 255,32,64,176,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 27 | 252,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252,0,0,0,0,0,134,254, 28 | 255,255,255,0,64,73,0,0,0,0,0,24,0,223,255,0,200,0,0,0,0,0,0,0,1,0,60,0,0,0,0, 29 | 0,0,0,0,0,0,0,0,16,224,1,30,0,96,255,191,0,0,0,0,0,0,255,7,0,0,0,0,0,0,0,0,0, 30 | 0,0,0,0,0,0,0,0,0,0,248,207,3,0,0,0,3,0,32,255,127,0,0,0,78,0,0,0,0,0,0,0,0,0, 31 | 0,0,0,0,0,0,0,0,252,0,0,0,0,0,0,0,0,0,16,0,32,30,0,48,0,1,0,0,0,0,0,0,0,0,16, 32 | 0,32,0,0,0,0,252,15,0,0,0,0,0,0,0,16,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,32,0, 33 | 0,0,0,3,0,0,0,0,0,0,0,0,16,0,32,0,0,0,0,253,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0, 34 | 255,7,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,255,0,0,0,0,0,0,0,16,0,32,0,0,0,0,0,0,0, 35 | 0,0,0,0,0,0,0,0,32,0,0,0,0,63,2,0,0,0,0,0,0,0,0,0,4,0,0,0,0,16,0,0,0,0,0,0, 36 | 128,0,128,192,223,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,254,255,255, 37 | 255,0,252,255,255,0,0,0,0,0,0,0,0,252,0,0,0,0,0,0,192,255,223,255,7,0,0,0,0,0, 38 | 0,0,0,0,0,128,6,0,252,0,0,24,62,0,0,128,191,0,204,0,0,0,0,0,0,0,0,0,0,0,8,0,0, 39 | 0,0,0,0,0,0,0,0,0,96,255,255,255,31,0,0,255,3,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0, 40 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 41 | 0,0,96,0,0,1,0,0,24,0,0,0,0,0,0,0,0,0,56,0,0,0,0,16,0,0,0,112,0,0,0,0,0,0,0,0, 42 | 0,0,0,0,0,0,0,48,0,0,254,127,47,0,0,255,3,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 43 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,49,0,0,0,0,0,0,0,0,0,0,0,0,0, 44 | 0,0,0,0,0,196,255,255,255,255,0,0,0,192,0,0,0,0,0,0,0,0,1,0,224,159,0,0,0,0, 45 | 127,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,16,0,0,252,255,255,255,31,0,0,0,0, 46 | 0,12,0,0,0,0,0,0,64,0,12,240,0,0,0,0,0,0,192,248,0,0,0,0,0,0,0,192,0,0,0,0,0, 47 | 0,0,0,255,0,255,255,255,33,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 48 | 0,255,255,255,255,127,0,0,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 49 | 160,3,224,0,224,0,224,0,96,128,248,255,255,255,252,255,255,255,255,255,127,31, 50 | 252,241,127,255,127,0,0,255,255,255,3,0,0,255,255,255,255,1,0,123,3,208,193, 51 | 175,66,0,12,31,188,255,255,0,0,0,0,0,2,255,255,255,255,255,255,255,255,255, 52 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 53 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,15,0,255,255, 54 | 255,255,127,0,0,0,255,7,0,0,255,255,255,255,255,255,255,255,255,255,63,0,0,0, 55 | 0,0,0,252,255,255,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 56 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 57 | 255,255,255,255,255,255,255,31,255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 58 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,224,135,3,254,0,0,0,0, 59 | 0,0,0,0,0,0,0,0,0,0,1,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255, 60 | 127,255,15,0,0,0,0,0,0,0,0,255,255,255,251,255,255,255,255,255,255,255,255, 61 | 255,255,15,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 62 | 255,255,255,255,255,255,255,255,255,255,63,0,0,0,255,15,30,255,255,255,1,252, 63 | 193,224,0,0,0,0,0,0,0,0,0,0,0,30,1,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0, 64 | 0,0,0,0,0,0,0,0,255,255,0,0,0,0,255,255,255,255,15,0,0,0,255,255,255,127,255, 65 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 66 | 255,255,255,255,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 67 | 0,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255, 68 | 255,255,255,255,127,0,0,0,0,0,0,192,0,224,0,0,0,0,0,0,0,0,0,0,0,128,15,112,0, 69 | 0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,255,255,127,0,3,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0, 70 | 0,0,0,0,0,0,0,0,0,0,0,0,68,8,0,0,0,15,255,3,0,0,0,0,0,0,240,0,0,0,0,0,0,0,0,0, 71 | 16,192,0,0,255,255,3,7,0,0,0,0,0,248,0,0,0,0,8,128,0,0,0,0,0,0,0,0,0,0,8,0, 72 | 255,63,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,240,0,0,128,11,0,0,0,0,0,0,0,128,2, 73 | 0,0,192,0,0,67,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,56, 74 | 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 75 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,2,0,0,0,0,0, 76 | 0,0,0,0,0,0,0,0,0,0,0,252,255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,0,0,0,0, 77 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,255,255,255,3,127,0,255,255,255,255,247, 78 | 255,127,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,254,255,0,252,1,0,0,248,1,0, 79 | 0,248,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,127,0,48,135,255,255,255,255,255, 80 | 143,255,0,0,0,0,0,0,224,255,255,7,255,15,0,0,0,0,0,0,255,255,255,255,255,63,0, 81 | 0,0,0,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, 82 | 0,0,0,0,128,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,143,0,0,0,128, 83 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135,255,0,255,1, 84 | 0,0,0,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,0,0,0,255,0,0,0, 85 | 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,127,0, 86 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,63,252,255,63,0,0,0,3,0,0,0, 87 | 0,0,0,254,3,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 88 | 225,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,0,0,0, 89 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 90 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,7,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255, 91 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 92 | 255,255,255,255,255,255,255,63,0,255,255,255,255,127,254,255,255,255,255,255, 93 | 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,63,0,0,0,0, 94 | 255,255,255,255,255,255,255,255,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 95 | 0,0,255,255,255,255,255,255,255,255,255,255,127,0,255,255,3,0,0,0,0,0,0,0,0,0, 96 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,8,0,0,0, 97 | 8,0,0,32,0,0,0,32,0,0,128,0,0,0,128,0,0,0,2,0,0,0,2,0,0,8,0,0,0,0,0,0,0,0,0,0, 98 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,255,255,255,255,255, 99 | 15,255,255,255,255,255,255,255,255,255,255,255,255,15,0,255,127,254,127,254, 100 | 255,254,255,0,0,0,0,255,7,255,255,255,127,255,255,255,255,255,255,255,15,255, 101 | 255,255,255,255,7,0,0,0,0,0,0,0,0,192,255,255,255,7,0,255,255,255,255,255,7, 102 | 255,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,1,0,191,255, 103 | 255,255,255,255,255,255,255,31,255,255,15,0,255,255,255,255,223,7,0,0,255,255, 104 | 1,0,255,255,255,255,255,255,255,127,253,255,255,255,255,255,255,255,255,255, 105 | 255,255,255,255,255,255,255,255,255,255,255,255,255,30,255,255,255,255,255, 106 | 255,255,63,15,0,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,255,255, 107 | 255,255,255,255,255,255,225,255,0,0,0,0,0,0,255,255,255,255,255,255,255,255, 108 | 63,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,15,0, 109 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 110 | -------------------------------------------------------------------------------- /src/musl-ctype/towctrans.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define CASEMAP(u1,u2,l) { (u1), (l)-(u1), (u2)-(u1)+1 } 6 | #define CASELACE(u1,u2) CASEMAP((u1),(u2),(u1)+1) 7 | 8 | static const struct { 9 | unsigned short upper; 10 | signed char lower; 11 | unsigned char len; 12 | } casemaps[] = { 13 | CASEMAP('A','Z','a'), 14 | CASEMAP(0xc0,0xde,0xe0), 15 | 16 | CASELACE(0x0100,0x012e), 17 | CASELACE(0x0132,0x0136), 18 | CASELACE(0x0139,0x0147), 19 | CASELACE(0x014a,0x0176), 20 | CASELACE(0x0179,0x017d), 21 | 22 | CASELACE(0x370,0x372), 23 | CASEMAP(0x391,0x3a1,0x3b1), 24 | CASEMAP(0x3a3,0x3ab,0x3c3), 25 | CASEMAP(0x400,0x40f,0x450), 26 | CASEMAP(0x410,0x42f,0x430), 27 | 28 | CASELACE(0x460,0x480), 29 | CASELACE(0x48a,0x4be), 30 | CASELACE(0x4c1,0x4cd), 31 | CASELACE(0x4d0,0x50e), 32 | 33 | CASELACE(0x514,0x526), 34 | CASEMAP(0x531,0x556,0x561), 35 | 36 | CASELACE(0x01a0,0x01a4), 37 | CASELACE(0x01b3,0x01b5), 38 | CASELACE(0x01cd,0x01db), 39 | CASELACE(0x01de,0x01ee), 40 | CASELACE(0x01f8,0x021e), 41 | CASELACE(0x0222,0x0232), 42 | CASELACE(0x03d8,0x03ee), 43 | 44 | CASELACE(0x1e00,0x1e94), 45 | CASELACE(0x1ea0,0x1efe), 46 | 47 | CASEMAP(0x1f08,0x1f0f,0x1f00), 48 | CASEMAP(0x1f18,0x1f1d,0x1f10), 49 | CASEMAP(0x1f28,0x1f2f,0x1f20), 50 | CASEMAP(0x1f38,0x1f3f,0x1f30), 51 | CASEMAP(0x1f48,0x1f4d,0x1f40), 52 | 53 | CASEMAP(0x1f68,0x1f6f,0x1f60), 54 | CASEMAP(0x1f88,0x1f8f,0x1f80), 55 | CASEMAP(0x1f98,0x1f9f,0x1f90), 56 | CASEMAP(0x1fa8,0x1faf,0x1fa0), 57 | CASEMAP(0x1fb8,0x1fb9,0x1fb0), 58 | CASEMAP(0x1fba,0x1fbb,0x1f70), 59 | CASEMAP(0x1fc8,0x1fcb,0x1f72), 60 | CASEMAP(0x1fd8,0x1fd9,0x1fd0), 61 | CASEMAP(0x1fda,0x1fdb,0x1f76), 62 | CASEMAP(0x1fe8,0x1fe9,0x1fe0), 63 | CASEMAP(0x1fea,0x1feb,0x1f7a), 64 | CASEMAP(0x1ff8,0x1ff9,0x1f78), 65 | CASEMAP(0x1ffa,0x1ffb,0x1f7c), 66 | 67 | CASELACE(0x246,0x24e), 68 | CASELACE(0x510,0x512), 69 | CASEMAP(0x2160,0x216f,0x2170), 70 | CASEMAP(0x2c00,0x2c2e,0x2c30), 71 | CASELACE(0x2c67,0x2c6b), 72 | CASELACE(0x2c80,0x2ce2), 73 | CASELACE(0x2ceb,0x2ced), 74 | 75 | CASELACE(0xa640,0xa66c), 76 | CASELACE(0xa680,0xa696), 77 | 78 | CASELACE(0xa722,0xa72e), 79 | CASELACE(0xa732,0xa76e), 80 | CASELACE(0xa779,0xa77b), 81 | CASELACE(0xa77e,0xa786), 82 | 83 | CASELACE(0xa790,0xa792), 84 | CASELACE(0xa7a0,0xa7a8), 85 | 86 | CASEMAP(0xff21,0xff3a,0xff41), 87 | { 0,0,0 } 88 | }; 89 | 90 | static const unsigned short pairs[][2] = { 91 | { 'I', 0x0131 }, 92 | { 'S', 0x017f }, 93 | { 0x0130, 'i' }, 94 | { 0x0178, 0x00ff }, 95 | { 0x0181, 0x0253 }, 96 | { 0x0182, 0x0183 }, 97 | { 0x0184, 0x0185 }, 98 | { 0x0186, 0x0254 }, 99 | { 0x0187, 0x0188 }, 100 | { 0x0189, 0x0256 }, 101 | { 0x018a, 0x0257 }, 102 | { 0x018b, 0x018c }, 103 | { 0x018e, 0x01dd }, 104 | { 0x018f, 0x0259 }, 105 | { 0x0190, 0x025b }, 106 | { 0x0191, 0x0192 }, 107 | { 0x0193, 0x0260 }, 108 | { 0x0194, 0x0263 }, 109 | { 0x0196, 0x0269 }, 110 | { 0x0197, 0x0268 }, 111 | { 0x0198, 0x0199 }, 112 | { 0x019c, 0x026f }, 113 | { 0x019d, 0x0272 }, 114 | { 0x019f, 0x0275 }, 115 | { 0x01a6, 0x0280 }, 116 | { 0x01a7, 0x01a8 }, 117 | { 0x01a9, 0x0283 }, 118 | { 0x01ac, 0x01ad }, 119 | { 0x01ae, 0x0288 }, 120 | { 0x01af, 0x01b0 }, 121 | { 0x01b1, 0x028a }, 122 | { 0x01b2, 0x028b }, 123 | { 0x01b7, 0x0292 }, 124 | { 0x01b8, 0x01b9 }, 125 | { 0x01bc, 0x01bd }, 126 | { 0x01c4, 0x01c6 }, 127 | { 0x01c4, 0x01c5 }, 128 | { 0x01c5, 0x01c6 }, 129 | { 0x01c7, 0x01c9 }, 130 | { 0x01c7, 0x01c8 }, 131 | { 0x01c8, 0x01c9 }, 132 | { 0x01ca, 0x01cc }, 133 | { 0x01ca, 0x01cb }, 134 | { 0x01cb, 0x01cc }, 135 | { 0x01f1, 0x01f3 }, 136 | { 0x01f1, 0x01f2 }, 137 | { 0x01f2, 0x01f3 }, 138 | { 0x01f4, 0x01f5 }, 139 | { 0x01f6, 0x0195 }, 140 | { 0x01f7, 0x01bf }, 141 | { 0x0220, 0x019e }, 142 | { 0x0386, 0x03ac }, 143 | { 0x0388, 0x03ad }, 144 | { 0x0389, 0x03ae }, 145 | { 0x038a, 0x03af }, 146 | { 0x038c, 0x03cc }, 147 | { 0x038e, 0x03cd }, 148 | { 0x038f, 0x03ce }, 149 | { 0x0399, 0x0345 }, 150 | { 0x0399, 0x1fbe }, 151 | { 0x03a3, 0x03c2 }, 152 | { 0x03f7, 0x03f8 }, 153 | { 0x03fa, 0x03fb }, 154 | { 0x1e60, 0x1e9b }, 155 | { 0xdf, 0xdf }, 156 | { 0x1e9e, 0xdf }, 157 | 158 | { 0x1f59, 0x1f51 }, 159 | { 0x1f5b, 0x1f53 }, 160 | { 0x1f5d, 0x1f55 }, 161 | { 0x1f5f, 0x1f57 }, 162 | { 0x1fbc, 0x1fb3 }, 163 | { 0x1fcc, 0x1fc3 }, 164 | { 0x1fec, 0x1fe5 }, 165 | { 0x1ffc, 0x1ff3 }, 166 | 167 | { 0x23a, 0x2c65 }, 168 | { 0x23b, 0x23c }, 169 | { 0x23d, 0x19a }, 170 | { 0x23e, 0x2c66 }, 171 | { 0x241, 0x242 }, 172 | { 0x243, 0x180 }, 173 | { 0x244, 0x289 }, 174 | { 0x245, 0x28c }, 175 | { 0x3f4, 0x3b8 }, 176 | { 0x3f9, 0x3f2 }, 177 | { 0x3fd, 0x37b }, 178 | { 0x3fe, 0x37c }, 179 | { 0x3ff, 0x37d }, 180 | { 0x4c0, 0x4cf }, 181 | 182 | { 0x2126, 0x3c9 }, 183 | { 0x212a, 'k' }, 184 | { 0x212b, 0xe5 }, 185 | { 0x2132, 0x214e }, 186 | { 0x2183, 0x2184 }, 187 | { 0x2c60, 0x2c61 }, 188 | { 0x2c62, 0x26b }, 189 | { 0x2c63, 0x1d7d }, 190 | { 0x2c64, 0x27d }, 191 | { 0x2c6d, 0x251 }, 192 | { 0x2c6e, 0x271 }, 193 | { 0x2c6f, 0x250 }, 194 | { 0x2c70, 0x252 }, 195 | { 0x2c72, 0x2c73 }, 196 | { 0x2c75, 0x2c76 }, 197 | { 0x2c7e, 0x23f }, 198 | { 0x2c7f, 0x240 }, 199 | { 0x2cf2, 0x2cf3 }, 200 | 201 | { 0xa77d, 0x1d79 }, 202 | { 0xa78b, 0xa78c }, 203 | { 0xa78d, 0x265 }, 204 | { 0xa7aa, 0x266 }, 205 | 206 | { 0x10c7, 0x2d27 }, 207 | { 0x10cd, 0x2d2d }, 208 | 209 | /* bogus greek 'symbol' letters */ 210 | { 0x376, 0x377 }, 211 | { 0x39c, 0xb5 }, 212 | { 0x392, 0x3d0 }, 213 | { 0x398, 0x3d1 }, 214 | { 0x3a6, 0x3d5 }, 215 | { 0x3a0, 0x3d6 }, 216 | { 0x39a, 0x3f0 }, 217 | { 0x3a1, 0x3f1 }, 218 | { 0x395, 0x3f5 }, 219 | { 0x3cf, 0x3d7 }, 220 | 221 | { 0,0 } 222 | }; 223 | 224 | 225 | static wchar_t __towcase(wchar_t wc, int lower) 226 | { 227 | int i; 228 | int lmul = 2*lower-1; 229 | int lmask = lower-1; 230 | /* no letters with case in these large ranges */ 231 | if (!iswalpha(wc) 232 | || (unsigned)wc - 0x0600 <= 0x0fff-0x0600 233 | || (unsigned)wc - 0x2e00 <= 0xa63f-0x2e00 234 | || (unsigned)wc - 0xa800 <= 0xfeff-0xa800) 235 | return wc; 236 | /* special case because the diff between upper/lower is too big */ 237 | if (lower && (unsigned)wc - 0x10a0 < 0x2e) { 238 | if (wc>0x10c5 && wc != 0x10c7 && wc != 0x10cd) { 239 | return wc; 240 | } else { 241 | return wc + 0x2d00 - 0x10a0; 242 | } 243 | } 244 | if (!lower && (unsigned)wc - 0x2d00 < 0x26) { 245 | if (wc>0x2d25 && wc != 0x2d27 && wc != 0x2d2d) { 246 | return wc; 247 | } else { 248 | return wc + 0x10a0 - 0x2d00; 249 | } 250 | } 251 | for (i=0; casemaps[i].len; i++) { 252 | int base = casemaps[i].upper + (lmask & casemaps[i].lower); 253 | if ((unsigned)wc-base < casemaps[i].len) { 254 | if (casemaps[i].lower == 1) 255 | return wc + lower - ((wc-casemaps[i].upper)&1); 256 | return wc + lmul*casemaps[i].lower; 257 | } 258 | } 259 | for (i=0; pairs[i][1-lower]; i++) { 260 | if (pairs[i][1-lower] == wc) 261 | return pairs[i][lower]; 262 | } 263 | if ((unsigned)wc - (0x10428 - 0x28*lower) < 0x28) 264 | return wc - 0x28 + 0x50*lower; 265 | return wc; 266 | } 267 | 268 | wint_t towupper(wint_t wc) 269 | { 270 | return __towcase(wc, 0); 271 | } 272 | 273 | wint_t towlower(wint_t wc) 274 | { 275 | return __towcase(wc, 1); 276 | } 277 | -------------------------------------------------------------------------------- /src/musl-ctype/wcswidth.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int wcswidth(const wchar_t *wcs, size_t n) 4 | { 5 | int l=0, k=0; 6 | for (; n-- && *wcs && (k = wcwidth(*wcs)) >= 0; l+=k, wcs++); 7 | return (k < 0) ? k : l; 8 | } 9 | -------------------------------------------------------------------------------- /src/musl-ctype/wctrans.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | wctrans_t wctrans(const char *class) 5 | { 6 | if (!strcmp(class, "toupper")) return (wctrans_t)1; 7 | if (!strcmp(class, "tolower")) return (wctrans_t)2; 8 | return 0; 9 | } 10 | 11 | wint_t towctrans(wint_t wc, wctrans_t trans) 12 | { 13 | if (trans == (wctrans_t)1) return towupper(wc); 14 | if (trans == (wctrans_t)2) return towlower(wc); 15 | return wc; 16 | } 17 | -------------------------------------------------------------------------------- /src/musl-multibyte/internal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code was written by Rich Felker in 2010; no copyright is claimed. 3 | * This code is in the public domain. Attribution is appreciated but 4 | * unnecessary. 5 | */ 6 | 7 | #include "internal.h" 8 | 9 | #define C(x) ( x<2 ? -1 : ( R(0x80,0xc0) | x ) ) 10 | #define D(x) C((x+16)) 11 | #define E(x) ( ( x==0 ? R(0xa0,0xc0) : \ 12 | x==0xd ? R(0x80,0xa0) : \ 13 | R(0x80,0xc0) ) \ 14 | | ( R(0x80,0xc0) >> 6 ) \ 15 | | x ) 16 | #define F(x) ( ( x>=5 ? 0 : \ 17 | x==0 ? R(0x90,0xc0) : \ 18 | x==4 ? R(0x80,0xa0) : \ 19 | R(0x80,0xc0) ) \ 20 | | ( R(0x80,0xc0) >> 6 ) \ 21 | | ( R(0x80,0xc0) >> 12 ) \ 22 | | x ) 23 | 24 | const uint32_t bittab[] = { 25 | C(0x2),C(0x3),C(0x4),C(0x5),C(0x6),C(0x7), 26 | C(0x8),C(0x9),C(0xa),C(0xb),C(0xc),C(0xd),C(0xe),C(0xf), 27 | D(0x0),D(0x1),D(0x2),D(0x3),D(0x4),D(0x5),D(0x6),D(0x7), 28 | D(0x8),D(0x9),D(0xa),D(0xb),D(0xc),D(0xd),D(0xe),D(0xf), 29 | E(0x0),E(0x1),E(0x2),E(0x3),E(0x4),E(0x5),E(0x6),E(0x7), 30 | E(0x8),E(0x9),E(0xa),E(0xb),E(0xc),E(0xd),E(0xe),E(0xf), 31 | F(0x0),F(0x1),F(0x2),F(0x3),F(0x4) 32 | }; 33 | 34 | #ifdef BROKEN_VISIBILITY 35 | __asm__(".hidden __fsmu8"); 36 | #endif 37 | -------------------------------------------------------------------------------- /src/musl-multibyte/internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This code was written by Rich Felker in 2010; no copyright is claimed. 3 | * This code is in the public domain. Attribution is appreciated but 4 | * unnecessary. 5 | */ 6 | 7 | #define bittab __fsmu8 8 | 9 | #include 10 | #include "libc.h" 11 | 12 | extern const uint32_t bittab[] ATTR_LIBC_VISIBILITY; 13 | 14 | /* Upper 6 state bits are a negative integer offset to bound-check next byte */ 15 | /* equivalent to: ( (b-0x80) | (b+offset) ) & ~0x3f */ 16 | #define OOB(c,b) (((((b)>>3)-0x10)|(((b)>>3)+((int32_t)(c)>>26))) & ~7) 17 | 18 | /* Interval [a,b). Either a must be 80 or b must be c0, lower 3 bits clear. */ 19 | #define R(a,b) ((uint32_t)((a==0x80 ? 0x40-b : -a) << 23)) 20 | #define FAILSTATE R(0x80,0x80) 21 | 22 | #define SA 0xc2u 23 | #define SB 0xf4u 24 | -------------------------------------------------------------------------------- /src/musl-multibyte/libc.h: -------------------------------------------------------------------------------- 1 | // Replacemenet for musl's libc 2 | 3 | #ifndef MUSL_LIBC_H 4 | #define MUSL_LIBC_H 5 | 6 | #define ATTR_LIBC_VISIBILITY __attribute__((visibility("hidden"))) 7 | 8 | #endif // MUSL_LIBC_H 9 | -------------------------------------------------------------------------------- /src/musl-multibyte/mblen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code was written by Rich Felker in 2010; no copyright is claimed. 3 | * This code is in the public domain. Attribution is appreciated but 4 | * unnecessary. 5 | */ 6 | 7 | #include 8 | 9 | int mblen(const char *s, size_t n) 10 | { 11 | return mbtowc(0, s, n); 12 | } 13 | -------------------------------------------------------------------------------- /src/musl-multibyte/mbsnrtowcs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code was written by Rich Felker in 2010; no copyright is claimed. 3 | * This code is in the public domain. Attribution is appreciated but 4 | * unnecessary. 5 | */ 6 | 7 | #include 8 | 9 | size_t mbsnrtowcs(wchar_t *restrict wcs, const char **restrict src, size_t n, size_t wn, mbstate_t *restrict st) 10 | { 11 | size_t l, cnt=0, n2; 12 | wchar_t *ws, wbuf[256]; 13 | const char *s = *src; 14 | 15 | if (!wcs) ws = wbuf, wn = sizeof wbuf / sizeof *wbuf; 16 | else ws = wcs; 17 | 18 | /* making sure output buffer size is at most n/4 will ensure 19 | * that mbsrtowcs never reads more than n input bytes. thus 20 | * we can use mbsrtowcs as long as it's practical.. */ 21 | 22 | while ( s && wn && ( (n2=n/4)>=wn || n2>32 ) ) { 23 | if (n2>=wn) n2=wn; 24 | n -= n2; 25 | l = mbsrtowcs(ws, &s, n2, st); 26 | if (!(l+1)) { 27 | cnt = l; 28 | wn = 0; 29 | break; 30 | } 31 | if (ws != wbuf) { 32 | ws += l; 33 | wn -= l; 34 | } 35 | cnt += l; 36 | } 37 | if (s) while (wn && n) { 38 | l = mbrtowc(ws, s, n, st); 39 | if (l+2<=2) { 40 | if (!(l+1)) { 41 | cnt = l; 42 | break; 43 | } 44 | if (!l) { 45 | s = 0; 46 | break; 47 | } 48 | /* have to roll back partial character */ 49 | *(unsigned *)st = 0; 50 | break; 51 | } 52 | s += l; n -= l; 53 | /* safe - this loop runs fewer than sizeof(wbuf)/8 times */ 54 | ws++; wn--; 55 | cnt++; 56 | } 57 | if (wcs) *src = s; 58 | return cnt; 59 | } 60 | -------------------------------------------------------------------------------- /src/musl-multibyte/mbsrtowcs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This code was written by Rich Felker in 2010; no copyright is claimed. 3 | * This code is in the public domain. Attribution is appreciated but 4 | * unnecessary. 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include "internal.h" 11 | 12 | size_t mbsrtowcs(wchar_t *restrict ws, const char **restrict src, size_t wn, mbstate_t *restrict st) 13 | { 14 | const unsigned char *s = (const void *)*src; 15 | size_t wn0 = wn; 16 | unsigned c = 0; 17 | 18 | if (st && (c = *(unsigned *)st)) { 19 | if (ws) { 20 | *(unsigned *)st = 0; 21 | goto resume; 22 | } else { 23 | goto resume0; 24 | } 25 | } 26 | 27 | if (!ws) for (;;) { 28 | if (*s-1u < 0x7f && (uintptr_t)s%4 == 0) { 29 | while (!(( *(uint32_t*)s | *(uint32_t*)s-0x01010101) & 0x80808080)) { 30 | s += 4; 31 | wn -= 4; 32 | } 33 | } 34 | if (*s-1u < 0x7f) { 35 | s++; 36 | wn--; 37 | continue; 38 | } 39 | if (*s-SA > SB-SA) break; 40 | c = bittab[*s++-SA]; 41 | resume0: 42 | if (OOB(c,*s)) { s--; break; } 43 | s++; 44 | if (c&(1U<<25)) { 45 | if (*s-0x80u >= 0x40) { s-=2; break; } 46 | s++; 47 | if (c&(1U<<19)) { 48 | if (*s-0x80u >= 0x40) { s-=3; break; } 49 | s++; 50 | } 51 | } 52 | wn--; 53 | c = 0; 54 | } else for (;;) { 55 | if (!wn) { 56 | *src = (const void *)s; 57 | return wn0; 58 | } 59 | if (*s-1u < 0x7f && (uintptr_t)s%4 == 0) { 60 | while (wn>=5 && !(( *(uint32_t*)s | *(uint32_t*)s-0x01010101) & 0x80808080)) { 61 | *ws++ = *s++; 62 | *ws++ = *s++; 63 | *ws++ = *s++; 64 | *ws++ = *s++; 65 | wn -= 4; 66 | } 67 | } 68 | if (*s-1u < 0x7f) { 69 | *ws++ = *s++; 70 | wn--; 71 | continue; 72 | } 73 | if (*s-SA > SB-SA) break; 74 | c = bittab[*s++-SA]; 75 | resume: 76 | if (OOB(c,*s)) { s--; break; } 77 | c = (c<<6) | *s++-0x80; 78 | if (c&(1U<<31)) { 79 | if (*s-0x80u >= 0x40) { s-=2; break; } 80 | c = (c<<6) | *s++-0x80; 81 | if (c&(1U<<31)) { 82 | if (*s-0x80u >= 0x40) { s-=3; break; } 83 | c = (c<<6) | *s++-0x80; 84 | } 85 | } 86 | *ws++ = c; 87 | wn--; 88 | c = 0; 89 | } 90 | 91 | if (!c && !*s) { 92 | if (ws) { 93 | *ws = 0; 94 | *src = 0; 95 | } 96 | return wn0-wn; 97 | } 98 | errno = EILSEQ; 99 | if (ws) *src = (const void *)s; 100 | return -1; 101 | } 102 | --------------------------------------------------------------------------------