summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorGravatar default2024-08-23 20:27:07 +0200
committerGravatar default2024-08-23 20:27:07 +0200
commit1370d6b64e984726c096139ab02f4493e6904e2f (patch)
tree10114b7874469fc96233ddf801d32b6d0bbbfe7d /data.c
parentSome optimizations. (diff)
downloadsnac2-1370d6b64e984726c096139ab02f4493e6904e2f.tar.gz
snac2-1370d6b64e984726c096139ab02f4493e6904e2f.tar.xz
snac2-1370d6b64e984726c096139ab02f4493e6904e2f.zip
Searches are now case-insensitive for all alphabets.
Diffstat (limited to 'data.c')
-rw-r--r--data.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/data.c b/data.c
index cfd20fe..22b821f 100644
--- a/data.c
+++ b/data.c
@@ -11,6 +11,7 @@
11#include "xs_time.h" 11#include "xs_time.h"
12#include "xs_regex.h" 12#include "xs_regex.h"
13#include "xs_match.h" 13#include "xs_match.h"
14#include "xs_unicode.h"
14 15
15#include "snac.h" 16#include "snac.h"
16 17
@@ -2414,7 +2415,7 @@ xs_list *content_search(snac *user, const char *regex,
2414 if (regex == NULL || *regex == '\0') 2415 if (regex == NULL || *regex == '\0')
2415 return xs_list_new(); 2416 return xs_list_new();
2416 2417
2417 xs *i_regex = xs_tolower_i(xs_dup(regex)); 2418 xs *i_regex = xs_utf8_to_lower(regex);
2418 2419
2419 xs_set seen; 2420 xs_set seen;
2420 2421
@@ -2510,10 +2511,12 @@ xs_list *content_search(snac *user, const char *regex,
2510 /* strip HTML */ 2511 /* strip HTML */
2511 c = xs_regex_replace_i(c, "<[^>]+>", " "); 2512 c = xs_regex_replace_i(c, "<[^>]+>", " ");
2512 c = xs_regex_replace_i(c, " {2,}", " "); 2513 c = xs_regex_replace_i(c, " {2,}", " ");
2513 c = xs_tolower_i(c); 2514
2515 /* convert to lowercase */
2516 xs *lc = xs_utf8_to_lower(c);
2514 2517
2515 /* apply regex */ 2518 /* apply regex */
2516 if (xs_regex_match(c, i_regex)) { 2519 if (xs_regex_match(lc, i_regex)) {
2517 if (xs_set_add(&seen, md5) == 1) 2520 if (xs_set_add(&seen, md5) == 1)
2518 show--; 2521 show--;
2519 } 2522 }