~ubuntu-branches/ubuntu/lucid/man-db/lucid

21 by Colin Watson
* Add a watch file.
1
Description: Fix assertion failure on 'man -l'
2
 We were failing an assertion with an uncompressed page and prefixed input
3
 (no-hyphenation, no-justification, or a non-English page).
4
Origin: upstream, http://bazaar.launchpad.net/~cjwatson/man-db/trunk/revision/1199
5
Forwarded: yes
6
Last-Update: 2010-03-02
7
8
Index: b/lib/pipeline.c
9
===================================================================
10
--- a/lib/pipeline.c
11
+++ b/lib/pipeline.c
12
@@ -329,6 +329,25 @@
13
 	return cmd;
14
 }
15
 
16
+static void passthrough (void *data ATTRIBUTE_UNUSED)
17
+{
18
+	for (;;) {
19
+		char buffer[4096];
20
+		int r = read (STDIN_FILENO, buffer, 4096);
21
+		if (r <= 0)
22
+			break;
23
+		if (fwrite (buffer, 1, (size_t) r, stdout) < (size_t) r)
24
+			break;
25
+	}
26
+
27
+	return;
28
+}
29
+
30
+command *command_new_passthrough (void)
31
+{
32
+	return command_new_function ("cat", &passthrough, NULL, NULL);
33
+}
34
+
35
 command *command_dup (command *cmd)
36
 {
37
 	command *newcmd = XMALLOC (command);
38
@@ -831,20 +850,6 @@
39
 	return p;
40
 }
41
 
42
-static void passthrough (void *data ATTRIBUTE_UNUSED)
43
-{
44
-	for (;;) {
45
-		char buffer[4096];
46
-		int r = read (STDIN_FILENO, buffer, 4096);
47
-		if (r <= 0)
48
-			break;
49
-		if (fwrite (buffer, 1, (size_t) r, stdout) < (size_t) r)
50
-			break;
51
-	}
52
-
53
-	return;
54
-}
55
-
56
 void pipeline_connect (pipeline *source, pipeline *sink, ...)
57
 {
58
 	va_list argv;
59
@@ -876,11 +881,8 @@
60
 		 * because it has nowhere to send output. Until this is
61
 		 * fixed, this kludge is necessary.
62
 		 */
63
-		if (arg->ncommands == 0) {
64
-			command *cmd = command_new_function
65
-				("cat", &passthrough, NULL, NULL);
66
-			pipeline_command (arg, cmd);
67
-		}
68
+		if (arg->ncommands == 0)
69
+			pipeline_command (arg, command_new_passthrough ());
70
 	}
71
 	va_end (argv);
72
 }
73
Index: b/lib/pipeline.h
74
===================================================================
75
--- a/lib/pipeline.h
76
+++ b/lib/pipeline.h
77
@@ -172,6 +172,9 @@
78
  */
79
 command *command_new_sequence (const char *name, ...) ATTRIBUTE_SENTINEL;
80
 
81
+/* Return a new command that just passes data from its input to its output. */
82
+command *command_new_passthrough (void);
83
+
84
 /* Return a duplicate of a command. */
85
 command *command_dup (command *cmd);
86
 
87
Index: b/src/man.c
88
===================================================================
89
--- a/src/man.c
90
+++ b/src/man.c
91
@@ -2390,9 +2390,16 @@
92
 #endif /* TROFF_IS_GROFF */
93
 
94
 		if (seq->u.sequence.ncommands) {
95
-			assert (decomp->ncommands == 1);
96
-			command_sequence_command (seq, decomp->commands[0]);
97
-			decomp->commands[0] = seq;
98
+			assert (decomp->ncommands <= 1);
99
+			if (decomp->ncommands) {
100
+				command_sequence_command
101
+					(seq, decomp->commands[0]);
102
+				decomp->commands[0] = seq;
103
+			} else {
104
+				command_sequence_command
105
+					(seq, command_new_passthrough ());
106
+				pipeline_command (decomp, seq);
107
+			}
108
 		} else
109
 			command_free (seq);
110
 	}