More search tweaks MUAHAHAHA.

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

25
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--;
}
if (xs_set_add(&seen, md5) == 1)
show--;
}
}
xs_set_free(&skipped);
xs_list *r = xs_set_result(&seen);
return xs_set_result(&seen);
if (skip) {
/* BAD */
while (skip--) {
r = xs_list_del(r, 0);
}
}
return r;
}