Skip to content

Commit 4d69f34

Browse files
committed
order filenames with case insenitive utf-8
see #60 thanks dreadbalaur
1 parent de69cf4 commit 4d69f34

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ master
22

33
- set VIPS_UNLIMITED to disable DoS limits on file load for libvips 8.18+
44
- unset VIPSHOME in flatpak builds
5+
- alt-left / alt-right use case-insensitive utf-8 ordering [dreadbalaur]
56

67
## 4.1.3 17/12/25
78

src/imagewindow.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,16 @@ sort_filenames(const void *a, const void *b)
285285
const char *f1 = (const char *) a;
286286
const char *f2 = (const char *) b;
287287

288-
return g_ascii_strcasecmp(f1, f2);
288+
/* Case-sensitive utf-8 filename sort.
289+
*/
290+
char *a_fold = g_utf8_casefold(f1, -1);
291+
char *b_fold = g_utf8_casefold(f2, -1);
292+
int result = g_utf8_collate(a_fold, b_fold);
293+
294+
g_free(a_fold);
295+
g_free(b_fold);
296+
297+
return result;
289298
}
290299

291300
static void
@@ -335,7 +344,7 @@ imagewindow_files_set_path(Imagewindow *win, char *path)
335344
g_autofree char *path = g_build_path("/", dirname, filename, NULL);
336345
g_autoptr(GFile) this_file = g_file_new_for_path(path);
337346

338-
// - never add the the passed-in filename (we add it above)
347+
// - never add the passed-in filename (we add it above)
339348
// - avoid directories and dotfiles
340349
if (!g_file_equal(file, this_file) &&
341350
!vips_isprefix(".", filename) &&

0 commit comments

Comments
 (0)