mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-10 17:03:47 +01:00
Remove use of FOREACH macros
This commit is contained in:
parent
61d6ff288f
commit
3841da009d
@ -974,41 +974,35 @@ typedef struct {
|
||||
int freq;
|
||||
} sample_t;
|
||||
|
||||
static int
|
||||
document_page_size_comp(const void *a, const void *b)
|
||||
{
|
||||
static int document_page_size_comp(const void* a, const void* b) {
|
||||
const sample_t* lhs = a;
|
||||
const sample_t* rhs = b;
|
||||
return rhs->freq - lhs->freq;
|
||||
}
|
||||
|
||||
static void
|
||||
document_open_page_most_frequent_size(zathura_document_t *document,
|
||||
unsigned int *width,
|
||||
unsigned int *height)
|
||||
{
|
||||
girara_list_t* samples = girara_list_new2(g_free);
|
||||
static void document_open_page_most_frequent_size(zathura_document_t* document, unsigned int* width,
|
||||
unsigned int* height) {
|
||||
girara_list_t* samples = girara_list_new2(g_free);
|
||||
const unsigned int number_of_pages = zathura_document_get_number_of_pages(document);
|
||||
|
||||
for (unsigned int page_id = 0; page_id < number_of_pages; ++page_id) {
|
||||
zathura_page_t* page = zathura_document_get_page(document, page_id);
|
||||
const double w = zathura_page_get_width(page);
|
||||
const double h = zathura_page_get_height(page);
|
||||
const double w = zathura_page_get_width(page);
|
||||
const double h = zathura_page_get_height(page);
|
||||
|
||||
bool found = false;
|
||||
GIRARA_LIST_FOREACH_BODY(samples, sample_t*, sample,
|
||||
for (size_t idx = 0; idx != girara_list_size(samples) && !found; ++idx) {
|
||||
sample_t* sample = girara_list_nth(samples, idx);
|
||||
if (fabs(sample->h - h) <= DBL_EPSILON && fabs(sample->w - w) <= DBL_EPSILON) {
|
||||
sample->freq++;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (found == false) {
|
||||
sample_t* sample = g_try_malloc0(sizeof(sample_t));
|
||||
sample->w = w;
|
||||
sample->h = h;
|
||||
sample->freq = 1;
|
||||
sample->w = w;
|
||||
sample->h = h;
|
||||
sample->freq = 1;
|
||||
girara_list_append(samples, sample);
|
||||
}
|
||||
}
|
||||
@ -1016,8 +1010,8 @@ document_open_page_most_frequent_size(zathura_document_t *document,
|
||||
girara_list_sort(samples, document_page_size_comp);
|
||||
|
||||
sample_t* max_sample = girara_list_nth(samples, 0);
|
||||
*width = max_sample->w;
|
||||
*height = max_sample->h;
|
||||
*width = max_sample->w;
|
||||
*height = max_sample->h;
|
||||
|
||||
girara_list_free(samples);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user