[BUG+PATCH] Wrong name sort.



I found a sorting buf in latest CVS version.
I have files sorted by name, case insensitive sort. However, the
sorting seems to be behaving strangely, as bunch of files that should
be sorted before or after filter.cc and filter.h (not sure if "." is
before or after letters while sorting) got stuffed in the listing
between these two files. Seems to me like dots are ignored when
sorting at all,

Now it looks like this:
│ filter.cc            │      89│-rw-------││                    │
 │              │
│ filtereddataset.cc   │     544│-rw-------││                    │
 │              │
│ filtereddataset.dep  │     149│-rw-------││                    │
 │              │
│ filtereddataset.h    │     451│-rw-------││                    │
 │              │
│ filtereddataset.o    │   94288│-rw-------││                    │
 │              │
│ filtereddataslice.cc │     658│-rw-------││                    │
 │              │
│ filtereddataslice.dep│     155│-rw-------││                    │
 │              │
│ filtereddataslice.h  │     555│-rw-------││                    │
 │              │
│ filtereddataslice.o  │   96936│-rw-------││                    │
 │              │
│ filter.h             │     172│-rw-------││                    │
 │              │

However, when I switched to case-sensitive sort, the files are sorted
as expected. When I looked in the source (dir.c, sort_name function),
strcmp is used for case-sensitive comparison and either strcoll or
g_strcasecmp for case-insensitive comparison (which in fact use
strcasecmp if it is available).

Seems there is problem with strcoll in libc6, see
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=368270 for example.

Suggested fix:
I think one extra test should be added there:
if "a.b" is sorted between "aa" and "ac", do not use strcoll
See attached patch which does exactly that.

I tested it and it fixes the problem.

Martin Petricek

Attachment: sort_order_bugfix.patch
Description: Binary data



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]