Blob Blame History Raw
diff -up man-db-2.5.9/src/man.c.sec man-db-2.5.9/src/man.c
--- man-db-2.5.9/src/man.c.sec	2010-11-17 12:31:24.000000000 +0100
+++ man-db-2.5.9/src/man.c	2011-03-23 15:28:41.000000000 +0100
@@ -2827,10 +2827,24 @@ static int compare_candidates (const str
 	 * moved out of order with respect to their parent sections.
 	 */
 	if (strcmp (lsource->ext, rsource->ext)) {
+		const char **sp;
+
+		/* If the user asked for an explicit section, sort exact
+		 * matches first.
+		 */
+		if (section) {
+			if (STREQ (lsource->ext, section)) {
+				if (!STREQ (rsource->ext, section))
+					return -1;
+			} else {
+				if (STREQ (rsource->ext, section))
+					return 1;
+			}
+		}
+
 		/* Find out whether lsource->ext is ahead of rsource->ext in
 		 * section_list.
 		 */
-		const char **sp;
 		for (sp = section_list; *sp; ++sp) {
 			if (!*(*sp + 1)) {
 				/* No extension */