aboutsummaryrefslogtreecommitdiff
path: root/util-linux/more.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-02-22 21:49:32 +0000
committerEric Andersen <andersen@codepoet.org>2001-02-22 21:49:32 +0000
commitffc40bf3de05a50a0f58be80fe76202b6b5972f8 (patch)
tree7cfdd28e0bb0b91324be4dce7d5422b078b5c358 /util-linux/more.c
parentb2007bffc530a4722e94ec702e1fe572e43d30c2 (diff)
downloadbusybox-w32-ffc40bf3de05a50a0f58be80fe76202b6b5972f8.tar.gz
busybox-w32-ffc40bf3de05a50a0f58be80fe76202b6b5972f8.tar.bz2
busybox-w32-ffc40bf3de05a50a0f58be80fe76202b6b5972f8.zip
Account for remainder, and reset page_height for each and every page.
Diffstat (limited to 'util-linux/more.c')
-rw-r--r--util-linux/more.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/util-linux/more.c b/util-linux/more.c
index 77e0c2f7e..2cfb3a815 100644
--- a/util-linux/more.c
+++ b/util-linux/more.c
@@ -71,7 +71,7 @@ extern int more_main(int argc, char **argv)
71 int please_display_more_prompt = 0; 71 int please_display_more_prompt = 0;
72 struct stat st; 72 struct stat st;
73 FILE *file; 73 FILE *file;
74 int len; 74 int len, page_height;
75 75
76#if defined BB_FEATURE_AUTOWIDTH && defined BB_FEATURE_USE_TERMIOS 76#if defined BB_FEATURE_AUTOWIDTH && defined BB_FEATURE_USE_TERMIOS
77 struct winsize win = { 0, 0, 0, 0 }; 77 struct winsize win = { 0, 0, 0, 0 };
@@ -114,6 +114,7 @@ extern int more_main(int argc, char **argv)
114 114
115#endif 115#endif
116 len = 0; 116 len = 0;
117 page_height = terminal_height;
117 while ((c = getc(file)) != EOF) { 118 while ((c = getc(file)) != EOF) {
118 119
119 if (please_display_more_prompt) { 120 if (please_display_more_prompt) {
@@ -162,6 +163,7 @@ extern int more_main(int argc, char **argv)
162 fflush(stdout); 163 fflush(stdout);
163#endif 164#endif
164 len=0; 165 len=0;
166 page_height = terminal_height;
165 } 167 }
166 168
167 /* 169 /*
@@ -188,10 +190,14 @@ extern int more_main(int argc, char **argv)
188 * no lines get lost off the top. */ 190 * no lines get lost off the top. */
189 if (len) { 191 if (len) {
190 div_t result = div( len, terminal_width); 192 div_t result = div( len, terminal_width);
191 if (result.quot) 193 if (result.quot) {
192 terminal_height-=(result.quot-1); 194 if (result.rem)
195 page_height-=result.quot;
196 else
197 page_height-=(result.quot-1);
198 }
193 } 199 }
194 if (++lines == terminal_height) { 200 if (++lines == page_height) {
195 please_display_more_prompt = 1; 201 please_display_more_prompt = 1;
196 } 202 }
197 len=0; 203 len=0;