Don't set the autocr flag on the serial console; clean up crap syslinux-3.81-pre12
authorH. Peter Anvin <hpa@zytor.com>
Sun, 24 May 2009 02:33:36 +0000 (19:33 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Sun, 24 May 2009 02:35:31 +0000 (19:35 -0700)
libutil would set the autocr flag on the serial console, which really
never was any point -- we already do \n -> \r\n conversion explicitly
in the serial code.  This was always very annoying to deal with if the
menu was interrupted.

Furthermore, drop completely unnecessary
initialization/deinitialization routines that completely duplicated
other code.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
NEWS
com32/libutil/ansiline.c
com32/libutil/ansiraw.c
com32/menu/menu.c
com32/menu/menumain.c
com32/menu/vesamenu.c

diff --git a/NEWS b/NEWS
index 7acd25b..8c940b1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,7 @@ Changes in 3.81:
          has changed, so the isohybrid utility must version-match
          isolinux.bin.
        * Drop support for ACPI 3 extended memory flags.
+       * Menu system: don't set the autocr flag on the serial console.
 
 Changes in 3.80:
        * New shuffler mechanism and API.
index 4cdac02..fffb2ba 100644 (file)
 #include <unistd.h>
 #include <console.h>
 
-static void __attribute__((destructor)) console_cleanup(void)
-{
-  /* For the serial console, be nice and clean up */
-  fputs("\033[0m\033[20l", stdout);
-}
-
 void console_ansi_std(void)
 {
   openconsole(&dev_stdcon_r, &dev_ansiserial_w);
-  fputs("\033[0m\033[20h", stdout);
 }
 
 #else
@@ -64,7 +57,6 @@ static void __attribute__((constructor)) console_init(void)
 
 static void __attribute__((destructor)) console_cleanup(void)
 {
-  fputs("\033[0m\033[20l", stdout);
   tcsetattr(0, TCSANOW, &original_termios_settings);
 }
 
@@ -83,8 +75,10 @@ void console_ansi_std(void)
   tio.c_iflag &= ~ICRNL;
   tio.c_iflag |= IGNCR;
   tio.c_lflag |= ICANON|ECHO;
+  if (!tio.c_oflag & OPOST)
+    tio.c_oflag = 0;
+  tio.c_oflag |= OPOST|ONLCR;
   tcsetattr(0, TCSANOW, &tio);
-  fputs("\033[0m\033[20h", stdout);
 }
 
 #endif
index c192744..c55a82e 100644 (file)
 #include <unistd.h>
 #include <console.h>
 
-static void __attribute__((destructor)) console_cleanup(void)
-{
-  /* For the serial console, be nice and clean up */
-  fputs("\033[0m\033[20l", stdout);
-}
-
 void console_ansi_raw(void)
 {
   openconsole(&dev_rawcon_r, &dev_ansiserial_w);
-  fputs("\033[0m\033[20h", stdout);
 }
 
 #else
@@ -64,7 +57,6 @@ static void __attribute__((constructor)) console_init(void)
 
 static void __attribute__((destructor)) console_cleanup(void)
 {
-  fputs("\033[0m\033[20l", stdout);
   tcsetattr(0, TCSANOW, &original_termios_settings);
 }
 
@@ -83,10 +75,12 @@ void console_ansi_raw(void)
   tio.c_iflag &= ~ICRNL;
   tio.c_iflag |= IGNCR;
   tio.c_lflag &= ~(ISIG|ICANON|ECHO);
+  if (!tio.c_oflag & OPOST)
+    tio.c_oflag = 0;
+  tio.c_oflag |= OPOST|ONLCR;
   tio.c_cc[VMIN]  = 0;
   tio.c_cc[VTIME] = 1;         /* Don't 100% busy-wait in Linux */
   tcsetattr(0, TCSAFLUSH, &tio);
-  fputs("\033[0m\033[20h", stdout);
 }
 
 #endif
index 9a6ad89..6d64bad 100644 (file)
 #include <consoles.h>
 #include "menu.h"
 
-void console_prepare(void)
-{
-  /* Nothing special to do */
-}
-
-void console_cleanup(void)
-{
-  /* Nothing special to do */
-}
-
 int draw_background(const char *arg)
 {
   /* Nothing to do... */
@@ -40,6 +30,5 @@ int draw_background(const char *arg)
 int main(int argc, char *argv[])
 {
   console_ansi_raw();
-
   return menu_main(argc, argv);
 }
index b3131fa..81780ea 100644 (file)
@@ -1052,8 +1052,6 @@ int menu_main(int argc, char *argv[])
 
   (void)argc;
 
-  console_prepare();
-
   if (getscreensize(1, &rows, &cols)) {
     /* Unknown screen size? */
     rows = 24;
@@ -1084,7 +1082,6 @@ int menu_main(int argc, char *argv[])
     cmdline = run_menu();
 
     printf("\033[?25h\033[%d;1H\033[0m", END_ROW);
-    console_cleanup();
 
     if ( cmdline ) {
       execute(cmdline, KT_NONE);
@@ -1093,7 +1090,5 @@ int menu_main(int argc, char *argv[])
     } else {
       return 0;                        /* Exit */
     }
-
-    console_prepare();         /* If we're looping... */
   }
 }
index 094b8f6..4dd4586 100644 (file)
 
 #include "menu.h"
 
-void console_prepare(void)
-{
-  fputs("\033[0m\033[25l", stdout);
-}
-
-void console_cleanup(void)
-{
-  /* For the serial console, be nice and clean up */
-  fputs("\033[0m", stdout);
-}
-
 int draw_background(const char *what)
 {
   if (!what)