diff options
author | Mark Whitley <markw@lineo.com> | 2000-06-21 22:53:16 +0000 |
---|---|---|
committer | Mark Whitley <markw@lineo.com> | 2000-06-21 22:53:16 +0000 |
commit | 4fa84e6b54c3e5313f6fbc133017f100a25b8f1a (patch) | |
tree | d69214eb94435f554e01d33a34577df91508589f /util-linux/more.c | |
parent | c6cdf5874751556c938242819eaa38b30508a20d (diff) | |
download | busybox-w32-4fa84e6b54c3e5313f6fbc133017f100a25b8f1a.tar.gz busybox-w32-4fa84e6b54c3e5313f6fbc133017f100a25b8f1a.tar.bz2 busybox-w32-4fa84e6b54c3e5313f6fbc133017f100a25b8f1a.zip |
Cleaned up some #ifdef spiderwebs.
Diffstat (limited to 'util-linux/more.c')
-rw-r--r-- | util-linux/more.c | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/util-linux/more.c b/util-linux/more.c index 131016578..841e28321 100644 --- a/util-linux/more.c +++ b/util-linux/more.c | |||
@@ -42,17 +42,16 @@ static const char more_usage[] = "more [FILE ...]\n" | |||
42 | 42 | ||
43 | /* ED: sparc termios is broken: revert back to old termio handling. */ | 43 | /* ED: sparc termios is broken: revert back to old termio handling. */ |
44 | #ifdef BB_FEATURE_USE_TERMIOS | 44 | #ifdef BB_FEATURE_USE_TERMIOS |
45 | 45 | # if #cpu(sparc) | |
46 | #if #cpu(sparc) | 46 | # include <termio.h> |
47 | # include <termio.h> | 47 | # define termios termio |
48 | # define termios termio | 48 | # define setTermSettings(fd,argp) ioctl(fd,TCSETAF,argp) |
49 | # define setTermSettings(fd,argp) ioctl(fd,TCSETAF,argp) | 49 | # define getTermSettings(fd,argp) ioctl(fd,TCGETA,argp) |
50 | # define getTermSettings(fd,argp) ioctl(fd,TCGETA,argp) | 50 | # else |
51 | #else | 51 | # include <termios.h> |
52 | # include <termios.h> | 52 | # define setTermSettings(fd,argp) tcsetattr(fd,TCSANOW,argp) |
53 | # define setTermSettings(fd,argp) tcsetattr(fd,TCSANOW,argp) | 53 | # define getTermSettings(fd,argp) tcgetattr(fd, argp); |
54 | # define getTermSettings(fd,argp) tcgetattr(fd, argp); | 54 | # endif |
55 | #endif | ||
56 | 55 | ||
57 | FILE *cin; | 56 | FILE *cin; |
58 | 57 | ||
@@ -64,24 +63,11 @@ void gotsig(int sig) | |||
64 | fprintf(stdout, "\n"); | 63 | fprintf(stdout, "\n"); |
65 | exit(TRUE); | 64 | exit(TRUE); |
66 | } | 65 | } |
67 | #endif | 66 | #endif /* BB_FEATURE_USE_TERMIOS */ |
68 | |||
69 | |||
70 | |||
71 | #define TERMINAL_WIDTH 79 /* not 80 in case terminal has linefold bug */ | ||
72 | #define TERMINAL_HEIGHT 24 | ||
73 | 67 | ||
74 | 68 | ||
75 | #if defined BB_FEATURE_AUTOWIDTH | 69 | static int terminal_width = 79; /* not 80 in case terminal has linefold bug */ |
76 | #ifdef BB_FEATURE_USE_TERMIOS | 70 | static int terminal_height = 24; |
77 | static int terminal_width = TERMINAL_WIDTH; | ||
78 | #endif | ||
79 | static int terminal_height = TERMINAL_HEIGHT; | ||
80 | #else | ||
81 | #define terminal_width TERMINAL_WIDTH | ||
82 | #define terminal_height TERMINAL_HEIGHT | ||
83 | #endif | ||
84 | |||
85 | 71 | ||
86 | 72 | ||
87 | extern int more_main(int argc, char **argv) | 73 | extern int more_main(int argc, char **argv) |
@@ -126,13 +112,13 @@ extern int more_main(int argc, char **argv) | |||
126 | new_settings.c_lflag &= ~ECHO; | 112 | new_settings.c_lflag &= ~ECHO; |
127 | setTermSettings(fileno(cin), &new_settings); | 113 | setTermSettings(fileno(cin), &new_settings); |
128 | 114 | ||
129 | #ifdef BB_FEATURE_AUTOWIDTH | 115 | # ifdef BB_FEATURE_AUTOWIDTH |
130 | ioctl(fileno(stdout), TIOCGWINSZ, &win); | 116 | ioctl(fileno(stdout), TIOCGWINSZ, &win); |
131 | if (win.ws_row > 4) | 117 | if (win.ws_row > 4) |
132 | terminal_height = win.ws_row - 2; | 118 | terminal_height = win.ws_row - 2; |
133 | if (win.ws_col > 0) | 119 | if (win.ws_col > 0) |
134 | terminal_width = win.ws_col - 1; | 120 | terminal_width = win.ws_col - 1; |
135 | #endif | 121 | # endif |
136 | 122 | ||
137 | (void) signal(SIGINT, gotsig); | 123 | (void) signal(SIGINT, gotsig); |
138 | (void) signal(SIGQUIT, gotsig); | 124 | (void) signal(SIGQUIT, gotsig); |
@@ -209,7 +195,10 @@ extern int more_main(int argc, char **argv) | |||
209 | if (++lines == terminal_height) | 195 | if (++lines == terminal_height) |
210 | please_display_more_prompt = 1; | 196 | please_display_more_prompt = 1; |
211 | } | 197 | } |
212 | /* If any key other than a return is hit, scroll by one page */ | 198 | /* |
199 | * If we just read a newline from the file being 'mored' and any | ||
200 | * key other than a return is hit, scroll by one page | ||
201 | */ | ||
213 | putc(c, stdout); | 202 | putc(c, stdout); |
214 | } | 203 | } |
215 | fclose(file); | 204 | fclose(file); |