From d62c8ee42767490dfc3c7127c07f53e4ac188dd4 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Wed, 14 Nov 2001 20:32:47 +0000 Subject: [PATCH] * dir.c (do_sort): Correctly handle the case when there is no ".." entry (i.e. panelized mode). --- src/ChangeLog | 5 +++++ src/dir.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index ed7b11fa9..0ab51793c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2001-11-14 Pavel Roskin + + * dir.c (do_sort): Correctly handle the case when there is no + ".." entry (i.e. panelized mode). + 2001-11-14 Andrew V. Samoilov * view.c (do_view_init): Make sure _file is not diff --git a/src/dir.c b/src/dir.c index 9f05527ca..7a587fa13 100644 --- a/src/dir.c +++ b/src/dir.c @@ -316,10 +316,12 @@ void do_sort (dir_list *list, sortfn *sort, int top, int reverse_f, int case_sensitive_f) { int i; + int dot_dot_found = 0; file_entry tmp_fe; for (i = 0; i < top + 1; i++) { /* put ".." first in list */ if (!strcmp (list->list [i].fname, "..")) { + dot_dot_found = 1; if (i > 0) { /* swap [i] and [0] */ memcpy (&tmp_fe, &(list->list [0]), sizeof (file_entry)); memcpy (&(list->list [0]), &(list->list [i]), sizeof (file_entry)); @@ -331,7 +333,8 @@ do_sort (dir_list *list, sortfn *sort, int top, int reverse_f, int case_sensitiv reverse = reverse_f ? -1 : 1; case_sensitive = case_sensitive_f; - qsort (&(list->list) [1], top, sizeof (file_entry), sort); + qsort (&(list->list) [dot_dot_found], + top + 1 - dot_dot_found, sizeof (file_entry), sort); } void