aboutsummaryrefslogtreecommitdiff
path: root/util-linux/more.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-02-23 01:39:26 +0000
committerEric Andersen <andersen@codepoet.org>2001-02-23 01:39:26 +0000
commit5723934f7c6f08769e0767eec4db0c88cdeda5c9 (patch)
tree909318fa0fadf02f81d7c4d31d5d12b0e97d8e49 /util-linux/more.c
parent41492d6c2371e8afafec67ad30657ab939ed2d70 (diff)
downloadbusybox-w32-5723934f7c6f08769e0767eec4db0c88cdeda5c9.tar.gz
busybox-w32-5723934f7c6f08769e0767eec4db0c88cdeda5c9.tar.bz2
busybox-w32-5723934f7c6f08769e0767eec4db0c88cdeda5c9.zip
Yet another fix. I think I got it this time.
-Erik
Diffstat (limited to 'util-linux/more.c')
-rw-r--r--util-linux/more.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/util-linux/more.c b/util-linux/more.c
index 2cfb3a815..f8b17b34a 100644
--- a/util-linux/more.c
+++ b/util-linux/more.c
@@ -67,8 +67,8 @@ static int terminal_height = 24;
67 67
68extern int more_main(int argc, char **argv) 68extern int more_main(int argc, char **argv)
69{ 69{
70 int c, lines = 0, input = 0; 70 int c, lines, input = 0;
71 int please_display_more_prompt = 0; 71 int please_display_more_prompt;
72 struct stat st; 72 struct stat st;
73 FILE *file; 73 FILE *file;
74 int len, page_height; 74 int len, page_height;
@@ -113,13 +113,13 @@ extern int more_main(int argc, char **argv)
113 (void) signal(SIGTERM, gotsig); 113 (void) signal(SIGTERM, gotsig);
114 114
115#endif 115#endif
116 len = 0; 116 len=0;
117 lines = 0;
117 page_height = terminal_height; 118 page_height = terminal_height;
119 please_display_more_prompt = 0;
118 while ((c = getc(file)) != EOF) { 120 while ((c = getc(file)) != EOF) {
119 121
120 if (please_display_more_prompt) { 122 if (please_display_more_prompt) {
121 lines = 0;
122 please_display_more_prompt = 0;
123 len = printf("--More-- "); 123 len = printf("--More-- ");
124 if (file != stdin) { 124 if (file != stdin) {
125#if _FILE_OFFSET_BITS == 64 125#if _FILE_OFFSET_BITS == 64
@@ -163,13 +163,15 @@ extern int more_main(int argc, char **argv)
163 fflush(stdout); 163 fflush(stdout);
164#endif 164#endif
165 len=0; 165 len=0;
166 lines = 0;
166 page_height = terminal_height; 167 page_height = terminal_height;
168 please_display_more_prompt = 0;
167 } 169 }
168 170
169 /* 171 /*
170 * There are two input streams to worry about here: 172 * There are two input streams to worry about here:
171 * 173 *
172 * c : the character we are reading from the file being "mored" 174 * c : the character we are reading from the file being "mored"
173 * input : a character received from the keyboard 175 * input : a character received from the keyboard
174 * 176 *
175 * If we hit a newline in the _file_ stream, we want to test and 177 * If we hit a newline in the _file_ stream, we want to test and
@@ -188,7 +190,7 @@ extern int more_main(int argc, char **argv)
188 } 190 }
189 /* Adjust the terminal height for any overlap, so that 191 /* Adjust the terminal height for any overlap, so that
190 * no lines get lost off the top. */ 192 * no lines get lost off the top. */
191 if (len) { 193 if (len >= terminal_width) {
192 div_t result = div( len, terminal_width); 194 div_t result = div( len, terminal_width);
193 if (result.quot) { 195 if (result.quot) {
194 if (result.rem) 196 if (result.rem)
@@ -197,7 +199,7 @@ extern int more_main(int argc, char **argv)
197 page_height-=(result.quot-1); 199 page_height-=(result.quot-1);
198 } 200 }
199 } 201 }
200 if (++lines == page_height) { 202 if (++lines >= page_height) {
201 please_display_more_prompt = 1; 203 please_display_more_prompt = 1;
202 } 204 }
203 len=0; 205 len=0;