From: Omar Polo Subject: gotwebd: use prev_display instead of hardcoding d_i - 2 To: gameoftrees@openbsd.org Date: Tue, 22 Nov 2022 12:05:07 +0100 Extracted for ease of review from a previous (pending) diff about refactoring gotweb_render_index. ----------------------------------------------- commit 0ceb1b9e49ae865b84f237977d7edbcaa9697161 from: Omar Polo date: Tue Nov 22 11:00:49 2022 UTC gotwebd: use prev_disp to decide when to we've reached max_repos instead of hardcoding d_i - 2 and so expecting only "." and ".." as skipped entries, use t->prev_disp that is the number of repositories traversed until now (both skipped due to the pagination and the ones actually rendered.) diff e18d071f3cc8912b9bfb6fb392689dc7394355dd 0ceb1b9e49ae865b84f237977d7edbcaa9697161 commit - e18d071f3cc8912b9bfb6fb392689dc7394355dd commit + 0ceb1b9e49ae865b84f237977d7edbcaa9697161 blob - 7cb4b4aa6c9a239aeb25328ef01b302f2131753a blob + fdc41cd4d2cb16ff84e4c42c6a8c826e6f239dc0 --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -1051,8 +1051,8 @@ gotweb_render_index(struct request *c) goto done; for (d_i = 0; d_i < d_cnt; d_i++) { - if (srv->max_repos > 0 && (d_i - 2) == srv->max_repos) - break; /* account for parent and self */ + if (srv->max_repos > 0 && t->prev_disp == srv->max_repos) + break; if (strcmp(sd_dent[d_i]->d_name, ".") == 0 || strcmp(sd_dent[d_i]->d_name, "..") == 0)