aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-12-15 23:26:44 +0300
committerYaroslav de la Peña Smirnov <yps@yaroslavps.com>2021-12-15 23:26:44 +0300
commit0e2f57884b494aa676686db132994a3df2b73c70 (patch)
treeef62e0e10723cb10d54fcadee468716416825fa8 /src
parent62d52b597d6a9cf4ed7ef0782fad8ca5eca24aa0 (diff)
downloadrevela-0e2f57884b494aa676686db132994a3df2b73c70.tar.gz
revela-0e2f57884b494aa676686db132994a3df2b73c70.zip
Order albums in descending order
As opposed to images which are in descending order. I think this way it makes more sense.
Diffstat (limited to 'src')
-rw-r--r--src/components.c12
1 files 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