patch-2.3.36 linux/drivers/char/lp.c

Next file: linux/drivers/char/mem.c
Previous file: linux/drivers/char/drm/tdfx_drv.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.35/linux/drivers/char/lp.c linux/drivers/char/lp.c
@@ -662,11 +662,30 @@
 	parport_negotiate (port, IEEE1284_MODE_COMPAT);
 
 	do {
-		/* Write the data. */
-		written = parport_write (port, s, count);
-		if (written > 0) {
-			s += written;
-			count -= written;
+		/* Write the data, converting LF->CRLF as we go. */
+		ssize_t canwrite = count;
+		char *line = strchr (s, '\n');
+		if (line)
+			canwrite = line - s;
+
+		written = parport_write (port, s, canwrite);
+		if (written <= 0)
+			continue;
+
+		s += written;
+		count -= written;
+		if (line) {
+			const char *crlf = "\r\n";
+			int i = 2;
+
+			/* Dodge the original '\n', and put '\r\n' instead. */
+			s++;
+			count--;
+			while (i) {
+				written = parport_write (port, crlf, i);
+				if (written > 0)
+					i -= written, crlf += written;
+			}
 		}
 	} while (count > 0 && (CONSOLE_LP_STRICT || written > 0));
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)