snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit 4867587032de0237aeff850ddedb1733c1f16073
parent 80ff16b21c7081165d346ff94b450f432a82ee47
Author: shtrophic <shtrophic@noreply.codeberg.org>
Date:   Wed, 20 Nov 2024 18:13:44 +0000

Merge branch 'master' into master

Diffstat:
Mmastoapi.c | 11++++++++++-
Mxs_unicode.h | 24++++++++++++++++++++++++
Mxs_unicode_tbl.h | 15+++++++++++++++
Mxs_version.h | 2+-
4 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/mastoapi.c b/mastoapi.c @@ -827,7 +827,16 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg) st = xs_dict_append(st, "url", id); st = xs_dict_append(st, "account", acct); - xs *fd = mastoapi_date(xs_dict_get(msg, "published")); + const char *published = xs_dict_get(msg, "published"); + xs *fd = NULL; + + if (published) + fd = mastoapi_date(published); + else { + xs *p = xs_str_iso_date(0); + fd = mastoapi_date(p); + } + st = xs_dict_append(st, "created_at", fd); { diff --git a/xs_unicode.h b/xs_unicode.h @@ -21,6 +21,7 @@ int xs_unicode_nfd(unsigned int cpoint, unsigned int *base, unsigned int *diac); int xs_unicode_nfc(unsigned int base, unsigned int diac, unsigned int *cpoint); int xs_unicode_is_alpha(unsigned int cpoint); + int xs_unicode_is_right_to_left(unsigned int cpoint); #ifdef _XS_H xs_str *xs_utf8_insert(xs_str *str, unsigned int cpoint, int *offset); @@ -350,6 +351,29 @@ int xs_unicode_is_alpha(unsigned int cpoint) } +int xs_unicode_is_right_to_left(unsigned int cpoint) +/* checks if a codepoint is a right-to-left letter */ +{ + int b = 0; + int t = xs_countof(xs_unicode_right_to_left_table) / 2 - 1; + + while (t >= b) { + int n = (b + t) / 2; + unsigned int *p = &xs_unicode_right_to_left_table[n * 2]; + + if (cpoint < p[0]) + t = n - 1; + else + if (cpoint > p[1]) + b = n + 1; + else + return 1; + } + + return 0; +} + + #ifdef _XS_H xs_str *xs_utf8_to_upper(const char *str) diff --git a/xs_unicode_tbl.h b/xs_unicode_tbl.h @@ -726,5 +726,20 @@ static unsigned int xs_unicode_alpha_table[] = { 0x1E7E0, 0x1E8C4, 0x1E900, 0x1E943, 0x1EE00, 0x1EEBB, 0x20000, 0x323AF, }; +static unsigned int xs_unicode_right_to_left_table[] = { + 0x05BE, 0x05BE, 0x05C0, 0x05C0, 0x05C3, 0x05C3, 0x05C6, 0x05C6, + 0x05D0, 0x05F4, 0x0608, 0x0608, 0x060B, 0x060B, 0x060D, 0x060D, + 0x061B, 0x064A, 0x066D, 0x066F, 0x0671, 0x06D5, 0x06E5, 0x06E6, + 0x06EE, 0x06EF, 0x06FA, 0x0710, 0x0712, 0x072F, 0x074D, 0x07A5, + 0x07B1, 0x07EA, 0x07F4, 0x07F5, 0x07FA, 0x07FA, 0x07FE, 0x0815, + 0x081A, 0x081A, 0x0824, 0x0824, 0x0828, 0x0828, 0x0830, 0x0858, + 0x085E, 0x088E, 0x08A0, 0x08C9, 0x200F, 0x200F, 0xFB1D, 0xFB1D, + 0xFB1F, 0xFB28, 0xFB2A, 0xFD3D, 0xFD50, 0xFDC7, 0xFDF0, 0xFDFC, + 0xFE70, 0xFEFC, 0x10800, 0x1091B, 0x10920, 0x10A00, 0x10A10, 0x10A35, + 0x10A40, 0x10AE4, 0x10AEB, 0x10B35, 0x10B40, 0x10D23, 0x10E80, 0x10EA9, + 0x10EAD, 0x10EB1, 0x10F00, 0x10F45, 0x10F51, 0x10F81, 0x10F86, 0x10FF6, + 0x1E800, 0x1E8CF, 0x1E900, 0x1E943, 0x1E94B, 0x1EEBB, +}; + #endif /* _XS_UNICODE_TBL_H */ diff --git a/xs_version.h b/xs_version.h @@ -1 +1 @@ -/* 35997d2dbc505320a62d3130daa95f638be8bb26 2024-11-05T16:47:36+01:00 */ +/* ab0749f821f1c98d16cbec53201bdf2ba2a24a43 2024-11-20T17:02:42+01:00 */