return ((BrowserSort & SORT_REVERSE) ? -r : r);
}
-static void browser_sort (struct browser_state *state)
+static int browser_compare (const void *a, const void *b)
{
- int (*f) (const void *, const void *);
+ struct folder_file *pa = (struct folder_file *) a;
+ struct folder_file *pb = (struct folder_file *) b;
+
+ if ((mutt_strcoll (pa->desc, "../") == 0) ||
+ (mutt_strcoll (pa->desc, "..") == 0))
+ return -1;
+ if ((mutt_strcoll (pb->desc, "../") == 0) ||
+ (mutt_strcoll (pb->desc, "..") == 0))
+ return 1;
switch (BrowserSort & SORT_MASK)
{
- case SORT_ORDER:
- return;
case SORT_DATE:
-#ifdef USE_NNTP
- if (option (OPTNEWS))
- return;
-#endif
- f = browser_compare_date;
+ return browser_compare_date(a, b);
break;
case SORT_SIZE:
-#ifdef USE_NNTP
- if (option (OPTNEWS))
- return;
-#endif
- f = browser_compare_size;
+ return browser_compare_size(a, b);
break;
case SORT_DESC:
- f = browser_compare_desc;
+ return browser_compare_desc(a, b);
break;
case SORT_COUNT:
- f = browser_compare_count;
+ return browser_compare_count(a, b);
break;
case SORT_COUNT_NEW:
- f = browser_compare_count_new;
+ return browser_compare_count_new(a, b);
break;
case SORT_SUBJECT:
default:
- f = browser_compare_subject;
+ return browser_compare_subject(a, b);
break;
}
- qsort (state->entry, state->entrylen, sizeof (struct folder_file), f);
+}
+
+static void browser_sort (struct browser_state *state)
+{
+ switch (BrowserSort & SORT_MASK)
+ {
+ case SORT_ORDER:
+ return;
+#ifdef USE_NNTP
+ case SORT_SIZE:
+ case SORT_DATE:
+ if (option (OPTNEWS))
+ return;
+#endif
+ default:
+ break;
+ }
+
+ qsort (state->entry, state->entrylen, sizeof (struct folder_file), browser_compare);
}
static int link_is_dir (const char *folder, const char *path)