shithub: nc

Download patch

ref: e423f457570af50cba086007c2a9f6db520151e1
parent: aac2549d724f05d5b5dcce35c6f3e29a936f8cd1
author: phil9 <[email protected]>
date: Tue Dec 27 11:45:52 EST 2022

fix dir name comparison

--- a/dirmodel.c
+++ b/dirmodel.c
@@ -3,11 +3,19 @@
 static int
 dircmpname(Dir *a, Dir *b)
 {
-	if(a->qid.type == b->qid.type)
-		return strcmp(a->name, b->name);
-	if(a->qid.type&QTDIR)
-		return -1;
-	return 1;
+	int cmp;
+
+	if(a->qid.type&QTDIR){
+		if(b->qid.type&QTDIR)
+			cmp = strcmp(a->name, b->name);
+		else
+			cmp = -1;	
+	}else if(b->qid.type&QTDIR){
+		cmp = 1;
+	}else{
+		cmp = strcmp(a->name, b->name);
+	}
+	return cmp;
 } 
 
 static void