summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar shtrophic2024-11-20 18:13:44 +0000
committerGravatar shtrophic2024-11-20 18:13:44 +0000
commit4867587032de0237aeff850ddedb1733c1f16073 (patch)
treea6da07b5cf657a3c93d5276fdfd041a9e0fbe403
parentmake sendmail executable if configured (diff)
parentNew function xs_unicode_right_to_left(). (diff)
downloadpenes-snac2-4867587032de0237aeff850ddedb1733c1f16073.tar.gz
penes-snac2-4867587032de0237aeff850ddedb1733c1f16073.tar.xz
penes-snac2-4867587032de0237aeff850ddedb1733c1f16073.zip
Merge branch 'master' into master
-rw-r--r--mastoapi.c11
-rw-r--r--xs_unicode.h24
-rw-r--r--xs_unicode_tbl.h15
-rw-r--r--xs_version.h2
4 files changed, 50 insertions, 2 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 1dd91dc..a529990 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -827,7 +827,16 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
827 st = xs_dict_append(st, "url", id); 827 st = xs_dict_append(st, "url", id);
828 st = xs_dict_append(st, "account", acct); 828 st = xs_dict_append(st, "account", acct);
829 829
830 xs *fd = mastoapi_date(xs_dict_get(msg, "published")); 830 const char *published = xs_dict_get(msg, "published");
831 xs *fd = NULL;
832
833 if (published)
834 fd = mastoapi_date(published);
835 else {
836 xs *p = xs_str_iso_date(0);
837 fd = mastoapi_date(p);
838 }
839
831 st = xs_dict_append(st, "created_at", fd); 840 st = xs_dict_append(st, "created_at", fd);
832 841
833 { 842 {
diff --git a/xs_unicode.h b/xs_unicode.h
index 9663190..cfcd8ff 100644
--- a/xs_unicode.h
+++ b/xs_unicode.h
@@ -21,6 +21,7 @@
21 int xs_unicode_nfd(unsigned int cpoint, unsigned int *base, unsigned int *diac); 21 int xs_unicode_nfd(unsigned int cpoint, unsigned int *base, unsigned int *diac);
22 int xs_unicode_nfc(unsigned int base, unsigned int diac, unsigned int *cpoint); 22 int xs_unicode_nfc(unsigned int base, unsigned int diac, unsigned int *cpoint);
23 int xs_unicode_is_alpha(unsigned int cpoint); 23 int xs_unicode_is_alpha(unsigned int cpoint);
24 int xs_unicode_is_right_to_left(unsigned int cpoint);
24 25
25#ifdef _XS_H 26#ifdef _XS_H
26 xs_str *xs_utf8_insert(xs_str *str, unsigned int cpoint, int *offset); 27 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)
350} 351}
351 352
352 353
354int xs_unicode_is_right_to_left(unsigned int cpoint)
355/* checks if a codepoint is a right-to-left letter */
356{
357 int b = 0;
358 int t = xs_countof(xs_unicode_right_to_left_table) / 2 - 1;
359
360 while (t >= b) {
361 int n = (b + t) / 2;
362 unsigned int *p = &xs_unicode_right_to_left_table[n * 2];
363
364 if (cpoint < p[0])
365 t = n - 1;
366 else
367 if (cpoint > p[1])
368 b = n + 1;
369 else
370 return 1;
371 }
372
373 return 0;
374}
375
376
353#ifdef _XS_H 377#ifdef _XS_H
354 378
355xs_str *xs_utf8_to_upper(const char *str) 379xs_str *xs_utf8_to_upper(const char *str)
diff --git a/xs_unicode_tbl.h b/xs_unicode_tbl.h
index ecd537b..ee8ce97 100644
--- a/xs_unicode_tbl.h
+++ b/xs_unicode_tbl.h
@@ -726,5 +726,20 @@ static unsigned int xs_unicode_alpha_table[] = {
726 0x1E7E0, 0x1E8C4, 0x1E900, 0x1E943, 0x1EE00, 0x1EEBB, 0x20000, 0x323AF, 726 0x1E7E0, 0x1E8C4, 0x1E900, 0x1E943, 0x1EE00, 0x1EEBB, 0x20000, 0x323AF,
727}; 727};
728 728
729static unsigned int xs_unicode_right_to_left_table[] = {
730 0x05BE, 0x05BE, 0x05C0, 0x05C0, 0x05C3, 0x05C3, 0x05C6, 0x05C6,
731 0x05D0, 0x05F4, 0x0608, 0x0608, 0x060B, 0x060B, 0x060D, 0x060D,
732 0x061B, 0x064A, 0x066D, 0x066F, 0x0671, 0x06D5, 0x06E5, 0x06E6,
733 0x06EE, 0x06EF, 0x06FA, 0x0710, 0x0712, 0x072F, 0x074D, 0x07A5,
734 0x07B1, 0x07EA, 0x07F4, 0x07F5, 0x07FA, 0x07FA, 0x07FE, 0x0815,
735 0x081A, 0x081A, 0x0824, 0x0824, 0x0828, 0x0828, 0x0830, 0x0858,
736 0x085E, 0x088E, 0x08A0, 0x08C9, 0x200F, 0x200F, 0xFB1D, 0xFB1D,
737 0xFB1F, 0xFB28, 0xFB2A, 0xFD3D, 0xFD50, 0xFDC7, 0xFDF0, 0xFDFC,
738 0xFE70, 0xFEFC, 0x10800, 0x1091B, 0x10920, 0x10A00, 0x10A10, 0x10A35,
739 0x10A40, 0x10AE4, 0x10AEB, 0x10B35, 0x10B40, 0x10D23, 0x10E80, 0x10EA9,
740 0x10EAD, 0x10EB1, 0x10F00, 0x10F45, 0x10F51, 0x10F81, 0x10F86, 0x10FF6,
741 0x1E800, 0x1E8CF, 0x1E900, 0x1E943, 0x1E94B, 0x1EEBB,
742};
743
729#endif /* _XS_UNICODE_TBL_H */ 744#endif /* _XS_UNICODE_TBL_H */
730 745
diff --git a/xs_version.h b/xs_version.h
index 84f7c5b..7c4246b 100644
--- 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 */