File man-db-2.9.4-alternitive.dif of Package man

---
 src/man.c |   23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

--- src/man.c
+++ src/man.c	2022-08-17 13:59:26.937398386 +0000
@@ -57,6 +57,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+#include <libalternatives.h>
 
 #include "argp.h"
 #include "attribute.h"
@@ -4171,9 +4172,25 @@ static void locate_page_in_manpath (cons
 {
 	char *mp;
 
-	GL_LIST_FOREACH (manpathlist, mp)
-		*found += locate_page (mp, page_section, page_name,
-				       candidates);
+	GL_LIST_FOREACH (manpathlist, mp) {
+		int count = locate_page (mp, page_section, page_name, candidates);
+		if (count == 0) {
+			/* Checking if there has been defined another manpage defined in the
+			 * priorities of libalternatives.
+			 */
+			char **alternitives = libalts_get_default_manpages(page_name);
+			for (char **alter = alternitives; *alter; alter++) {
+				char *p_name, *p_section;
+				split_page_name (*alter, &p_name, &p_section);
+				if (p_name && strlen(p_name) > 0 &&
+				    p_section && strlen(p_section) > 0)
+					count = locate_page (mp, p_section, p_name, candidates);
+				free(*alter);
+			}
+			free(alternitives);
+		}
+		*found += count;
+	}
 }
 
 /*
openSUSE Build Service is sponsored by