summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/u8c/err.h.d/geterr.c (renamed from src/u8c/geterr.c)4
-rw-r--r--src/u8c/err.h.d/regerrhandl.c (renamed from src/u8c/regerrhandl.c)2
-rw-r--r--src/u8c/err.h.d/seterr.c (renamed from src/u8c/seterr.c)2
-rw-r--r--src/u8c/fmt.h.d/fmt.c (renamed from src/u8c/fmt.c)0
-rw-r--r--src/u8c/fmt.h.d/print.c (renamed from src/u8c/print.c)0
-rw-r--r--src/u8c/fmt.h.d/println.c (renamed from src/u8c/println.c)0
-rw-r--r--src/u8c/fmt.h.d/setfmt.c (renamed from src/u8c/setfmt.c)2
-rw-r--r--src/u8c/fmt.h.d/vfmt.c (renamed from src/u8c/vfmt.c)2
-rw-r--r--src/u8c/fmt.h.d/vprint.c (renamed from src/u8c/vprint.c)2
-rw-r--r--src/u8c/intern.h48
-rw-r--r--src/u8c/intern.h.d/dat.c (renamed from src/u8c/dat.c)2
-rw-r--r--src/u8c/is.h.d/isalnum.c (renamed from src/u8c/isalnum.c)0
-rw-r--r--src/u8c/is.h.d/isalpha.c (renamed from src/u8c/isalpha.c)0
-rw-r--r--src/u8c/is.h.d/iscntrl.c (renamed from src/u8c/iscntrl.c)0
-rw-r--r--src/u8c/is.h.d/isdigit.c (renamed from src/u8c/isdigit.c)0
-rw-r--r--src/u8c/is.h.d/ispunct.c (renamed from src/u8c/ispunct.c)0
-rw-r--r--src/u8c/is.h.d/isspace.c (renamed from src/u8c/isspace.c)0
-rw-r--r--src/u8c/is.h.d/isxdigit.c (renamed from src/u8c/isxdigit.c)0
-rw-r--r--src/u8c/main.h.d/abrtfn.c (renamed from src/u8c/abrt.c)6
-rw-r--r--src/u8c/main.h.d/debug.c (renamed from src/u8c/debug.c)0
-rw-r--r--src/u8c/main.h.d/end.c (renamed from src/u8c/end.c)2
-rw-r--r--src/u8c/main.h.d/init.c (renamed from src/u8c/init.c)3
-rw-r--r--src/u8c/main.h.d/thrdsafe.c (renamed from src/u8c/thrdsafe.c)0
-rw-r--r--src/u8c/u16.h.d/u16alloc.c (renamed from src/u8c/u16alloc.c)1
-rw-r--r--src/u8c/u16.h.d/u16free.c (renamed from src/u8c/u16free.c)0
-rw-r--r--src/u8c/u32.h.d/u32alloc.c (renamed from src/u8c/u32alloc.c)1
-rw-r--r--src/u8c/u32.h.d/u32cat.c (renamed from src/u8c/u32cat.c)0
-rw-r--r--src/u8c/u32.h.d/u32cmp.c (renamed from src/u8c/u32cmp.c)0
-rw-r--r--src/u8c/u32.h.d/u32cp.c (renamed from src/u8c/u32cp.c)0
-rw-r--r--src/u8c/u32.h.d/u32fndchr.c (renamed from src/u8c/u32fndchr.c)0
-rw-r--r--src/u8c/u32.h.d/u32fndpat.c (renamed from src/u8c/u32fndpat.c)0
-rw-r--r--src/u8c/u32.h.d/u32free.c (renamed from src/u8c/u32free.c)0
-rw-r--r--src/u8c/u32.h.d/u32ins.c (renamed from src/u8c/u32ins.c)0
-rw-r--r--src/u8c/u32.h.d/u32substr.c (renamed from src/u8c/u32substr.c)0
-rw-r--r--src/u8c/u32.h.d/u32sz.c (renamed from src/u8c/u32sz.c)0
-rw-r--r--src/u8c/u8.h.d/u8alloc.c (renamed from src/u8c/u8alloc.c)1
-rw-r--r--src/u8c/u8.h.d/u8dec.c (renamed from src/u8c/u8dec.c)34
-rw-r--r--src/u8c/u8.h.d/u8enc.c (renamed from src/u8c/u8enc.c)18
-rw-r--r--src/u8c/u8.h.d/u8free.c (renamed from src/u8c/u8free.c)0
39 files changed, 38 insertions, 92 deletions
diff --git a/src/u8c/geterr.c b/src/u8c/err.h.d/geterr.c
index 3d8c220..58f3612 100644
--- a/src/u8c/geterr.c
+++ b/src/u8c/err.h.d/geterr.c
@@ -13,19 +13,17 @@
If not, see <https://www.gnu.org/licenses/>.
*/
-# include "intern.h"
# include <stdbool.h>
# include <stddef.h>
# include <stdint.h>
# include <u8c/err.h>
+# include <u8c/intern.h>
# include <u8c/u32.h>
bool u8c_geterr(size_t * const _sz,char32_t const * * const _out) {
# if defined(u8c_bethrdsafe)
mtx_lock(&u8c_dat.errlock);
# endif
u8c_u32cp(_sz,_out,u8c_dat.err);
- u8c_u32free(&u8c_dat.err);
- u8c_u32cp(_sz,&u8c_dat.err,U"");
# if defined(u8c_bethrdsafe)
mtx_unlock(&u8c_dat.errlock);
# endif
diff --git a/src/u8c/regerrhandl.c b/src/u8c/err.h.d/regerrhandl.c
index ef41e31..5e97177 100644
--- a/src/u8c/regerrhandl.c
+++ b/src/u8c/err.h.d/regerrhandl.c
@@ -13,10 +13,10 @@
If not, see <https://www.gnu.org/licenses/>.
*/
-# include "intern.h"
# include <stdbool.h>
# include <stddef.h>
# include <u8c/err.h>
+# include <u8c/intern.h>
static void u8c_regerrhandl_seterrhandl(enum u8c_errtyp _typ,u8c_errhandltyp _errhandl) {
u8c_dat.errhandls[(size_t)_typ] = _errhandl;
}
diff --git a/src/u8c/seterr.c b/src/u8c/err.h.d/seterr.c
index f356e5f..017e45e 100644
--- a/src/u8c/seterr.c
+++ b/src/u8c/err.h.d/seterr.c
@@ -13,13 +13,13 @@
If not, see <https://www.gnu.org/licenses/>.
*/
-# include "intern.h"
# include <assert.h>
# include <stdbool.h>
# include <stddef.h>
# include <stdint.h>
# include <u8c/err.h>
# include <u8c/fmt.h>
+# include <u8c/intern.h>
# include <u8c/u32.h>
# if defined(u8c_bethrdsafe)
# include <threads.h>
diff --git a/src/u8c/fmt.c b/src/u8c/fmt.h.d/fmt.c
index 43f1ea4..43f1ea4 100644
--- a/src/u8c/fmt.c
+++ b/src/u8c/fmt.h.d/fmt.c
diff --git a/src/u8c/print.c b/src/u8c/fmt.h.d/print.c
index 8785ad8..8785ad8 100644
--- a/src/u8c/print.c
+++ b/src/u8c/fmt.h.d/print.c
diff --git a/src/u8c/println.c b/src/u8c/fmt.h.d/println.c
index 1a924ad..1a924ad 100644
--- a/src/u8c/println.c
+++ b/src/u8c/fmt.h.d/println.c
diff --git a/src/u8c/setfmt.c b/src/u8c/fmt.h.d/setfmt.c
index 05fa9c1..7956ea3 100644
--- a/src/u8c/setfmt.c
+++ b/src/u8c/fmt.h.d/setfmt.c
@@ -13,10 +13,10 @@
If not, see <https://www.gnu.org/licenses/>.
*/
-# include "intern.h"
# include <stdbool.h>
# include <stdint.h>
# include <u8c/fmt.h>
+# include <u8c/intern.h>
# if defined(u8c_bethrdsafe)
# include <threads.h>
# endif
diff --git a/src/u8c/vfmt.c b/src/u8c/fmt.h.d/vfmt.c
index ed7e13f..5b0c1e1 100644
--- a/src/u8c/vfmt.c
+++ b/src/u8c/fmt.h.d/vfmt.c
@@ -21,6 +21,6 @@
# if defined(u8c_bethrdsafe)
# include <threads.h>
# endif
-bool u8c_vfmt(size_t * const _sz,char32_t const * * const _out,char32_t const * const _in,va_list _args) {
+bool u8c_vfmt(size_t * const _sz,char32_t const * * const _out,char32_t const * const _in,[[maybe_unused]] va_list _args) {
return u8c_u32cp(_sz,_out,_in);
}
diff --git a/src/u8c/vprint.c b/src/u8c/fmt.h.d/vprint.c
index 7555ce1..8d824a8 100644
--- a/src/u8c/vprint.c
+++ b/src/u8c/fmt.h.d/vprint.c
@@ -13,7 +13,6 @@
If not, see <https://www.gnu.org/licenses/>.
*/
-# include "intern.h"
# include <assert.h>
# include <stdarg.h>
# include <stdbool.h>
@@ -23,6 +22,7 @@
# include <u8c/SIZE_C.h>
# include <u8c/err.h>
# include <u8c/fmt.h>
+# include <u8c/intern.h>
# include <u8c/u32.h>
# include <u8c/u8.h>
# include <uchar.h>
diff --git a/src/u8c/intern.h b/src/u8c/intern.h
deleted file mode 100644
index ab7644c..0000000
--- a/src/u8c/intern.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- Copyright 2021 Gabriel Jensen
-
- This file is part of u8c.
-
- u8c is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
-
- u8c 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 Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License along with u8c.
-
- If not, see <https://www.gnu.org/licenses/>.
-*/
-# if !defined(u8c_sym_dattyp)
-# define u8c_sym_dattyp
-# include <stdalign.h>
-# include <stdbool.h>
-# include <stddef.h>
-# include <stdint.h>
-# include <u8c/SIZE_C.h>
-# include <u8c/err.h>
-# include <uchar.h>
-# if defined(u8c_bethrdsafe)
-# include <threads.h>
-# endif
-/* Enumerations: */
-/* Type definitions: */
-/* Structures: */
-struct u8c_dattyp {
- char32_t const * err;
- u8c_errhandltyp errhandls[(size_t)u8c_errtyp_maxerrtyp];
- uint_least8_t fmtbase;
- bool fmtendian;
- uint_least8_t stat;
-# if defined(u8c_bethrdsafe)
- mtx_t errlock;
- mtx_t errhandlslock;
- mtx_t fmtlock;
- mtx_t outlock;
-# endif
-};
-/* Functions */
-/* Constants & Variables: */
-extern struct u8c_dattyp u8c_dat;
-/* Macros: */
-# endif
diff --git a/src/u8c/dat.c b/src/u8c/intern.h.d/dat.c
index 55203c6..77d4962 100644
--- a/src/u8c/dat.c
+++ b/src/u8c/intern.h.d/dat.c
@@ -13,11 +13,11 @@
If not, see <https://www.gnu.org/licenses/>.
*/
-# include "intern.h"
# include <stdbool.h>
# include <stddef.h>
# include <stdint.h>
# include <u8c/SIZE_C.h>
+# include <u8c/intern.h>
struct u8c_dattyp u8c_dat = {
.err = NULL,
.fmtendian = false,
diff --git a/src/u8c/isalnum.c b/src/u8c/is.h.d/isalnum.c
index 13834c3..13834c3 100644
--- a/src/u8c/isalnum.c
+++ b/src/u8c/is.h.d/isalnum.c
diff --git a/src/u8c/isalpha.c b/src/u8c/is.h.d/isalpha.c
index d5952dc..d5952dc 100644
--- a/src/u8c/isalpha.c
+++ b/src/u8c/is.h.d/isalpha.c
diff --git a/src/u8c/iscntrl.c b/src/u8c/is.h.d/iscntrl.c
index 4dcf543..4dcf543 100644
--- a/src/u8c/iscntrl.c
+++ b/src/u8c/is.h.d/iscntrl.c
diff --git a/src/u8c/isdigit.c b/src/u8c/is.h.d/isdigit.c
index 8b799d9..8b799d9 100644
--- a/src/u8c/isdigit.c
+++ b/src/u8c/is.h.d/isdigit.c
diff --git a/src/u8c/ispunct.c b/src/u8c/is.h.d/ispunct.c
index f6b041f..f6b041f 100644
--- a/src/u8c/ispunct.c
+++ b/src/u8c/is.h.d/ispunct.c
diff --git a/src/u8c/isspace.c b/src/u8c/is.h.d/isspace.c
index 9473476..9473476 100644
--- a/src/u8c/isspace.c
+++ b/src/u8c/is.h.d/isspace.c
diff --git a/src/u8c/isxdigit.c b/src/u8c/is.h.d/isxdigit.c
index 4a59b0d..4a59b0d 100644
--- a/src/u8c/isxdigit.c
+++ b/src/u8c/is.h.d/isxdigit.c
diff --git a/src/u8c/abrt.c b/src/u8c/main.h.d/abrtfn.c
index 6773827..80a03e3 100644
--- a/src/u8c/abrt.c
+++ b/src/u8c/main.h.d/abrtfn.c
@@ -13,7 +13,6 @@
If not, see <https://www.gnu.org/licenses/>.
*/
-# include "intern.h"
# include <inttypes.h>
# include <stdbool.h>
# include <stdint.h>
@@ -21,9 +20,10 @@
# include <stdlib.h>
# include <stdnoreturn.h>
# include <time.h>
+# include <u8c/intern.h>
# include <u8c/main.h>
-noreturn bool u8c_abrt(char const * const _fl,long long const _ln,char const * const _fn,char const * const _why) {
- fprintf(stderr,"u8c: *** Aborted (\"%s\":%lld in function \"%s\": \"%s\" @ %" PRIuMAX ") ***\nLibrary diagnostics:\n debug:%s\n status:%" PRIuLEAST8 "\n thread-safe:%s\n version:%" PRIuLEAST64 "\n",_fl,_ln,_fn,_why,(intmax_t)time(NULL),u8c_dbg ? "true" : "false",u8c_dat.stat,u8c_thrdsafe ? "true" : "false",u8c_ver);
+noreturn bool u8c_abrtfn(char const * const _fl,long const _ln,char const * const _fn,char const * const _why) {
+ fprintf(stderr,"u8c: *** Aborted (\"%s\":%li in function \"%s\": \"%s\" @ %" PRIuMAX ") ***\nLibrary diagnostics:\n debug:%s\n status:%" PRIuLEAST8 "\n thread-safe:%s\n version:%" PRIuLEAST64 "\n",_fl,_ln,_fn,_why,(intmax_t)time(NULL),u8c_dbg ? "true" : "false",u8c_dat.stat,u8c_thrdsafe ? "true" : "false",u8c_ver);
fprintf(stderr,"Trying to clean up...\n");
u8c_end();
fprintf(stderr,"Aborting...\n");
diff --git a/src/u8c/debug.c b/src/u8c/main.h.d/debug.c
index e42275c..e42275c 100644
--- a/src/u8c/debug.c
+++ b/src/u8c/main.h.d/debug.c
diff --git a/src/u8c/end.c b/src/u8c/main.h.d/end.c
index f0e82e3..ef8114c 100644
--- a/src/u8c/end.c
+++ b/src/u8c/main.h.d/end.c
@@ -13,11 +13,11 @@
If not, see <https://www.gnu.org/licenses/>.
*/
-# include "intern.h"
# include <stdbool.h>
# include <stdint.h>
# include <stdlib.h>
# include <u8c/SIZE_C.h>
+# include <u8c/intern.h>
# include <u8c/main.h>
# include <u8c/u32.h>
# if defined(u8c_bethrdsafe)
diff --git a/src/u8c/init.c b/src/u8c/main.h.d/init.c
index 3769109..0b34577 100644
--- a/src/u8c/init.c
+++ b/src/u8c/main.h.d/init.c
@@ -16,12 +16,11 @@
# if !defined(__STDC_UTF_32__)
# error UTF-32 is required.
# endif
-# include "intern.h"
-# include <setjmp.h>
# include <stdbool.h>
# include <stddef.h>
# include <stdint.h>
# include <u8c/err.h>
+# include <u8c/intern.h>
# include <u8c/main.h>
# include <u8c/u32.h>
# if defined(u8c_bethrdsafe)
diff --git a/src/u8c/thrdsafe.c b/src/u8c/main.h.d/thrdsafe.c
index 9d8e41a..9d8e41a 100644
--- a/src/u8c/thrdsafe.c
+++ b/src/u8c/main.h.d/thrdsafe.c
diff --git a/src/u8c/u16alloc.c b/src/u8c/u16.h.d/u16alloc.c
index 2945e79..3906017 100644
--- a/src/u8c/u16alloc.c
+++ b/src/u8c/u16.h.d/u16alloc.c
@@ -13,7 +13,6 @@
If not, see <https://www.gnu.org/licenses/>.
*/
-# include "intern.h"
# include <stdbool.h>
# include <stdlib.h>
# include <u8c/err.h>
diff --git a/src/u8c/u16free.c b/src/u8c/u16.h.d/u16free.c
index d447562..d447562 100644
--- a/src/u8c/u16free.c
+++ b/src/u8c/u16.h.d/u16free.c
diff --git a/src/u8c/u32alloc.c b/src/u8c/u32.h.d/u32alloc.c
index 341fa03..b64a1ee 100644
--- a/src/u8c/u32alloc.c
+++ b/src/u8c/u32.h.d/u32alloc.c
@@ -13,7 +13,6 @@
If not, see <https://www.gnu.org/licenses/>.
*/
-# include "intern.h"
# include <stdbool.h>
# include <stdlib.h>
# include <u8c/err.h>
diff --git a/src/u8c/u32cat.c b/src/u8c/u32.h.d/u32cat.c
index 600e0dc..600e0dc 100644
--- a/src/u8c/u32cat.c
+++ b/src/u8c/u32.h.d/u32cat.c
diff --git a/src/u8c/u32cmp.c b/src/u8c/u32.h.d/u32cmp.c
index 8a6617d..8a6617d 100644
--- a/src/u8c/u32cmp.c
+++ b/src/u8c/u32.h.d/u32cmp.c
diff --git a/src/u8c/u32cp.c b/src/u8c/u32.h.d/u32cp.c
index 95a9b35..95a9b35 100644
--- a/src/u8c/u32cp.c
+++ b/src/u8c/u32.h.d/u32cp.c
diff --git a/src/u8c/u32fndchr.c b/src/u8c/u32.h.d/u32fndchr.c
index 228c553..228c553 100644
--- a/src/u8c/u32fndchr.c
+++ b/src/u8c/u32.h.d/u32fndchr.c
diff --git a/src/u8c/u32fndpat.c b/src/u8c/u32.h.d/u32fndpat.c
index 5a1b5d2..5a1b5d2 100644
--- a/src/u8c/u32fndpat.c
+++ b/src/u8c/u32.h.d/u32fndpat.c
diff --git a/src/u8c/u32free.c b/src/u8c/u32.h.d/u32free.c
index a0b120b..a0b120b 100644
--- a/src/u8c/u32free.c
+++ b/src/u8c/u32.h.d/u32free.c
diff --git a/src/u8c/u32ins.c b/src/u8c/u32.h.d/u32ins.c
index 7fccb7c..7fccb7c 100644
--- a/src/u8c/u32ins.c
+++ b/src/u8c/u32.h.d/u32ins.c
diff --git a/src/u8c/u32substr.c b/src/u8c/u32.h.d/u32substr.c
index 855d062..855d062 100644
--- a/src/u8c/u32substr.c
+++ b/src/u8c/u32.h.d/u32substr.c
diff --git a/src/u8c/u32sz.c b/src/u8c/u32.h.d/u32sz.c
index deb1ecd..deb1ecd 100644
--- a/src/u8c/u32sz.c
+++ b/src/u8c/u32.h.d/u32sz.c
diff --git a/src/u8c/u8alloc.c b/src/u8c/u8.h.d/u8alloc.c
index a046a28..ba02bc8 100644
--- a/src/u8c/u8alloc.c
+++ b/src/u8c/u8.h.d/u8alloc.c
@@ -13,7 +13,6 @@
If not, see <https://www.gnu.org/licenses/>.
*/
-# include "intern.h"
# include <stdbool.h>
# include <stdlib.h>
# include <u8c/err.h>
diff --git a/src/u8c/u8dec.c b/src/u8c/u8.h.d/u8dec.c
index a484601..365c81a 100644
--- a/src/u8c/u8dec.c
+++ b/src/u8c/u8.h.d/u8dec.c
@@ -33,19 +33,19 @@ bool u8c_u8dec(size_t * const _sz,char32_t const * * const _out,unsigned char co
insz = n;
goto nottoobig;
}
- if(tmp >= UINT8_C(0xF8)) { /* Too big. */
+ if(tmp >= UINT8_C(0b11111000)) { /* Too big. */
u8c_seterr(U"u8c_u8dec: Character out of range (too big).",u8c_errtyp_u8oor);
return true;
}
- if(tmp >= UINT8_C(0xF0)) { /* Four byte. */
+ if(tmp >= UINT8_C(0b11110000)) { /* Four byte. */
n += SIZE_C(0x4);
continue;
}
- if(tmp >= UINT8_C(0xE0)) { /* Three bytes. */
+ if(tmp >= UINT8_C(0b11100000)) { /* Three bytes. */
n += SIZE_C(0x3);
continue;
}
- if(tmp >= UINT8_C(0xC0)) { /* Two bytes. */
+ if(tmp >= UINT8_C(0b11000000)) { /* Two bytes. */
n += SIZE_C(0x2);
continue;
}
@@ -64,39 +64,39 @@ nottoobig:;
return false;
}
for(register size_t n = SIZE_C(0x0),outn = SIZE_C(0x0);n < insz;outn += SIZE_C(0x1)) { /* Second pass: decode UTF-8. */
- if(_in[n] >= UINT8_C(0xF0)) { /* Four byte. */
- uint_least32_t codep = (_in[n] ^ UINT32_C(0xF0)) << UINT32_C(0x12);
+ if(_in[n] >= UINT8_C(0b11110000)) { /* Four bytes. */
+ uint_least32_t codep = (_in[n] ^ UINT32_C(0b11110000)) << UINT32_C(0x12);
n += SIZE_C(0x1);
- codep += (_in[n] ^ UINT32_C(0x80)) << UINT32_C(0xC);
+ codep += (_in[n] ^ UINT32_C(0b10000000)) << UINT32_C(0xC);
n += SIZE_C(0x1);
- codep += (_in[n] ^ UINT32_C(0x80)) << UINT32_C(0x6);
+ codep += (_in[n] ^ UINT32_C(0b10000000)) << UINT32_C(0x6);
n += SIZE_C(0x1);
- codep += (uint_least32_t)(_in[n]) ^ SIZE_C(0x80);
+ codep += (uint_least32_t)(_in[n]) ^ SIZE_C(0b10000000);
n += SIZE_C(0x1);
out[outn] = codep;
continue;
}
- if(_in[n] >= UINT8_C(0xE0)) { /* Three bytes. */
- uint_least32_t codep = (_in[n] ^ UINT32_C(0xE0)) << UINT32_C(0xC);
+ if(_in[n] >= UINT8_C(0b11100000)) { /* Three bytes. */
+ uint_least32_t codep = (_in[n] ^ UINT32_C(0b11100000)) << UINT32_C(0xC);
n += SIZE_C(0x1);
- codep += (_in[n] ^ UINT32_C(0x80)) << UINT32_C(0x6);
+ codep += (_in[n] ^ UINT32_C(0b10000000)) << UINT32_C(0x6);
n += SIZE_C(0x1);
- codep += _in[n] ^ UINT32_C(0x80);
+ codep += _in[n] ^ UINT32_C(0b10000000);
n += SIZE_C(0x1);
out[outn] = codep;
continue;
}
- if(_in[n] >= UINT8_C(0xC0)) { /* Two bytes. */
- uint_least32_t codep = (_in[n] ^ UINT32_C(0xC0)) << UINT32_C(0x6);
+ if(_in[n] >= UINT8_C(0b11000000)) { /* Two bytes. */
+ uint_least32_t codep = (_in[n] ^ UINT32_C(0b11000000)) << UINT32_C(0x6);
n += SIZE_C(0x1);
- codep += _in[n] ^ UINT32_C(0x80);
+ codep += _in[n] ^ UINT32_C(0b10000000);
n += SIZE_C(0x1);
out[outn] = codep;
continue;
}
/* One byte. */
out[outn] = (uint_least32_t)(_in[n]);
- n += SIZE_C(0x1);
+ n += SIZE_C(0x1);
continue;
}
u8c_u32free(_out);
diff --git a/src/u8c/u8enc.c b/src/u8c/u8.h.d/u8enc.c
index 61ccb2a..f3f3570 100644
--- a/src/u8c/u8enc.c
+++ b/src/u8c/u8.h.d/u8enc.c
@@ -19,7 +19,7 @@
# include <stdint.h>
# include <u8c/SIZE_C.h>
# include <u8c/err.h>
-# include <u8c/main.h>
+# include <u8c/u32.h>
# include <u8c/u8.h>
# include <uchar.h>
bool u8c_u8enc(size_t * const _sz,unsigned char const * * const _out,char32_t const * const _in) {
@@ -29,7 +29,7 @@ bool u8c_u8enc(size_t * const _sz,unsigned char const * * const _out,char32_t co
size_t outsz = SIZE_C(0x0); /* Size of output array /bytes). */
for(register size_t n = SIZE_C(0x0);n <= SIZE_MAX;n += SIZE_C(0x1)) { /* First pass: get size of input array, and determine size of output array. */
register char32_t const tmp = _in[n];
- if(tmp > u8c_unimax) { /* Codepoint out of range. */
+ if(tmp > u8c_u32max) { /* Codepoint out of range. */
u8c_seterr(U"u8c_u8enc: Codepoint out of range (too big).",u8c_errtyp_u32oor);
return true;
}
@@ -65,27 +65,27 @@ nottoobig:;
for(register size_t n = SIZE_C(0x0), outn = SIZE_C(0x0);n < insz;n += SIZE_C(0x1),outn += SIZE_C(0x1)) { /* Second pass: encode each codepoint into UTF-8. */
register char32_t const tmp = _in[n];
if(tmp >= UINT32_C(0x10000)) { // Four bytes.
- out[outn] = UINT8_C(0xF0) + (uint_least8_t)(tmp >> UINT32_C(0x12));
+ out[outn] = UINT8_C(0b11110000) + (uint_least8_t)(tmp >> UINT32_C(0x12));
outn += SIZE_C(0x1);
- out[outn] = UINT8_C(0x80) + (uint_least8_t)(tmp >> UINT32_C(0xC) & UINT8_C(0x3F));
+ out[outn] = UINT8_C(0b10000000) + (uint_least8_t)(tmp >> UINT32_C(0xC) & UINT8_C(0b00111111));
outn += SIZE_C(0x1);
- out[outn] = UINT8_C(0x80) + (uint_least8_t)(tmp >> UINT32_C(0x6) & UINT8_C(0x3F));
+ out[outn] = UINT8_C(0b10000000) + (uint_least8_t)(tmp >> UINT32_C(0x6) & UINT8_C(0b00111111));
outn += SIZE_C(0x1);
- out[outn] = UINT8_C(0x80) + (uint_least8_t)(tmp & UINT32_C(0x3F));
+ out[outn] = UINT8_C(0b10000000) + (uint_least8_t)(tmp & UINT32_C(0b00111111));
continue;
}
if(tmp >= UINT32_C(0x800)) { /* Three bytes. */
out[outn] = UINT8_C(0xE0) + (uint_least8_t)(tmp >> UINT32_C(0xC));
outn += SIZE_C(0x1);
- out[outn] = UINT8_C(0x80) + (uint_least8_t)(tmp >> UINT32_C(0x6) & UINT8_C(0x3F));
+ out[outn] = UINT8_C(0x80) + (uint_least8_t)(tmp >> UINT32_C(0x6) & UINT8_C(0b00111111));
outn += SIZE_C(0x1);
- out[outn] = UINT8_C(0x80) + (uint_least8_t)(tmp & UINT32_C(0x3F));
+ out[outn] = UINT8_C(0x80) + (uint_least8_t)(tmp & UINT32_C(0b00111111));
continue;
}
if(tmp >= UINT32_C(0x80)) { /* Two bytes. */
out[outn] = UINT8_C(0xC0) + (uint_least8_t)(tmp >> UINT8_C(0x6));
outn += SIZE_C(0x1);
- out[outn] = UINT8_C(0x80) + (uint_least8_t)(tmp & UINT8_C(0x3F));
+ out[outn] = UINT8_C(0x80) + (uint_least8_t)(tmp & UINT8_C(0b00111111));
continue;
}
/* One byte. */
diff --git a/src/u8c/u8free.c b/src/u8c/u8.h.d/u8free.c
index af5a6bd..af5a6bd 100644
--- a/src/u8c/u8free.c
+++ b/src/u8c/u8.h.d/u8free.c