Переглянути джерело

Renamed xs_utf8_toupper() and xs_utf8_tolower().

grunfink 4 днів тому
батько
коміт
45200308ad
6 змінених файлів з 25 додано та 25 видалено
  1. 2 2
      activitypub.c
  2. 5 5
      data.c
  3. 1 1
      format.c
  4. 6 6
      html.c
  5. 1 1
      mastoapi.c
  6. 10 10
      xs_unicode.h

+ 2 - 2
activitypub.c

@@ -425,7 +425,7 @@ int hashtag_in_msg(const xs_list *hashtags, const xs_dict *msg)
 
                     if (xs_is_string(type) && xs_is_string(name)) {
                         if (strcmp(type, "Hashtag") == 0) {
-                            xs *lc_name = xs_utf8_to_lower(name);
+                            xs *lc_name = xs_utf8_tolower(name);
 
                             if (xs_list_in(hashtags, lc_name) != -1)
                                 return 1;
@@ -1009,7 +1009,7 @@ xs_str *process_tags(snac *snac, const char *content, xs_list **tag)
             if (*v == '#') {
                 /* hashtag */
                 xs *d = xs_dict_new();
-                xs *n = xs_utf8_to_lower(v);
+                xs *n = xs_utf8_tolower(v);
                 xs *h = xs_fmt("%s?t=%s", srv_baseurl, n + 1);
                 xs *l = xs_fmt("<a href=\"%s\" class=\"mention hashtag\" rel=\"tag\">%s</a>", h, v);
 

+ 5 - 5
data.c

@@ -2477,7 +2477,7 @@ void tag_index(const char *id, const xs_dict *obj)
                 if (*name == '\0')
                     continue;
 
-                xs* name_cased = xs_utf8_to_lower((xs_str *)name);
+                xs* name_cased = xs_utf8_tolower((xs_str *)name);
 
                 xs *md5_tag   = xs_md5_hex(name_cased, strlen(name_cased));
                 xs *tag_dir   = xs_fmt("%s/%c%c", g_tag_dir, md5_tag[0], md5_tag[1]);
@@ -2507,7 +2507,7 @@ xs_str *tag_fn(const char *tag)
     if (*tag == '#')
         tag++;
 
-    xs *lw_tag = xs_utf8_to_lower(tag);
+    xs *lw_tag = xs_utf8_tolower(tag);
     xs *md5    = xs_md5_hex(lw_tag, strlen(lw_tag));
 
     return xs_fmt("%s/tag/%c%c/%s.idx", srv_basedir, md5[0], md5[1], md5);
@@ -3102,7 +3102,7 @@ int content_match(const char *file, const xs_dict *msg)
             /* massage content (strip HTML tags, etc.) */
             xs *c1 = xs_regex_replace(v, "<[^>]+>", " ");
             c1 = xs_regex_replace_i(c1, " {2,}", " ");
-            xs *c = xs_utf8_to_lower(c1);
+            xs *c = xs_utf8_tolower(c1);
 
             while (!r && !feof(f)) {
                 xs *rx = xs_strip_i(xs_readline(f));
@@ -3128,7 +3128,7 @@ xs_list *content_search(snac *user, const char *regex,
     if (regex == NULL || *regex == '\0')
         return xs_list_new();
 
-    xs *i_regex = xs_utf8_to_lower(regex);
+    xs *i_regex = xs_utf8_tolower(regex);
 
     xs_set seen;
 
@@ -3261,7 +3261,7 @@ xs_list *content_search(snac *user, const char *regex,
         c = xs_regex_replace_i(c, " {2,}", " ");
 
         /* convert to lowercase */
-        xs *lc = xs_utf8_to_lower(c);
+        xs *lc = xs_utf8_tolower(c);
 
         /* apply regex */
         if (xs_regex_match(lc, i_regex)) {

+ 1 - 1
format.c

@@ -489,7 +489,7 @@ xs_str *sanitize(const char *content)
         if (n & 0x1) {
             xs *s1  = xs_strip_i(xs_crop_i(xs_dup(v), v[1] == '/' ? 2 : 1, -1));
             xs *l1  = xs_split_n(s1, " ", 1);
-            xs *tag = xs_utf8_to_lower(xs_list_get(l1, 0));
+            xs *tag = xs_utf8_tolower(xs_list_get(l1, 0));
             xs *s2  = NULL;
             int i;
 

+ 6 - 6
html.c

@@ -173,7 +173,7 @@ xs_str *actor_pronouns(xs_dict *actor)
 
     if (xs_is_list((attachment = xs_dict_get(actor, "attachment")))) {
         xs_list_foreach(attachment, d) {
-            xs *prop = xs_utf8_to_lower(xs_dict_get(d, "name"));
+            xs *prop = xs_utf8_tolower(xs_dict_get(d, "name"));
             /* make sure that we are reading the correct metadata */
             if (strlen(prop) == 8 && strcmp(prop, "pronouns") == 0) {
                 /* safeguard from NULL values */
@@ -3295,7 +3295,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
     const char *o_content = xs_dict_get_def(msg, "content", "");
 
     if (xs_is_string(o_content) && xs_is_list(tags) && xs_list_len(tags)) {
-        xs *content = xs_utf8_to_lower(o_content);
+        xs *content = xs_utf8_tolower(o_content);
         const xs_dict *tag;
 
         xs_html *add_hashtags = xs_html_tag("ul",
@@ -3309,7 +3309,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
                 const char *name   = xs_dict_get(tag, "name");
 
                 if (xs_is_string(o_href) && xs_is_string(name)) {
-                    xs *href = xs_utf8_to_lower(o_href);
+                    xs *href = xs_utf8_tolower(o_href);
 
                     if (xs_str_in(content, href) == -1 && xs_str_in(content, name) == -1) {
                         /* not in the content: add here */
@@ -6297,7 +6297,7 @@ int html_post_handler(const xs_dict *req, const char *q_path,
                 if (xs_startswith(s1, "https:/"))
                     s2 = xs_dup(s1);
                 else {
-                    s2 = xs_utf8_to_lower(s1);
+                    s2 = xs_utf8_tolower(s1);
 
                     if (*s2 != '#')
                         s2 = xs_str_prepend_i(s2, "#");
@@ -6331,7 +6331,7 @@ int html_post_handler(const xs_dict *req, const char *q_path,
                 if (*s1 == '\0')
                     continue;
 
-                xs *s2 = xs_utf8_to_lower(s1);
+                xs *s2 = xs_utf8_tolower(s1);
                 if (*s2 != '#')
                     s2 = xs_str_prepend_i(s2, "#");
 
@@ -6360,7 +6360,7 @@ int html_post_handler(const xs_dict *req, const char *q_path,
                 if (*s1 == '\0')
                     continue;
 
-                xs *s2 = xs_utf8_to_lower(s1);
+                xs *s2 = xs_utf8_tolower(s1);
 
                 new_words = xs_list_insert_sorted(new_words, s2);
             }

+ 1 - 1
mastoapi.c

@@ -1954,7 +1954,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
                 const char *aq = xs_dict_get(args, "q");
 
                 if (!xs_is_null(aq)) {
-                    xs *q    = xs_utf8_to_lower(aq);
+                    xs *q    = xs_utf8_tolower(aq);
                     out      = xs_list_new();
                     xs *wing = following_list(&snac1);
                     xs *wers = follower_list(&snac1);

+ 10 - 10
xs_unicode.h

@@ -16,8 +16,8 @@
  unsigned int *_xs_unicode_lower_search(unsigned int cpoint);
  #define xs_unicode_is_upper(cpoint) (!!_xs_unicode_upper_search(cpoint))
  #define xs_unicode_is_lower(cpoint) (!!_xs_unicode_lower_search(cpoint))
- unsigned int xs_unicode_to_upper(unsigned int cpoint);
- unsigned int xs_unicode_to_lower(unsigned int cpoint);
+ unsigned int xs_unicode_toupper(unsigned int cpoint);
+ unsigned int xs_unicode_tolower(unsigned int cpoint);
  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);
@@ -29,8 +29,8 @@
  xs_str *xs_utf8_insert(xs_str *str, unsigned int cpoint, int *offset);
  xs_str *xs_utf8_cat(xs_str *str, unsigned int cpoint);
  xs_str *xs_utf8_crop_i(xs_str *str, int begin, int end);
- xs_str *xs_utf8_to_upper(const char *str);
- xs_str *xs_utf8_to_lower(const char *str);
+ xs_str *xs_utf8_toupper(const char *str);
+ xs_str *xs_utf8_tolower(const char *str);
  xs_str *xs_utf8_to_nfd(const char *str);
  xs_str *xs_utf8_to_nfc(const char *str);
 #endif
@@ -306,7 +306,7 @@ unsigned int *_xs_unicode_lower_search(unsigned int cpoint)
 }
 
 
-unsigned int xs_unicode_to_lower(unsigned int cpoint)
+unsigned int xs_unicode_tolower(unsigned int cpoint)
 /* returns the cpoint to lowercase */
 {
     if (cpoint < 0x80)
@@ -318,7 +318,7 @@ unsigned int xs_unicode_to_lower(unsigned int cpoint)
 }
 
 
-unsigned int xs_unicode_to_upper(unsigned int cpoint)
+unsigned int xs_unicode_toupper(unsigned int cpoint)
 /* returns the cpoint to uppercase */
 {
     if (cpoint < 0x80)
@@ -425,14 +425,14 @@ int xs_unicode_is_right_to_left(unsigned int cpoint)
 
 #ifdef _XS_H
 
-xs_str *xs_utf8_to_upper(const char *str)
+xs_str *xs_utf8_toupper(const char *str)
 {
     xs_str *s = xs_str_new(NULL);
     unsigned int cpoint;
     int offset = 0;
 
     while ((cpoint = xs_utf8_dec(&str))) {
-        cpoint = xs_unicode_to_upper(cpoint);
+        cpoint = xs_unicode_toupper(cpoint);
         s = xs_utf8_insert(s, cpoint, &offset);
     }
 
@@ -440,14 +440,14 @@ xs_str *xs_utf8_to_upper(const char *str)
 }
 
 
-xs_str *xs_utf8_to_lower(const char *str)
+xs_str *xs_utf8_tolower(const char *str)
 {
     xs_str *s = xs_str_new(NULL);
     unsigned int cpoint;
     int offset = 0;
 
     while ((cpoint = xs_utf8_dec(&str))) {
-        cpoint = xs_unicode_to_lower(cpoint);
+        cpoint = xs_unicode_tolower(cpoint);
         s = xs_utf8_insert(s, cpoint, &offset);
     }