commit 4520030

grunfink  ·  2026-09-14 14:29:48 +0000 UTC
parent f378194
Renamed xs_utf8_toupper() and xs_utf8_tolower().
6 files changed,  +25, -25
M data.c
M html.c
+2, -2
 1@@ -425,7 +425,7 @@ int hashtag_in_msg(const xs_list *hashtags, const xs_dict *msg)
 2 
 3                     if (xs_is_string(type) && xs_is_string(name)) {
 4                         if (strcmp(type, "Hashtag") == 0) {
 5-                            xs *lc_name = xs_utf8_to_lower(name);
 6+                            xs *lc_name = xs_utf8_tolower(name);
 7 
 8                             if (xs_list_in(hashtags, lc_name) != -1)
 9                                 return 1;
10@@ -1009,7 +1009,7 @@ xs_str *process_tags(snac *snac, const char *content, xs_list **tag)
11             if (*v == '#') {
12                 /* hashtag */
13                 xs *d = xs_dict_new();
14-                xs *n = xs_utf8_to_lower(v);
15+                xs *n = xs_utf8_tolower(v);
16                 xs *h = xs_fmt("%s?t=%s", srv_baseurl, n + 1);
17                 xs *l = xs_fmt("<a href=\"%s\" class=\"mention hashtag\" rel=\"tag\">%s</a>", h, v);
18 
M data.c
+5, -5
 1@@ -2477,7 +2477,7 @@ void tag_index(const char *id, const xs_dict *obj)
 2                 if (*name == '\0')
 3                     continue;
 4 
 5-                xs* name_cased = xs_utf8_to_lower((xs_str *)name);
 6+                xs* name_cased = xs_utf8_tolower((xs_str *)name);
 7 
 8                 xs *md5_tag   = xs_md5_hex(name_cased, strlen(name_cased));
 9                 xs *tag_dir   = xs_fmt("%s/%c%c", g_tag_dir, md5_tag[0], md5_tag[1]);
10@@ -2507,7 +2507,7 @@ xs_str *tag_fn(const char *tag)
11     if (*tag == '#')
12         tag++;
13 
14-    xs *lw_tag = xs_utf8_to_lower(tag);
15+    xs *lw_tag = xs_utf8_tolower(tag);
16     xs *md5    = xs_md5_hex(lw_tag, strlen(lw_tag));
17 
18     return xs_fmt("%s/tag/%c%c/%s.idx", srv_basedir, md5[0], md5[1], md5);
19@@ -3102,7 +3102,7 @@ int content_match(const char *file, const xs_dict *msg)
20             /* massage content (strip HTML tags, etc.) */
21             xs *c1 = xs_regex_replace(v, "<[^>]+>", " ");
22             c1 = xs_regex_replace_i(c1, " {2,}", " ");
23-            xs *c = xs_utf8_to_lower(c1);
24+            xs *c = xs_utf8_tolower(c1);
25 
26             while (!r && !feof(f)) {
27                 xs *rx = xs_strip_i(xs_readline(f));
28@@ -3128,7 +3128,7 @@ xs_list *content_search(snac *user, const char *regex,
29     if (regex == NULL || *regex == '\0')
30         return xs_list_new();
31 
32-    xs *i_regex = xs_utf8_to_lower(regex);
33+    xs *i_regex = xs_utf8_tolower(regex);
34 
35     xs_set seen;
36 
37@@ -3261,7 +3261,7 @@ xs_list *content_search(snac *user, const char *regex,
38         c = xs_regex_replace_i(c, " {2,}", " ");
39 
40         /* convert to lowercase */
41-        xs *lc = xs_utf8_to_lower(c);
42+        xs *lc = xs_utf8_tolower(c);
43 
44         /* apply regex */
45         if (xs_regex_match(lc, i_regex)) {
+1, -1
1@@ -489,7 +489,7 @@ xs_str *sanitize(const char *content)
2         if (n & 0x1) {
3             xs *s1  = xs_strip_i(xs_crop_i(xs_dup(v), v[1] == '/' ? 2 : 1, -1));
4             xs *l1  = xs_split_n(s1, " ", 1);
5-            xs *tag = xs_utf8_to_lower(xs_list_get(l1, 0));
6+            xs *tag = xs_utf8_tolower(xs_list_get(l1, 0));
7             xs *s2  = NULL;
8             int i;
9 
M html.c
+6, -6
 1@@ -173,7 +173,7 @@ xs_str *actor_pronouns(xs_dict *actor)
 2 
 3     if (xs_is_list((attachment = xs_dict_get(actor, "attachment")))) {
 4         xs_list_foreach(attachment, d) {
 5-            xs *prop = xs_utf8_to_lower(xs_dict_get(d, "name"));
 6+            xs *prop = xs_utf8_tolower(xs_dict_get(d, "name"));
 7             /* make sure that we are reading the correct metadata */
 8             if (strlen(prop) == 8 && strcmp(prop, "pronouns") == 0) {
 9                 /* safeguard from NULL values */
10@@ -3295,7 +3295,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
11     const char *o_content = xs_dict_get_def(msg, "content", "");
12 
13     if (xs_is_string(o_content) && xs_is_list(tags) && xs_list_len(tags)) {
14-        xs *content = xs_utf8_to_lower(o_content);
15+        xs *content = xs_utf8_tolower(o_content);
16         const xs_dict *tag;
17 
18         xs_html *add_hashtags = xs_html_tag("ul",
19@@ -3309,7 +3309,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
20                 const char *name   = xs_dict_get(tag, "name");
21 
22                 if (xs_is_string(o_href) && xs_is_string(name)) {
23-                    xs *href = xs_utf8_to_lower(o_href);
24+                    xs *href = xs_utf8_tolower(o_href);
25 
26                     if (xs_str_in(content, href) == -1 && xs_str_in(content, name) == -1) {
27                         /* not in the content: add here */
28@@ -6297,7 +6297,7 @@ int html_post_handler(const xs_dict *req, const char *q_path,
29                 if (xs_startswith(s1, "https:/"))
30                     s2 = xs_dup(s1);
31                 else {
32-                    s2 = xs_utf8_to_lower(s1);
33+                    s2 = xs_utf8_tolower(s1);
34 
35                     if (*s2 != '#')
36                         s2 = xs_str_prepend_i(s2, "#");
37@@ -6331,7 +6331,7 @@ int html_post_handler(const xs_dict *req, const char *q_path,
38                 if (*s1 == '\0')
39                     continue;
40 
41-                xs *s2 = xs_utf8_to_lower(s1);
42+                xs *s2 = xs_utf8_tolower(s1);
43                 if (*s2 != '#')
44                     s2 = xs_str_prepend_i(s2, "#");
45 
46@@ -6360,7 +6360,7 @@ int html_post_handler(const xs_dict *req, const char *q_path,
47                 if (*s1 == '\0')
48                     continue;
49 
50-                xs *s2 = xs_utf8_to_lower(s1);
51+                xs *s2 = xs_utf8_tolower(s1);
52 
53                 new_words = xs_list_insert_sorted(new_words, s2);
54             }
+1, -1
1@@ -1954,7 +1954,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
2                 const char *aq = xs_dict_get(args, "q");
3 
4                 if (!xs_is_null(aq)) {
5-                    xs *q    = xs_utf8_to_lower(aq);
6+                    xs *q    = xs_utf8_tolower(aq);
7                     out      = xs_list_new();
8                     xs *wing = following_list(&snac1);
9                     xs *wers = follower_list(&snac1);
+10, -10
 1@@ -16,8 +16,8 @@
 2  unsigned int *_xs_unicode_lower_search(unsigned int cpoint);
 3  #define xs_unicode_is_upper(cpoint) (!!_xs_unicode_upper_search(cpoint))
 4  #define xs_unicode_is_lower(cpoint) (!!_xs_unicode_lower_search(cpoint))
 5- unsigned int xs_unicode_to_upper(unsigned int cpoint);
 6- unsigned int xs_unicode_to_lower(unsigned int cpoint);
 7+ unsigned int xs_unicode_toupper(unsigned int cpoint);
 8+ unsigned int xs_unicode_tolower(unsigned int cpoint);
 9  int xs_unicode_nfd(unsigned int cpoint, unsigned int *base, unsigned int *diac);
10  int xs_unicode_nfc(unsigned int base, unsigned int diac, unsigned int *cpoint);
11  int xs_unicode_is_alpha(unsigned int cpoint);
12@@ -29,8 +29,8 @@
13  xs_str *xs_utf8_insert(xs_str *str, unsigned int cpoint, int *offset);
14  xs_str *xs_utf8_cat(xs_str *str, unsigned int cpoint);
15  xs_str *xs_utf8_crop_i(xs_str *str, int begin, int end);
16- xs_str *xs_utf8_to_upper(const char *str);
17- xs_str *xs_utf8_to_lower(const char *str);
18+ xs_str *xs_utf8_toupper(const char *str);
19+ xs_str *xs_utf8_tolower(const char *str);
20  xs_str *xs_utf8_to_nfd(const char *str);
21  xs_str *xs_utf8_to_nfc(const char *str);
22 #endif
23@@ -306,7 +306,7 @@ unsigned int *_xs_unicode_lower_search(unsigned int cpoint)
24 }
25 
26 
27-unsigned int xs_unicode_to_lower(unsigned int cpoint)
28+unsigned int xs_unicode_tolower(unsigned int cpoint)
29 /* returns the cpoint to lowercase */
30 {
31     if (cpoint < 0x80)
32@@ -318,7 +318,7 @@ unsigned int xs_unicode_to_lower(unsigned int cpoint)
33 }
34 
35 
36-unsigned int xs_unicode_to_upper(unsigned int cpoint)
37+unsigned int xs_unicode_toupper(unsigned int cpoint)
38 /* returns the cpoint to uppercase */
39 {
40     if (cpoint < 0x80)
41@@ -425,14 +425,14 @@ int xs_unicode_is_right_to_left(unsigned int cpoint)
42 
43 #ifdef _XS_H
44 
45-xs_str *xs_utf8_to_upper(const char *str)
46+xs_str *xs_utf8_toupper(const char *str)
47 {
48     xs_str *s = xs_str_new(NULL);
49     unsigned int cpoint;
50     int offset = 0;
51 
52     while ((cpoint = xs_utf8_dec(&str))) {
53-        cpoint = xs_unicode_to_upper(cpoint);
54+        cpoint = xs_unicode_toupper(cpoint);
55         s = xs_utf8_insert(s, cpoint, &offset);
56     }
57 
58@@ -440,14 +440,14 @@ xs_str *xs_utf8_to_upper(const char *str)
59 }
60 
61 
62-xs_str *xs_utf8_to_lower(const char *str)
63+xs_str *xs_utf8_tolower(const char *str)
64 {
65     xs_str *s = xs_str_new(NULL);
66     unsigned int cpoint;
67     int offset = 0;
68 
69     while ((cpoint = xs_utf8_dec(&str))) {
70-        cpoint = xs_unicode_to_lower(cpoint);
71+        cpoint = xs_unicode_tolower(cpoint);
72         s = xs_utf8_insert(s, cpoint, &offset);
73     }
74