Submited by: William Immendorf <will.immendorf@gmail.com>
Date: 2010-05-07
Inital Package Version: 2.5.7
Origin: Upstream commit 1199, http://bazaar.launchpad.net/~cjwatson/man-db/trunk/revision/1199
Upstream Status: From Upstream Bazaar

Description: This fixes a issue in when you try to view certan man pages with
man (I've seen this happen with ifort's man page, this acually happend to me
when I was trying to test out various forigen language man pages), man errors
out with this message:

man: man.c:2393: display: Assertion `decomp->ncommands == 1' failed. Aborted
Aborted

and then quits. This is a issue specific to Man-DB-2.5.7, 2.5.6 diddn't have
this issue. This is a well known issue and will be fixed with the release of
Man-DB-2.5.8.

diff -Naur man-db-2.5.7.orig/lib/pipeline.c man-db-2.5.7/lib/pipeline.c
--- man-db-2.5.7.orig/lib/pipeline.c	2010-05-07 19:31:50.784188731 -0500
+++ man-db-2.5.7/lib/pipeline.c	2010-05-07 19:32:45.275061944 -0500
@@ -329,6 +329,25 @@
 	return cmd;
 }
 
+static void passthrough (void *data ATTRIBUTE_UNUSED)
+{
+	for (;;) {
+		char buffer[4096];
+		int r = read (STDIN_FILENO, buffer, 4096);
+		if (r <= 0)
+			break;
+		if (fwrite (buffer, 1, (size_t) r, stdout) < (size_t) r)
+			break;
+	}
+
+	return;
+}
+
+command *command_new_passthrough (void)
+{
+	return command_new_function ("cat", &passthrough, NULL, NULL);
+}
+
 command *command_dup (command *cmd)
 {
 	command *newcmd = XMALLOC (command);
@@ -831,20 +850,6 @@
 	return p;
 }
 
-static void passthrough (void *data ATTRIBUTE_UNUSED)
-{
-	for (;;) {
-		char buffer[4096];
-		int r = read (STDIN_FILENO, buffer, 4096);
-		if (r <= 0)
-			break;
-		if (fwrite (buffer, 1, (size_t) r, stdout) < (size_t) r)
-			break;
-	}
-
-	return;
-}
-
 void pipeline_connect (pipeline *source, pipeline *sink, ...)
 {
 	va_list argv;
@@ -876,11 +881,8 @@
 		 * because it has nowhere to send output. Until this is
 		 * fixed, this kludge is necessary.
 		 */
-		if (arg->ncommands == 0) {
-			command *cmd = command_new_function
-				("cat", &passthrough, NULL, NULL);
-			pipeline_command (arg, cmd);
-		}
+		if (arg->ncommands == 0)
+			pipeline_command (arg, command_new_passthrough ());
 	}
 	va_end (argv);
 }
diff -Naur man-db-2.5.7.orig/lib/pipeline.h man-db-2.5.7/lib/pipeline.h
--- man-db-2.5.7.orig/lib/pipeline.h	2010-05-07 19:31:50.785191356 -0500
+++ man-db-2.5.7/lib/pipeline.h	2010-05-07 19:32:45.275061944 -0500
@@ -172,6 +172,9 @@
  */
 command *command_new_sequence (const char *name, ...) ATTRIBUTE_SENTINEL;
 
+/* Return a new command that just passes data from its input to its output. */
+command *command_new_passthrough (void);
+
 /* Return a duplicate of a command. */
 command *command_dup (command *cmd);
 
diff -Naur man-db-2.5.7.orig/NEWS man-db-2.5.7/NEWS
--- man-db-2.5.7.orig/NEWS	2010-05-07 19:31:50.779187160 -0500
+++ man-db-2.5.7/NEWS	2010-05-07 19:32:45.275061944 -0500
@@ -1,3 +1,15 @@
+man-db 2.5.8
+============
+
+Major changes since man-db 2.5.7:
+
+	Fixes:
+	------
+
+	o Fix assertion failure on 'man -l' with an uncompressed page and
+	  any of --no-hyphenation, --no-justification, or a non-English
+	  page.
+
 man-db 2.5.7 (16 February 2010)
 ===============================
 
diff -Naur man-db-2.5.7.orig/src/man.c man-db-2.5.7/src/man.c
--- man-db-2.5.7.orig/src/man.c	2010-05-07 19:31:50.746062788 -0500
+++ man-db-2.5.7/src/man.c	2010-05-07 19:32:45.277061513 -0500
@@ -2390,9 +2390,16 @@
 #endif /* TROFF_IS_GROFF */
 
 		if (seq->u.sequence.ncommands) {
-			assert (decomp->ncommands == 1);
-			command_sequence_command (seq, decomp->commands[0]);
-			decomp->commands[0] = seq;
+			assert (decomp->ncommands <= 1);
+			if (decomp->ncommands) {
+				command_sequence_command
+					(seq, decomp->commands[0]);
+				decomp->commands[0] = seq;
+			} else {
+				command_sequence_command
+					(seq, command_new_passthrough ());
+				pipeline_command (decomp, seq);
+			}
 		} else
 			command_free (seq);
 	}
