patch-2.2.16 linux/arch/alpha/lib/srm_printk.c

Next file: linux/arch/alpha/lib/srm_puts.c
Previous file: linux/arch/alpha/lib/srm_fixup.S
Back to the patch index
Back to the overall index

diff -urN v2.2.15/linux/arch/alpha/lib/srm_printk.c linux/arch/alpha/lib/srm_printk.c
@@ -10,12 +10,31 @@
 {
 	static char buf[1024];
         va_list args;
-        long i;
+        long len, num_lf;
+        char *src, *dst;
 
         va_start(args, fmt);
-        i = vsprintf(buf,fmt,args);
+        len = vsprintf(buf, fmt, args);
         va_end(args);
 
-	srm_puts(buf);	
-        return i;
+        /* Count number of linefeeds in string. */
+        num_lf = 0;
+        for (src = buf; *src; ++src) {
+                if (*src == '\n') {
+                        ++num_lf;
+                }
+        }
+
+	/* Expand each linefeed into carriage-return/linefeed. */
+        if (num_lf) {
+                for (dst = src + num_lf; src >= buf; ) {
+                        if (*src == '\n') {
+                                *dst-- = '\r';
+                        }
+                        *dst-- = *src--;
+                }
+        }
+
+	srm_puts(buf, num_lf+len);	
+        return len;
 }

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