Do not #include <termio.h> as it is deprecated in favor of termios.h and avoid non-portable ioctl calls in favour of tcgetattr and tcsetattr.
Showing the changes to src/core/util_console.cpp (1 of 1 file). Show all
Unified · Split
| @@ -92,14 +92,8 @@ void io_addhistory( const char * addme ) · 91 unmodified lines | |||
| 92 | // kb hit | 92 | // kb hit |
| 93 | #ifndef __PLATFORM_WIN32__ | 93 | #ifndef __PLATFORM_WIN32__ |
| 94 | #include <string.h> | 94 | #include <string.h> |
| 95 | #ifdef __PLATFORM_MACOSX__ | ||
| 96 | #include <termios.h> | 95 | #include <termios.h> |
| 97 | static struct termios g_save; | 96 | static struct termios g_save; |
| 98 | #else | ||
| 99 | #include <termio.h> | ||
| 100 | static struct termio g_save; | ||
| 101 | #endif | ||
| 102 | |||
| 103 | #include <unistd.h> | 97 | #include <unistd.h> |
| 104 | #include <sys/ioctl.h> | 98 | #include <sys/ioctl.h> |
| 105 | #else | 99 | #else |
| @@ -118,15 +112,9 @@ t_CKBOOL kb_initscr() · 12 unmodified lines | |||
| 118 | if( g_init ) return FALSE; | 112 | if( g_init ) return FALSE; |
| 119 | 113 | ||
| 120 | #ifndef __PLATFORM_WIN32__ | 114 | #ifndef __PLATFORM_WIN32__ |
| 121 | |||
| 122 | #ifdef __PLATFORM_MACOSX__ | ||
| 123 | struct termios term; | 115 | struct termios term; |
| 124 | if( ioctl( 0, TIOCGETA, &term ) == -1 ) | 116 | if( tcgetattr(0, &term) == -1 ) |
| 125 | #else | 117 | { |
| 126 | struct termio term; | ||
| 127 | if( ioctl( 0, TCGETA, &term ) == -1 ) | ||
| 128 | #endif | ||
| 129 | { | ||
| 130 | EM_log( CK_LOG_SEVERE, "(kbhit disabled): standard input not a tty!"); | 118 | EM_log( CK_LOG_SEVERE, "(kbhit disabled): standard input not a tty!"); |
| 131 | return FALSE; | 119 | return FALSE; |
| 132 | } | 120 | } |
| @@ -142,12 +130,7 @@ t_CKBOOL kb_initscr() · 9 unmodified lines | |||
| 142 | term.c_cc[VMIN] = 0; | 130 | term.c_cc[VMIN] = 0; |
| 143 | term.c_cc[VTIME]=0; | 131 | term.c_cc[VTIME]=0; |
| 144 | 132 | ||
| 145 | #ifdef __PLATFORM_MACOSX__ | 133 | tcsetattr( 0, TCSADRAIN, &term ); |
| 146 | ioctl( 0, TIOCSETA, &term ); | ||
| 147 | #else | ||
| 148 | ioctl( 0, TCSETA, &term ); | ||
| 149 | #endif | ||
| 150 | |||
| 151 | #endif | 134 | #endif |
| 152 | 135 | ||
| 153 | g_init = TRUE; | 136 | g_init = TRUE; |
| @@ -161,11 +144,7 @@ void kb_endwin() · 7 unmodified lines | |||
| 161 | if( !g_init ) return; | 144 | if( !g_init ) return; |
| 162 | 145 | ||
| 163 | #ifndef __PLATFORM_WIN32__ | 146 | #ifndef __PLATFORM_WIN32__ |
| 164 | #ifdef __PLATFORM_MACOSX__ | 147 | tcsetattr( 0, TCSADRAIN, &g_save ); |
| 165 | ioctl( 0, TIOCSETA, &g_save ); | ||
| 166 | #else | ||
| 167 | ioctl( 0, TCSETA, &g_save ); | ||
| 168 | #endif | ||
| 169 | #endif | 148 | #endif |
| 170 | 149 | ||
| 171 | g_init = FALSE; | 150 | g_init = FALSE; |