diff options
Diffstat (limited to 'lib')
27 files changed, 59 insertions, 59 deletions
diff --git a/lib/cli/optparse.c b/lib/cli/optparse.c index 7134b37..8178b85 100644 --- a/lib/cli/optparse.c +++ b/lib/cli/optparse.c @@ -14,19 +14,19 @@ #define IS_SHORTOPT(s) ((s).len >= 2 && (s).p[0] == '-' && (s).p[1] != '-') #define error(st, msg, x) \ - _Generic((x), struct u8view: error_s, rune: error_r)((st), (msg), (x)) + _Generic((x), u8view_t: error_s, rune: error_r)((st), (msg), (x)) static rune error_r(struct optparser *, const char *, rune); -static rune error_s(struct optparser *, const char *, struct u8view); +static rune error_s(struct optparser *, const char *, u8view_t); static rune shortopt(struct optparser *, const struct cli_option *, size_t); rune optparse(struct optparser *st, const struct cli_option *opts, size_t nopts) { st->errmsg[0] = '\0'; - st->optarg = (struct u8view){}; + st->optarg = (u8view_t){}; - struct u8view opt = {.p = st->_argv[st->optind]}; + u8view_t opt = {.p = st->_argv[st->optind]}; if (opt.p == nullptr) return 0; opt.len = strlen(opt.p); @@ -48,13 +48,13 @@ optparse(struct optparser *st, const struct cli_option *opts, size_t nopts) const struct cli_option *o = nullptr; const char8_t *eq_p = u8chr(opt, '='); - struct u8view opt_no_eq = { + u8view_t opt_no_eq = { .p = opt.p, .len = eq_p == nullptr ? opt.len : (size_t)(eq_p - opt.p), }; for (size_t i = 0; i < nopts; i++) { - struct u8view lo = opts[i].longopt; + u8view_t lo = opts[i].longopt; if (lo.p == nullptr || !u8haspfx(lo, opt_no_eq)) continue; if (o != nullptr) @@ -72,10 +72,10 @@ optparse(struct optparser *st, const struct cli_option *opts, size_t nopts) break; case CLI_OPT: if (eq_p == nullptr) - st->optarg = (struct u8view){}; + st->optarg = (u8view_t){}; else { ASSUME(opt.len > opt_no_eq.len); - st->optarg = (struct u8view){ + st->optarg = (u8view_t){ .p = eq_p + 1, .len = opt.len - opt_no_eq.len + 1, }; @@ -89,7 +89,7 @@ optparse(struct optparser *st, const struct cli_option *opts, size_t nopts) st->optarg.len = strlen(st->optarg.p); } else { ASSUME(opt.len > opt_no_eq.len); - st->optarg = (struct u8view){ + st->optarg = (u8view_t){ .p = eq_p + 1, .len = opt.len - opt_no_eq.len + 1, }; @@ -124,11 +124,11 @@ shortopt(struct optparser *st, const struct cli_option *opts, size_t nopts) goto out; } if (opts[i].argtype == CLI_OPT) { - st->optarg = (struct u8view){}; + st->optarg = (u8view_t){}; goto out; } if (st->_argv[st->optind + 1] == nullptr) { - st->optarg = (struct u8view){}; + st->optarg = (u8view_t){}; return error(st, CLI_MSG_MISSING, ch); } st->optarg.p = st->_argv[st->optind + 1]; @@ -142,7 +142,7 @@ out: } rune -error_s(struct optparser *st, const char *msg, struct u8view s) +error_s(struct optparser *st, const char *msg, u8view_t s) { snprintf(st->errmsg, sizeof(st->errmsg), u8"%s ā ā%.*sā", msg, SV_PRI_ARGS(s)); diff --git a/lib/mbstring/u8chk.c b/lib/mbstring/u8chk.c index bf93005..332a450 100644 --- a/lib/mbstring/u8chk.c +++ b/lib/mbstring/u8chk.c @@ -2,7 +2,7 @@ #include "rune.h" const char8_t * -u8chk(struct u8view sv) +u8chk(u8view_t sv) { int w; rune ch; diff --git a/lib/mbstring/u8chr.c b/lib/mbstring/u8chr.c index 4831695..5ddcdd8 100644 --- a/lib/mbstring/u8chr.c +++ b/lib/mbstring/u8chr.c @@ -74,7 +74,7 @@ memmem4(const char8_t *h, size_t k, const char8_t *n) } const char8_t * -u8chr(struct u8view sv, rune ch) +u8chr(u8view_t sv, rune ch) { char8_t buf[U8_LEN_MAX]; int m = rtou8(buf, sizeof(buf), ch); diff --git a/lib/mbstring/u8cmp.c b/lib/mbstring/u8cmp.c index e54f984..5c56878 100644 --- a/lib/mbstring/u8cmp.c +++ b/lib/mbstring/u8cmp.c @@ -6,7 +6,7 @@ y.len both being 0 */ int -u8cmp(struct u8view x, struct u8view y) +u8cmp(u8view_t x, u8view_t y) { if (x.len != y.len) return x.len > y.len ? +1 : -1; diff --git a/lib/mbstring/u8cspn.c b/lib/mbstring/u8cspn.c index 827373f..cdeb659 100644 --- a/lib/mbstring/u8cspn.c +++ b/lib/mbstring/u8cspn.c @@ -1,7 +1,7 @@ #include "mbstring.h" size_t -u8cspn(struct u8view sv, const rune *p, size_t n) +u8cspn(u8view_t sv, const rune *p, size_t n) { rune ch; size_t k, w; diff --git a/lib/mbstring/u8cut.c b/lib/mbstring/u8cut.c index 3dd9663..36df561 100644 --- a/lib/mbstring/u8cut.c +++ b/lib/mbstring/u8cut.c @@ -2,7 +2,7 @@ #include "mbstring.h" rune -u8cut(struct u8view *restrict x, struct u8view *restrict y, const rune *seps, +u8cut(u8view_t *restrict x, u8view_t *restrict y, const rune *seps, size_t n) { ASSUME(y != nullptr); diff --git a/lib/mbstring/u8haspfx.c b/lib/mbstring/u8haspfx.c index c61efbb..abc5e76 100644 --- a/lib/mbstring/u8haspfx.c +++ b/lib/mbstring/u8haspfx.c @@ -4,7 +4,7 @@ #include "mbstring.h" bool -u8haspfx(struct u8view sv, struct u8view pfx) +u8haspfx(u8view_t sv, u8view_t pfx) { return sv.len >= pfx.len && memeq(sv.p, pfx.p, pfx.len); } diff --git a/lib/mbstring/u8hassfx.c b/lib/mbstring/u8hassfx.c index 8ea4456..ac72778 100644 --- a/lib/mbstring/u8hassfx.c +++ b/lib/mbstring/u8hassfx.c @@ -4,7 +4,7 @@ #include "mbstring.h" bool -u8hassfx(struct u8view sv, struct u8view sfx) +u8hassfx(u8view_t sv, u8view_t sfx) { return sv.len >= sfx.len && memeq(sv.p + sv.len - sfx.len, sfx.p, sfx.len); } diff --git a/lib/mbstring/u8len.c b/lib/mbstring/u8len.c index 23c55c5..26696a3 100644 --- a/lib/mbstring/u8len.c +++ b/lib/mbstring/u8len.c @@ -1,7 +1,7 @@ #include "mbstring.h" size_t -u8len(struct u8view sv) +u8len(u8view_t sv) { size_t m = 0; while (u8next(nullptr, &sv)) diff --git a/lib/mbstring/u8next.c b/lib/mbstring/u8next.c index 518de49..fe2dabf 100644 --- a/lib/mbstring/u8next.c +++ b/lib/mbstring/u8next.c @@ -1,7 +1,7 @@ #include "mbstring.h" int -u8next(rune *ch, struct u8view *sv) +u8next(rune *ch, u8view_t *sv) { int n = 0; diff --git a/lib/mbstring/u8rchr.c b/lib/mbstring/u8rchr.c index 825f8fd..47eaa4c 100644 --- a/lib/mbstring/u8rchr.c +++ b/lib/mbstring/u8rchr.c @@ -64,7 +64,7 @@ memrchr4(const char8_t *h, size_t k, const char8_t *n) } const char8_t * -u8rchr(struct u8view sv, rune ch) +u8rchr(u8view_t sv, rune ch) { char8_t buf[U8_LEN_MAX]; int n = rtou8(buf, ch, sizeof(buf)); diff --git a/lib/mbstring/u8spn.c b/lib/mbstring/u8spn.c index d41fcbc..f704ff8 100644 --- a/lib/mbstring/u8spn.c +++ b/lib/mbstring/u8spn.c @@ -1,7 +1,7 @@ #include "mbstring.h" size_t -u8spn(struct u8view sv, const rune *p, size_t n) +u8spn(u8view_t sv, const rune *p, size_t n) { rune ch; size_t k = 0, w; diff --git a/lib/unicode/prop/uprop_blkname.c b/lib/unicode/prop/uprop_blkname.c index 490f133..d55d731 100644 --- a/lib/unicode/prop/uprop_blkname.c +++ b/lib/unicode/prop/uprop_blkname.c @@ -4,7 +4,7 @@ #define _(...) \ {(const char8_t []){__VA_ARGS__}, sizeof((const char8_t []){__VA_ARGS__})} -static const struct u8view lookup[] = { +static const u8view_t lookup[] = { [BLK_NB] = _('N', 'o', ' ', 'B', 'l', 'o', 'c', 'k'), [BLK_ADLAM] = _('A', 'd', 'l', 'a', 'm'), [BLK_AEGEAN_NUMBERS] = _('A', 'e', 'g', 'e', 'a', 'n', ' ', 'N', 'u', 'm', 'b', 'e', 'r', 's'), @@ -336,7 +336,7 @@ static const struct u8view lookup[] = { [BLK_ZNAMENNY_MUSIC] = _('Z', 'n', 'a', 'm', 'e', 'n', 'n', 'y', ' ', 'M', 'u', 's', 'i', 'c', 'a', 'l', ' ', 'N', 'o', 't', 'a', 't', 'i', 'o', 'n'), }; -struct u8view +u8view_t uprop_blkname(enum uprop_blk blk) { ASSUME(blk < lengthof(lookup)); diff --git a/lib/unicode/prop/uprop_get_na.c b/lib/unicode/prop/uprop_get_na.c index f9df254..9b51838 100644 --- a/lib/unicode/prop/uprop_get_na.c +++ b/lib/unicode/prop/uprop_get_na.c @@ -7,7 +7,7 @@ #define _(...) \ {(const char8_t []){__VA_ARGS__}, sizeof((const char8_t []){__VA_ARGS__})} -static const struct u8view lookup[] = { +static const u8view_t lookup[] = { [RUNE_C(0x000020)] = _('S', 'P', 'A', 'C', 'E'), [RUNE_C(0x000021)] = _('E', 'X', 'C', 'L', 'A', 'M', 'A', 'T', 'I', 'O', 'N', ' ', 'M', 'A', 'R', 'K'), [RUNE_C(0x000022)] = _('Q', 'U', 'O', 'T', 'A', 'T', 'I', 'O', 'N', ' ', 'M', 'A', 'R', 'K'), @@ -34838,8 +34838,8 @@ static const struct u8view lookup[] = { [RUNE_C(0x0E01EF)] = _('V', 'A', 'R', 'I', 'A', 'T', 'I', 'O', 'N', ' ', 'S', 'E', 'L', 'E', 'C', 'T', 'O', 'R', '-', '2', '5', '6'), }; -struct u8view +u8view_t uprop_get_na(rune ch) { - return ch < lengthof(lookup) ? lookup[ch] : (struct u8view){}; + return ch < lengthof(lookup) ? lookup[ch] : (u8view_t){}; } diff --git a/lib/unicode/prop/uprop_get_na1.c b/lib/unicode/prop/uprop_get_na1.c index d1b9ec9..ac6fe06 100644 --- a/lib/unicode/prop/uprop_get_na1.c +++ b/lib/unicode/prop/uprop_get_na1.c @@ -7,7 +7,7 @@ #define _(...) \ {(const char8_t []){__VA_ARGS__}, sizeof((const char8_t []){__VA_ARGS__})} -static const struct u8view lookup[] = { +static const u8view_t lookup[] = { [RUNE_C(0x000000)] = _('N', 'U', 'L', 'L'), [RUNE_C(0x000001)] = _('S', 'T', 'A', 'R', 'T', ' ', 'O', 'F', ' ', 'H', 'E', 'A', 'D', 'I', 'N', 'G'), [RUNE_C(0x000002)] = _('S', 'T', 'A', 'R', 'T', ' ', 'O', 'F', ' ', 'T', 'E', 'X', 'T'), @@ -1988,8 +1988,8 @@ static const struct u8view lookup[] = { [RUNE_C(0x00FFE4)] = _('F', 'U', 'L', 'L', 'W', 'I', 'D', 'T', 'H', ' ', 'B', 'R', 'O', 'K', 'E', 'N', ' ', 'V', 'E', 'R', 'T', 'I', 'C', 'A', 'L', ' ', 'B', 'A', 'R'), }; -struct u8view +u8view_t uprop_get_na1(rune ch) { - return ch < lengthof(lookup) ? lookup[ch] : (struct u8view){}; + return ch < lengthof(lookup) ? lookup[ch] : (u8view_t){}; } diff --git a/lib/unicode/string/u8casefold.c b/lib/unicode/string/u8casefold.c index c7694a9..e3a3402 100644 --- a/lib/unicode/string/u8casefold.c +++ b/lib/unicode/string/u8casefold.c @@ -7,7 +7,7 @@ #include "unicode/string.h" char8_t * -u8casefold(size_t *dstn, struct u8view sv, enum caseflags flags, alloc_fn alloc, +u8casefold(size_t *dstn, u8view_t sv, enum caseflags flags, alloc_fn alloc, void *alloc_ctx) { ASSUME(dstn != nullptr); diff --git a/lib/unicode/string/u8gcnt.c b/lib/unicode/string/u8gcnt.c index 6dfc519..bea30fa 100644 --- a/lib/unicode/string/u8gcnt.c +++ b/lib/unicode/string/u8gcnt.c @@ -1,7 +1,7 @@ #include "unicode/string.h" size_t -u8gcnt(struct u8view sv) +u8gcnt(u8view_t sv) { size_t m = 0; while (u8gnext(nullptr, &sv)) diff --git a/lib/unicode/string/u8gnext.c b/lib/unicode/string/u8gnext.c index 272711f..7c551f7 100644 --- a/lib/unicode/string/u8gnext.c +++ b/lib/unicode/string/u8gnext.c @@ -17,7 +17,7 @@ struct gbrk_state { static bool u8isgbrk(rune, rune, struct gbrk_state *); size_t -u8gnext(struct u8view *g, struct u8view *sv) +u8gnext(u8view_t *g, u8view_t *sv) { int m; rune ch1; diff --git a/lib/unicode/string/u8lower.c b/lib/unicode/string/u8lower.c index cd6a79f..2b1ec36 100644 --- a/lib/unicode/string/u8lower.c +++ b/lib/unicode/string/u8lower.c @@ -17,7 +17,7 @@ uprop_ccc_0_or_230(rune ch) } char8_t * -u8lower(size_t *dstn, struct u8view sv, enum caseflags flags, alloc_fn alloc, +u8lower(size_t *dstn, u8view_t sv, enum caseflags flags, alloc_fn alloc, void *alloc_ctx) { ASSUME(dstn != nullptr); @@ -57,7 +57,7 @@ u8lower(size_t *dstn, struct u8view sv, enum caseflags flags, alloc_fn alloc, if (before_dot_cnt == 0 || more_above_cnt == 0) { rune ch = 0; before_dot_cnt = more_above_cnt = 0; - struct u8view cpy = sv; + u8view_t cpy = sv; do { before_dot_cnt++; @@ -76,7 +76,7 @@ u8lower(size_t *dstn, struct u8view sv, enum caseflags flags, alloc_fn alloc, if (final_sigma.after == 0) { rune ch = 0; - struct u8view cpy = sv; + u8view_t cpy = sv; do final_sigma.after++; diff --git a/lib/unicode/string/u8norm.c b/lib/unicode/string/u8norm.c index 91c6aa5..02156ea 100644 --- a/lib/unicode/string/u8norm.c +++ b/lib/unicode/string/u8norm.c @@ -39,7 +39,7 @@ static const qcfn qc_lookup[] = { }; char8_t * -u8norm(size_t *dstn, struct u8view src, alloc_fn alloc, void *ctx, +u8norm(size_t *dstn, u8view_t src, alloc_fn alloc, void *ctx, enum normform nf) { ASSUME(dstn != nullptr); @@ -48,7 +48,7 @@ u8norm(size_t *dstn, struct u8view src, alloc_fn alloc, void *ctx, { qcfn f = qc_lookup[nf]; - struct u8view sv = src; + u8view_t sv = src; enum uprop_ccc prvcc = 0, curcc; for (rune ch; ucsnext(&ch, &sv) != 0; prvcc = curcc) { curcc = uprop_get_ccc(ch); @@ -143,7 +143,7 @@ compbuf(char8_t *dst, size_t *dstn) { int wC, wL; rune C, L; - struct u8view sv = {dst, *dstn}; + u8view_t sv = {dst, *dstn}; while ((wL = ucsnext(&L, &sv)) != 0) { if (uprop_get_ccc(L) != CCC_NR) @@ -151,7 +151,7 @@ compbuf(char8_t *dst, size_t *dstn) char8_t *after_L = (char8_t *)sv.p; enum uprop_ccc prevcc = 0; - struct u8view sv_ = sv; + u8view_t sv_ = sv; while ((wC = ucsnext(&C, &sv_)) != 0) { enum uprop_ccc curcc = uprop_get_ccc(C); diff --git a/lib/unicode/string/u8title.c b/lib/unicode/string/u8title.c index 45bb37c..3a85f4d 100644 --- a/lib/unicode/string/u8title.c +++ b/lib/unicode/string/u8title.c @@ -18,7 +18,7 @@ uprop_ccc_0_or_230(rune ch) } char8_t * -u8title(size_t *dstn, struct u8view sv, enum caseflags flags, alloc_fn alloc, +u8title(size_t *dstn, u8view_t sv, enum caseflags flags, alloc_fn alloc, void *alloc_ctx) { ASSUME(dstn != nullptr); @@ -33,7 +33,7 @@ u8title(size_t *dstn, struct u8view sv, enum caseflags flags, alloc_fn alloc, rune ch; bool nl_IJ = false; size_t n, before_dot_cnt, more_above_cnt; - struct u8view word = {}, wcpy = sv; + u8view_t word = {}, wcpy = sv; struct { bool before; size_t after; @@ -65,7 +65,7 @@ u8title(size_t *dstn, struct u8view sv, enum caseflags flags, alloc_fn alloc, if (before_dot_cnt == 0 || more_above_cnt == 0) { rune ch = 0; before_dot_cnt = more_above_cnt = 0; - struct u8view cpy = sv; + u8view_t cpy = sv; do { before_dot_cnt++; @@ -84,7 +84,7 @@ u8title(size_t *dstn, struct u8view sv, enum caseflags flags, alloc_fn alloc, if (final_sigma.after == 0) { rune ch = 0; - struct u8view cpy = sv; + u8view_t cpy = sv; do final_sigma.after++; diff --git a/lib/unicode/string/u8upper.c b/lib/unicode/string/u8upper.c index 4c47613..a77fcd8 100644 --- a/lib/unicode/string/u8upper.c +++ b/lib/unicode/string/u8upper.c @@ -7,7 +7,7 @@ #include "unicode/string.h" char8_t * -u8upper(size_t *dstn, struct u8view sv, enum caseflags flags, alloc_fn alloc, +u8upper(size_t *dstn, u8view_t sv, enum caseflags flags, alloc_fn alloc, void *alloc_ctx) { ASSUME(dstn != nullptr); diff --git a/lib/unicode/string/u8wcnt.c b/lib/unicode/string/u8wcnt.c index f71faf5..fb34dad 100644 --- a/lib/unicode/string/u8wcnt.c +++ b/lib/unicode/string/u8wcnt.c @@ -1,7 +1,7 @@ #include "unicode/string.h" size_t -u8wcnt(struct u8view sv) +u8wcnt(u8view_t sv) { size_t m = 0; while (u8wnext(nullptr, &sv)) diff --git a/lib/unicode/string/u8wcnt_human.c b/lib/unicode/string/u8wcnt_human.c index 60e7f95..f3377ee 100644 --- a/lib/unicode/string/u8wcnt_human.c +++ b/lib/unicode/string/u8wcnt_human.c @@ -1,7 +1,7 @@ #include "unicode/string.h" size_t -u8wcnt_human(struct u8view sv) +u8wcnt_human(u8view_t sv) { size_t m = 0; while (u8wnext_human(nullptr, &sv)) diff --git a/lib/unicode/string/u8wdth.c b/lib/unicode/string/u8wdth.c index 7a58069..db51b06 100644 --- a/lib/unicode/string/u8wdth.c +++ b/lib/unicode/string/u8wdth.c @@ -3,7 +3,7 @@ #include "unicode/string.h" size_t -u8wdth(struct u8view sv, int ts) +u8wdth(u8view_t sv, int ts) { rune ch; size_t n = 0; diff --git a/lib/unicode/string/u8wnext.c b/lib/unicode/string/u8wnext.c index 7590884..493ec9f 100644 --- a/lib/unicode/string/u8wnext.c +++ b/lib/unicode/string/u8wnext.c @@ -17,16 +17,16 @@ struct wbrk_state { struct { enum uprop_wbrk prev[2], next[2]; } raw, skip; - struct u8view raw_v, skip_v, mid_v; + u8view_t raw_v, skip_v, mid_v; int ri_parity : 1; }; static bool advance(struct wbrk_state *); -static size_t findwbrk(struct u8view); -static struct wbrk_state mkwbrkstate(struct u8view); +static size_t findwbrk(u8view_t); +static struct wbrk_state mkwbrkstate(u8view_t); size_t -u8wnext(struct u8view *w, struct u8view *sv) +u8wnext(u8view_t *w, u8view_t *sv) { ASSUME(sv != nullptr); ASSUME(sv->p != nullptr); @@ -36,7 +36,7 @@ u8wnext(struct u8view *w, struct u8view *sv) size_t off = findwbrk(*sv); if (w != nullptr) - *w = (struct u8view){sv->p, off}; + *w = (u8view_t){sv->p, off}; ASSUME(sv->len >= off); VSHFT(sv, off); @@ -44,7 +44,7 @@ u8wnext(struct u8view *w, struct u8view *sv) } size_t -findwbrk(struct u8view sv) +findwbrk(u8view_t sv) { ASSUME(sv.p != nullptr); @@ -177,7 +177,7 @@ findwbrk(struct u8view sv) } struct wbrk_state -mkwbrkstate(struct u8view sv) +mkwbrkstate(u8view_t sv) { struct wbrk_state ws = { .raw = {{WBRK_EOT, WBRK_EOT}, {WBRK_EOT, WBRK_EOT}}, diff --git a/lib/unicode/string/u8wnext_human.c b/lib/unicode/string/u8wnext_human.c index 953d942..0f750c9 100644 --- a/lib/unicode/string/u8wnext_human.c +++ b/lib/unicode/string/u8wnext_human.c @@ -4,15 +4,15 @@ #include "unicode/string.h" size_t -u8wnext_human(struct u8view *dst, struct u8view *sv) +u8wnext_human(u8view_t *dst, u8view_t *sv) { ASSUME(sv != nullptr); ASSUME(sv->p != nullptr); - struct u8view w; + u8view_t w; while (u8wnext(&w, sv)) { rune ch; - struct u8view cpy = w; + u8view_t cpy = w; while (u8next(&ch, &cpy)) { if (uprop_get_gc(ch) & (GC_L | GC_N)) { if (dst != nullptr) |