projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
convert() is used by dos2unix and unix2dos
[oweals/busybox.git]
/
more.c
diff --git
a/more.c
b/more.c
index 2cfb3a8152dadd48fcd2e847d7067c243bb11d9b..732396f03341a918b974136b3911f1cb97b85c2b 100644
(file)
--- a/
more.c
+++ b/
more.c
@@
-67,8
+67,8
@@
static int terminal_height = 24;
extern int more_main(int argc, char **argv)
{
extern int more_main(int argc, char **argv)
{
- int c, lines
= 0
, input = 0;
- int please_display_more_prompt
= 0
;
+ int c, lines, input = 0;
+ int please_display_more_prompt;
struct stat st;
FILE *file;
int len, page_height;
struct stat st;
FILE *file;
int len, page_height;
@@
-91,7
+91,7
@@
extern int more_main(int argc, char **argv)
#ifdef BB_FEATURE_USE_TERMIOS
cin = fopen("/dev/tty", "r");
if (!cin)
#ifdef BB_FEATURE_USE_TERMIOS
cin = fopen("/dev/tty", "r");
if (!cin)
- cin = fopen("/dev/console", "r");
+ cin =
x
fopen("/dev/console", "r");
getTermSettings(fileno(cin), &initial_settings);
new_settings = initial_settings;
new_settings.c_cc[VMIN] = 1;
getTermSettings(fileno(cin), &initial_settings);
new_settings = initial_settings;
new_settings.c_cc[VMIN] = 1;
@@
-113,24
+113,24
@@
extern int more_main(int argc, char **argv)
(void) signal(SIGTERM, gotsig);
#endif
(void) signal(SIGTERM, gotsig);
#endif
- len = 0;
+ len=0;
+ lines = 0;
page_height = terminal_height;
page_height = terminal_height;
+ please_display_more_prompt = 0;
while ((c = getc(file)) != EOF) {
if (please_display_more_prompt) {
while ((c = getc(file)) != EOF) {
if (please_display_more_prompt) {
- lines = 0;
- please_display_more_prompt = 0;
len = printf("--More-- ");
if (file != stdin) {
#if _FILE_OFFSET_BITS == 64
len += printf("(%d%% of %lld bytes)",
len = printf("--More-- ");
if (file != stdin) {
#if _FILE_OFFSET_BITS == 64
len += printf("(%d%% of %lld bytes)",
+ (int) (100 * ((double) ftell(file) /
+ (double) st.st_size)), (long long)st.st_size);
#else
len += printf("(%d%% of %ld bytes)",
#else
len += printf("(%d%% of %ld bytes)",
+ (int) (100 * ((double) ftell(file) /
+ (double) st.st_size)), (long)st.st_size);
#endif
#endif
- (int) (100 *
- ((double) ftell(file) /
- (double) st.st_size)),
- st.st_size);
}
len += printf("%s",
#ifdef BB_FEATURE_USE_TERMIOS
}
len += printf("%s",
#ifdef BB_FEATURE_USE_TERMIOS
@@
-154,22
+154,22
@@
extern int more_main(int argc, char **argv)
#ifdef BB_FEATURE_USE_TERMIOS
/* Erase the "More" message */
#ifdef BB_FEATURE_USE_TERMIOS
/* Erase the "More" message */
+ putc('\r', stdout);
while (--len >= 0)
while (--len >= 0)
- putc('\b', stdout);
- while (++len <= terminal_width)
putc(' ', stdout);
putc(' ', stdout);
- while (--len >= 0)
- putc('\b', stdout);
+ putc('\r', stdout);
fflush(stdout);
#endif
len=0;
fflush(stdout);
#endif
len=0;
+ lines = 0;
page_height = terminal_height;
page_height = terminal_height;
+ please_display_more_prompt = 0;
}
/*
* There are two input streams to worry about here:
*
}
/*
* There are two input streams to worry about here:
*
- *
c
: the character we are reading from the file being "mored"
+ *
c
: the character we are reading from the file being "mored"
* input : a character received from the keyboard
*
* If we hit a newline in the _file_ stream, we want to test and
* input : a character received from the keyboard
*
* If we hit a newline in the _file_ stream, we want to test and
@@
-188,7
+188,7
@@
extern int more_main(int argc, char **argv)
}
/* Adjust the terminal height for any overlap, so that
* no lines get lost off the top. */
}
/* Adjust the terminal height for any overlap, so that
* no lines get lost off the top. */
- if (len) {
+ if (len
>= terminal_width
) {
div_t result = div( len, terminal_width);
if (result.quot) {
if (result.rem)
div_t result = div( len, terminal_width);
if (result.quot) {
if (result.rem)
@@
-197,7
+197,7
@@
extern int more_main(int argc, char **argv)
page_height-=(result.quot-1);
}
}
page_height-=(result.quot-1);
}
}
- if (++lines
=
= page_height) {
+ if (++lines
>
= page_height) {
please_display_more_prompt = 1;
}
len=0;
please_display_more_prompt = 1;
}
len=0;