From 0e2f57884b494aa676686db132994a3df2b73c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Wed, 15 Dec 2021 23:26:44 +0300 Subject: Order albums in descending order As opposed to images which are in descending order. I think this way it makes more sense. --- src/components.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components.c b/src/components.c index 876cb39..bb610fe 100644 --- a/src/components.c +++ b/src/components.c @@ -14,9 +14,6 @@ #define MAXTIME \ ((unsigned long long)1 << ((sizeof(time_t) * CHAR_BIT) - 1)) - 1 -#define TSTAMP_CMP(T, a, b) \ - (((T *)a)->tstamp > ((T *)b)->tstamp) - (((T *)a)->tstamp < ((T *)b)->tstamp) - /* * Reverses the order of the parent directories, changes '/' and spaces to '-', * lowers the case of letters. E.g. "2019/Spain/Santiago de Compostela" -> @@ -179,7 +176,9 @@ image_new(char *src, const struct stat *pstat, struct album *album) int image_cmp(const void *a, const void *b) { - return TSTAMP_CMP(struct image, a, b); + /* Compare in ascending order */ + return (((struct image *)a)->tstamp > ((struct image *)b)->tstamp) + - (((struct image *)a)->tstamp < ((struct image *)b)->tstamp); } void @@ -226,7 +225,10 @@ album_new(struct album_config *conf, struct site *site, const char *src, int album_cmp(const void *a, const void *b) { - return TSTAMP_CMP(struct album, a, b); + /* Compare in descending order */ + return (((struct album *)a)->tstamp < ((struct album *)b)->tstamp) + - (((struct album *)a)->tstamp > ((struct album *)b)->tstamp); + } void -- cgit v1.2.3