diff options
129 files changed, 797 insertions, 1405 deletions
@@ -1,5 +1,5 @@ CC = clang -CFLAGS = -std=c17 -Wall -Wextra -Wmissing-prototypes -Wpadded -pedantic-errors -Iinclude -fPIC +CFLAGS = -std=c17 -Wall -Wextra -Wmissing-prototypes -pedantic-errors -Iinclude -fPIC ifneq ($(thrdsafe),0) CFLAGS += -Du8c_bethrdsafe endif @@ -10,52 +10,16 @@ CFLAGS += -O3 -DNDEBUG endif LDFLAGS = -shared -lpthread HDRS = \ - include/u8c/SIZE_C.h \ - include/u8c/abrt.h \ - include/u8c/col.h \ - include/u8c/dbg.h \ - include/u8c/dbgprint.h \ - include/u8c/end.h \ - include/u8c/errhandltyp.h \ - include/u8c/errtyp.h \ - include/u8c/fmt.h \ - include/u8c/fmttyp.h \ - include/u8c/geterr.h \ - include/u8c/init.h \ - include/u8c/isalnum.h \ - include/u8c/isalpha.h \ - include/u8c/iscntrl.h \ - include/u8c/isdigit.h \ - include/u8c/ispunct.h \ - include/u8c/isspace.h \ - include/u8c/isxdigit.h \ - include/u8c/print.h \ - include/u8c/println.h \ - include/u8c/regerrhandl.h \ - include/u8c/seterr.h \ - include/u8c/setfmt.h \ - include/u8c/thrdsafe.h \ - include/u8c/u32alloc.h \ - include/u8c/u32cat.h \ - include/u8c/u32cmp.h \ - include/u8c/u32cp.h \ - include/u8c/u32fndchr.h \ - include/u8c/u32fndpat.h \ - include/u8c/u32free.h \ - include/u8c/u32ins.h \ - include/u8c/u32substr.h \ - include/u8c/u32sz.h \ - include/u8c/u8alloc.h \ - include/u8c/u8dec.h \ - include/u8c/u8enc.h \ - include/u8c/u8free.h \ - include/u8c/unimax.h \ - include/u8c/ver.h \ - include/u8c/vfmt.h \ - include/u8c/vprint.h + include/u8c/err.h \ + include/u8c/fmt.h \ + include/u8c/is.h \ + include/u8c/main.h \ + include/u8c/SIZE_C.h \ + include/u8c/u16.h \ + include/u8c/u32.h \ + include/u8c/u8.h HDRS_PRIV = \ - src/u8c/dat.h \ - src/u8c/dattyp.h + src/u8c/intern.h SRCS = \ src/u8c/abrt.c \ src/u8c/dat.c \ @@ -77,6 +41,8 @@ SRCS = \ src/u8c/seterr.c \ src/u8c/setfmt.c \ src/u8c/thrdsafe.c \ + src/u8c/u16alloc.c \ + src/u8c/u16free.c \ src/u8c/u32alloc.c \ src/u8c/u32cat.c \ src/u8c/u32cmp.c \ @@ -141,7 +107,7 @@ DOCS = \ docs/u8c_ver.3.gz \ docs/u8c_vfmt.3.gz \ docs/u8c_vprint.3.gz -$(DOCS): +$(DOCS):errhandltyp gzip --keep $(DOCS:.gz=) test: $(LIB) test.c $(CC) -std=c17 -Wall -Wextra -Wpedantic -Iinclude -O3 -g -L. -lu8c -o $@ [email protected] diff --git a/changelog.md b/changelog.md index f87e9c5..583941f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,68 @@ +# 20 + +* Update documentation. +* Optimise `u8c_println`, +* Make `u8c_print`, `u8c_println`, and `u8c_vprint` thread-safe (if thread-safe is not disabled). +* Create base for UTF-16 related functions: + * Add function for allocating UTF-16 strings; `u8c_u16alloc`. + * Add function for deallocating UTF-16 strings; `u8c_u16free`. +* Restructure headers: + * `u8c/SIZE_C.h`: + * `SIZE_C` + * `u8c/err.h`: + * `u8c_errtyp` + * `u8c_errhandltyp` + * `u8c_geterr` + * `u8c_regerrhandl` + * `u8c_seterr` + * `u8c/fmt`: + * `u8c_dbgprint` + * `u8c_fmt` + * `u8c_fmttyp` + * `u8c_print` + * `u8c_println` + * `u8c_setfmt` + * `u8c_vfmt` + * `u8c_vprint` + * `u8c/is.h`: + * `u8c_isalnum` + * `u8c_isalpha` + * `u8c_iscntrl` + * `u8c_isdigit` + * `u8c_ispunct` + * `u8c_isspace` + * `u8c_isxdigit` + * `u8c/main.h`: + * `u8c_dbg` + * `u8c_abrt` + * `u8c_end` + * `u8c_init` + * `u8c_thrdsafe` + * `u8c_unimax` + * `u8c_ver` + * `u8c/u16.h`: + * `u8c_u16alloc` + * `u8c_u16free` + * `u8c/u32.h`: + * `u8c_u32alloc` + * `u8c_u32cat` + * `u8c_u32cmp` + * `u8c_u32cp` + * `u8c_u32fndchr` + * `u8c_u32fndpat` + * `u8c_u32free` + * `u8c_u32ins` + * `u8c_u32substr` + * `u8c_u32sz` + * `u8c/u8.h`: + * `u8c_u8alloc` + * `u8c_u8dec` + * `u8c_u8enc` + * `u8c_u8free` +* Disable *-Wpadded*. +* Update `SIZE_C`. +* Always use character constants (instead of numerical values). + # 1↋ * Add more codepoints to `u8c_ispunct`. diff --git a/docs/u8c_abrt.3 b/docs/u8c_abrt.3 index 0445701..6ea816c 100644 --- a/docs/u8c_abrt.3 +++ b/docs/u8c_abrt.3 @@ -6,6 +6,7 @@ u8c_abrt - Abort - Abort program with diagnostic information. .PP .nf \f[C] +/* # include <u8c/main.h> */ # include <stdbool.h # include <stdnoreturn.h> # include <uchar.h> @@ -16,7 +17,7 @@ extern noreturn bool u8c_abrt(char const * const fl,long long const ln,char cons .PP The function \f[B]u8c_abrt\f[R] aborts the program and prints diagnostic infiormation to \f[B]stderr\f[R]. .PP -\f[B]__FILE__\f[R] is to be passed at \f[B]fl\f[R], \f[B](long long)__LINE__\f[R] at \f[B]ln\f[B], and \f[B]__func__\f[R] at \f[B]fn\f[R]. A standard string (\f[B]char const *\f[R]) must be passed at \f[B]why\f[R], which explains the reason for aborting. +\f[B]__FILE__\f[R] is to be passed at \f[B]fl\f[R], \f[B](long long)__LINE__\f[R] at \f[B]ln\f[R], and \f[B]__func__\f[R] at \f[B]fn\f[R]. A standard string (\f[B]char const *\f[R]) must be passed at \f[B]why\f[R], which explains the reason for aborting. .PP All arguments are printed, in the end followed by a timestamp representing the number of seconds passed since the current epoch (as returned by \f[B]time(NULL)\f[R]). .SH VERSION diff --git a/docs/u8c_col.3 b/docs/u8c_col.3 index b0fb658..784a67d 100644 --- a/docs/u8c_col.3 +++ b/docs/u8c_col.3 @@ -6,28 +6,29 @@ u8c_col - Colour - Set of macros expanding to hexadecimal colour value expressio .PP .nf \f[C] +/* # include <u8c/fmt.h> */ # include <stdint.h> -# define u8c_col_azure (UINT32_C(0x3DA9E1)) -# define u8c_col_ash (UINT32_C(0xD2D2CC)) -# define u8c_col_black (UINT32_C(0x444747)) -# define u8c_col_blue (UINT32_C(0x3D3DE1)) -# define u8c_col_chartreuse (UINT32_C(0xA9E13D)) -# define u8c_col_cyan (UINT32_C(0x3DE1E1)) -# define u8c_col_green (UINT32_C(0x3ED13D)) -# define u8c_col_magenta (UINT32_C(0xE13DE1)) -# define u8c_col_mint (UINT32_C(0x3DE1A9)) -# define u8c_col_orange (UINT32_C(0xE1A93D)) -# define u8c_col_red (UINT32_C(0xE13D3D)) -# define u8c_col_rose (UINT32_C(0xE13DA9)) -# define u8c_col_silver (UINT32_C(0x9CA1A1)) -# define u8c_col_violet (UINT32_C(0xA93dE1)) -# define u8c_col_white (UINT32_C(0xF8F8F1)) -# define u8c_col_yellow (UINT32_C(0xE1E13D)) +static uint_least32_t const u8c_col_azure = UINT32_C(0x3DA9E1); +static uint_least32_t const u8c_col_ash = UINT32_C(0xD2D2CC); +static uint_least32_t const u8c_col_black = UINT32_C(0x444747); +static uint_least32_t const u8c_col_blue = UINT32_C(0x3D3DE1); +static uint_least32_t const u8c_col_chartreuse = UINT32_C(0xA9E13D); +static uint_least32_t const u8c_col_cyan = UINT32_C(0x3DE1E1); +static uint_least32_t const u8c_col_green = UINT32_C(0x3ED13D); +static uint_least32_t const u8c_col_magenta = UINT32_C(0xE13DE1); +static uint_least32_t const u8c_col_mint = UINT32_C(0x3DE1A9); +static uint_least32_t const u8c_col_orange = UINT32_C(0xE1A93D); +static uint_least32_t const u8c_col_red = UINT32_C(0xE13D3D); +static uint_least32_t const u8c_col_rose = UINT32_C(0xE13DA9); +static uint_least32_t const u8c_col_silver = UINT32_C(0x9CA1A1); +static uint_least32_t const u8c_col_violet = UINT32_C(0xA93dE1); +static uint_least32_t const u8c_col_white = UINT32_C(0xF8F8F1); +static uint_least32_t const u8c_col_yellow = UINT32_C(0xE1E13D); \f[R] .fi .SH DESCRIPTION .PP -The macro set \f[B]u8c_col\f[R] contains sixteen macros expanding to hexadecimal colour value expressions of type \f[B]uint_least32_t\f[R]. +The constant set \f[B]u8c_col\f[R] contains sixteen constants with colour values. .SH VERSION .PP u8c 2 diff --git a/docs/u8c_dbg.3 b/docs/u8c_dbg.3 index d1f95eb..d461d4e 100644 --- a/docs/u8c_dbg.3 +++ b/docs/u8c_dbg.3 @@ -6,6 +6,7 @@ u8c_dbg - Debug - Whether or not the library is in debug mode. .PP .nf \f[C] +/* # include <u8c/main.h> */ # include <stdbool.h> extern bool const u8c_dbg; \f[R] diff --git a/docs/u8c_dbgprint.3 b/docs/u8c_dbgprint.3 index e7c609f..3d400dc 100644 --- a/docs/u8c_dbgprint.3 +++ b/docs/u8c_dbgprint.3 @@ -6,6 +6,7 @@ u8c_dbgprint - Debug print - Print line if debug mode is enabled. .PP .nf \f[C] +/* # include <u8c/fmt.h> */ # if defined(NDEBUG) # define u8c_dbgprint(...) ((void)0x0) # else diff --git a/docs/u8c_end.3 b/docs/u8c_end.3 index bf8c81e..593af14 100644 --- a/docs/u8c_end.3 +++ b/docs/u8c_end.3 @@ -6,6 +6,7 @@ u8c_end - End - Finalise u8c and clean up. .PP .nf \f[C] +/* # include <u8c/main.h> */ # include <stdbool.h> extern bool u8c_end(void); \f[R] diff --git a/docs/u8c_errhandltyp.3 b/docs/u8c_errhandltyp.3 index ac7f8e2..0477d2c 100644 --- a/docs/u8c_errhandltyp.3 +++ b/docs/u8c_errhandltyp.3 @@ -6,6 +6,7 @@ u8c_errhandltyp - Error handler type - Type to be used for error handlers passer .PP .nf \f[C] +/* # include <u8c/err.h> */ # include <u8c/errtyp.h> typedef void (* u8c_errhandltyp)(enum u8c_errtyp); \f[R] diff --git a/docs/u8c_errtyp.3 b/docs/u8c_errtyp.3 index cd0a282..f42ac10 100644 --- a/docs/u8c_errtyp.3 +++ b/docs/u8c_errtyp.3 @@ -6,6 +6,7 @@ u8c_errtyp - Error type - Enumeration for specifying the type of error. .PP .nf \f[C] +/* # include <u8c/err.h> */ enum u8c_errtyp { u8c_errtyp_badalloc, u8c_errtyp_badio, diff --git a/docs/u8c_fmt.3 b/docs/u8c_fmt.3 index cbb823b..e1499fd 100644 --- a/docs/u8c_fmt.3 +++ b/docs/u8c_fmt.3 @@ -6,6 +6,7 @@ u8c_fmt - Format - Format UTF-32 string. .PP .nf \f[C] +/* # include <u8c/fmt.h> */ # include <stddef.h> # include <uchar.h> extern bool u8c_fmt(size_t * const outsz,char32_t const * * const out,char32_t const * const in,...); diff --git a/docs/u8c_fmttyp.3 b/docs/u8c_fmttyp.3 index 8cdea7c..04c4391 100644 --- a/docs/u8c_fmttyp.3 +++ b/docs/u8c_fmttyp.3 @@ -6,6 +6,7 @@ u8c_fmttyp - Format type - Format specifier to be used by \f[C]u8c_fmt\f[R] or \ .PP .nf \f[C] +/* # include <u8c/fmt.h> */ enum u8c_fmttyp { u8c_fmttyp_bgcol, u8c_fmttyp_bgcol0, diff --git a/docs/u8c_geterr.3 b/docs/u8c_geterr.3 index c74b25f..e19d50d 100644 --- a/docs/u8c_geterr.3 +++ b/docs/u8c_geterr.3 @@ -6,6 +6,7 @@ u8c_geterr - Get error - Get last error set by \f[C]u8c_seterr\f[R]. .PP .nf \f[C] +/* # include <u8c/err.h> */ # include <stdbool.h> # include <stddef.h> # include <uchar.h> diff --git a/docs/u8c_init.3 b/docs/u8c_init.3 index 0491a0b..35f6346 100644 --- a/docs/u8c_init.3 +++ b/docs/u8c_init.3 @@ -6,6 +6,7 @@ u8c_init - Initialise - Initialise and start an u8c session. .PP .nf \f[C] +/* # include <u8c/main.h> */ # include <stdbool.h> # include <u8c/errtyp.h> extern bool u8c_init(void); diff --git a/docs/u8c_isalnum.3 b/docs/u8c_isalnum.3 index c8f9dcc..273c673 100644 --- a/docs/u8c_isalnum.3 +++ b/docs/u8c_isalnum.3 @@ -6,6 +6,7 @@ u8c_isalnum - Is alphanumeric - Check if a character is alphanumeric. .PP .nf \f[C] +/* # include <u8c/is.h> */ # include <stdbool.h> # include <stdint.h> # include <uchar.h> diff --git a/docs/u8c_isalpha.3 b/docs/u8c_isalpha.3 index c6cc372..a063974 100644 --- a/docs/u8c_isalpha.3 +++ b/docs/u8c_isalpha.3 @@ -6,6 +6,7 @@ u8c_isalpha - Is alphabetic - Check if a character is alphabetic. .PP .nf \f[C] +/* # include <u8c/is.h> */ # include <stdbool.h> # include <stdint.h> # include <uchar.h> diff --git a/docs/u8c_iscntrl.3 b/docs/u8c_iscntrl.3 index 1c27b82..b4fa794 100644 --- a/docs/u8c_iscntrl.3 +++ b/docs/u8c_iscntrl.3 @@ -6,6 +6,7 @@ u8c_iscntrl - Is control - Check if a character is a control character. .PP .nf \f[C] +/* # include <u8c/is.h> */ # include <stdbool.h> # include <stdint.h> # include <uchar.h> diff --git a/docs/u8c_isdigit.3 b/docs/u8c_isdigit.3 index 6b3ec4a..0e93230 100644 --- a/docs/u8c_isdigit.3 +++ b/docs/u8c_isdigit.3 @@ -6,6 +6,7 @@ u8c_isdigit - Is digit - Check if a character is a dozenal digit. .PP .nf \f[C] +/* # include <u8c/is.h> */ # include <stdbool.h> # include <stdint.h> # include <uchar.h> diff --git a/docs/u8c_ispunct.3 b/docs/u8c_ispunct.3 index af607cb..db9878e 100644 --- a/docs/u8c_ispunct.3 +++ b/docs/u8c_ispunct.3 @@ -6,6 +6,7 @@ u8c_ispunct - Is punctuation - Check if a character is a punctuation mark. .PP .nf \f[C] +/* # include <u8c/is.h> */ # include <stdbool.h> # include <stdint.h> # include <uchar.h> diff --git a/docs/u8c_isspace.3 b/docs/u8c_isspace.3 index 72ad3e1..e78395d 100644 --- a/docs/u8c_isspace.3 +++ b/docs/u8c_isspace.3 @@ -6,6 +6,7 @@ u8c_isspace - Is space - Check if a character is an whitespace. .PP .nf \f[C] +/* # include <u8c/is.h> */ # include <stdbool.h> # include <stdint.h> # include <uchar.h> diff --git a/docs/u8c_isxdigit.3 b/docs/u8c_isxdigit.3 index 66c7955..7bb7649 100644 --- a/docs/u8c_isxdigit.3 +++ b/docs/u8c_isxdigit.3 @@ -6,6 +6,7 @@ u8c_isxdigit - Is hexadecimal digit - Check if a character is a hexadecimal digi .PP .nf \f[C] +/* # include <u8c/is.h> */ # include <stdbool.h> # include <stdint.h> # include <uchar.h> diff --git a/docs/u8c_print.3 b/docs/u8c_print.3 index 54a7466..7b5f55f 100644 --- a/docs/u8c_print.3 +++ b/docs/u8c_print.3 @@ -6,6 +6,7 @@ u8c_print - Print - Format UTF-32 and print it to file. .PP .nf \f[C] +/* # include <u8c/fmt.h> */ # include <stdbool.h> # include <stdio.h> # include <uchar.h> diff --git a/docs/u8c_println.3 b/docs/u8c_println.3 index 72345a6..14b8131 100644 --- a/docs/u8c_println.3 +++ b/docs/u8c_println.3 @@ -6,6 +6,7 @@ u8c_println - Print line - Format UTF-32 and print it to file (followed by a new .PP .nf \f[C] +/* # include <u8c/fmt.h> */ # include <stdbool.h> # include <stdio.h> # include <uchar.h> diff --git a/docs/u8c_regerrhandl.3 b/docs/u8c_regerrhandl.3 index 7b2f824..27be625 100644 --- a/docs/u8c_regerrhandl.3 +++ b/docs/u8c_regerrhandl.3 @@ -6,6 +6,7 @@ u8c_regerrhandl - Register error handler - Register error handler function to be .PP .nf \f[C] +/* # include <u8c/err.h> */ # include <stdbool.h> # include <u8c/errhandltyp.h> # include <u8c/errtyp.h> diff --git a/docs/u8c_seterr.3 b/docs/u8c_seterr.3 index 49125f5..be9ed98 100644 --- a/docs/u8c_seterr.3 +++ b/docs/u8c_seterr.3 @@ -6,6 +6,7 @@ u8c_seterr - Set error - Set error and call error handler. .PP .nf \f[C] +/* # include <u8c/err.h> */ # include <stdbool.h> # include <u8c/errtyp.h> # include <uchar.h> diff --git a/docs/u8c_setfmt.3 b/docs/u8c_setfmt.3 index 105019e..65d7646 100644 --- a/docs/u8c_setfmt.3 +++ b/docs/u8c_setfmt.3 @@ -6,6 +6,7 @@ u8c_setfmt - Set format - Set format to be used by \f[B]u8c_fmt\f[R] and company .PP .nf \f[C] +/* # include <u8c/fmt.h> */ # include <stdbool.h> # include <stdint.h> extern bool u8c_setfmt(uint_least8_t const base,uint_least8_t const endian); diff --git a/docs/u8c_thrdsafe.3 b/docs/u8c_thrdsafe.3 index b229734..09a0e3f 100644 --- a/docs/u8c_thrdsafe.3 +++ b/docs/u8c_thrdsafe.3 @@ -6,6 +6,7 @@ u8c_thrdsafe - Thread-safe - Whether or not u8c is thread-safe. .PP .nf \f[C] +/* # include <u8c/main.h> */ # include <stdbool.h> extern bool const u8c_thrdsafe; \f[R] diff --git a/docs/u8c_u16alloc.3 b/docs/u8c_u16alloc.3 new file mode 100644 index 0000000..96a59a6 --- /dev/null +++ b/docs/u8c_u16alloc.3 @@ -0,0 +1,20 @@ +.TH "u8c_u16alloc" "3" "" "u8c" "u8c API Manual" +.SH NAME +.PP +u8c_u16alloc - UTF-16 allocate - Allocate UTF-16 string. +.SH DECLARATION +.PP +.nf +\f[C] +/* # include <u8c/u16.h> */ +# include <stdbool.h> +# include <stddef.h> +# include <uchar.h> +extern bool u8c_u16alloc(char16_t * * const u16,size_t const sz); +\f[R] +.fi +.SH DESCRIPTION +.PP +.SH VERSION +.PP +u8c 20 diff --git a/docs/u8c_u16free.3 b/docs/u8c_u16free.3 new file mode 100644 index 0000000..7674794 --- /dev/null +++ b/docs/u8c_u16free.3 @@ -0,0 +1,19 @@ +.TH "u8c_u16free" "3" "" "u8c" "u8c API Manual" +.SH NAME +.PP +u8c_u16free - UTF-16 free - Deallocate UTF-16 string and set it to \f[B]NULL\f[R]. +.SH DECLARATION +.PP +.nf +\f[C] +/* # include <u8c/u16.h> */ +# include <stdbool.h> +# include <uchar.h> +extern bool u8c_u16free(char16_t const * * const u16); +\f[R] +.fi +.SH DESCRIPTION +.PP +.SH VERSION +.PP +u8c 20 diff --git a/docs/u8c_u32alloc.3 b/docs/u8c_u32alloc.3 index 8288f55..4ced722 100644 --- a/docs/u8c_u32alloc.3 +++ b/docs/u8c_u32alloc.3 @@ -6,6 +6,7 @@ u8c_u32alloc - UTF-32 allocate - Allocate UTF-32 string. .PP .nf \f[C] +/* # include <u8c/u32.h> */ # include <stdbool.h> # include <stddef.h> # include <uchar.h> diff --git a/docs/u8c_u32cat.3 b/docs/u8c_u32cat.3 index b600f9f..78d8a5c 100644 --- a/docs/u8c_u32cat.3 +++ b/docs/u8c_u32cat.3 @@ -6,6 +6,7 @@ u8c_u32cat - UTF-32 concatenate - Concatenate two UTF-32 strings. .PP .nf \f[C] +/* # include <u8c/u32.h> */ # include <stdbool.h> # include <stddef.h> # include <uchar.h> diff --git a/docs/u8c_u32cmp.3 b/docs/u8c_u32cmp.3 index c4d41bd..2954a8d 100644 --- a/docs/u8c_u32cmp.3 +++ b/docs/u8c_u32cmp.3 @@ -6,6 +6,7 @@ u8c_u32cmp - UTF-32 compare - Compare two UTF-32 strings. .PP .nf \f[C] +/* # include <u8c/u32.h> */ # include <stdbool.h> # include <stdint.h> # include <uchar.h> diff --git a/docs/u8c_u32cp.3 b/docs/u8c_u32cp.3 index ad28884..507e36e 100644 --- a/docs/u8c_u32cp.3 +++ b/docs/u8c_u32cp.3 @@ -6,6 +6,7 @@ u8c_u32cp - UTF-32 copy - Copy an UTF-32 string. .PP .nf \f[C] +/* # include <u8c/u32.h> */ # include <stdbool.h> # include <stddef.h> # include <uchar.h> diff --git a/docs/u8c_u32fndchr.3 b/docs/u8c_u32fndchr.3 index a7f688e..566985e 100644 --- a/docs/u8c_u32fndchr.3 +++ b/docs/u8c_u32fndchr.3 @@ -6,6 +6,7 @@ u8c_u32fndchr - UTF-32 find character - Find the first occurence of an UTF-32 ch .PP .nf \f[C] +/* # include <u8c/u32.h> */ # include <stdbool.h> # include <stddef.h> # include <uchar.h> diff --git a/docs/u8c_u32fndpat.3 b/docs/u8c_u32fndpat.3 index 1caf194..b74da9b 100644 --- a/docs/u8c_u32fndpat.3 +++ b/docs/u8c_u32fndpat.3 @@ -6,6 +6,7 @@ u8c_u32fndpat - UTF-32 find pattern - Find the first occurence of an UTF-32 patt .PP .nf \f[C] +/* # include <u8c/u32.h> */ # include <stdbool.h> # include <stddef.h> # include <uchar.h> diff --git a/docs/u8c_u32free.3 b/docs/u8c_u32free.3 index da74052..0dd58f1 100644 --- a/docs/u8c_u32free.3 +++ b/docs/u8c_u32free.3 @@ -1,11 +1,12 @@ .TH "u8c_u32free" "3" "" "u8c" "u8c API Manual" .SH NAME .PP -u8c_u32free - UTF-32 free - Free UTF-32 string. +u8c_u32free - UTF-32 free - Deallocate UTF-32 string and set it to \f[B]NULL\f[R]. .SH DECLARATION .PP .nf \f[C] +/* # include <u8c/u32.h> */ # include <stdbool.h> # include <uchar.h> extern bool u8c_u32free(char32_t const * * const u32); diff --git a/docs/u8c_u32ins.3 b/docs/u8c_u32ins.3 index ea62cae..8dc54c7 100644 --- a/docs/u8c_u32ins.3 +++ b/docs/u8c_u32ins.3 @@ -6,6 +6,7 @@ u8c_u32ins - UTF-32 insert - Insert an UTF-32 string into another UTF-32 string. .PP .nf \f[C] +/* # include <u8c/u32.h> */ # include <stdbool.h> # include <stddef.h> # include <uchar.h> diff --git a/docs/u8c_u32substr.3 b/docs/u8c_u32substr.3 index b35bebe..8615447 100644 --- a/docs/u8c_u32substr.3 +++ b/docs/u8c_u32substr.3 @@ -6,6 +6,7 @@ u8c_u32substr - UTF-32 sub-string - Get sub-string of an UTF-32 string. .PP .nf \f[C] +/* # include <u8c/u32.h> */ # include <stdbool.h> # include <stddef.h> # include <uchar.h> diff --git a/docs/u8c_u32sz.3 b/docs/u8c_u32sz.3 index 0a7fab9..61254b7 100644 --- a/docs/u8c_u32sz.3 +++ b/docs/u8c_u32sz.3 @@ -6,6 +6,7 @@ u8c_u32sz - UTF-32 size - Get the size of an UTF-32 string. .PP .nf \f[C] +/* # include <u8c/u32.h> */ # include <stdbool.h> # include <stddef.h> # include <uchar.h> diff --git a/docs/u8c_u8alloc.3 b/docs/u8c_u8alloc.3 index 8fbda08..ab0cf15 100644 --- a/docs/u8c_u8alloc.3 +++ b/docs/u8c_u8alloc.3 @@ -6,6 +6,7 @@ u8c_u8alloc - UTF-8 allocate - Allocate UTF-8 string. .PP .nf \f[C] +/* # include <u8c/u8.h> */ # include <stdbool.h> # include <stddef.h> extern bool u8c_u8alloc(unsigned char * * const u32,size_t const sz); diff --git a/docs/u8c_u8dec.3 b/docs/u8c_u8dec.3 index 2afe4dd..e4f7fc8 100644 --- a/docs/u8c_u8dec.3 +++ b/docs/u8c_u8dec.3 @@ -9,6 +9,7 @@ u8c_u8dec - UTF-8 decode - Convert an UTF-8 string to UTF-32. .IP .nf \f[C] +/* # include <u8c/u8.h> */ # include <stdbool.h> # include <stddef.h> # include <uchar.h> diff --git a/docs/u8c_u8enc.3 b/docs/u8c_u8enc.3 index 64feaf1..d6fc549 100644 --- a/docs/u8c_u8enc.3 +++ b/docs/u8c_u8enc.3 @@ -9,6 +9,7 @@ u8c_u8enc - UTF-8 encode - Convert an UTF-32 string to UTF-8. .IP .nf \f[C] +/* # include <u8c/u8.h> */ # include <stdbool.h> # include <stddef.h> # include <uchar.h> diff --git a/docs/u8c_u8free.3 b/docs/u8c_u8free.3 index 8c2c0ba..da10a20 100644 --- a/docs/u8c_u8free.3 +++ b/docs/u8c_u8free.3 @@ -1,11 +1,12 @@ .TH "u8c_u8free" "3" "" "u8c" "u8c API Manual" .SH NAME .PP -u8c_u8free - UTF-8 free - Free UTF-8 string and set it to \f[B]NULL\f[R]. +u8c_u8free - UTF-8 free - Deallocate UTF-8 string and set it to \f[B]NULL\f[R]. .SH DECLARATION .PP .nf \f[C] +/* # include <u8c/u8.h> */ # include <stdbool.h> extern bool u8c_u8free(unsigned char const * * const u8); \f[R] diff --git a/docs/u8c_unimax.3 b/docs/u8c_unimax.3 index 7b35dc9..8f6165d 100644 --- a/docs/u8c_unimax.3 +++ b/docs/u8c_unimax.3 @@ -6,6 +6,7 @@ u8c_unimax - Unicode maximum - Maximum valid Unicode codepoint. .PP .nf \f[C] +/* # include <u8c/main.h> */ # include <stdint.h> # include <uchar.h> # define u8c_unimax ((char32_t)UINT32_C(0x10FFFF)) diff --git a/docs/u8c_ver.3 b/docs/u8c_ver.3 index 7c2ea39..388b5cb 100644 --- a/docs/u8c_ver.3 +++ b/docs/u8c_ver.3 @@ -6,6 +6,7 @@ u8c_ver - Version - Version of the u8c API. .PP .nf \f[C] +/* # include <u8c/main.h> */ # include <stdint.h> # define u8c_ver (UINT64_C(/* version */)) \f[R] diff --git a/docs/u8c_vfmt.3 b/docs/u8c_vfmt.3 index 9b2f626..0eff93a 100644 --- a/docs/u8c_vfmt.3 +++ b/docs/u8c_vfmt.3 @@ -6,6 +6,7 @@ u8c_vfmt - Variadic format - Format UTF-32 string. .PP .nf \f[C] +/* # include <u8c/fmt.h> */ # include <stdarg.h> # include <stdbool.h> # include <stddef.h> diff --git a/docs/u8c_vprint.3 b/docs/u8c_vprint.3 index 5db1cee..e3d58f6 100644 --- a/docs/u8c_vprint.3 +++ b/docs/u8c_vprint.3 @@ -6,6 +6,7 @@ u8c_vprint - Variadic print - Format UTF-32 and print it to file. .PP .nf \f[C] +/* # include <u8c/fmt.h> */ # include <stdarg.h> # include <stdbool.h> # include <stdio.h> diff --git a/include/u8c/SIZE_C.h b/include/u8c/SIZE_C.h index 4a8d513..542ddfd 100644 --- a/include/u8c/SIZE_C.h +++ b/include/u8c/SIZE_C.h @@ -13,18 +13,17 @@ If not, see <https://www.gnu.org/licenses/>. */ -/* Size constant */ # if !defined(SIZE_C) # include <limits.h> # 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 ## lu -# elif SIZE_MAX == ULLONG_MAX -# define SIZE_C(val) val ## llu +# if SIZE_MAX == UINT_LEAST8_MAX +# define SIZE_C(val) UINT8_C(val) +# elif SIZE_MAX == UINT_LEAST16_MAX +# define SIZE_C(val) UINT16_C(val) +# elif SIZE_MAX == UINT_LEAST32_MAX +# define SIZE_C(val) UINT32s_C(val) +# elif SIZE_MAX == UINT_LEAST64_MAX +# define SIZE_C(val) UINT64_C(val) # else # define SIZE_C(val) ((size_t)UINTMAX_C(val)) # endif diff --git a/include/u8c/col.h b/include/u8c/col.h deleted file mode 100644 index 9096608..0000000 --- a/include/u8c/col.h +++ /dev/null @@ -1,36 +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/>. -*/ -/* Colour */ -# if !defined(u8c_sym_col) -# define u8c_sym_col -# include <stdint.h> -# define u8c_col_azure (UINT32_C(0x3DA9E1)) -# define u8c_col_ash (UINT32_C(0xD2D2CC)) -# define u8c_col_black (UINT32_C(0x444747)) -# define u8c_col_blue (UINT32_C(0x3D3DE1)) -# define u8c_col_chartreuse (UINT32_C(0xA9E13D)) -# define u8c_col_cyan (UINT32_C(0x3DE1E1)) -# define u8c_col_green (UINT32_C(0x3ED13D)) -# define u8c_col_magenta (UINT32_C(0xE13DE1)) -# define u8c_col_mint (UINT32_C(0x3DE1A9)) -# define u8c_col_orange (UINT32_C(0xE1A93D)) -# define u8c_col_red (UINT32_C(0xE13D3D)) -# define u8c_col_rose (UINT32_C(0xE13DA9)) -# define u8c_col_silver (UINT32_C(0x9CA1A1)) -# define u8c_col_violet (UINT32_C(0xA93dE1)) -# define u8c_col_white (UINT32_C(0xF8F8F1)) -# define u8c_col_yellow (UINT32_C(0xE1E13D)) -# endif diff --git a/include/u8c/dbg.h b/include/u8c/dbg.h deleted file mode 100644 index e517a79..0000000 --- a/include/u8c/dbg.h +++ /dev/null @@ -1,21 +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/>. -*/ -/* Debug */ -# if !defined(u8c_sym_dbg) -# define u8c_sym_dbg -# include <stdbool.h> -extern bool const u8c_dbg; -# endif diff --git a/include/u8c/dbgprint.h b/include/u8c/dbgprint.h deleted file mode 100644 index 8c5ea31..0000000 --- a/include/u8c/dbgprint.h +++ /dev/null @@ -1,26 +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/>. -*/ -/* Debug print */ -# if !defined(u8c_sym_dbgprint) -# define u8c_sym_dbgprint -# if defined(NDEBUG) -# define u8c_dbgprint(...) ((void)0x0) -# else -# include <u8c/println.h> -# include <stdio.h> -# define u8c_dbgprint(...) u8c_println(stderr,__VA_ARGS__) -# endif -# endif diff --git a/include/u8c/end.h b/include/u8c/end.h deleted file mode 100644 index 5cc7922..0000000 --- a/include/u8c/end.h +++ /dev/null @@ -1,20 +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_end) -# define u8c_sym_end -# include <stdbool.h> -extern bool u8c_end(void); -# endif diff --git a/include/u8c/errtyp.h b/include/u8c/err.h index 00a6ef8..c6b0f9f 100644 --- a/include/u8c/errtyp.h +++ b/include/u8c/err.h @@ -13,9 +13,12 @@ If not, see <https://www.gnu.org/licenses/>. */ -/* Error type */ -# if !defined(u8c_sym_errtyp) -# define u8c_sym_errtyp +# if !defined(u8c_hdr_err) +# define u8c_hdr_err +# include <stdbool.h> +# include <stddef.h> +# include <uchar.h> +/* Enumerations: */ enum u8c_errtyp { u8c_errtyp_badalloc, /* Bad allocation */ u8c_errtyp_badio, /* Bad input or output */ @@ -26,4 +29,13 @@ enum u8c_errtyp { u8c_errtyp_maxerrtyp, /* Maximum error type */ u8c_errtyp_all, /* All */ }; +/* Type definitions: */ +typedef void (* u8c_errhandltyp)(enum u8c_errtyp); +/* Structures: */ +/* Functions */ +extern bool u8c_geterr( size_t * const sz, char32_t const * * const out); +extern bool u8c_regerrhandl(enum u8c_errtyp typ,u8c_errhandltyp errhandl); +extern bool u8c_seterr( char32_t const * const msg,enum u8c_errtyp typ); +/* Constants & Variables: */ +/* Macros: */ # endif diff --git a/include/u8c/errhandltyp.h b/include/u8c/errhandltyp.h deleted file mode 100644 index 310f6a6..0000000 --- a/include/u8c/errhandltyp.h +++ /dev/null @@ -1,20 +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_errhandltyp) -# define u8c_sym_errhandltyp -# include <u8c/errtyp.h> -typedef void (* u8c_errhandltyp)(enum u8c_errtyp); -# endif diff --git a/include/u8c/fmt.h b/include/u8c/fmt.h index 4f7ed1b..138acd6 100644 --- a/include/u8c/fmt.h +++ b/include/u8c/fmt.h @@ -13,10 +13,75 @@ If not, see <https://www.gnu.org/licenses/>. */ -/* Format */ -# if !defined(u8c_sym_fmt) -# define u8c_sym_fmt +# if !defined(u8c_hdr_fmt) +# define u8c_hdr_fmt +# include <stdarg.h> +# include <stdbool.h> # include <stddef.h> +# include <stdint.h> +# include <stdio.h> # include <uchar.h> -extern bool u8c_fmt(size_t * const outsz,char32_t const * * const out,char32_t const * const in,...); +/* Enumerations: */ +enum u8c_fmttyp { + u8c_fmttyp_bgcol, /* Background colour (uint_least32_t) */ + u8c_fmttyp_bgcol0, /* Background colour #0 */ + 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 (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) */ +}; +/* Type definitions: */ +/* Structures: */ +/* Functions */ +extern bool u8c_fmt( size_t * const outsz,char32_t const * * const out, char32_t const * const in,...); +extern bool u8c_print( FILE * fp, char32_t const * const msg, ...); +extern bool u8c_println(FILE * fp, char32_t const * const msg, ...); +extern bool u8c_setfmt( uint_least8_t const base, uint_least8_t const endian); +extern bool u8c_vfmt( size_t * const sz, char32_t const * * const out, char32_t const * const in,va_list args); +extern bool u8c_vprint( FILE * fp, char32_t const * const msg, va_list args); +/* Constants & Variables: */ +static uint_least32_t const u8c_col_azure = UINT32_C(0x3DA9E1); +static uint_least32_t const u8c_col_ash = UINT32_C(0xD2D2CC); +static uint_least32_t const u8c_col_black = UINT32_C(0x444747); +static uint_least32_t const u8c_col_blue = UINT32_C(0x3D3DE1); +static uint_least32_t const u8c_col_chartreuse = UINT32_C(0xA9E13D); +static uint_least32_t const u8c_col_cyan = UINT32_C(0x3DE1E1); +static uint_least32_t const u8c_col_green = UINT32_C(0x3ED13D); +static uint_least32_t const u8c_col_magenta = UINT32_C(0xE13DE1); +static uint_least32_t const u8c_col_mint = UINT32_C(0x3DE1A9); +static uint_least32_t const u8c_col_orange = UINT32_C(0xE1A93D); +static uint_least32_t const u8c_col_red = UINT32_C(0xE13D3D); +static uint_least32_t const u8c_col_rose = UINT32_C(0xE13DA9); +static uint_least32_t const u8c_col_silver = UINT32_C(0x9CA1A1); +static uint_least32_t const u8c_col_violet = UINT32_C(0xA93dE1); +static uint_least32_t const u8c_col_white = UINT32_C(0xF8F8F1); +static uint_least32_t const u8c_col_yellow = UINT32_C(0xE1E13D); +/* Macros: */ +# if defined(NDEBUG) +# define u8c_dbgprint(...) ((void)0x0) +# else +# define u8c_dbgprint(...) u8c_println(stderr,__VA_ARGS__) +# endif # endif diff --git a/include/u8c/fmttyp.h b/include/u8c/fmttyp.h deleted file mode 100644 index cce9a2f..0000000 --- a/include/u8c/fmttyp.h +++ /dev/null @@ -1,49 +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/>. -*/ -/* Format type */ -# if !defined(u8c_sym_fmttyp) -# define u8c_sym_fmttyp -enum u8c_fmttyp { - u8c_fmttyp_bgcol, /* Background colour (uint_least32_t) */ - u8c_fmttyp_bgcol0, /* Background colour #0 */ - 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 (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 deleted file mode 100644 index 70acc4f..0000000 --- a/include/u8c/geterr.h +++ /dev/null @@ -1,23 +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/>. -*/ -/* Get error */ -# if !defined(u8c_sym_geterr) -# define u8c_sym_geterr -# include <stdbool.h> -# include <stddef.h> -# 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 deleted file mode 100644 index e19cb5b..0000000 --- a/include/u8c/init.h +++ /dev/null @@ -1,22 +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/>. -*/ -/* Initialise */ -# if !defined(u8c_sym_init) -# define u8c_sym_init -# include <stdbool.h> -# include <u8c/errtyp.h> -extern bool u8c_init(void); -# endif diff --git a/include/u8c/isxdigit.h b/include/u8c/is.h index 57e1392..20097cf 100644 --- a/include/u8c/isxdigit.h +++ b/include/u8c/is.h @@ -13,11 +13,22 @@ If not, see <https://www.gnu.org/licenses/>. */ -/* Is hexadecimal digit */ -# if !defined(luma_sym_isxdigit) -# define luma_sym_isxdigit +# if !defined(u8c_hdr_is) +# define u8c_hdr_is # include <stdbool.h> # include <stdint.h> # include <uchar.h> +/* Enumerations: */ +/* Type definitions: */ +/* Structures: */ +/* Functions */ +extern bool u8c_isalnum( uint_least8_t * const res,char32_t const chr); +extern bool u8c_isalpha( uint_least8_t * const res,char32_t const chr); +extern bool u8c_iscntrl( uint_least8_t * const res,char32_t const chr); +extern bool u8c_isdigit( uint_least8_t * const res,char32_t const chr); +extern bool u8c_ispunct( uint_least8_t * const res,char32_t const chr); +extern bool u8c_isspace( uint_least8_t * const res,char32_t const chr); extern bool u8c_isxdigit(uint_least8_t * const res,char32_t const chr); +/* Constants & Variables: */ +/* Macros: */ # endif diff --git a/include/u8c/isalpha.h b/include/u8c/isalpha.h deleted file mode 100644 index a43363f..0000000 --- a/include/u8c/isalpha.h +++ /dev/null @@ -1,23 +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/>. -*/ -/* Is alphabetic */ -# if !defined(luma_sym_isalpha) -# define luma_sym_isalpha -# include <stdbool.h> -# include <stdint.h> -# 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 deleted file mode 100644 index 5ffe157..0000000 --- a/include/u8c/iscntrl.h +++ /dev/null @@ -1,23 +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/>. -*/ -/* Is control */ -# if !defined(luma_sym_iscntrl) -# define luma_sym_iscntrl -# include <stdbool.h> -# include <stdint.h> -# 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 deleted file mode 100644 index a28dd9a..0000000 --- a/include/u8c/isdigit.h +++ /dev/null @@ -1,23 +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/>. -*/ -/* Is digit */ -# if !defined(luma_sym_isdigit) -# define luma_sym_isdigit -# include <stdbool.h> -# include <stdint.h> -# 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 deleted file mode 100644 index 9834491..0000000 --- a/include/u8c/ispunct.h +++ /dev/null @@ -1,23 +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/>. -*/ -/* Is punctuation */ -# if !defined(luma_sym_ispunct) -# define luma_sym_ispunct -# include <stdbool.h> -# include <stdint.h> -# 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 deleted file mode 100644 index 78cafea..0000000 --- a/include/u8c/isspace.h +++ /dev/null @@ -1,23 +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/>. -*/ -/* Is space */ -# if !defined(luma_sym_isspace) -# define luma_sym_isspace -# include <stdbool.h> -# include <stdint.h> -# include <uchar.h> -extern bool u8c_isspace(uint_least8_t * const res,char32_t const chr); -# endif diff --git a/include/u8c/isalnum.h b/include/u8c/main.h index b951f5e..49049f6 100644 --- a/include/u8c/isalnum.h +++ b/include/u8c/main.h @@ -13,11 +13,24 @@ If not, see <https://www.gnu.org/licenses/>. */ -/* Is alphanumeric */ -# if !defined(luma_sym_isalnum) -# define luma_sym_isalnum +/* Abort */ +# if !defined(u8c_hdr_main) +# define u8c_hdr_main # include <stdbool.h> # include <stdint.h> +# include <stdnoreturn.h> # include <uchar.h> -extern bool u8c_isalnum(uint_least8_t * const res,char32_t const chr); +/* Enumerations: */ +/* Type definitions: */ +/* Structures: */ +/* Functions */ +extern noreturn bool u8c_abrt(char const * const fl,long long const ln,char const * const fn,char const * const why); +extern bool u8c_end( void); +extern bool u8c_init(void); +/* Constants & Variables: */ +extern bool const u8c_dbg; +extern bool const u8c_thrdsafe; +static char32_t const u8c_unimax = (char32_t)UINT32_C(0x10FFFF); +static uint_least64_t const u8c_ver = UINT64_C(0x19); +/* Macros: */ # endif diff --git a/include/u8c/print.h b/include/u8c/print.h deleted file mode 100644 index f76c942..0000000 --- a/include/u8c/print.h +++ /dev/null @@ -1,23 +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/>. -*/ -/* Print */ -# if !defined(u8c_sym_print) -# define u8c_sym_print -# include <stdbool.h> -# include <stdio.h> -# 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 deleted file mode 100644 index 8d80353..0000000 --- a/include/u8c/println.h +++ /dev/null @@ -1,23 +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/>. -*/ -/* Print line */ -# if !defined(u8c_sym_println) -# define u8c_sym_println -# include <stdbool.h> -# include <stdio.h> -# include <uchar.h> -extern bool u8c_println(FILE * fp,char32_t const * const msg,...); -# endif diff --git a/include/u8c/regerrhandl.h b/include/u8c/regerrhandl.h deleted file mode 100644 index d94869a..0000000 --- a/include/u8c/regerrhandl.h +++ /dev/null @@ -1,23 +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/>. -*/ -/* Register error handler */ -# if !defined(u8c_sym_regerrhandl) -# define u8c_sym_regerrhandl -# include <stdbool.h> -# include <u8c/errhandltyp.h> -# include <u8c/errtyp.h> -extern bool u8c_regerrhandl(enum u8c_errtyp typ,u8c_errhandltyp errhandl); -# endif diff --git a/include/u8c/seterr.h b/include/u8c/seterr.h deleted file mode 100644 index b143f5d..0000000 --- a/include/u8c/seterr.h +++ /dev/null @@ -1,23 +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/>. -*/ -/* Set error */ -# if !defined(u8c_sym_seterr) -# define u8c_sym_seterr -# include <stdbool.h> -# include <u8c/errtyp.h> -# include <uchar.h> -extern bool u8c_seterr(char32_t const * const msg,enum u8c_errtyp _typ); -# endif diff --git a/include/u8c/thrdsafe.h b/include/u8c/thrdsafe.h deleted file mode 100644 index 2ab6709..0000000 --- a/include/u8c/thrdsafe.h +++ /dev/null @@ -1,21 +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/>. -*/ -/* Thread-safe */ -# if !defined(u8c_sym_thrdsafe) -# define u8c_sym_thrdsafe -# include <stdbool.h> -extern bool const u8c_thrdsafe; -# endif diff --git a/include/u8c/u32alloc.h b/include/u8c/u16.h index 5241ee6..1babb69 100644 --- a/include/u8c/u32alloc.h +++ b/include/u8c/u16.h @@ -13,11 +13,17 @@ If not, see <https://www.gnu.org/licenses/>. */ -/* UTF-32 allocate */ -# if !defined(u8c_sym_u32alloc) -# define u8c_sym_u32alloc +# if !defined(u8c_hdr_u16) +# define u8c_hdr_u16 # include <stdbool.h> # include <stddef.h> # include <uchar.h> -extern bool u8c_u32alloc(char32_t * * const u32,size_t const sz); +/* Enumerations: */ +/* Type definitions: */ +/* Structures: */ +/* Functions */ +extern bool u8c_u16alloc(char16_t * * const u16,size_t const sz); +extern bool u8c_u16free(char16_t const * * const u16); +/* Constants & Variables: */ +/* Macros: */ # endif diff --git a/include/u8c/u32.h b/include/u8c/u32.h new file mode 100644 index 0000000..08ac161 --- /dev/null +++ b/include/u8c/u32.h @@ -0,0 +1,37 @@ +/* + 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_hdr_u32) +# define u8c_hdr_u32 +# include <stdbool.h> +# include <stddef.h> +# include <uchar.h> +/* Enumerations: */ +/* Type definitions: */ +/* Structures: */ +/* Functions */ +extern bool u8c_u32alloc(char32_t * * const u32,size_t const sz); +extern bool u8c_u32cat(size_t * const sz,char32_t const * * const out,char32_t const * const lstr,char32_t const * const rstr); +extern bool u8c_u32cmp(uint_least8_t * const res,char32_t const * const lstr,char32_t const * const rstr); +extern bool u8c_u32cp(size_t * const sz,char32_t const * * const out,char32_t const * const in); +extern bool u8c_u32fndchr(size_t * const pos,char32_t const * const in,char32_t const chr); +extern bool u8c_u32fndpat(size_t * const pos,char32_t const * const in,char32_t const * const pat); +extern bool u8c_u32free(char32_t const * * const u32); +extern bool u8c_u32ins(size_t * const sz,char32_t const * * const out,size_t const pos,char32_t const * const str0,char32_t const * const str1); +extern bool u8c_u32substr(char32_t const * * const out,size_t const start,size_t const len,char32_t const * const in); +extern bool u8c_u32sz(size_t * sz,char32_t const * in); +/* Constants & Variables: */ +/* Macros: */ +# endif diff --git a/include/u8c/u32cmp.h b/include/u8c/u32cmp.h deleted file mode 100644 index d638255..0000000 --- a/include/u8c/u32cmp.h +++ /dev/null @@ -1,22 +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(luma_sym_u32cmp) -# define luma_sym_u32cmp -# include <stdbool.h> -# include <stdint.h> -# 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 deleted file mode 100644 index a79d087..0000000 --- a/include/u8c/u32cp.h +++ /dev/null @@ -1,22 +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(luma_sym_u32cp) -# define luma_sym_u32cp -# include <stdbool.h> -# include <stddef.h> -# 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 deleted file mode 100644 index 2ba83a1..0000000 --- a/include/u8c/u32fndchr.h +++ /dev/null @@ -1,22 +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(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 deleted file mode 100644 index a17948b..0000000 --- a/include/u8c/u32fndpat.h +++ /dev/null @@ -1,23 +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/>. -*/ -/* 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 deleted file mode 100644 index 4525b22..0000000 --- a/include/u8c/u32free.h +++ /dev/null @@ -1,22 +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/>. -*/ -/* 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/u32ins.h b/include/u8c/u32ins.h deleted file mode 100644 index 70a2440..0000000 --- a/include/u8c/u32ins.h +++ /dev/null @@ -1,23 +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/>. -*/ -/* UTF-32 insert */ -# if !defined(luma_sym_u32ins) -# define luma_sym_u32ins -# include <stdbool.h> -# include <stddef.h> -# include <uchar.h> -extern bool u8c_u32ins(size_t * const sz,char32_t const * * const out,size_t const pos,char32_t const * const str0,char32_t const * const str1); -# endif diff --git a/include/u8c/u32substr.h b/include/u8c/u32substr.h deleted file mode 100644 index e9258a4..0000000 --- a/include/u8c/u32substr.h +++ /dev/null @@ -1,23 +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/>. -*/ -/* 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 deleted file mode 100644 index f182e92..0000000 --- a/include/u8c/u32sz.h +++ /dev/null @@ -1,23 +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/>. -*/ -/* UTF-32 size */ -# if !defined(u8c_sym_u32sz) -# define u8c_sym_u32sz -# include <stdbool.h> -# include <stddef.h> -# include <uchar.h> -extern bool u8c_u32sz(size_t * sz,char32_t const * in); -# endif diff --git a/include/u8c/u32cat.h b/include/u8c/u8.h index 7672cb7..f47666b 100644 --- a/include/u8c/u32cat.h +++ b/include/u8c/u8.h @@ -13,11 +13,19 @@ If not, see <https://www.gnu.org/licenses/>. */ -/* UTF-32 concatenate */ -# if !defined(luma_sym_u32cat) -# define luma_sym_u32cat +# if !defined(u8c_hdr_u8) +# define u8c_hdr_u8 # 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); +/* Enumerations: */ +/* Type definitions: */ +/* Structures: */ +/* Functions */ +extern bool u8c_u8alloc(unsigned char * * const u32,size_t const sz); +extern bool u8c_u8dec( size_t * const sz, char32_t const * * const out,unsigned char const * const in); +extern bool u8c_u8enc( size_t * const sz, unsigned char const * * const out,char32_t const * const in); +extern bool u8c_u8free( unsigned char const * * const u8); +/* Constants & Variables: */ +/* Macros: */ # endif diff --git a/include/u8c/u8alloc.h b/include/u8c/u8alloc.h deleted file mode 100644 index b5c2516..0000000 --- a/include/u8c/u8alloc.h +++ /dev/null @@ -1,22 +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/>. -*/ -/* 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 deleted file mode 100644 index 2b76df8..0000000 --- a/include/u8c/u8dec.h +++ /dev/null @@ -1,23 +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/>. -*/ -/* UTF-8 decode */ -# if !defined(u8c_sym_dec) -# define u8c_sym_dec -# include <stdbool.h> -# include <stddef.h> -# 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 deleted file mode 100644 index 096e65a..0000000 --- a/include/u8c/u8enc.h +++ /dev/null @@ -1,23 +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/>. -*/ -/* UTF-8 encode */ -# if !defined(u8c_sym_enc) -# define u8c_sym_enc -# include <stdbool.h> -# include <stddef.h> -# 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 deleted file mode 100644 index f1994dd..0000000 --- a/include/u8c/u8free.h +++ /dev/null @@ -1,21 +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/>. -*/ -/* 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 deleted file mode 100644 index 5baa4de..0000000 --- a/include/u8c/unimax.h +++ /dev/null @@ -1,22 +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/>. -*/ -/* Unicode maximum */ -# if !defined(u8c_sym_unimax) -# define u8c_sym_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 deleted file mode 100644 index 454c851..0000000 --- a/include/u8c/ver.h +++ /dev/null @@ -1,21 +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/>. -*/ -/* Version */ -# if !defined(u8c_sym_ver) -# define u8c_sym_ver -# include <stdint.h> -# define u8c_ver (UINT64_C(0x18)) -# endif diff --git a/include/u8c/vfmt.h b/include/u8c/vfmt.h deleted file mode 100644 index 8db9e05..0000000 --- a/include/u8c/vfmt.h +++ /dev/null @@ -1,24 +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/>. -*/ -/* Variadic format */ -# if !defined(u8c_sym_vfmt) -# define u8c_sym_vfmt -# include <stdarg.h> -# include <stdbool.h> -# include <stddef.h> -# 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 deleted file mode 100644 index 41e7e41..0000000 --- a/include/u8c/vprint.h +++ /dev/null @@ -1,24 +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/>. -*/ -/* Variadic print */ -# if !defined(u8c_sym_vprint) -# define u8c_sym_vprint -# include <stdarg.h> -# include <stdbool.h> -# include <stdio.h> -# include <uchar.h> -extern bool u8c_vprint(FILE * fp,char32_t const * const msg,va_list args); -# endif diff --git a/src/u8c/abrt.c b/src/u8c/abrt.c index 28361ec..6773827 100644 --- a/src/u8c/abrt.c +++ b/src/u8c/abrt.c @@ -13,7 +13,7 @@ If not, see <https://www.gnu.org/licenses/>. */ -# include "dat.h" +# include "intern.h" # include <inttypes.h> # include <stdbool.h> # include <stdint.h> @@ -21,11 +21,7 @@ # include <stdlib.h> # include <stdnoreturn.h> # include <time.h> -# include <u8c/abrt.h> -# include <u8c/dbg.h> -# include <u8c/end.h> -# include <u8c/thrdsafe.h> -# include <u8c/ver.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); fprintf(stderr,"Trying to clean up...\n"); diff --git a/src/u8c/dat.c b/src/u8c/dat.c index 26d17ef..55203c6 100644 --- a/src/u8c/dat.c +++ b/src/u8c/dat.c @@ -13,8 +13,7 @@ If not, see <https://www.gnu.org/licenses/>. */ -# include "dat.h" -# include "dattyp.h" +# include "intern.h" # include <stdbool.h> # include <stddef.h> # include <stdint.h> diff --git a/src/u8c/dat.h b/src/u8c/dat.h deleted file mode 100644 index fdda8c7..0000000 --- a/src/u8c/dat.h +++ /dev/null @@ -1,21 +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/>. -*/ -/* Data */ -# if !defined(u8c_sym_dat) -# define u8c_sym_dat -# include "dattyp.h" -extern struct u8c_dattyp u8c_dat; -# endif diff --git a/src/u8c/debug.c b/src/u8c/debug.c index faa668e..e42275c 100644 --- a/src/u8c/debug.c +++ b/src/u8c/debug.c @@ -15,7 +15,7 @@ */ # include <stdbool.h> # include <stdint.h> -# include <u8c/dbg.h> +# include <u8c/main.h> bool const u8c_dbg = # if defined(NDEBUG) false; diff --git a/src/u8c/end.c b/src/u8c/end.c index 80d39aa..f0e82e3 100644 --- a/src/u8c/end.c +++ b/src/u8c/end.c @@ -13,13 +13,13 @@ If not, see <https://www.gnu.org/licenses/>. */ -# include "dat.h" +# include "intern.h" # include <stdbool.h> # include <stdint.h> # include <stdlib.h> -# include <u8c/end.h> # include <u8c/SIZE_C.h> -# include <u8c/u32free.h> +# include <u8c/main.h> +# include <u8c/u32.h> # if defined(u8c_bethrdsafe) # include <threads.h> # endif @@ -32,6 +32,7 @@ bool u8c_end(void) { mtx_destroy(&u8c_dat.errhandlslock); mtx_destroy(&u8c_dat.errlock); mtx_destroy(&u8c_dat.fmtlock); + mtx_destroy(&u8c_dat.outlock); # endif /* Free error message: */ u8c_u32free(&u8c_dat.err); diff --git a/src/u8c/fmt.c b/src/u8c/fmt.c index 7ea690b..43f1ea4 100644 --- a/src/u8c/fmt.c +++ b/src/u8c/fmt.c @@ -18,8 +18,7 @@ # include <stddef.h> # include <stdint.h> # include <u8c/fmt.h> -# include <u8c/u32cp.h> -# include <u8c/vfmt.h> +# include <u8c/u32.h> bool u8c_fmt(size_t * const _outsz,char32_t const * * const _out,char32_t const * const _in,...) { va_list args; va_start(args,_in); diff --git a/src/u8c/geterr.c b/src/u8c/geterr.c index 65b8eba..3d8c220 100644 --- a/src/u8c/geterr.c +++ b/src/u8c/geterr.c @@ -13,14 +13,12 @@ If not, see <https://www.gnu.org/licenses/>. */ -# include "dat.h" +# include "intern.h" # include <stdbool.h> # include <stddef.h> # include <stdint.h> -# include <u8c/geterr.h> -# include <u8c/seterr.h> -# include <u8c/u32cp.h> -# include <u8c/u32free.h> +# include <u8c/err.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); diff --git a/src/u8c/init.c b/src/u8c/init.c index 0b8a100..3769109 100644 --- a/src/u8c/init.c +++ b/src/u8c/init.c @@ -13,15 +13,17 @@ If not, see <https://www.gnu.org/licenses/>. */ -# include "dat.h" +# 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/errtyp.h> -# include <u8c/init.h> -# include <u8c/seterr.h> -# include <u8c/u32cp.h> +# include <u8c/err.h> +# include <u8c/main.h> +# include <u8c/u32.h> # if defined(u8c_bethrdsafe) # include <threads.h> # endif @@ -37,6 +39,9 @@ bool u8c_init() { if(mtx_init(&u8c_dat.fmtlock,mtx_plain) == thrd_error) { return true; } + if(mtx_init(&u8c_dat.outlock,mtx_plain) == thrd_error) { + return true; + } # endif /* Set default error message: */ u8c_dat.err = NULL; diff --git a/src/u8c/dattyp.h b/src/u8c/intern.h index aa61b21..ab7644c 100644 --- a/src/u8c/dattyp.h +++ b/src/u8c/intern.h @@ -15,28 +15,34 @@ */ # if !defined(u8c_sym_dattyp) # define u8c_sym_dattyp +# include <stdalign.h> # include <stdbool.h> # include <stddef.h> # include <stdint.h> -# include <u8c/errhandltyp.h> -# include <u8c/errtyp.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 { - bool fmtendian; - unsigned char pad0[sizeof(void(*)(void)) - SIZE_C(0x1)]; /* Padding. */ 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) - unsigned char pad1[sizeof(void(*)(void)) - SIZE_C(0x2)]; /* Padding. */ 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/isalnum.c b/src/u8c/isalnum.c index f8b5686..13834c3 100644 --- a/src/u8c/isalnum.c +++ b/src/u8c/isalnum.c @@ -17,9 +17,7 @@ # include <stdbool.h> # include <stddef.h> # include <stdint.h> -# include <u8c/isalnum.h> -# include <u8c/isalpha.h> -# include <u8c/isdigit.h> +# include <u8c/is.h> bool u8c_isalnum(uint_least8_t * const _res,char32_t const _chr) { assert(_res != NULL); uint_least8_t res = UINT8_C(0x0); diff --git a/src/u8c/isalpha.c b/src/u8c/isalpha.c index b960bf5..d5952dc 100644 --- a/src/u8c/isalpha.c +++ b/src/u8c/isalpha.c @@ -17,121 +17,121 @@ # include <stdbool.h> # include <stddef.h> # include <stdint.h> -# include <u8c/isalpha.h> +# include <u8c/is.h> bool u8c_isalpha(uint_least8_t * const _res,char32_t const _chr) { assert(_res != NULL); switch(_chr) { default: *_res = UINT8_C(0x0); break; - case UINT32_C(0x61): /* LATIN SMALL LETTER A */ - case UINT32_C(0x62): /* LATIN SMALL LETTER B */ - case UINT32_C(0x63): /* LATIN SMALL LETTER C */ - case UINT32_C(0x64): /* LATIN SMALL LETTER D */ - case UINT32_C(0x65): /* LATIN SMALL LETTER E */ - case UINT32_C(0x66): /* LATIN SMALL LETTER F */ - case UINT32_C(0x67): /* LATIN SMALL LETTER G */ - case UINT32_C(0x68): /* LATIN SMALL LETTER H */ - case UINT32_C(0x69): /* LATIN SMALL LETTER I */ - case UINT32_C(0x6A): /* LATIN SMALL LETTER J */ - case UINT32_C(0x6B): /* LATIN SMALL LETTER K */ - case UINT32_C(0x6C): /* LATIN SMALL LETTER L */ - case UINT32_C(0x6D): /* LATIN SMALL LETTER M */ - case UINT32_C(0x6E): /* LATIN SMALL LETTER N */ - case UINT32_C(0x6F): /* LATIN SMALL LETTER O */ - case UINT32_C(0x70): /* LATIN SMALL LETTER P */ - case UINT32_C(0x71): /* LATIN SMALL LETTER Q */ - case UINT32_C(0x72): /* LATIN SMALL LETTER R */ - case UINT32_C(0x73): /* LATIN SMALL LETTER S */ - case UINT32_C(0x74): /* LATIN SMALL LETTER T */ - case UINT32_C(0x75): /* LATIN SMALL LETTER U */ - case UINT32_C(0x76): /* LATIN SMALL LETTER V */ - case UINT32_C(0x77): /* LATIN SMALL LETTER W */ - case UINT32_C(0x78): /* LATIN SMALL LETTER X */ - case UINT32_C(0x79): /* LATIN SMALL LETTER Y */ - case UINT32_C(0x7A): /* LATIN SMALL LETTER Z */ - case UINT32_C(0xDF): /* LATIN SMALL LETTER SHARP S */ - case UINT32_C(0xE1): /* LATIN SMALL LETTER A WITH ACUTE */ - case UINT32_C(0xE4): /* LATIN SMALL LETTER A WITH DIAERESIS */ - case UINT32_C(0xE5): /* LATIN SMALL LETTER A WITH RING ABOVE */ - case UINT32_C(0xE6): /* LATIN SMALL LETTER AE */ - case UINT32_C(0xE7): /* LATIN SMALL LETTER C WITH CEDILLA */ - case UINT32_C(0xE9): /* LATIN SMALL LETTER E WITH ACUTE */ - case UINT32_C(0xED): /* LATIN SMALL LETTER I WITH ACUTE */ - case UINT32_C(0xF0): /* LATIN SMALL LETTER ETH */ - case UINT32_C(0xF3): /* LATIN SMALL LETTER O WITH ACUTE */ - case UINT32_C(0xF6): /* LATIN SMALL LETTER O WITH DIAERESIS */ - case UINT32_C(0xF8): /* LATIN SMALL LETTER O WITH STROKE */ - case UINT32_C(0xFA): /* LATIN SMALL LETTER U WITH ACUTE */ - case UINT32_C(0xFC): /* U WITH TWO DOTS */ - case UINT32_C(0xFD): /* LATIN SMALL LETTER Y WITH ACUTE */ - case UINT32_C(0xFE): /* LATIN SMALL LETTER THORN */ - case UINT32_C(0x105): /* LATIN SMALL LETTER A WITH OGONEK */ - case UINT32_C(0x107): /* LATIN SMALL LETTER C WITH ACUTE */ - case UINT32_C(0x10D): /* LATIN SMALL LETTER C WITH CARON */ - case UINT32_C(0x10F): /* LATIN SMALL LETTER D WITH CARON */ - case UINT32_C(0x119): /* LATIN SMALL LETTER E WITH OGONEK */ - case UINT32_C(0x11B): /* LATIN SMALL LETTER E WITH CARON */ - case UINT32_C(0x11F): /* LATIN SMALL LETTER G WITH BREVE */ - case UINT32_C(0x131): /* LATIN SMALL LETTER DOTLESS I */ - case UINT32_C(0x133): /* LATIN SMALL LIGATURE LJ */ - case UINT32_C(0x138): /* LATIN SMALL LETTER KRA */ - case UINT32_C(0x142): /* LATIN SMALL LETTER L WITH STROKE */ - case UINT32_C(0x144): /* LATIN SMALL LETTER N WITH ACUTE */ - case UINT32_C(0x148): /* LATIN SMALL LETTER N WITH CARON */ - case UINT32_C(0x14B): /* LATIN SMALL LETTER ENG */ - case UINT32_C(0x153): /* LATIN SMALL LIGATURE OE */ - case UINT32_C(0x159): /* LATIN SMALL LETTER R WITH CARON */ - case UINT32_C(0x15B): /* LATIN SMALL LETTER S WITH ACUTE */ - case UINT32_C(0x15F): /* LATIN SMALL LETTER S WITH CEDILLA */ - case UINT32_C(0x161): /* LATIN SMALL LETTER S WITH CARON */ - case UINT32_C(0x165): /* LATIN SMALL LETTER T WITH CARON */ - case UINT32_C(0x16F): /* LATIN SMALL LETTER U WITH RING ABOVE */ - case UINT32_C(0x17A): /* LATIN SMALL LETTER Z WITH ACUTE */ - case UINT32_C(0x17C): /* LATIN SMALL LETTER Z WITH DOT ABOVE */ - case UINT32_C(0x17E): /* LATIN SMALL LETTER Z WITH CARON */ - case UINT32_C(0x1BF): /* LATIN LETTER WYNN */ - case UINT32_C(0x1DD): /* LATIN SMALL LETTER TURNED E */ - case UINT32_C(0x21D): /* LATIN SMALL LETTER YOGH */ - case UINT32_C(0x251): /* LATIN SMALL LETTER ALPHA */ - case UINT32_C(0x254): /* LATIN SMALL LETTER OPEN O */ - case UINT32_C(0x259): /* LATIN SMALL LETTER SCHWA */ - case UINT32_C(0x25B): /* LATIN SMALL LETTER OPEN E */ - case UINT32_C(0x263): /* LATIN SMALL LETTER GAMMA */ - case UINT32_C(0x269): /* LATIN SMALL LETTER IOTA */ - case UINT32_C(0x283): /* LATIN SMALL LETTER ESH */ - case UINT32_C(0x28A): /* LATIN SMALL LETTER UPSILON */ - case UINT32_C(0x28B): /* LATIN SMALL LETTER V WITH HOOK */ - case UINT32_C(0x292): /* LATIN SMALL LETTER EZH */ - case UINT32_C(0x294): /* LATIN SMALL LETTER GLOTTAL STOP */ - case UINT32_C(0x3B1): /* GREEK SMALL LETTER ALPHA */ - case UINT32_C(0x3B2): /* GREEK SMALL LETTER BETA */ - case UINT32_C(0x3B3): /* GREEK SMALL LETTER GAMMA */ - case UINT32_C(0x3B4): /* GREEK SMALL LETTER DELTA */ - case UINT32_C(0x3B5): /* GREEK SMALL LETTER EPSILON */ - case UINT32_C(0x3B6): /* GREEK SMALL LETTER ZETA */ - case UINT32_C(0x3B7): /* GREEK SMALL LETTER ETA */ - case UINT32_C(0x3B8): /* GREEK SMALL LETTER THETA */ - case UINT32_C(0x3B9): /* GREEK SMALL LETTER IOTA */ - case UINT32_C(0x3BA): /* GREEK SMALL LETTER KAPPA */ - case UINT32_C(0x3BB): /* GREEK SMALL LETTER LAMBDA */ - case UINT32_C(0x3BC): /* GREEK SMALL LETTER MU */ - case UINT32_C(0x3BD): /* GREEK SMALL LETTER NU */ - case UINT32_C(0x3BE): /* GREEK SMALL LETTER XI */ - case UINT32_C(0x3BF): /* GREEK SMALL LETTER OMICRON */ - case UINT32_C(0x3C0): /* GREEK SMALL LETTER PI */ - case UINT32_C(0x3C1): /* GREEK SMALL LETTER RHO */ - case UINT32_C(0x3C2): /* GREEK SMALL LETTER FINAL SIGMA */ - case UINT32_C(0x3C3): /* GREEK SMALL LETTER SIGMA */ - case UINT32_C(0x3C4): /* GREEK SMALL LETTER TAU */ - case UINT32_C(0x3C5): /* GREEK SMALL LETTER UPSILON */ - case UINT32_C(0x3C6): /* GREEK SMALL LETTER PHI */ - case UINT32_C(0x3C7): /* GREEK SMALL LETTER CHI */ - case UINT32_C(0x3C8): /* GREEK SMALL LETTER PSI */ - case UINT32_C(0x3C9): /* GREEK SMALL LETTER OMEGA */ - case UINT32_C(0x1D79): /* LATIN SMALL LETTER INSULAR G */ - case UINT32_C(0xA7B7): /* LATIN SMALL LETTER OMEGA */ - case UINT32_C(0xFB00): /* LATIN SMALL LIGATURE FF */ + case U'a': /* LATIN SMALL LETTER A */ + case U'b': /* LATIN SMALL LETTER B */ + case U'c': /* LATIN SMALL LETTER C */ + case U'd': /* LATIN SMALL LETTER D */ + case U'e': /* LATIN SMALL LETTER E */ + case U'f': /* LATIN SMALL LETTER F */ + case U'g': /* LATIN SMALL LETTER G */ + case U'h': /* LATIN SMALL LETTER H */ + case U'i': /* LATIN SMALL LETTER I */ + case U'j': /* LATIN SMALL LETTER J */ + case U'k': /* LATIN SMALL LETTER K */ + case U'l': /* LATIN SMALL LETTER L */ + case U'm': /* LATIN SMALL LETTER M */ + case U'n': /* LATIN SMALL LETTER N */ + case U'o': /* LATIN SMALL LETTER O */ + case U'p': /* LATIN SMALL LETTER P */ + case U'q': /* LATIN SMALL LETTER Q */ + case U'r': /* LATIN SMALL LETTER R */ + case U's': /* LATIN SMALL LETTER S */ + case U't': /* LATIN SMALL LETTER T */ + case U'u': /* LATIN SMALL LETTER U */ + case U'v': /* LATIN SMALL LETTER V */ + case U'w': /* LATIN SMALL LETTER W */ + case U'x': /* LATIN SMALL LETTER X */ + case U'y': /* LATIN SMALL LETTER Y */ + case U'z': /* LATIN SMALL LETTER Z */ + case U'\u00DF': /* LATIN SMALL LETTER SHARP S */ + case U'\u00E1': /* LATIN SMALL LETTER A WITH ACUTE */ + case U'\u00E4': /* LATIN SMALL LETTER A WITH DIAERESIS */ + case U'\u00E5': /* LATIN SMALL LETTER A WITH RING ABOVE */ + case U'\u00E6': /* LATIN SMALL LETTER AE */ + case U'\u00E7': /* LATIN SMALL LETTER C WITH CEDILLA */ + case U'\u00E9': /* LATIN SMALL LETTER E WITH ACUTE */ + case U'\u00ED': /* LATIN SMALL LETTER I WITH ACUTE */ + case U'\u00F0': /* LATIN SMALL LETTER ETH */ + case U'\u00F3': /* LATIN SMALL LETTER O WITH ACUTE */ + case U'\u00F6': /* LATIN SMALL LETTER O WITH DIAERESIS */ + case U'\u00F8': /* LATIN SMALL LETTER O WITH STROKE */ + case U'\u00FA': /* LATIN SMALL LETTER U WITH ACUTE */ + case U'\u00FC': /* U WITH TWO DOTS */ + case U'\u00FD': /* LATIN SMALL LETTER Y WITH ACUTE */ + case U'\u00FE': /* LATIN SMALL LETTER THORN */ + case U'\u0105': /* LATIN SMALL LETTER A WITH OGONEK */ + case U'\u0107': /* LATIN SMALL LETTER C WITH ACUTE */ + case U'\u010D': /* LATIN SMALL LETTER C WITH CARON */ + case U'\u010F': /* LATIN SMALL LETTER D WITH CARON */ + case U'\u0119': /* LATIN SMALL LETTER E WITH OGONEK */ + case U'\u011B': /* LATIN SMALL LETTER E WITH CARON */ + case U'\u011F': /* LATIN SMALL LETTER G WITH BREVE */ + case U'\u0131': /* LATIN SMALL LETTER DOTLESS I */ + case U'\u0133': /* LATIN SMALL LIGATURE LJ */ + case U'\u0138': /* LATIN SMALL LETTER KRA */ + case U'\u0142': /* LATIN SMALL LETTER L WITH STROKE */ + case U'\u0144': /* LATIN SMALL LETTER N WITH ACUTE */ + case U'\u0148': /* LATIN SMALL LETTER N WITH CARON */ + case U'\u014B': /* LATIN SMALL LETTER ENG */ + case U'\u0153': /* LATIN SMALL LIGATURE OE */ + case U'\u0159': /* LATIN SMALL LETTER R WITH CARON */ + case U'\u015B': /* LATIN SMALL LETTER S WITH ACUTE */ + case U'\u015F': /* LATIN SMALL LETTER S WITH CEDILLA */ + case U'\u0161': /* LATIN SMALL LETTER S WITH CARON */ + case U'\u0165': /* LATIN SMALL LETTER T WITH CARON */ + case U'\u016F': /* LATIN SMALL LETTER U WITH RING ABOVE */ + case U'\u017A': /* LATIN SMALL LETTER Z WITH ACUTE */ + case U'\u017C': /* LATIN SMALL LETTER Z WITH DOT ABOVE */ + case U'\u017E': /* LATIN SMALL LETTER Z WITH CARON */ + case U'\u01BF': /* LATIN LETTER WYNN */ + case U'\u01DD': /* LATIN SMALL LETTER TURNED E */ + case U'\u021D': /* LATIN SMALL LETTER YOGH */ + case U'\u0251': /* LATIN SMALL LETTER ALPHA */ + case U'\u0254': /* LATIN SMALL LETTER OPEN O */ + case U'\u0259': /* LATIN SMALL LETTER SCHWA */ + case U'\u025B': /* LATIN SMALL LETTER OPEN E */ + case U'\u0263': /* LATIN SMALL LETTER GAMMA */ + case U'\u0269': /* LATIN SMALL LETTER IOTA */ + case U'\u0283': /* LATIN SMALL LETTER ESH */ + case U'\u028A': /* LATIN SMALL LETTER UPSILON */ + case U'\u028B': /* LATIN SMALL LETTER V WITH HOOK */ + case U'\u0292': /* LATIN SMALL LETTER EZH */ + case U'\u0294': /* LATIN SMALL LETTER GLOTTAL STOP */ + case U'\u03B1': /* GREEK SMALL LETTER ALPHA */ + case U'\u03B2': /* GREEK SMALL LETTER BETA */ + case U'\u03B3': /* GREEK SMALL LETTER GAMMA */ + case U'\u03B4': /* GREEK SMALL LETTER DELTA */ + case U'\u03B5': /* GREEK SMALL LETTER EPSILON */ + case U'\u03B6': /* GREEK SMALL LETTER ZETA */ + case U'\u03B7': /* GREEK SMALL LETTER ETA */ + case U'\u03B8': /* GREEK SMALL LETTER THETA */ + case U'\u03B9': /* GREEK SMALL LETTER IOTA */ + case U'\u03BA': /* GREEK SMALL LETTER KAPPA */ + case U'\u03BB': /* GREEK SMALL LETTER LAMBDA */ + case U'\u03BC': /* GREEK SMALL LETTER MU */ + case U'\u03BD': /* GREEK SMALL LETTER NU */ + case U'\u03BE': /* GREEK SMALL LETTER XI */ + case U'\u03BF': /* GREEK SMALL LETTER OMICRON */ + case U'\u03C0': /* GREEK SMALL LETTER PI */ + case U'\u03C1': /* GREEK SMALL LETTER RHO */ + case U'\u03C2': /* GREEK SMALL LETTER FINAL SIGMA */ + case U'\u03C3': /* GREEK SMALL LETTER SIGMA */ + case U'\u03C4': /* GREEK SMALL LETTER TAU */ + case U'\u03C5': /* GREEK SMALL LETTER UPSILON */ + case U'\u03C6': /* GREEK SMALL LETTER PHI */ + case U'\u03C7': /* GREEK SMALL LETTER CHI */ + case U'\u03C8': /* GREEK SMALL LETTER PSI */ + case U'\u03C9': /* GREEK SMALL LETTER OMEGA */ + case U'\u1D79': /* LATIN SMALL LETTER INSULAR G */ + case U'\uA7B7': /* LATIN SMALL LETTER OMEGA */ + case U'\uFB00': /* LATIN SMALL LIGATURE FF */ *_res = UINT8_C(0x1); break; } diff --git a/src/u8c/iscntrl.c b/src/u8c/iscntrl.c index 4d698b2..4dcf543 100644 --- a/src/u8c/iscntrl.c +++ b/src/u8c/iscntrl.c @@ -17,45 +17,45 @@ # include <stdbool.h> # include <stddef.h> # include <stdint.h> -# include <u8c/iscntrl.h> +# include <u8c/is.h> bool u8c_iscntrl(uint_least8_t * const _res,char32_t const _chr) { assert(_res != NULL); switch(_chr) { default: *_res = UINT8_C(0x0); break; - case UINT32_C(0x0): /* NULL */ - case UINT32_C(0x1): /* START OF HEADING */ - case UINT32_C(0x2): /* START OF TEXT */ - case UINT32_C(0x3): /* END OF TEXT */ - case UINT32_C(0x4): /* END OF TRANSMISSION */ - case UINT32_C(0x5): /* ENQUIRY */ - case UINT32_C(0x6): /* ACKNOWLEDGE */ - case UINT32_C(0x7): /* BELL */ - case UINT32_C(0x8): /* BACKSPACE */ - case UINT32_C(0x9): /* HORIZONTAL TABULATION */ - case UINT32_C(0xA): /* NEW LINE */ - case UINT32_C(0xB): /* VERTICAL TABULATION */ - case UINT32_C(0xC): /* FORM FEED */ - case UINT32_C(0xD): /* CARRIAGE RETURN */ - case UINT32_C(0xE): /* SHIFT OUT */ - case UINT32_C(0xF): /* SHIFT IN */ - case UINT32_C(0x10): /* DATA LINK ESCAPE */ - case UINT32_C(0x11): /* DEVICE CONTROL ONE */ - case UINT32_C(0x12): /* DEVICE CONTROL TWO */ - case UINT32_C(0x13): /* DEVICE CONTROL THREE */ - case UINT32_C(0x14): /* DEVICE CONTROL FOUR */ - case UINT32_C(0x15): /* NEGATIVE ACKNOWLEDGE */ - case UINT32_C(0x16): /* SYNCHRONOUS IDLE */ - case UINT32_C(0x17): /* END OF TRANSMISSION BLOCK */ - case UINT32_C(0x18): /* CANCEL */ - case UINT32_C(0x19): /* END OF MEDIUM */ - case UINT32_C(0x1A): /* SUBSTITUTE */ - case UINT32_C(0x1B): /* ESCAPE */ - case UINT32_C(0x1C): /* FILE SEPERATOR */ - case UINT32_C(0x1D): /* GROUP SEPERATOR */ - case UINT32_C(0x1E): /* RECORD SEPERATOR */ - case UINT32_C(0x1F): /* UNIT SEPERATOR */ + case U'\x0': /* NULL */ + case U'\x1': /* START OF HEADING */ + case U'\x2': /* START OF TEXT */ + case U'\x3': /* END OF TEXT */ + case U'\x4': /* END OF TRANSMISSION */ + case U'\x5': /* ENQUIRY */ + case U'\x6': /* ACKNOWLEDGE */ + case U'\a': /* BELL */ + case U'\b': /* BACKSPACE */ + case U'\t': /* HORIZONTAL TABULATION */ + case U'\n': /* NEW LINE */ + case U'\v': /* VERTICAL TABULATION */ + case U'\f': /* FORM FEED */ + case U'\r': /* CARRIAGE RETURN */ + case U'\xE': /* SHIFT OUT */ + case U'\xF': /* SHIFT IN */ + case U'\x10': /* DATA LINK ESCAPE */ + case U'\x11': /* DEVICE CONTROL ONE */ + case U'\x12': /* DEVICE CONTROL TWO */ + case U'\x13': /* DEVICE CONTROL THREE */ + case U'\x14': /* DEVICE CONTROL FOUR */ + case U'\x15': /* NEGATIVE ACKNOWLEDGE */ + case U'\x16': /* SYNCHRONOUS IDLE */ + case U'\x17': /* END OF TRANSMISSION BLOCK */ + case U'\x18': /* CANCEL */ + case U'\x19': /* END OF MEDIUM */ + case U'\x1A': /* SUBSTITUTE */ + case U'\x1B': /* ESCAPE */ + case U'\x1C': /* FILE SEPERATOR */ + case U'\x1D': /* GROUP SEPERATOR */ + case U'\x1E': /* RECORD SEPERATOR */ + case U'\x1F': /* UNIT SEPERATOR */ *_res = UINT8_C(0x1); break; } diff --git a/src/u8c/isdigit.c b/src/u8c/isdigit.c index e4c6f78..8b799d9 100644 --- a/src/u8c/isdigit.c +++ b/src/u8c/isdigit.c @@ -17,25 +17,25 @@ # include <stdbool.h> # include <stddef.h> # include <stdint.h> -# include <u8c/isdigit.h> +# include <u8c/is.h> bool u8c_isdigit(uint_least8_t * const _res,char32_t const _chr) { assert(_res != NULL); switch(_chr) { default: *_res = UINT8_C(0x0); break; - case UINT32_C(0x30): /* DIGIT ZERO */ - case UINT32_C(0x31): /* DIGIT ONE */ - case UINT32_C(0x32): /* DIGIT TWO */ - case UINT32_C(0x33): /* DIGIT THREE */ - case UINT32_C(0x34): /* DIGIT FOUR */ - case UINT32_C(0x35): /* DIGIT FIVE */ - case UINT32_C(0x36): /* DIGIT SIX */ - case UINT32_C(0x37): /* DIGIT SEVEN */ - case UINT32_C(0x38): /* DIGIT EIGHT */ - case UINT32_C(0x39): /* DIGIT NINE */ - case UINT32_C(0x218A): /* TURNED DIGIT TWO */ - case UINT32_C(0x218B): /* TURNED DIGIT THREE */ + case U'0': /* DIGIT ZERO */ + case U'1': /* DIGIT ONE */ + case U'2': /* DIGIT TWO */ + case U'3': /* DIGIT THREE */ + case U'4': /* DIGIT FOUR */ + case U'5': /* DIGIT FIVE */ + case U'6': /* DIGIT SIX */ + case U'7': /* DIGIT SEVEN */ + case U'8': /* DIGIT EIGHT */ + case U'9': /* DIGIT NINE */ + case U'\u218A': /* TURNED DIGIT TWO */ + case U'\u218B': /* TURNED DIGIT THREE */ *_res = UINT8_C(0x1); break; } diff --git a/src/u8c/ispunct.c b/src/u8c/ispunct.c index eb4fb16..f6b041f 100644 --- a/src/u8c/ispunct.c +++ b/src/u8c/ispunct.c @@ -17,133 +17,134 @@ # include <stdbool.h> # include <stddef.h> # include <stdint.h> -# include <u8c/ispunct.h> +# include <u8c/is.h> bool u8c_ispunct(uint_least8_t * const _res,char32_t const _chr) { assert(_res != NULL); switch(_chr) { default: *_res = UINT8_C(0x0); break; - case UINT32_C(0x21): /* EXCLAMATION MARK */ - case UINT32_C(0x22): /* QUOTATION MARK */ - case UINT32_C(0x23): /* NUMBER SIGN */ - case UINT32_C(0x24): /* DOLLAR SIGN */ - case UINT32_C(0x25): /* PERCENT SIGN */ - case UINT32_C(0x26): /* AMPERSAND */ - case UINT32_C(0x27): /* APOSTROPHE */ - case UINT32_C(0x28): /* LEFT PARANTHESIS */ - case UINT32_C(0x29): /* RIGHT PARANTHESIS */ - case UINT32_C(0x2A): /* ASTERISK */ - case UINT32_C(0x2B): /* PLUS SIGN */ - case UINT32_C(0x2C): /* COMMA */ - case UINT32_C(0x2D): /* HYPHEN-MINUS */ - case UINT32_C(0x2E): /* FULL STOP */ - case UINT32_C(0x2F): /* SOLIDUS */ - case UINT32_C(0x3A): /* COLON */ - case UINT32_C(0x3B): /* SEMICOLON */ - case UINT32_C(0x3C): /* LESS-THAN SIGN */ - case UINT32_C(0x3D): /* EQUALS SIGN */ - case UINT32_C(0x3E): /* GREATER-THAN SIGN */ - case UINT32_C(0x3F): /* QUESTION MARK */ - case UINT32_C(0x40): /* COMMERCIAL AT */ - case UINT32_C(0x5B): /* LEFT SQUARE BRACKET */ - case UINT32_C(0x5C): /* REVERSE SOLIDUS */ - case UINT32_C(0x5D): /* RIGHT SQUARE BRACKET */ - case UINT32_C(0x5E): /* CIRCUMFLEX ACCENT */ - case UINT32_C(0x5F): /* LOW LINE */ - case UINT32_C(0x60): /* GRAVE ACCENT */ - case UINT32_C(0x7B): /* LEFT CURLY BRACKET */ - case UINT32_C(0x7C): /* VERTICAL LINE */ - case UINT32_C(0x7D): /* RIGHT CURLY BRACKET */ - case UINT32_C(0x7E): /* TILDE */ - case UINT32_C(0xA1): /* INVERT EXCLAMATION MARK */ - case UINT32_C(0xA2): /* CENT SIGN */ - case UINT32_C(0xA3): /* POUND SIGN */ - case UINT32_C(0xA4): /* CURRENCY SIGN */ - case UINT32_C(0xA5): /* YEN SIGN */ - case UINT32_C(0xA7): /* SECTION SIGN */ - case UINT32_C(0xA8): /* DIAERESIS */ - case UINT32_C(0xA9): /* COPYRIGHT SIGN */ - case UINT32_C(0xAB): /* LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */ - case UINT32_C(0xAE): /* REGISTERED SIGN */ - case UINT32_C(0xB0): /* DEGREE SIGN */ - case UINT32_C(0xB4): /* ACUTE ACCENT */ - case UINT32_C(0xB6): /* PILCROW SIGN */ - case UINT32_C(0xBB): /* RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */ - case UINT32_C(0xB1): /* PLUS MINUS SIGN */ - case UINT32_C(0xBF): /* INVERT QUESTION MARK */ - case UINT32_C(0xD7): /* MULTIPLICATION SIGN */ - case UINT32_C(0xF7): /* DIVISION SIGN */ - case UINT32_C(0x2010): /* HYPHEN */ - case UINT32_C(0x2013): /* EN DASH */ - case UINT32_C(0x2014): /* EM DASH */ - case UINT32_C(0x2018): /* LEFT SINGLE QUOTATION MARK */ - case UINT32_C(0x2019): /* RIGHT SINGLE QUOTATION MARK */ - case UINT32_C(0x201C): /* LEFT DOUBLE QUOTATION MARK */ - case UINT32_C(0x201D): /* RIGHT DOUBLE QUOTATION MARK */ - case UINT32_C(0x2026): /* HORIZONTAL ELLIPSIS */ - case UINT32_C(0x2030): /* PER MILLE SIGN */ - case UINT32_C(0x20A3): /* FRENCH FRANC SIGN */ - case UINT32_C(0x20A4): /* LIRA SIGN */ - case UINT32_C(0x20A8): /* RUPEE SIGN */ - case UINT32_C(0x20A9): /* WON SIGN */ - case UINT32_C(0x20AC): /* EURO SIGN */ - case UINT32_C(0x20B9): /* INDIAN RUPEE SIGN */ - case UINT32_C(0x20BF): /* BITCOIN SIGN */ - case UINT32_C(0x2103): /* DEGREE CELSIUS */ - case UINT32_C(0x2107): /* EULER CONSTANT */ - case UINT32_C(0x2109): /* DEGREE FAHRENHEIT */ - case UINT32_C(0x210E): /* PLANCK CONSTANT */ - case UINT32_C(0x2117): /* SOUND RECORDING COPYRIGHT */ - case UINT32_C(0x2122): /* TRADE MARK SIGN */ - case UINT32_C(0x2125): /* OUNCE SIGN */ - case UINT32_C(0x2126): /* OHM SIGN */ - case UINT32_C(0x212A): /* KELVIN SIGN */ - case UINT32_C(0x214D): /* AKTIESELSKAB */ - case UINT32_C(0x2205): /* EMPTY SET */ - case UINT32_C(0x2212): /* MINUS SIGN */ - case UINT32_C(0x221A): /* SQUARE ROOT */ - case UINT32_C(0x221B): /* CUBE ROOT */ - case UINT32_C(0x221C): /* FOURTH ROOT */ - case UINT32_C(0x221E): /* INFINITY */ - case UINT32_C(0x2248): /* ALMOST EQUAL TO */ - case UINT32_C(0x2260): /* NOT EQUAL TO */ - case UINT32_C(0x2264): /* LESS-THAN OR EQUAL TO */ - case UINT32_C(0x2265): /* GREATER-THAN OR EQUAL TO */ - case UINT32_C(0x2609): /* SUN */ - case UINT32_C(0x263F): /* MERCURY */ - case UINT32_C(0x2640): /* FEMALE SIGN */ - case UINT32_C(0x2641): /* EARTH */ - case UINT32_C(0x2642): /* MALE SIGN */ - case UINT32_C(0x2643): /* JUPITER */ - case UINT32_C(0x2644): /* SATURN */ - case UINT32_C(0x2645): /* URANUS */ - case UINT32_C(0x2646): /* NEPTUNE */ - case UINT32_C(0x2647): /* PLUTO */ - case UINT32_C(0x26A2): /* DOUBLED FEMALE SIGN */ - case UINT32_C(0x26A3): /* DOUBLED MALE SIGN */ - case UINT32_C(0x26A4): /* INTERLOCKED FEMALE AND MALE SIGN */ - case UINT32_C(0x26A5): /* MALE AND FEMALE SIGN */ - case UINT32_C(0x26B3): /* CERES */ - case UINT32_C(0x26B4): /* PALLAS */ - case UINT32_C(0x26B5): /* JUNO */ - case UINT32_C(0x26B6): /* VESTA */ - case UINT32_C(0x26B7): /* CHIRON */ - case UINT32_C(0x2BD8): /* PROSERPINA */ - case UINT32_C(0x2BD9): /* ASTRAEA */ - case UINT32_C(0x2BDA): /* HYGIEA */ - case UINT32_C(0x2BDB): /* PHOLOS */ - case UINT32_C(0x2BDC): /* NESSUS */ - case UINT32_C(0x2E2E): /* INVERTED QUESTION MARK */ - case UINT32_C(0x33D7): /* SQUARE PH */ - case UINT32_C(0xFDFC): /* RIAL SIGN */ - case UINT32_C(0x1F10D): /* CIRCLED ZERO WITH SLASH */ - case UINT32_C(0x1F10E): /* CIRCLED ANTICKLOCKWISE ARROW */ - case UINT32_C(0x1F10F): /* CIRCLED DOLLAR SIGN WITH OVERLAID BACKSLASH */ - case UINT32_C(0x1F12F): /* COPYLEFT SYMBOL */ - case UINT32_C(0x1F16D): /* CIRCLED CC */ - case UINT32_C(0x1F16E): /* CIRCLED C WITH OVERLAID BACKSLASH */ - case UINT32_C(0x1F16F): /* CIRCLED HUMAN FIGURE */ + case U'!': /* EXCLAMATION MARK */ + case U'\"': /* QUOTATION MARK */ + case U'#': /* NUMBER SIGN */ + case U'\u0024': /* DOLLAR SIGN */ + case U'%': /* PERCENT SIGN */ + case U'&': /* AMPERSAND */ + case U'\'': /* APOSTROPHE */ + case U'(': /* LEFT PARANTHESIS */ + case U')': /* RIGHT PARANTHESIS */ + case U'*': /* ASTERISK */ + case U'+': /* PLUS SIGN */ + case U',': /* COMMA */ + case U'-': /* HYPHEN-MINUS */ + case U'.': /* FULL STOP */ + case U'/': /* SOLIDUS */ + case U':': /* COLON */ + case U';': /* SEMICOLON */ + case U'<': /* LESS-THAN SIGN */ + case U'=': /* EQUALS SIGN */ + case U'>': /* GREATER-THAN SIGN */ + case U'\?': /* QUESTION MARK */ + case U'\u0040': /* COMMERCIAL AT */ + case U'[': /* LEFT SQUARE BRACKET */ + case U'\\': /* REVERSE SOLIDUS */ + case U']': /* RIGHT SQUARE BRACKET */ + case U'^': /* CIRCUMFLEX ACCENT */ + case U'_': /* LOW LINE */ + case U'\u0060': /* GRAVE ACCENT */ + case U'{': /* LEFT CURLY BRACKET */ + case U'|': /* VERTICAL LINE */ + case U'}': /* RIGHT CURLY BRACKET */ + case U'~': /* TILDE */ + case U'\u00A1': /* INVERT EXCLAMATION MARK */ + case U'\u00A2': /* CENT SIGN */ + case U'\u00A3': /* POUND SIGN */ + case U'\u00A4': /* CURRENCY SIGN */ + case U'\u00A5': /* YEN SIGN */ + case U'\u00A7': /* SECTION SIGN */ + case U'\u00A8': /* DIAERESIS */ + case U'\u00A9': /* COPYRIGHT SIGN */ + case U'\u00AB': /* LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */ + case U'\u00AE': /* REGISTERED SIGN */ + case U'\u00B0': /* DEGREE SIGN */ + case U'\u00B4': /* ACUTE ACCENT */ + case U'\u00B6': /* PILCROW SIGN */ + case U'\u00BB': /* RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */ + case U'\u00B1': /* PLUS MINUS SIGN */ + case U'\u00BF': /* INVERT QUESTION MARK */ + case U'\u00D7': /* MULTIPLICATION SIGN */ + case U'\u00F7': /* DIVISION SIGN */ + case U'\u2010': /* HYPHEN */ + case U'\u2013': /* EN DASH */ + case U'\u2014': /* EM DASH */ + case U'\u2018': /* LEFT SINGLE QUOTATION MARK */ + case U'\u2019': /* RIGHT SINGLE QUOTATION MARK */ + case U'\u201C': /* LEFT DOUBLE QUOTATION MARK */ + case U'\u201D': /* RIGHT DOUBLE QUOTATION MARK */ + case U'\u2026': /* HORIZONTAL ELLIPSIS */ + case U'\u2030': /* PER MILLE SIGN */ + case U'\u20A3': /* FRENCH FRANC SIGN */ + case U'\u20A4': /* LIRA SIGN */ + case U'\u20A8': /* RUPEE SIGN */ + case U'\u20A9': /* WON SIGN */ + case U'\u20AC': /* EURO SIGN */ + case U'\u20B9': /* INDIAN RUPEE SIGN */ + case U'\u20BF': /* BITCOIN SIGN */ + case U'\u2103': /* DEGREE CELSIUS */ + case U'\u2107': /* EULER CONSTANT */ + case U'\u2109': /* DEGREE FAHRENHEIT */ + case U'\u210E': /* PLANCK CONSTANT */ + case U'\u2117': /* SOUND RECORDING COPYRIGHT */ + case U'\u2122': /* TRADE MARK SIGN */ + case U'\u2125': /* OUNCE SIGN */ + case U'\u2126': /* OHM SIGN */ + case U'\u212A': /* KELVIN SIGN */ + case U'\u214D': /* AKTIESELSKAB */ + case U'\u2205': /* EMPTY SET */ + case U'\u2212': /* MINUS SIGN */ + case U'\u221A': /* SQUARE ROOT */ + case U'\u221B': /* CUBE ROOT */ + case U'\u221C': /* FOURTH ROOT */ + case U'\u221E': /* INFINITY */ + case U'\u2228': /* LOGICAL OR */ + case U'\u2248': /* ALMOST EQUAL TO */ + case U'\u2260': /* NOT EQUAL TO */ + case U'\u2264': /* LESS-THAN OR EQUAL TO */ + case U'\u2265': /* GREATER-THAN OR EQUAL TO */ + case U'\u2609': /* SUN */ + case U'\u263F': /* MERCURY */ + case U'\u2640': /* FEMALE SIGN */ + case U'\u2641': /* EARTH */ + case U'\u2642': /* MALE SIGN */ + case U'\u2643': /* JUPITER */ + case U'\u2644': /* SATURN */ + case U'\u2645': /* URANUS */ + case U'\u2646': /* NEPTUNE */ + case U'\u2647': /* PLUTO */ + case U'\u26A2': /* DOUBLED FEMALE SIGN */ + case U'\u26A3': /* DOUBLED MALE SIGN */ + case U'\u26A4': /* INTERLOCKED FEMALE AND MALE SIGN */ + case U'\u26A5': /* MALE AND FEMALE SIGN */ + case U'\u26B3': /* CERES */ + case U'\u26B4': /* PALLAS */ + case U'\u26B5': /* JUNO */ + case U'\u26B6': /* VESTA */ + case U'\u26B7': /* CHIRON */ + case U'\u2BD8': /* PROSERPINA */ + case U'\u2BD9': /* ASTRAEA */ + case U'\u2BDA': /* HYGIEA */ + case U'\u2BDB': /* PHOLOS */ + case U'\u2BDC': /* NESSUS */ + case U'\u2E2E': /* INVERTED QUESTION MARK */ + case U'\u33D7': /* SQUARE PH */ + case U'\uFDFC': /* RIAL SIGN */ + case U'\U0001F10D': /* CIRCLED ZERO WITH SLASH */ + case U'\U0001F10E': /* CIRCLED ANTICKLOCKWISE ARROW */ + case U'\U0001F10F': /* CIRCLED DOLLAR SIGN WITH OVERLAID BACKSLASH */ + case U'\U0001F12F': /* COPYLEFT SYMBOL */ + case U'\U0001F16D': /* CIRCLED CC */ + case U'\U0001F16E': /* CIRCLED C WITH OVERLAID BACKSLASH */ + case U'\U0001F16F': /* CIRCLED HUMAN FIGURE */ *_res = UINT8_C(0x1); break; } diff --git a/src/u8c/isspace.c b/src/u8c/isspace.c index deca03c..9473476 100644 --- a/src/u8c/isspace.c +++ b/src/u8c/isspace.c @@ -17,19 +17,19 @@ # include <stdbool.h> # include <stddef.h> # include <stdint.h> -# include <u8c/isspace.h> +# include <u8c/is.h> bool u8c_isspace(uint_least8_t * const _res,char32_t const _chr) { assert(_res != NULL); switch(_chr) { default: *_res = UINT8_C(0x0); break; - case UINT32_C(0x9): /* HORIZONTAL TABULATION */ - case UINT32_C(0xA): /* NEW LINE */ - case UINT32_C(0xB): /* VERTICAL TABULATION */ - case UINT32_C(0xC): /* FORM FEED */ - case UINT32_C(0xD): /* CARRIAGE RETURN */ - case UINT32_C(0x20): /* SPACE */ + case U'\t': /* HORIZONTAL TABULATION */ + case U'\n': /* NEW LINE */ + case U'\v': /* VERTICAL TABULATION */ + case U'\f': /* FORM FEED */ + case U'\r': /* CARRIAGE RETURN */ + case U' ': /* SPACE */ *_res = UINT8_C(0x1); break; } diff --git a/src/u8c/isxdigit.c b/src/u8c/isxdigit.c index ae12ae3..4a59b0d 100644 --- a/src/u8c/isxdigit.c +++ b/src/u8c/isxdigit.c @@ -17,29 +17,29 @@ # include <stdbool.h> # include <stddef.h> # include <stdint.h> -# include <u8c/isxdigit.h> +# include <u8c/is.h> bool u8c_isxdigit(uint_least8_t * const _res,char32_t const _chr) { assert(_res != NULL); switch(_chr) { default: *_res = UINT8_C(0x0); break; - case UINT32_C(0x30): /* DIGIT ZERO */ - case UINT32_C(0x31): /* DIGIT ONE */ - case UINT32_C(0x32): /* DIGIT TWO */ - case UINT32_C(0x33): /* DIGIT THREE */ - case UINT32_C(0x34): /* DIGIT FOUR */ - case UINT32_C(0x35): /* DIGIT FIVE */ - case UINT32_C(0x36): /* DIGIT SIX */ - case UINT32_C(0x37): /* DIGIT SEVEN */ - case UINT32_C(0x38): /* DIGIT EIGHT */ - case UINT32_C(0x39): /* DIGIT NINE */ - case UINT32_C(0x41): /* LATIN CAPITAL LETTER A */ - case UINT32_C(0x42): /* LATIN CAPITAL LETTER B */ - case UINT32_C(0x43): /* LATIN CAPITAL LETTER C */ - case UINT32_C(0x44): /* LATIN CAPITAL LETTER D */ - case UINT32_C(0x45): /* LATIN CAPITAL LETTER E */ - case UINT32_C(0x46): /* LATIN CAPITAL LETTER F */ + case U'0': /* DIGIT ZERO */ + case U'1': /* DIGIT ONE */ + case U'2': /* DIGIT TWO */ + case U'3': /* DIGIT THREE */ + case U'4': /* DIGIT FOUR */ + case U'5': /* DIGIT FIVE */ + case U'6': /* DIGIT SIX */ + case U'7': /* DIGIT SEVEN */ + case U'8': /* DIGIT EIGHT */ + case U'9': /* DIGIT NINE */ + case U'A': /* LATIN CAPITAL LETTER A */ + case U'B': /* LATIN CAPITAL LETTER B */ + case U'C': /* LATIN CAPITAL LETTER C */ + case U'D': /* LATIN CAPITAL LETTER D */ + case U'E': /* LATIN CAPITAL LETTER E */ + case U'F': /* LATIN CAPITAL LETTER F */ *_res = UINT8_C(0x1); break; } diff --git a/src/u8c/print.c b/src/u8c/print.c index 5c34749..8785ad8 100644 --- a/src/u8c/print.c +++ b/src/u8c/print.c @@ -16,8 +16,7 @@ # include <stdarg.h> # include <stdbool.h> # include <stdint.h> -# include <u8c/print.h> -# include <u8c/vprint.h> +# include <u8c/fmt.h> bool u8c_print(FILE * _fp,char32_t const * const _msg,...) { va_list args; va_start(args,_msg); diff --git a/src/u8c/println.c b/src/u8c/println.c index 76b0f72..1a924ad 100644 --- a/src/u8c/println.c +++ b/src/u8c/println.c @@ -18,20 +18,21 @@ # include <stdbool.h> # include <stdint.h> # include <stdio.h> -# include <u8c/errtyp.h> -# include <u8c/println.h> -# include <u8c/seterr.h> -# include <u8c/vprint.h> +# include <u8c/fmt.h> +# include <u8c/u32.h> +# include <uchar.h> bool u8c_println(FILE * _fp,char32_t const * const _msg,...) { assert(_fp != NULL); va_list args; va_start(args,_msg); - if(u8c_vprint(_fp,_msg,args)) { - return true; - } - if(fputc(0xA,stdout) == EOF) { - u8c_seterr(U"u8c_println: Unable to write to stdout (end of file).",u8c_errtyp_badio); - return false; + char32_t const * msg = NULL; + u8c_u32cat(NULL,&msg,_msg,U"\n"); + { + register bool const val = u8c_vprint(_fp,msg,args); + u8c_u32free(&msg); + if(val) { + return true; + } } va_end(args); return false; diff --git a/src/u8c/regerrhandl.c b/src/u8c/regerrhandl.c index 6a0d82f..ef41e31 100644 --- a/src/u8c/regerrhandl.c +++ b/src/u8c/regerrhandl.c @@ -13,12 +13,10 @@ If not, see <https://www.gnu.org/licenses/>. */ -# include "dat.h" +# include "intern.h" # include <stdbool.h> # include <stddef.h> -# include <u8c/errhandltyp.h> -# include <u8c/errtyp.h> -# include <u8c/regerrhandl.h> +# include <u8c/err.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/seterr.c index adde683..f356e5f 100644 --- a/src/u8c/seterr.c +++ b/src/u8c/seterr.c @@ -13,16 +13,14 @@ If not, see <https://www.gnu.org/licenses/>. */ -# include "dat.h" +# include "intern.h" # include <assert.h> # include <stdbool.h> # include <stddef.h> # include <stdint.h> -# include <u8c/dbgprint.h> -# include <u8c/errtyp.h> -# include <u8c/seterr.h> -# include <u8c/u32cp.h> -# include <u8c/u32free.h> +# include <u8c/err.h> +# include <u8c/fmt.h> +# include <u8c/u32.h> # if defined(u8c_bethrdsafe) # include <threads.h> # endif diff --git a/src/u8c/setfmt.c b/src/u8c/setfmt.c index 70b5c93..05fa9c1 100644 --- a/src/u8c/setfmt.c +++ b/src/u8c/setfmt.c @@ -13,11 +13,10 @@ If not, see <https://www.gnu.org/licenses/>. */ -# include "dat.h" +# include "intern.h" # include <stdbool.h> # include <stdint.h> -# include <u8c/seterr.h> -# include <u8c/setfmt.h> +# include <u8c/fmt.h> # if defined(u8c_bethrdsafe) # include <threads.h> # endif diff --git a/src/u8c/thrdsafe.c b/src/u8c/thrdsafe.c index c32a2e7..9d8e41a 100644 --- a/src/u8c/thrdsafe.c +++ b/src/u8c/thrdsafe.c @@ -15,7 +15,7 @@ */ # include <stdbool.h> # include <stdint.h> -# include <u8c/thrdsafe.h> +# include <u8c/main.h> bool const u8c_thrdsafe = # if defined(u8c_bethrdsafe) true; diff --git a/include/u8c/abrt.h b/src/u8c/u16alloc.c index a068ff2..2945e79 100644 --- a/include/u8c/abrt.h +++ b/src/u8c/u16alloc.c @@ -13,11 +13,18 @@ If not, see <https://www.gnu.org/licenses/>. */ -/* Abort */ -# if !defined(u8c_sym_abrt) -# define u8c_sym_abrt +# include "intern.h" # include <stdbool.h> -# include <stdnoreturn.h> +# include <stdlib.h> +# include <u8c/err.h> +# include <u8c/u16.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 +bool u8c_u16alloc(char16_t * * const _u16,size_t const _sz) { + char16_t * arr = NULL; + if((arr = calloc(sizeof *arr,_sz)) == NULL) { + u8c_seterr(U"u8c_u16alloc: Unable to allocate resources (not enough memory?).",u8c_errtyp_badalloc); + return false; + } + *_u16 = arr; + return false; +} diff --git a/include/u8c/setfmt.h b/src/u8c/u16free.c index f742bea..d447562 100644 --- a/include/u8c/setfmt.h +++ b/src/u8c/u16free.c @@ -13,10 +13,12 @@ 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 +# include <stdlib.h> +# include <u8c/u16.h> +bool u8c_u16free(char16_t const * * const _u16) { + free((char16_t *)*_u16); + *_u16 = NULL; + return false; +} diff --git a/src/u8c/u32alloc.c b/src/u8c/u32alloc.c index ddd5493..341fa03 100644 --- a/src/u8c/u32alloc.c +++ b/src/u8c/u32alloc.c @@ -13,13 +13,11 @@ If not, see <https://www.gnu.org/licenses/>. */ -# include "dat.h" -# include <setjmp.h> +# include "intern.h" # include <stdbool.h> # include <stdlib.h> -# include <u8c/errtyp.h> -# include <u8c/seterr.h> -# include <u8c/u32alloc.h> +# include <u8c/err.h> +# include <u8c/u32.h> # include <uchar.h> bool u8c_u32alloc(char32_t * * const _u32,size_t const _sz) { char32_t * arr = NULL; diff --git a/src/u8c/u32cat.c b/src/u8c/u32cat.c index b2b6773..600e0dc 100644 --- a/src/u8c/u32cat.c +++ b/src/u8c/u32cat.c @@ -17,12 +17,8 @@ # include <stdbool.h> # include <stdlib.h> # include <u8c/SIZE_C.h> -# include <u8c/seterr.h> -# include <u8c/u32alloc.h> -# include <u8c/u32cat.h> -# include <u8c/u32cp.h> -# include <u8c/u32free.h> -# include <u8c/u32sz.h> +# include <u8c/err.h> +# include <u8c/u32.h> # include <uchar.h> bool u8c_u32cat(size_t * const _sz,char32_t const * * const _out,char32_t const * const _lstr,char32_t const * const _rstr) { assert(_out != NULL); diff --git a/src/u8c/u32cmp.c b/src/u8c/u32cmp.c index 5c06e30..8a6617d 100644 --- a/src/u8c/u32cmp.c +++ b/src/u8c/u32cmp.c @@ -17,10 +17,9 @@ # include <stdbool.h> # include <stddef.h> # include <stdint.h> -# include <u8c/errtyp.h> -# include <u8c/seterr.h> # include <u8c/SIZE_C.h> -# include <u8c/u32cmp.h> +# include <u8c/err.h> +# include <u8c/u32.h> bool u8c_u32cmp(uint_least8_t * const _res,char32_t const * const _lstr,char32_t const * const _rstr) { assert(_res != NULL); assert(_lstr != NULL); diff --git a/src/u8c/u32cp.c b/src/u8c/u32cp.c index 979686f..95a9b35 100644 --- a/src/u8c/u32cp.c +++ b/src/u8c/u32cp.c @@ -17,11 +17,8 @@ # include <stdbool.h> # include <stdlib.h> # include <u8c/SIZE_C.h> -# include <u8c/seterr.h> -# include <u8c/u32alloc.h> -# include <u8c/u32cp.h> -# include <u8c/u32free.h> -# include <u8c/u32sz.h> +# include <u8c/err.h> +# include <u8c/u32.h> bool u8c_u32cp(size_t * const _sz,char32_t const * * const _out,char32_t const * const _in) { assert(_out != NULL); assert(_in != NULL); diff --git a/src/u8c/u32fndchr.c b/src/u8c/u32fndchr.c index ab4b5e1..228c553 100644 --- a/src/u8c/u32fndchr.c +++ b/src/u8c/u32fndchr.c @@ -18,17 +18,15 @@ # include <stddef.h> # include <stdint.h> # include <u8c/SIZE_C.h> -# include <u8c/errtyp.h> -# include <u8c/seterr.h> -# include <u8c/u32fndchr.h> -# include <u8c/u32sz.h> +# include <u8c/err.h> +# include <u8c/u32.h> bool u8c_u32fndchr(size_t * const _pos,char32_t const * const _in,char32_t const _chr) { assert(_pos != NULL); assert(_in != NULL); for(register size_t n = SIZE_C(0x0);n <= SIZE_MAX;n += SIZE_C(0x1)) { register uint_least32_t const tmp = _in[n]; - if(tmp == UINT32_C(0x0)) { - if(_chr == UINT32_C(0x0)) { + if(tmp == U'\x0') { + if(_chr == U'\x0') { *_pos = n; return false; } diff --git a/src/u8c/u32fndpat.c b/src/u8c/u32fndpat.c index 05071e5..5a1b5d2 100644 --- a/src/u8c/u32fndpat.c +++ b/src/u8c/u32fndpat.c @@ -18,12 +18,8 @@ # include <stddef.h> # include <stdint.h> # include <u8c/SIZE_C.h> -# include <u8c/seterr.h> -# include <u8c/u32cmp.h> -# include <u8c/u32fndpat.h> -# include <u8c/u32free.h> -# include <u8c/u32substr.h> -# include <u8c/u32sz.h> +# include <u8c/err.h> +# include <u8c/u32.h> bool u8c_u32fndpat(size_t * const _pos,char32_t const * const _in,char32_t const * const _pat) { assert(_pos != NULL); assert(_in != NULL); diff --git a/src/u8c/u32free.c b/src/u8c/u32free.c index b57e392..a0b120b 100644 --- a/src/u8c/u32free.c +++ b/src/u8c/u32free.c @@ -16,7 +16,7 @@ # include <stdbool.h> # include <stdint.h> # include <stdlib.h> -# include <u8c/u32free.h> +# include <u8c/u32.h> bool u8c_u32free(char32_t const * * const _u32) { free((char32_t *)*_u32); /* This cast does indeed discard a const-qualifier, but it is not undefined behaviour, as the array must have been allocated by calloc or malloc, meaning it's original type is not const-qualified. */ *_u32 = NULL; diff --git a/src/u8c/u32ins.c b/src/u8c/u32ins.c index f5d9d4e..7fccb7c 100644 --- a/src/u8c/u32ins.c +++ b/src/u8c/u32ins.c @@ -17,11 +17,7 @@ # include <stdbool.h> # include <stddef.h> # include <u8c/SIZE_C.h> -# include <u8c/u32alloc.h> -# include <u8c/u32cat.h> -# include <u8c/u32free.h> -# include <u8c/u32ins.h> -# include <u8c/u32substr.h> +# include <u8c/u32.h> # include <uchar.h> bool u8c_u32ins(size_t * const _sz,char32_t const * * const _out,size_t const _pos,char32_t const * const _str0,char32_t const * const _str1) { assert(_out != NULL); diff --git a/src/u8c/u32substr.c b/src/u8c/u32substr.c index f23cffa..855d062 100644 --- a/src/u8c/u32substr.c +++ b/src/u8c/u32substr.c @@ -17,10 +17,7 @@ # include <stdbool.h> # include <stdlib.h> # include <u8c/SIZE_C.h> -# include <u8c/u32alloc.h> -# include <u8c/u32free.h> -# include <u8c/u32substr.h> -# include <u8c/u32sz.h> +# include <u8c/u32.h> # include <uchar.h> bool u8c_u32substr(char32_t const * * const _out,size_t const _start,size_t const _len,char32_t const * const _in) { assert(_out != NULL); diff --git a/src/u8c/u32sz.c b/src/u8c/u32sz.c index 3320ae2..deb1ecd 100644 --- a/src/u8c/u32sz.c +++ b/src/u8c/u32sz.c @@ -18,8 +18,7 @@ # include <stddef.h> # include <stdint.h> # include <u8c/SIZE_C.h> -# include <u8c/u32fndchr.h> -# include <u8c/u32sz.h> +# include <u8c/u32.h> # include <uchar.h> bool u8c_u32sz(size_t * const _sz,char32_t const * const _in) { assert(_sz != NULL); diff --git a/src/u8c/u8alloc.c b/src/u8c/u8alloc.c index 4e7bc3d..a046a28 100644 --- a/src/u8c/u8alloc.c +++ b/src/u8c/u8alloc.c @@ -13,13 +13,11 @@ If not, see <https://www.gnu.org/licenses/>. */ -# include "dat.h" -# include <setjmp.h> +# include "intern.h" # include <stdbool.h> # include <stdlib.h> -# include <u8c/errtyp.h> -# include <u8c/seterr.h> -# include <u8c/u8alloc.h> +# include <u8c/err.h> +# include <u8c/u8.h> bool u8c_u8alloc(unsigned char * * const _u8,size_t const _sz) { unsigned char * arr = NULL; if((arr = calloc(sizeof *arr,_sz)) == NULL) { diff --git a/src/u8c/u8dec.c b/src/u8c/u8dec.c index 8e9c2f2..a484601 100644 --- a/src/u8c/u8dec.c +++ b/src/u8c/u8dec.c @@ -18,11 +18,9 @@ # include <stddef.h> # include <stdint.h> # include <u8c/SIZE_C.h> -# include <u8c/errtyp.h> -# include <u8c/seterr.h> -# include <u8c/u32alloc.h> -# include <u8c/u32free.h> -# include <u8c/u8dec.h> +# include <u8c/err.h> +# include <u8c/u32.h> +# include <u8c/u8.h> # include <uchar.h> bool u8c_u8dec(size_t * const _sz,char32_t const * * const _out,unsigned char const * const _in) { assert(_out != NULL); diff --git a/src/u8c/u8enc.c b/src/u8c/u8enc.c index 541dd8d..61ccb2a 100644 --- a/src/u8c/u8enc.c +++ b/src/u8c/u8enc.c @@ -18,12 +18,9 @@ # include <stddef.h> # include <stdint.h> # include <u8c/SIZE_C.h> -# include <u8c/errtyp.h> -# include <u8c/seterr.h> -# include <u8c/u8alloc.h> -# include <u8c/u8enc.h> -# include <u8c/u8free.h> -# include <u8c/unimax.h> +# include <u8c/err.h> +# include <u8c/main.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) { assert(_out != NULL); diff --git a/src/u8c/u8free.c b/src/u8c/u8free.c index 4e3a026..af5a6bd 100644 --- a/src/u8c/u8free.c +++ b/src/u8c/u8free.c @@ -16,7 +16,7 @@ # include <stdbool.h> # include <stdint.h> # include <stdlib.h> -# include <u8c/u8free.h> +# include <u8c/u8.h> bool u8c_u8free(unsigned char const * * const _u8) { free((unsigned char *)*_u8); *_u8 = NULL; diff --git a/src/u8c/vfmt.c b/src/u8c/vfmt.c index 292db80..ed7e13f 100644 --- a/src/u8c/vfmt.c +++ b/src/u8c/vfmt.c @@ -15,8 +15,8 @@ */ # include <stdarg.h> # include <stdbool.h> -# include <u8c/u32cp.h> -# include <u8c/vfmt.h> +# include <u8c/fmt.h> +# include <u8c/u32.h> # include <uchar.h> # if defined(u8c_bethrdsafe) # include <threads.h> diff --git a/src/u8c/vprint.c b/src/u8c/vprint.c index a86afcf..7555ce1 100644 --- a/src/u8c/vprint.c +++ b/src/u8c/vprint.c @@ -13,6 +13,7 @@ If not, see <https://www.gnu.org/licenses/>. */ +# include "intern.h" # include <assert.h> # include <stdarg.h> # include <stdbool.h> @@ -20,14 +21,14 @@ # include <stdio.h> # include <stdlib.h> # include <u8c/SIZE_C.h> -# include <u8c/errtyp.h> -# include <u8c/seterr.h> -# include <u8c/u32free.h> -# include <u8c/u8enc.h> -# include <u8c/u8free.h> -# include <u8c/vfmt.h> -# include <u8c/vprint.h> +# include <u8c/err.h> +# include <u8c/fmt.h> +# include <u8c/u32.h> +# include <u8c/u8.h> # include <uchar.h> +# if defined(u8c_bethrdsafe) +# include <threads.h> +# endif bool u8c_vprint(FILE * _fp,char32_t const * const _msg,va_list _args) { assert(_msg != NULL); char32_t const * str0 = NULL; @@ -36,9 +37,18 @@ bool u8c_vprint(FILE * _fp,char32_t const * const _msg,va_list _args) { unsigned char const * str1 = NULL; u8c_u8enc(&str1sz,&str1,str0); assert(str1sz > SIZE_C(0x0)); - if(fwrite(str1,sizeof(uint_least8_t),str1sz - SIZE_C(0x1),_fp) < str1sz - SIZE_C(0x1)) { - u8c_seterr(U"u8c_vprint: fwrite: Unable to write to stdout.",u8c_errtyp_badio); - return true; +# if defined(u8c_bethrdsafe) + mtx_lock(&u8c_dat.outlock); +# endif + { + register size_t const val = fwrite(str1,sizeof(uint_least8_t),str1sz - SIZE_C(0x1),_fp); +# if defined(u8c_bethrdsafe) + mtx_unlock(&u8c_dat.outlock); +# endif + if(val < str1sz - SIZE_C(0x1)) { + u8c_seterr(U"u8c_vprint: fwrite: Unable to write to stdout.",u8c_errtyp_badio); + return true; + } } u8c_u32free(&str0); u8c_u8free(&str1); @@ -5,43 +5,12 @@ # include <stdio.h> # include <stdlib.h> # include <u8c/SIZE_C.h> -# include <u8c/abrt.h> -# include <u8c/col.h> -# include <u8c/dbgprint.h> -# include <u8c/dbg.h> -# include <u8c/end.h> +# include <u8c/err.h> # include <u8c/fmt.h> -# include <u8c/fmttyp.h> -# include <u8c/geterr.h> -# include <u8c/init.h> -# include <u8c/isalnum.h> -# include <u8c/isalpha.h> -# include <u8c/iscntrl.h> -# include <u8c/isdigit.h> -# include <u8c/isxdigit.h> -# include <u8c/ispunct.h> -# include <u8c/isspace.h> -# include <u8c/print.h> -# include <u8c/println.h> -# include <u8c/regerrhandl.h> -# include <u8c/seterr.h> -# include <u8c/setfmt.h> -# include <u8c/thrdsafe.h> -# include <u8c/u32cat.h> -# include <u8c/u32cmp.h> -# include <u8c/u32cp.h> -# include <u8c/u32fndchr.h> -# include <u8c/u32fndpat.h> -# include <u8c/u32free.h> -# include <u8c/u32ins.h> -# include <u8c/u32substr.h> -# include <u8c/u32sz.h> -# include <u8c/u8dec.h> -# include <u8c/u8enc.h> -# include <u8c/u8free.h> -# include <u8c/ver.h> -# include <u8c/vfmt.h> -# include <u8c/vprint.h> +# include <u8c/is.h> +# include <u8c/main.h> +# include <u8c/u32.h> +# include <u8c/u8.h> static void testmsg(char const * fmt,...) { va_list args; va_start(args,fmt); @@ -109,12 +78,12 @@ int main(void) { testmsgdone(); testmsg("Text formatting"); { - u8c_println(stdout,U"The number is .",u8c_fmttyp_fgcol,u8c_col_mint,u8c_fmttyp_fgcol0,u8c_fmttyp_int,(int_least64_t){-0x10}); + u8c_println(stdout,U"The \uFFFCnumber\uFFFC is \uFFFC.",u8c_fmttyp_fgcol,u8c_col_mint,u8c_fmttyp_fgcol0,u8c_fmttyp_int,(int_least64_t){-0x10}); } testmsgdone(); testmsg("Colour text"); { - u8c_println(stdout,U"redorangeyellowchartreusegreenmintcyanazurebluevioletmagentarose",u8c_fmttyp_fgcol,u8c_col_red,u8c_fmttyp_fgcol,u8c_col_orange,u8c_fmttyp_fgcol,u8c_col_yellow,u8c_fmttyp_fgcol,u8c_col_chartreuse,u8c_fmttyp_fgcol,u8c_col_green,u8c_fmttyp_fgcol,u8c_col_mint,u8c_fmttyp_fgcol,u8c_col_cyan,u8c_fmttyp_fgcol,u8c_col_azure,u8c_fmttyp_fgcol,u8c_col_blue,u8c_fmttyp_fgcol,u8c_col_violet,u8c_fmttyp_fgcol,u8c_col_magenta,u8c_fmttyp_fgcol,u8c_col_rose,u8c_fmttyp_fgcol0); + u8c_println(stdout,U"\uFFFCred\uFFFCorange\uFFFCyellow\uFFFCchartreuse\uFFFCgreen\uFFFCmint\uFFFCcyan\uFFFCazure\uFFFCblue\uFFFCviolet\uFFFCmagenta\uFFFCrose\uFFFC",u8c_fmttyp_fgcol,u8c_col_red,u8c_fmttyp_fgcol,u8c_col_orange,u8c_fmttyp_fgcol,u8c_col_yellow,u8c_fmttyp_fgcol,u8c_col_chartreuse,u8c_fmttyp_fgcol,u8c_col_green,u8c_fmttyp_fgcol,u8c_col_mint,u8c_fmttyp_fgcol,u8c_col_cyan,u8c_fmttyp_fgcol,u8c_col_azure,u8c_fmttyp_fgcol,u8c_col_blue,u8c_fmttyp_fgcol,u8c_col_violet,u8c_fmttyp_fgcol,u8c_col_magenta,u8c_fmttyp_fgcol,u8c_col_rose,u8c_fmttyp_fgcol0); } testmsgdone(); testmsg("Combining characters"); @@ -252,7 +221,7 @@ int main(void) { testmsgdone(); testmsg("u8c_u32fndchr"); { - char32_t const * str = U"Proprietary as in Microsoft."; + char32_t const * str = U"Proprietary as in Micro$oft."; size_t pos0 = SIZE_C(0x0); size_t pos1 = SIZE_C(0x0); u8c_u32fndchr(&pos0,str,U'M'); @@ -265,7 +234,7 @@ int main(void) { testmsgdone(); testmsg("u8c_u32fndpat"); { - char32_t const * str = U"Proprietary as in Microsoft."; + char32_t const * str = U"Proprietary as in Micro$oft."; size_t pos0 = SIZE_C(0x0); size_t pos1 = SIZE_C(0x0); u8c_u32fndpat(&pos0,str,U"as in"); |