diff options
Diffstat (limited to 'include/u8c')
38 files changed, 319 insertions, 233 deletions
diff --git a/include/u8c/SIZE_C.h b/include/u8c/SIZE_C.h index 1591252..4a8d513 100644 --- a/include/u8c/SIZE_C.h +++ b/include/u8c/SIZE_C.h @@ -15,31 +15,17 @@ */ /* Size constant */ # if !defined(SIZE_C) -# if !defined(__cplusplus) # include <limits.h> -# endif -# if defined(__cplusplus) && __cplusplus > 0x31512l -/* C++23 has a size_t suffix. */ -# define SIZE_C(val) val ## uz +# include <stdint.h> +# if SIZE_MAX == USHRT_MAX +# define SIZE_C(val) ((unsigned short)val) # elif SIZE_MAX == UINT_MAX # define SIZE_C(val) val # elif SIZE_MAX == ULONG_MAX -# define SIZE_C(val) val ## ul +# define SIZE_C(val) val ## lu # elif SIZE_MAX == ULLONG_MAX -# define SIZE_C(val) val ## ull -# elif SIZE_MAX == UINTMAX_MAX -# include <stdint.h> -# define SIZE_C(val) (UINTMAX_C(val)) +# define SIZE_C(val) val ## llu # else -/* Cannot match width; construct new element of type "size_t" */ -# if defined(__cplusplus) -/* C++ has value initialisation. */ -# include <cstddef> -# define SIZE_C(val) (std::size_t{val}) -# else -/* C has compound literals. */ -# include <stddef.h> -# define SIZE_C(val) ((size_t){val}) -# endif +# define SIZE_C(val) ((size_t)UINTMAX_C(val)) # endif # endif diff --git a/include/u8c/abrt.h b/include/u8c/abrt.h new file mode 100644 index 0000000..a068ff2 --- /dev/null +++ b/include/u8c/abrt.h @@ -0,0 +1,23 @@ +/* + 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/>. +*/ +/* Abort */ +# if !defined(u8c_sym_abrt) +# define u8c_sym_abrt +# include <stdbool.h> +# include <stdnoreturn.h> +# include <uchar.h> +extern noreturn bool u8c_abrt(char const * const fl,long long const ln,char const * const fn,char const * const why); +# endif diff --git a/include/u8c/debug.h b/include/u8c/dbg.h index 3bd2dfd..e389195 100644 --- a/include/u8c/debug.h +++ b/include/u8c/dbg.h @@ -16,12 +16,6 @@ /* Debug */ # if !defined(u8c_sym_debug) # define u8c_sym_debug -# include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t const u8c_debug; -# if defined(__cplusplus) -} -# endif +# include <stdbool.h> +extern bool const u8c_dbg; # endif diff --git a/include/u8c/dbgprint.h b/include/u8c/dbgprint.h index 42fcb16..2f974d2 100644 --- a/include/u8c/dbgprint.h +++ b/include/u8c/dbgprint.h @@ -16,11 +16,7 @@ /* Debug print */ # if !defined(u8c_dbgprint) # if defined(NDEBUG) -# if defined(__cplusplus) -# define u8c_dbgprint(...) (static_cast<void>(0x0)); -# else # define u8c_dbgprint(...) ((void)0x0) -# endif # else # include <u8c/println.h> # include <stdio.h> diff --git a/include/u8c/end.h b/include/u8c/end.h index 1322496..01c8c24 100644 --- a/include/u8c/end.h +++ b/include/u8c/end.h @@ -16,12 +16,6 @@ /* End */ # if !defined(u8c_sym_end) # define u8c_sym_end -# include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_end(void); -# if defined(__cplusplus) -} -# endif +# include <stdbool.h> +extern bool u8c_end(void); # endif diff --git a/include/u8c/fmt.h b/include/u8c/fmt.h index 61ee8b2..4f7ed1b 100644 --- a/include/u8c/fmt.h +++ b/include/u8c/fmt.h @@ -17,12 +17,6 @@ # if !defined(u8c_sym_fmt) # define u8c_sym_fmt # include <stddef.h> -# include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_fmt(size_t * const outsz,uint_least32_t const * * const out,uint_least32_t const * const in,...); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_fmt(size_t * const outsz,char32_t const * * const out,char32_t const * const in,...); # endif diff --git a/include/u8c/fmttyp.h b/include/u8c/fmttyp.h index d9b27de..cce9a2f 100644 --- a/include/u8c/fmttyp.h +++ b/include/u8c/fmttyp.h @@ -17,13 +17,33 @@ # if !defined(u8c_sym_fmttyp) # define u8c_sym_fmttyp enum u8c_fmttyp { - u8c_fmttyp_bgcol, /* Background colour */ + u8c_fmttyp_bgcol, /* Background colour (uint_least32_t) */ u8c_fmttyp_bgcol0, /* Background colour #0 */ - u8c_fmttyp_chr, /* Character */ - u8c_fmttyp_fgcol, /* Foreground colour */ + u8c_fmttyp_bool, /* Boolean (bool) */ + u8c_fmttyp_byt, /* Byte (char) */ + u8c_fmttyp_chr, /* Character (uint_least32_t) */ + u8c_fmttyp_fgcol, /* Foreground colour (uint_least32_t) */ u8c_fmttyp_fgcol0, /* Foreground colour #0 */ - u8c_fmttyp_int, /* Integer */ - u8c_fmttyp_str, /* String */ - u8c_fmttyp_uint, /* Unsigned integer */ + u8c_fmttyp_int, /* Integer (int) */ + u8c_fmttyp_int16, /* Integer 16 bit (int_least16_t) */ + u8c_fmttyp_int32, /* Integer 32 bit (int_least32_t) */ + u8c_fmttyp_int64, /* Integer 64 bit (int_least64_t) */ + u8c_fmttyp_int8, /* Integer 8 bit (int_least8_t) */ + u8c_fmttyp_llong, /* Long long (long long) */ + u8c_fmttyp_long, /* Long (long) */ + u8c_fmttyp_sbyt, /* Signed byte (signed char) */ + u8c_fmttyp_shrt, /* Short (short) */ + u8c_fmttyp_str, /* String (char32_t const *) */ + u8c_fmttyp_sz, /* Size (size_t) */ + u8c_fmttyp_tm, /* Time (uint_least64_t) */ + u8c_fmttyp_ubyt, /* Unsigned byte (unsigned char) */ + u8c_fmttyp_uint, /* Unsigned integer (unsigned int) */ + u8c_fmttyp_uint16, /* Unsigned integer 16 bit (uint_least16_t) */ + u8c_fmttyp_uint32, /* Unsigned integer 32 bit (uint_least32_t) */ + u8c_fmttyp_uint64, /* Unsigned integer 64 bit (uint_least64_t) */ + u8c_fmttyp_uint8, /* Unsigned integer 8 bit (uint_least8_t) */ + u8c_fmttyp_ulong, /* Unsigned long (unsigned long) */ + u8c_fmttyp_ullong, /* Unsigned long long (unsigned long long) */ + u8c_fmttyp_ushrt, /* Unsigned short (unsigned short) */ }; # endif diff --git a/include/u8c/geterr.h b/include/u8c/geterr.h index 45a25ac..70acc4f 100644 --- a/include/u8c/geterr.h +++ b/include/u8c/geterr.h @@ -16,13 +16,8 @@ /* Get error */ # if !defined(u8c_sym_geterr) # define u8c_sym_geterr +# include <stdbool.h> # include <stddef.h> -# include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_geterr(size_t * const sz,uint_least32_t const * * const out); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_geterr(size_t * const sz,char32_t const * * const out); # endif diff --git a/include/u8c/init.h b/include/u8c/init.h index 823c1fb..1aa4804 100644 --- a/include/u8c/init.h +++ b/include/u8c/init.h @@ -16,12 +16,6 @@ /* Initialise */ # if !defined(u8c_sym_init) # define u8c_sym_init -# include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_init(void); -# if defined(__cplusplus) -} -# endif +# include <stdbool.h> +extern bool u8c_init(void); # endif diff --git a/include/u8c/isalnum.h b/include/u8c/isalnum.h index 0b61bfd..b951f5e 100644 --- a/include/u8c/isalnum.h +++ b/include/u8c/isalnum.h @@ -13,15 +13,11 @@ If not, see <https://www.gnu.org/licenses/>. */ -/* Is digit */ +/* Is alphanumeric */ # if !defined(luma_sym_isalnum) # define luma_sym_isalnum +# include <stdbool.h> # include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_isalnum(uint_least8_t * const res,uint_least32_t const chr); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_isalnum(uint_least8_t * const res,char32_t const chr); # endif diff --git a/include/u8c/isalpha.h b/include/u8c/isalpha.h index 3493dc0..a43363f 100644 --- a/include/u8c/isalpha.h +++ b/include/u8c/isalpha.h @@ -13,15 +13,11 @@ If not, see <https://www.gnu.org/licenses/>. */ -/* Is digit */ +/* Is alphabetic */ # if !defined(luma_sym_isalpha) # define luma_sym_isalpha +# include <stdbool.h> # include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_isalpha(uint_least8_t * const res,uint_least32_t const chr); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_isalpha(uint_least8_t * const res,char32_t const chr); # endif diff --git a/include/u8c/iscntrl.h b/include/u8c/iscntrl.h index 0f52911..5ffe157 100644 --- a/include/u8c/iscntrl.h +++ b/include/u8c/iscntrl.h @@ -13,15 +13,11 @@ If not, see <https://www.gnu.org/licenses/>. */ -/* Is digit */ +/* Is control */ # if !defined(luma_sym_iscntrl) # define luma_sym_iscntrl +# include <stdbool.h> # include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_iscntrl(uint_least8_t * const res,uint_least32_t const chr); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_iscntrl(uint_least8_t * const res,char32_t const chr); # endif diff --git a/include/u8c/isdigit.h b/include/u8c/isdigit.h index c2053c7..a28dd9a 100644 --- a/include/u8c/isdigit.h +++ b/include/u8c/isdigit.h @@ -16,12 +16,8 @@ /* Is digit */ # if !defined(luma_sym_isdigit) # define luma_sym_isdigit +# include <stdbool.h> # include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_isdigit(uint_least8_t * const res,uint_least32_t const chr); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_isdigit(uint_least8_t * const res,char32_t const chr); # endif diff --git a/include/u8c/ispunct.h b/include/u8c/ispunct.h index a4da5c9..9834491 100644 --- a/include/u8c/ispunct.h +++ b/include/u8c/ispunct.h @@ -13,15 +13,11 @@ If not, see <https://www.gnu.org/licenses/>. */ -/* Is digit */ +/* Is punctuation */ # if !defined(luma_sym_ispunct) # define luma_sym_ispunct +# include <stdbool.h> # include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_ispunct(uint_least8_t * const res,uint_least32_t const chr); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_ispunct(uint_least8_t * const res,char32_t const chr); # endif diff --git a/include/u8c/isspace.h b/include/u8c/isspace.h index 35f9d4f..78cafea 100644 --- a/include/u8c/isspace.h +++ b/include/u8c/isspace.h @@ -13,15 +13,11 @@ If not, see <https://www.gnu.org/licenses/>. */ -/* Is digit */ +/* Is space */ # if !defined(luma_sym_isspace) # define luma_sym_isspace +# include <stdbool.h> # include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_isspace(uint_least8_t * const res,uint_least32_t const chr); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_isspace(uint_least8_t * const res,char32_t const chr); # endif diff --git a/include/u8c/txt.h b/include/u8c/isxdigit.h index 4959e81..57e1392 100644 --- a/include/u8c/txt.h +++ b/include/u8c/isxdigit.h @@ -13,17 +13,11 @@ If not, see <https://www.gnu.org/licenses/>. */ -/* Text */ -# if !defined(__STDC_UTF_32__) -# error UTF-32 is required to use u8c_txt. -# else -# if !defined(u8c_txt) -# if defined(__cplusplus) -# include <cstdint> -# define u8c_txt(txt) (reinterpret_cast<std::uint_least32_t const *>(U ## txt)) -# else +/* Is hexadecimal digit */ +# if !defined(luma_sym_isxdigit) +# define luma_sym_isxdigit +# include <stdbool.h> # include <stdint.h> -# define u8c_txt(txt) (uint_least32_t const *)U ## txt -# endif -# endif +# include <uchar.h> +extern bool u8c_isxdigit(uint_least8_t * const res,char32_t const chr); # endif diff --git a/include/u8c/print.h b/include/u8c/print.h index f77875d..f76c942 100644 --- a/include/u8c/print.h +++ b/include/u8c/print.h @@ -16,13 +16,8 @@ /* Print */ # if !defined(u8c_sym_print) # define u8c_sym_print -# include <stdint.h> +# include <stdbool.h> # include <stdio.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_print(FILE * fp,uint_least32_t const * const msg,...); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_print(FILE * fp,char32_t const * const msg,...); # endif diff --git a/include/u8c/println.h b/include/u8c/println.h index d6874de..8d80353 100644 --- a/include/u8c/println.h +++ b/include/u8c/println.h @@ -16,13 +16,8 @@ /* Print line */ # if !defined(u8c_sym_println) # define u8c_sym_println -# include <stdint.h> +# include <stdbool.h> # include <stdio.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_println(FILE * fp,uint_least32_t const * const msg,...); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_println(FILE * fp,char32_t const * const msg,...); # endif diff --git a/include/u8c/seterr.h b/include/u8c/seterr.h index ae2f534..3f3e793 100644 --- a/include/u8c/seterr.h +++ b/include/u8c/seterr.h @@ -16,6 +16,7 @@ /* Set error */ # if !defined(u8c_sym_seterr) # define u8c_sym_seterr -# include <stdint.h> -extern uint_least8_t u8c_seterr(uint_least32_t const * const msg); +# include <stdbool.h> +# include <uchar.h> +extern bool u8c_seterr(char32_t const * const msg); # endif diff --git a/include/u8c/setfmt.h b/include/u8c/setfmt.h new file mode 100644 index 0000000..f742bea --- /dev/null +++ b/include/u8c/setfmt.h @@ -0,0 +1,22 @@ +/* + 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/>. +*/ +/* Set format */ +# if !defined(u8c_sym_setfmt) +# define u8c_sym_setfmt +# include <stdbool.h> +# include <stdint.h> +extern bool u8c_setfmt(uint_least8_t const base,uint_least8_t const endian); +# endif diff --git a/include/u8c/thrdsafe.h b/include/u8c/thrdsafe.h index 1de6a31..2ab6709 100644 --- a/include/u8c/thrdsafe.h +++ b/include/u8c/thrdsafe.h @@ -16,12 +16,6 @@ /* Thread-safe */ # if !defined(u8c_sym_thrdsafe) # define u8c_sym_thrdsafe -# include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t const u8c_thrdsafe; -# if defined(__cplusplus) -} -# endif +# include <stdbool.h> +extern bool const u8c_thrdsafe; # endif diff --git a/include/u8c/u32alloc.h b/include/u8c/u32alloc.h new file mode 100644 index 0000000..5241ee6 --- /dev/null +++ b/include/u8c/u32alloc.h @@ -0,0 +1,23 @@ +/* + 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/>. +*/ +/* UTF-32 allocate */ +# if !defined(u8c_sym_u32alloc) +# define u8c_sym_u32alloc +# include <stdbool.h> +# include <stddef.h> +# include <uchar.h> +extern bool u8c_u32alloc(char32_t * * const u32,size_t const sz); +# endif diff --git a/include/u8c/u32cat.h b/include/u8c/u32cat.h new file mode 100644 index 0000000..7672cb7 --- /dev/null +++ b/include/u8c/u32cat.h @@ -0,0 +1,23 @@ +/* + 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/>. +*/ +/* UTF-32 concatenate */ +# if !defined(luma_sym_u32cat) +# define luma_sym_u32cat +# include <stdbool.h> +# include <stddef.h> +# include <uchar.h> +extern bool u8c_u32cat(size_t * const sz,char32_t const * * const out,char32_t const * const lstr,char32_t const * const rstr); +# endif diff --git a/include/u8c/u32cmp.h b/include/u8c/u32cmp.h index 5ca3d5d..ffc2729 100644 --- a/include/u8c/u32cmp.h +++ b/include/u8c/u32cmp.h @@ -16,12 +16,8 @@ /* UTF-32 compare */ # if !defined(luma_sym_u32cmp) # define luma_sym_u32cmp +# include <stdbool.h> # include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_u32cmp(uint_least8_t * const res,uint_least32_t const * const lstr,uint_least32_t const * const rstr); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_u32cmp(uint_least8_t * const res,char32_t const * const lstr,char32_t const * const rstr); # endif diff --git a/include/u8c/u32cp.h b/include/u8c/u32cp.h index 66cc870..01e2ae1 100644 --- a/include/u8c/u32cp.h +++ b/include/u8c/u32cp.h @@ -16,13 +16,8 @@ /* UTF-32 copy */ # if !defined(luma_sym_u32cp) # define luma_sym_u32cp +# include <stdbool.h> # include <stddef.h> -# include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_u32cp(size_t * const sz,uint_least32_t const * * const out,uint_least32_t const * const in); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_u32cp(size_t * const sz,char32_t const * * const out,char32_t const * const in); # endif diff --git a/include/u8c/u32fndchr.h b/include/u8c/u32fndchr.h new file mode 100644 index 0000000..d52682d --- /dev/null +++ b/include/u8c/u32fndchr.h @@ -0,0 +1,23 @@ +/* + 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/>. +*/ +/* UTF-32 find character */ +# if !defined(luma_sym_u32fndchr) +# define luma_sym_u32fndchr +# include <stdbool.h> +# include <stddef.h> +# include <uchar.h> +extern bool u8c_u32fndchr(size_t * const pos,char32_t const * const in,char32_t const chr); +# endif diff --git a/include/u8c/u32fndpat.h b/include/u8c/u32fndpat.h new file mode 100644 index 0000000..a17948b --- /dev/null +++ b/include/u8c/u32fndpat.h @@ -0,0 +1,23 @@ +/* + 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/>. +*/ +/* UTF-32 find pattern */ +# if !defined(luma_sym_u32fndpat) +# define luma_sym_u32fndpat +# include <stdbool.h> +# include <stddef.h> +# include <uchar.h> +extern bool u8c_u32fndpat(size_t * const pos,char32_t const * const in,char32_t const * const pat); +# endif diff --git a/include/u8c/u32free.h b/include/u8c/u32free.h index fd431e0..4525b22 100644 --- a/include/u8c/u32free.h +++ b/include/u8c/u32free.h @@ -13,15 +13,10 @@ If not, see <https://www.gnu.org/licenses/>. */ -/* Format */ -# if !defined(u8c_u32free) -# if defined(__cplusplus) -# include <cstdint> -# include <cstdlib> -# define u8c_u32free(u32) (std::free(const_cast<uint_least32_t *>(u32))) -# else -# include <stdint.h> -# include <stdlib.h> -# define u8c_u32free(u32) (free((uint_least32_t *)u32)) -# endif +/* UTF-32 free */ +# if !defined(u8c_sym_u32free) +# define u8c_sym_u32free +# include <stdbool.h> +# include <uchar.h> +extern bool u8c_u32free(char32_t const * * const u32); # endif diff --git a/include/u8c/u32substr.h b/include/u8c/u32substr.h new file mode 100644 index 0000000..e9258a4 --- /dev/null +++ b/include/u8c/u32substr.h @@ -0,0 +1,23 @@ +/* + 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/>. +*/ +/* UTF-32 sub-string */ +# if !defined(luma_sym_u32substr) +# define luma_sym_u32substr +# include <stdbool.h> +# include <stddef.h> +# include <uchar.h> +extern bool u8c_u32substr(char32_t const * * const out,size_t const start,size_t const len,char32_t const * const in); +# endif diff --git a/include/u8c/u32sz.h b/include/u8c/u32sz.h index b97ccdb..f182e92 100644 --- a/include/u8c/u32sz.h +++ b/include/u8c/u32sz.h @@ -16,13 +16,8 @@ /* UTF-32 size */ # if !defined(u8c_sym_u32sz) # define u8c_sym_u32sz +# include <stdbool.h> # include <stddef.h> -# include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_u32sz(size_t * sz,uint_least32_t const * in); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_u32sz(size_t * sz,char32_t const * in); # endif diff --git a/include/u8c/u8alloc.h b/include/u8c/u8alloc.h new file mode 100644 index 0000000..b5c2516 --- /dev/null +++ b/include/u8c/u8alloc.h @@ -0,0 +1,22 @@ +/* + 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/>. +*/ +/* UTF-8 allocate */ +# if !defined(u8c_sym_u8alloc) +# define u8c_sym_u8alloc +# include <stdbool.h> +# include <stddef.h> +extern bool u8c_u8alloc(unsigned char * * const u32,size_t const sz); +# endif diff --git a/include/u8c/u8dec.h b/include/u8c/u8dec.h index eed43ae..2b76df8 100644 --- a/include/u8c/u8dec.h +++ b/include/u8c/u8dec.h @@ -16,13 +16,8 @@ /* UTF-8 decode */ # if !defined(u8c_sym_dec) # define u8c_sym_dec +# include <stdbool.h> # include <stddef.h> -# include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_u8dec(size_t * const sz,uint_least32_t const * * const out,uint_least8_t const * const in); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_u8dec(size_t * const sz,char32_t const * * const out,unsigned char const * const in); # endif diff --git a/include/u8c/u8enc.h b/include/u8c/u8enc.h index 8040f8d..096e65a 100644 --- a/include/u8c/u8enc.h +++ b/include/u8c/u8enc.h @@ -16,13 +16,8 @@ /* UTF-8 encode */ # if !defined(u8c_sym_enc) # define u8c_sym_enc +# include <stdbool.h> # include <stddef.h> -# include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_u8enc(size_t * const sz,uint_least8_t const * * const out,uint_least32_t const * const in); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_u8enc(size_t * const sz,unsigned char const * * const out,char32_t const * const in); # endif diff --git a/include/u8c/u8free.h b/include/u8c/u8free.h index 1ae3242..f1994dd 100644 --- a/include/u8c/u8free.h +++ b/include/u8c/u8free.h @@ -13,15 +13,9 @@ If not, see <https://www.gnu.org/licenses/>. */ -/* Format */ -# if !defined(u8c_u8free) -# if defined(__cplusplus) -# include <cstdint> -# include <cstdlib> -# define u8c_u8free(u8) (std::free(const_cast<std::uint_least8_t *>(u8))) -# else -# include <stdint.h> -# include <stdlib.h> -# define u8c_u8free(u8) (free((uint_least8_t *)u8)) -# endif +/* UTF-8 free */ +# if !defined(u8c_sym_u8free) +# define u8c_sym_u8free +# include <stdbool.h> +extern bool u8c_u8free(unsigned char const * * const u8); # endif diff --git a/include/u8c/unimax.h b/include/u8c/unimax.h new file mode 100644 index 0000000..10c8be6 --- /dev/null +++ b/include/u8c/unimax.h @@ -0,0 +1,21 @@ +/* + 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/>. +*/ +/* Unicode maximum */ +# if !defined(u8c_unimax) +# include <stdint.h> +# include <uchar.h> +# define u8c_unimax ((char32_t)UINT32_C(0x10FFFF)) +# endif diff --git a/include/u8c/ver.h b/include/u8c/ver.h index f10872c..054052d 100644 --- a/include/u8c/ver.h +++ b/include/u8c/ver.h @@ -16,5 +16,5 @@ /* Version */ # if !defined(u8c_ver) # include <stdint.h> -# define u8c_ver (UINT64_C(0x11)) +# define u8c_ver (UINT64_C(0x12)) # endif diff --git a/include/u8c/vfmt.h b/include/u8c/vfmt.h index d4ae9b0..8db9e05 100644 --- a/include/u8c/vfmt.h +++ b/include/u8c/vfmt.h @@ -17,13 +17,8 @@ # if !defined(u8c_sym_vfmt) # define u8c_sym_vfmt # include <stdarg.h> +# include <stdbool.h> # include <stddef.h> -# include <stdint.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_vfmt(size_t * const sz,uint_least32_t const * * const out,uint_least32_t const * const in,va_list args); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_vfmt(size_t * const sz,char32_t const * * const out,char32_t const * const in,va_list args); # endif diff --git a/include/u8c/vprint.h b/include/u8c/vprint.h index ace9612..41e7e41 100644 --- a/include/u8c/vprint.h +++ b/include/u8c/vprint.h @@ -17,13 +17,8 @@ # if !defined(u8c_sym_vprint) # define u8c_sym_vprint # include <stdarg.h> -# include <stdint.h> +# include <stdbool.h> # include <stdio.h> -# if defined(__cplusplus) -extern "C" { -# endif -extern uint_least8_t u8c_vprint(FILE * fp,uint_least32_t const * const msg,va_list args); -# if defined(__cplusplus) -} -# endif +# include <uchar.h> +extern bool u8c_vprint(FILE * fp,char32_t const * const msg,va_list args); # endif |