Default to \n -> \r\n in ANSI and xserial
authorH. Peter Anvin <hpa@zytor.com>
Tue, 24 Jun 2008 22:25:14 +0000 (15:25 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Tue, 24 Jun 2008 22:25:14 +0000 (15:25 -0700)
Default to \n -> \r\n conversion in the ANSI and xserial modules,
rather than relying on escape codes to make that behave.  This
effectively means that as far as the serial port is concerned, this
behavior cannot be turned off (with less than having the xserial state
machine interpret this sequence) and the escape code *should not* be
used.

That is fine for our applications, though.

com32/lib/sys/ansi.c
com32/lib/sys/stdcon_write.c
com32/lib/sys/xserial_write.c
com32/menu/vesamenu.c

index 5af4a76..29a069f 100644 (file)
@@ -46,7 +46,7 @@ static const struct term_state default_state =
   .reverse = 0,
   .fg = 7,
   .bg = 0,
-  .autocr = 0,
+  .autocr = 1,                 /* Mimic \n -> \r\n conversion by default */
   .saved_xy = { 0, 0 },
   .cursor = 1,
   .state = st_init,
index ef51b76..458d2c2 100644 (file)
@@ -28,7 +28,7 @@
 /*
  * stdcon_write.c
  *
- * Writing to the console
+ * Writing to the console; \n -> \r\n conversion.
  */
 
 #include <errno.h>
index ef540d4..6d0d0f7 100644 (file)
@@ -28,7 +28,7 @@
 /*
  * xserial_write.c
  *
- * Raw writing to the serial port; no \n -> \r\n translation, but
+ * Raw writing to the serial port; \n -> \r\n translation, and
  * convert \1# sequences.
  */
 
@@ -73,6 +73,9 @@ ssize_t __xserial_write(struct file_info *fp, const void *buf, size_t count)
       if (ch >= 1 && ch <= 5) {
        state = st_tbl;
        ndigits = ch;
+      } else if (ch == '\n') {
+       emit('\r');
+       emit('\n');
       } else {
        emit(ch);
       }
index cebbb34..094b8f6 100644 (file)
 
 void console_prepare(void)
 {
-  fputs("\033[0m\033[20h\033[25l", stdout);
+  fputs("\033[0m\033[25l", stdout);
 }
 
 void console_cleanup(void)
 {
   /* For the serial console, be nice and clean up */
-  fputs("\033[0m\033[20l", stdout);
+  fputs("\033[0m", stdout);
 }
 
 int draw_background(const char *what)