GNOME Bugzilla – Bug 770695
Wrong file order in .cbz
Last modified: 2016-10-05 13:23:53 UTC
When opening a .cbz file it shows the images in the wrong order: ex. file contains 1.jpg ... 20.jpg program shows 1.jpg 10.jpg 11.jpg ... 2.jpg 20.jpg 21.jpg ... The way file are sorted is alphabetical and not numerical.
Created attachment 335203 [details] [review] comics: Sort pages in natural order Evince was sorting pages in lexicographic order. In doing so, often files named page1, page2, ..., page9, page10, ... to be sorted as page1, page10, ..., page2. This patch introduces the usage of strverscmp(). This function is missing on all non-glibc platforms.
Do you mean that this makes evince stop compiling on Windows? I know we don't distribute evince on windows but it is still available in mingw through msys2.
(In reply to José Aliste from comment #2) > Do you mean that this makes evince stop compiling on Windows? I know we > don't distribute evince on windows but it is still available in mingw > through msys2. I have never tested in these platforms, but if you feel better I can also: 1. conditionally use it in supported platforms; OR 2. implement our own natural sort.
I am inclined for 1.
(In reply to Germán Poo-Caamaño from comment #4) > I am inclined for 1. I did some research and according to https://www.gnu.org/software/gnulib/manual/html_node/strverscmp.html, the problem seems to be fixed by now. The list of gnulib supported platforms is https://www.gnu.org/software/gnulib/manual/html_node/Target-Platforms.html I am not able to test it on different platforms, but I'm reattaching the patch with a newer commit message (dropping the portability comment, if that's the case).
Created attachment 336671 [details] [review] comics: Sort pages in natural order Evince was sorting pages in lexicographic order. In doing so, often files named page1, page2, ..., page9, page10, ... to be sorted as page1, page10, ..., page2.
Attachment 336671 [details] pushed as 3977c03 - comics: Sort pages in natural order
This causes build failure on FreeBSD: backend/comics/comics-document.c:470:10: error: implicit declaration of function 'strverscmp' is invalid in C99 [-Werror,-Wimplicit-function-declaration] (In reply to Felipe Borges from comment #5) > (In reply to Germán Poo-Caamaño from comment #4) > > I am inclined for 1. > > I did some research and according to > https://www.gnu.org/software/gnulib/manual/html_node/strverscmp.html, the > problem seems to be fixed by now. > > The list of gnulib supported platforms is > https://www.gnu.org/software/gnulib/manual/html_node/Target-Platforms.html > > I am not able to test it on different platforms, but I'm reattaching the > patch with a newer commit message (dropping the portability comment, if > that's the case). Evince doesn't use gnulib, so the portability problem cannot be fixed by gnulib.
It seems that nautilus uses g_utf8_collate_key_for_filename() to avoid portability problems.
(In reply to Ting-Wei Lan from comment #9) > It seems that nautilus uses g_utf8_collate_key_for_filename() to avoid > portability problems. great. I will revert the commit and propose another patch using what you proposed.
Created attachment 336981 [details] [review] comics: Sort pages in natural order Use g_utf8_collate_key_for_filename to convert the page filenames into collation keys in order to compare using strcmp(). This prevents pages named such as page1, page2, page10, to be sorted as page1, page10, page2...
Thanks, attachment 336981 [details] [review] fixes the build error.
Attachment 336981 [details] pushed as 3cace57 - comics: Sort pages in natural order