div

X11 image viewer
git clone https://git.porkepik.fr/div
Log | Files | Refs | README | LICENSE

commit db0cd625ef7b9a134552285c5cbd311918a6708c
parent 0e65889114842403d2ca82fd5f2bfb8689fb2b96
Author: Thomas Philippe <dev@porkepik.fr>
Date:   Fri,  7 Aug 2020 17:37:35 +0200

sort images alphanumerically

Diffstat:
Mdiv.c | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/div.c b/div.c @@ -1,7 +1,6 @@ /* TODO - set window title - - display filename, res, file size */ #include <dirent.h> @@ -99,7 +98,6 @@ check_file(char *path) } } - static void check_args(int argc, char **argv) { @@ -115,6 +113,14 @@ check_args(int argc, char **argv) } } +static int +filenamecmp(const void *a, const void *b) +{ + const char *arg1 = *(const char **)a; + const char *arg2 = *(const char **)b; + return strcmp(arg1, arg2); +} + static void rgb_to_bgr(void) { @@ -136,7 +142,7 @@ init_img(char *filepath) printf("Could not open %s\n", filepath); return 1; } - printf("Opened: %s\n", filepath); + printf("Opened: %s, %dx%d\n", filepath, img.width, img.height); rgb_to_bgr(); img.dpy_data = img.data; @@ -395,6 +401,7 @@ main(int argc, char **argv) if (argc < 2) usage(); check_args(argc, argv); + qsort(filepaths, nimgs, sizeof(char *), filenamecmp); for (i = 0; i <= nimgs - 1; i++) { status = init_img(filepaths[i]);