summaryrefslogtreecommitdiff
path: root/src/filelist.c
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-02-28 17:24:20 +0100
committerDaniel Friesel <derf@finalrewind.org>2018-02-28 17:24:20 +0100
commitac3356c15f2160d1b252ae6afe50a328cebc9ee7 (patch)
tree9c36b944b2f3c8503991e427a1dce16c3a77d185 /src/filelist.c
parent8eaa39234a54fcdd3c9050a01790b152598af80d (diff)
parent7acf83ea6d6f36e418f43a3408632944fbb7bcde (diff)
Merge branch 'natural-sort' of https://github.com/ulteq/feh into ulteq-natural-sort
Diffstat (limited to 'src/filelist.c')
-rw-r--r--src/filelist.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/filelist.c b/src/filelist.c
index 9a4af27..159491a 100644
--- a/src/filelist.c
+++ b/src/filelist.c
@@ -399,12 +399,18 @@ void feh_file_dirname(char *dst, feh_file * f, int maxlen)
int feh_cmp_filename(void *file1, void *file2)
{
- return(strcmp(FEH_FILE(file1)->filename, FEH_FILE(file2)->filename));
+ if (!opt.version_sort)
+ return(strcmp(FEH_FILE(file1)->filename, FEH_FILE(file2)->filename));
+ else
+ return(strverscmp(FEH_FILE(file1)->filename, FEH_FILE(file2)->filename));
}
int feh_cmp_name(void *file1, void *file2)
{
- return(strcmp(FEH_FILE(file1)->name, FEH_FILE(file2)->name));
+ if (!opt.version_sort)
+ return(strcmp(FEH_FILE(file1)->name, FEH_FILE(file2)->name));
+ else
+ return(strverscmp(FEH_FILE(file1)->name, FEH_FILE(file2)->name));
}
int feh_cmp_dirname(void *file1, void *file2)
@@ -413,8 +419,13 @@ int feh_cmp_dirname(void *file1, void *file2)
int cmp;
feh_file_dirname(dir1, FEH_FILE(file1), PATH_MAX);
feh_file_dirname(dir2, FEH_FILE(file2), PATH_MAX);
- if ((cmp = strcmp(dir1, dir2)) != 0)
- return(cmp);
+ if (!opt.version_sort) {
+ if ((cmp = strcmp(dir1, dir2)) != 0)
+ return(cmp);
+ } else {
+ if ((cmp = strverscmp(dir1, dir2)) != 0)
+ return(cmp);
+ }
return(feh_cmp_name(file1, file2));
}