More search tweaks MUAHAHAHA.

This commit is contained in:
default 2024-05-10 12:22:36 +02:00
parent 5d1577af3c
commit d12ebcef82

21
data.c
View File

@ -2499,10 +2499,8 @@ xs_list *content_search(snac *user, const char *regex,
return xs_list_new();
xs_set seen;
xs_set skipped;
xs_set_init(&seen);
xs_set_init(&skipped);
if (max_secs == 0)
max_secs = 3;
@ -2523,6 +2521,8 @@ xs_list *content_search(snac *user, const char *regex,
xs_list_next(pub_tl, &pub_md5, &pub_c);
xs_list_next(priv_tl, &priv_md5, &priv_c);
show += skip;
while (show > 0) {
char *md5 = NULL;
enum { NONE, PUBLIC, PRIVATE } from = NONE;
@ -2594,20 +2594,21 @@ xs_list *content_search(snac *user, const char *regex,
xs *l = xs_regex_select_n(c, regex, 1);
if (xs_list_len(l)) {
if (skip > 0) {
if (xs_set_add(&skipped, md5) == 1)
skip--;
}
else {
if (xs_set_add(&seen, md5) == 1)
show--;
}
}
xs_list *r = xs_set_result(&seen);
if (skip) {
/* BAD */
while (skip--) {
r = xs_list_del(r, 0);
}
}
xs_set_free(&skipped);
return xs_set_result(&seen);
return r;
}