mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2025-02-21 12:51:48 +01:00
Minor improvements, comment out debug print outs
This commit is contained in:
parent
16bdee675c
commit
7b6c2518e6
37
preview.c
37
preview.c
@ -32,22 +32,25 @@ static int cmp_prev_mimetype(const void *p1, const void *p2)
|
|||||||
Preview *pr1 = *(Preview **)p1;
|
Preview *pr1 = *(Preview **)p1;
|
||||||
Preview *pr2 = *(Preview **)p2;
|
Preview *pr2 = *(Preview **)p2;
|
||||||
|
|
||||||
if (pr1->type[0] == '\0')
|
if (!pr1->type && pr2->type)
|
||||||
return 1;
|
return 1;
|
||||||
else if (pr2->type[0] == '\0')
|
else if (pr1->type && !pr2->type)
|
||||||
|
return -1;
|
||||||
|
else if (!pr1->type && !pr2->type)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!pr1->subtype && pr2->subtype)
|
||||||
|
return 1;
|
||||||
|
else if (pr1->subtype && !pr2->subtype)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!pr1->subtype && pr2->subtype) {
|
|
||||||
return 1;
|
|
||||||
} else if (pr1->subtype && !pr2->subtype) {
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
int ret = strcmp(pr1->type, pr2->type);
|
int ret = strcmp(pr1->type, pr2->type);
|
||||||
|
|
||||||
if (ret == 0 && pr1->subtype && pr2->subtype)
|
if (ret == 0 && pr1->subtype && pr2->subtype)
|
||||||
return strcmp(pr1->subtype, pr2->subtype);
|
return strcmp(pr1->subtype, pr2->subtype);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void init_previews(Preview *ps, size_t len)
|
void init_previews(Preview *ps, size_t len)
|
||||||
{
|
{
|
||||||
@ -66,6 +69,9 @@ void init_previews(Preview *ps, size_t len)
|
|||||||
|
|
||||||
qsort(sorted_by_ext, len, PREVP_SIZE, cmp_prev_ext);
|
qsort(sorted_by_ext, len, PREVP_SIZE, cmp_prev_ext);
|
||||||
qsort(sorted_by_mimetype, len, PREVP_SIZE, cmp_prev_mimetype);
|
qsort(sorted_by_mimetype, len, PREVP_SIZE, cmp_prev_mimetype);
|
||||||
|
|
||||||
|
/* for (size_t i = 0; i < len; i++) */
|
||||||
|
/* printf("%s %s\n", sorted_by_mimetype[i]->type, sorted_by_mimetype[i]->subtype); */
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup_previews(void)
|
void cleanup_previews(void)
|
||||||
@ -121,14 +127,17 @@ static Preview *find_by_mimetype(char const *mimetype)
|
|||||||
for (size_t i = 0; i < prevs_length; i++) {
|
for (size_t i = 0; i < prevs_length; i++) {
|
||||||
p = sorted_by_mimetype[i];
|
p = sorted_by_mimetype[i];
|
||||||
|
|
||||||
if (strcmp(t, p->type) == 0) {
|
if (!p->type)
|
||||||
if (p->subtype) {
|
return p;
|
||||||
|
|
||||||
|
if (strcmp(t, p->type) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!p->subtype)
|
||||||
|
return p;
|
||||||
|
|
||||||
if (strcmp(s, p->subtype) == 0)
|
if (strcmp(s, p->subtype) == 0)
|
||||||
return p;
|
return p;
|
||||||
} else {
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user