diff options
Diffstat (limited to 'src/filelist.c')
-rw-r--r-- | src/filelist.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/filelist.c b/src/filelist.c index 9a4af27..453f795 100644 --- a/src/filelist.c +++ b/src/filelist.c @@ -397,14 +397,26 @@ void feh_file_dirname(char *dst, feh_file * f, int maxlen) dst[n] = '\0'; } +#ifdef HAVE_VERSCMP +inline int strcmp_or_strverscmp(const char *s1, const char *s2) +{ + if (!opt.version_sort) + return(strcmp(s1, s2)); + else + return(strverscmp(s1, s2)); +} +#else +#define strcmp_or_strverscmp strcmp +#endif + int feh_cmp_filename(void *file1, void *file2) { - return(strcmp(FEH_FILE(file1)->filename, FEH_FILE(file2)->filename)); + return(strcmp_or_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)); + return(strcmp_or_strverscmp(FEH_FILE(file1)->name, FEH_FILE(file2)->name)); } int feh_cmp_dirname(void *file1, void *file2) @@ -413,7 +425,7 @@ 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) + if ((cmp = strcmp_or_strverscmp(dir1, dir2)) != 0) return(cmp); return(feh_cmp_name(file1, file2)); } |