aboutsummaryrefslogtreecommitdiff
path: root/more.c
diff options
context:
space:
mode:
Diffstat (limited to 'more.c')
-rw-r--r--more.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/more.c b/more.c
index d5711aa2f..f84214905 100644
--- a/more.c
+++ b/more.c
@@ -33,25 +33,17 @@
33 33
34static const char more_usage[] = "more [file ...]\n"; 34static const char more_usage[] = "more [file ...]\n";
35 35
36/* ED: sparc termios is broken: revert back to old termio handling. */
37#ifdef BB_FEATURE_USE_TERMIOS 36#ifdef BB_FEATURE_USE_TERMIOS
38 37
39#if #cpu(sparc) 38#include <termio.h>
40# define USE_OLD_TERMIO
41# include <termio.h>
42# define termios termio
43# define stty(fd,argp) ioctl(fd,TCSETAF,argp)
44#else
45# include <termios.h>
46# define stty(fd,argp) tcsetattr(fd,TCSANOW,argp)
47#endif
48 39
49FILE *cin; 40FILE *cin;
50struct termios initial_settings, new_settings; 41/* sparc and other have broken termios support: use old termio handling. */
42struct termio initial_settings, new_settings;
51 43
52void gotsig(int sig) 44void gotsig(int sig)
53{ 45{
54 stty(fileno(cin), &initial_settings); 46 ioctl(fileno(cin), TCSETAF, &initial_settings);
55 fprintf(stdout, "\n"); 47 fprintf(stdout, "\n");
56 exit(TRUE); 48 exit(TRUE);
57} 49}
@@ -106,15 +98,11 @@ extern int more_main(int argc, char **argv)
106 cin = fopen("/dev/tty", "r"); 98 cin = fopen("/dev/tty", "r");
107 if (!cin) 99 if (!cin)
108 cin = fopen("/dev/console", "r"); 100 cin = fopen("/dev/console", "r");
109#ifdef USE_OLD_TERMIO
110 ioctl(fileno(cin), TCGETA, &initial_settings); 101 ioctl(fileno(cin), TCGETA, &initial_settings);
111#else
112 tcgetattr(fileno(cin), &initial_settings);
113#endif
114 new_settings = initial_settings; 102 new_settings = initial_settings;
115 new_settings.c_lflag &= ~ICANON; 103 new_settings.c_lflag &= ~ICANON;
116 new_settings.c_lflag &= ~ECHO; 104 new_settings.c_lflag &= ~ECHO;
117 stty(fileno(cin), &new_settings); 105 ioctl(fileno(cin), TCSETAF, &new_settings);
118 106
119#ifdef BB_FEATURE_AUTOWIDTH 107#ifdef BB_FEATURE_AUTOWIDTH
120 ioctl(fileno(stdout), TIOCGWINSZ, &win); 108 ioctl(fileno(stdout), TIOCGWINSZ, &win);