diff options
author | Mark Wong <mark@2ndQuadrant.com> | 2020-09-30 00:51:07 +0000 |
---|---|---|
committer | Mark Wong <markwkm@gmail.com> | 2020-10-07 19:47:17 -0700 |
commit | 3ec66999f4b14485305fc0eb0d7819ce15e99c22 (patch) | |
tree | 380f9f75f3a7a1f353af203732dfc2acdbf11a8d | |
parent | 7af8bf8dbda9369896f819d83441d20ad659af1e (diff) |
Remove code using obsolete termio
Expect to use termios.h.
-rw-r--r-- | screen.c | 62 | ||||
-rw-r--r-- | sprompt.c | 43 |
2 files changed, 2 insertions, 103 deletions
@@ -26,22 +26,14 @@ #include <sgtty.h> #define SGTTY #else -#ifdef TCGETA -#define TERMIO -#include <termio.h> -#else -#define TERMIOS #include <termios.h> -#endif -#endif -#if defined(TERMIO) || defined(TERMIOS) +#endif /* CBREAK */ #ifndef TAB3 #ifdef OXTABS #define TAB3 OXTABS #else #define TAB3 0 -#endif -#endif +#endif /* OXTABS */ #endif #include "screen.h" #include "boolean.h" @@ -74,14 +66,8 @@ char *terminal_end; static struct sgttyb old_settings; static struct sgttyb new_settings; #endif -#ifdef TERMIO -static struct termio old_settings; -static struct termio new_settings; -#endif -#ifdef TERMIOS static struct termios old_settings; static struct termios new_settings; -#endif static char is_a_terminal = No; #ifdef TOStop @@ -289,18 +275,10 @@ init_termcap(int interactive) smart_terminal = No; } #endif -#ifdef TERMIO - if (ioctl(STDOUT, TCGETA, &old_settings) == -1) - { - smart_terminal = No; - } -#endif -#ifdef TERMIOS if (tcgetattr(STDOUT, &old_settings) == -1) { smart_terminal = No; } -#endif } void @@ -337,31 +315,6 @@ init_screen() putcap(terminal_init); } #endif -#ifdef TERMIO - if (ioctl(STDOUT, TCGETA, &old_settings) != -1) - { - /* copy the settings so we can modify them */ - new_settings = old_settings; - - /* turn off ICANON, character echo and tab expansion */ - new_settings.c_lflag &= ~(ICANON | ECHO); - new_settings.c_oflag &= ~(TAB3); - new_settings.c_cc[VMIN] = 1; - new_settings.c_cc[VTIME] = 0; - (void) ioctl(STDOUT, TCSETA, &new_settings); - - /* remember the erase and kill characters */ - ch_erase = old_settings.c_cc[VERASE]; - ch_kill = old_settings.c_cc[VKILL]; - - /* remember that it really is a terminal */ - is_a_terminal = Yes; - - /* send the termcap initialization string */ - putcap(terminal_init); - } -#endif -#ifdef TERMIOS if (tcgetattr(STDOUT, &old_settings) != -1) { /* copy the settings so we can modify them */ @@ -384,7 +337,6 @@ init_screen() /* send the termcap initialization string */ putcap(terminal_init); } -#endif if (!is_a_terminal) { @@ -414,12 +366,7 @@ end_screen() (void) ioctl(STDOUT, TIOCLSET, &old_lword); #endif #endif -#ifdef TERMIO - (void) ioctl(STDOUT, TCSETA, &old_settings); -#endif -#ifdef TERMIOS (void) tcsetattr(STDOUT, TCSADRAIN, &old_settings); -#endif } } @@ -435,12 +382,7 @@ reinit_screen() (void) ioctl(STDOUT, TIOCLSET, &new_lword); #endif #endif -#ifdef TERMIO - (void) ioctl(STDOUT, TCSETA, &new_settings); -#endif -#ifdef TERMIOS (void) tcsetattr(STDOUT, TCSADRAIN, &new_settings); -#endif } /* send init string */ @@ -28,9 +28,7 @@ */ #include "c.h" -#ifdef HAVE_TERMIOS_H #include <termios.h> -#endif extern char *simple_prompt(const char *prompt, int maxlen, bool echo); @@ -42,15 +40,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo) FILE *termin, *termout; -#ifdef HAVE_TERMIOS_H struct termios t_orig, t; -#else -#ifdef WIN32 - HANDLE t = NULL; - LPDWORD t_orig = NULL; -#endif -#endif destination = (char *) malloc(maxlen + 1); if (!destination) @@ -63,10 +54,6 @@ simple_prompt(const char *prompt, int maxlen, bool echo) termin = fopen(DEVTTY, "r"); termout = fopen(DEVTTY, "w"); if (!termin || !termout -#ifdef WIN32 - /* See DEVTTY comment for msys */ - || (getenv("OSTYPE") && strcmp(getenv("OSTYPE"), "msys") == 0) -#endif ) { if (termin) @@ -77,7 +64,6 @@ simple_prompt(const char *prompt, int maxlen, bool echo) termout = stderr; } -#ifdef HAVE_TERMIOS_H if (!echo) { tcgetattr(fileno(termin), &t); @@ -85,22 +71,6 @@ simple_prompt(const char *prompt, int maxlen, bool echo) t.c_lflag &= ~ECHO; tcsetattr(fileno(termin), TCSAFLUSH, &t); } -#else -#ifdef WIN32 - if (!echo) - { - /* get a new handle to turn echo off */ - t_orig = (LPDWORD) malloc(sizeof(DWORD)); - t = GetStdHandle(STD_INPUT_HANDLE); - - /* save the old configuration first */ - GetConsoleMode(t, t_orig); - - /* set to the new mode */ - SetConsoleMode(t, ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT); - } -#endif -#endif if (prompt) { @@ -130,25 +100,12 @@ simple_prompt(const char *prompt, int maxlen, bool echo) /* remove trailing newline */ destination[length - 1] = '\0'; -#ifdef HAVE_TERMIOS_H if (!echo) { tcsetattr(fileno(termin), TCSAFLUSH, &t_orig); fputs("\n", termout); fflush(termout); } -#else -#ifdef WIN32 - if (!echo) - { - /* reset to the original console mode */ - SetConsoleMode(t, *t_orig); - fputs("\n", termout); - fflush(termout); - free(t_orig); - } -#endif -#endif if (termin != stdin) { |