patch-1.3.37 linux/arch/alpha/boot/main.c

Next file: linux/arch/alpha/config.in
Previous file: linux/Makefile
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.36/linux/arch/alpha/boot/main.c linux/arch/alpha/boot/main.c
@@ -24,13 +24,36 @@
 int printk(const char * fmt, ...)
 {
 	va_list args;
-	int i;
+	int i, j, written, remaining, num_nl;
 	static char buf[1024];
+	char * str;
 
 	va_start(args, fmt);
 	i = vsprintf(buf, fmt, args);
 	va_end(args);
-	puts(buf,i);
+
+	/* expand \n into \r\n: */
+
+	num_nl = 0;
+	for (j = 0; j < i; ++j) {
+	    if (buf[j] == '\n')
+	    	++num_nl;
+	}
+	remaining = i + num_nl;
+	for (j = i - 1; j >= 0; --j) {
+	    buf[j + num_nl] = buf[j];
+	    if (buf[j] == '\n') {
+	    	--num_nl;
+		buf[j + num_nl] = '\r';
+	    }
+	}
+
+	str = buf;
+	do {
+	    written = puts(str, remaining);
+	    remaining -= written;
+	    str += written;
+	} while (remaining > 0);
 	return i;
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this