From 49805175e3882a35602c347e8bffc031506674bc Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Wed, 28 Mar 2001 02:14:28 +0000
Subject: [PATCH] files.c:diralphasort() - Changed stat calls to lstat to stop
 abort on symlinks, otherwise return 0.  (Matthias Andree, fixes bug #58)

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@578 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 BUGS      | 2 ++
 ChangeLog | 4 ++++
 files.c   | 8 ++------
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/BUGS b/BUGS
index 6e8c7548..5f47aab0 100644
--- a/BUGS
+++ b/BUGS
@@ -103,6 +103,8 @@
   the first fail if no string is entered (56) [FIXED].
 - Page down on a file of editwinrows fails (again). Reported by Ryan
   Krebs (57) [FIXED].
+- File browser aborts on Solaris in qsort() call.  (Reported by
+  Matthias Andree) (58) [FIXED by Matthias Andree].
 
 ** Open BUGS **
 
diff --git a/ChangeLog b/ChangeLog
index aee08bfd..6a1e4453 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,10 @@ CVS -
 	- Minor patch for intl check (really this time) (Albert Chin)
 - faq.html:
 	- Fixed typo in section 6.1 (discovered by Bob Farmer).
+- files.c:
+  diralphasort()
+	- Changed stat calls to lstat to stop abort on symlinks, otherwise
+	  return 0.  (Matthias Andree, fixes bug #58)
 
 nano-1.0.0 - 03/22/2001
 - General
diff --git a/files.c b/files.c
index ebc9b554..63d8fd6b 100644
--- a/files.c
+++ b/files.c
@@ -318,7 +318,7 @@ int do_insertfile(void)
  * we don't set the global variable filename to it's name, and don't
  * print out how many lines we wrote on the statusbar.
  * 
- * tmp means we are writing a tmp file in a secute fashion.  We use
+ * tmp means we are writing a tmp file in a secure fashion.  We use
  * it when spell checking or dumping the file on an error.
  */
 int write_file(char *name, int tmp)
@@ -1005,11 +1005,7 @@ int diralphasort(const void *va, const void *vb) {
     char *a = *(char **)va, *b = *(char **)vb;
     int answer = 0;
 
-    if (stat(a, &file1info) == -1)
-	answer = 1;
-    else if (stat(b, &file2info) == -1)
-	answer = 1;
-    else {
+    if ((lstat(a, &file1info) != -1) && (lstat(b, &file2info) != -1)) {
 	/* If is a is a dir and b isn't, return -1.
 	   Else if b is a dir and a isn't, return 0.
 	   Else return a < b */
-- 
GitLab