diff options
Diffstat (limited to 'src')
39 files changed, 446 insertions, 436 deletions
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/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/src/u8c/u16alloc.c b/src/u8c/u16alloc.c new file mode 100644 index 0000000..2945e79 --- /dev/null +++ b/src/u8c/u16alloc.c @@ -0,0 +1,30 @@ +/* + 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/>. +*/ +# include "intern.h" +# include <stdbool.h> +# include <stdlib.h> +# include <u8c/err.h> +# include <u8c/u16.h> +# include <uchar.h> +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/src/u8c/dat.h b/src/u8c/u16free.c index fdda8c7..d447562 100644 --- a/src/u8c/dat.h +++ b/src/u8c/u16free.c @@ -13,9 +13,12 @@ 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 +# include <stdbool.h> +# include <stdint.h> +# 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); |