summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen2001-02-22 21:49:32 +0000
committerEric Andersen2001-02-22 21:49:32 +0000
commitffc40bf3de05a50a0f58be80fe76202b6b5972f8 (patch)
tree7cfdd28e0bb0b91324be4dce7d5422b078b5c358
parentb2007bffc530a4722e94ec702e1fe572e43d30c2 (diff)
downloadbusybox-ffc40bf3de05a50a0f58be80fe76202b6b5972f8.zip
busybox-ffc40bf3de05a50a0f58be80fe76202b6b5972f8.tar.gz
Account for remainder, and reset page_height for each and every page.
-rw-r--r--more.c14
-rw-r--r--util-linux/more.c14
2 files changed, 20 insertions, 8 deletions
diff --git a/more.c b/more.c
index 77e0c2f..2cfb3a8 100644
--- a/more.c
+++ b/more.c
@@ -71,7 +71,7 @@ extern int more_main(int argc, char **argv)
int please_display_more_prompt = 0;
struct stat st;
FILE *file;
- int len;
+ int len, page_height;
#if defined BB_FEATURE_AUTOWIDTH && defined BB_FEATURE_USE_TERMIOS
struct winsize win = { 0, 0, 0, 0 };
@@ -114,6 +114,7 @@ extern int more_main(int argc, char **argv)
#endif
len = 0;
+ page_height = terminal_height;
while ((c = getc(file)) != EOF) {
if (please_display_more_prompt) {
@@ -162,6 +163,7 @@ extern int more_main(int argc, char **argv)
fflush(stdout);
#endif
len=0;
+ page_height = terminal_height;
}
/*
@@ -188,10 +190,14 @@ extern int more_main(int argc, char **argv)
* no lines get lost off the top. */
if (len) {
div_t result = div( len, terminal_width);
- if (result.quot)
- terminal_height-=(result.quot-1);
+ if (result.quot) {
+ if (result.rem)
+ page_height-=result.quot;
+ else
+ page_height-=(result.quot-1);
+ }
}
- if (++lines == terminal_height) {
+ if (++lines == page_height) {
please_display_more_prompt = 1;
}
len=0;
diff --git a/util-linux/more.c b/util-linux/more.c
index 77e0c2f..2cfb3a8 100644
--- a/util-linux/more.c
+++ b/util-linux/more.c
@@ -71,7 +71,7 @@ extern int more_main(int argc, char **argv)
int please_display_more_prompt = 0;
struct stat st;
FILE *file;
- int len;
+ int len, page_height;
#if defined BB_FEATURE_AUTOWIDTH && defined BB_FEATURE_USE_TERMIOS
struct winsize win = { 0, 0, 0, 0 };
@@ -114,6 +114,7 @@ extern int more_main(int argc, char **argv)
#endif
len = 0;
+ page_height = terminal_height;
while ((c = getc(file)) != EOF) {
if (please_display_more_prompt) {
@@ -162,6 +163,7 @@ extern int more_main(int argc, char **argv)
fflush(stdout);
#endif
len=0;
+ page_height = terminal_height;
}
/*
@@ -188,10 +190,14 @@ extern int more_main(int argc, char **argv)
* no lines get lost off the top. */
if (len) {
div_t result = div( len, terminal_width);
- if (result.quot)
- terminal_height-=(result.quot-1);
+ if (result.quot) {
+ if (result.rem)
+ page_height-=result.quot;
+ else
+ page_height-=(result.quot-1);
+ }
}
- if (++lines == terminal_height) {
+ if (++lines == page_height) {
please_display_more_prompt = 1;
}
len=0;