X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=util-linux%2Fmore.c;h=05fe86970ade5ce5abafa96d52b8d900bafbbc54;hb=081df62b921cf17f1d4c4e0214abfa273c92cfde;hp=780cddf665e1b75dfb105047a5dd65b5f46c2ba3;hpb=439e3df65300100e4b63580141eaa238c30431d5;p=oweals%2Fbusybox.git diff --git a/util-linux/more.c b/util-linux/more.c index 780cddf66..05fe86970 100644 --- a/util-linux/more.c +++ b/util-linux/more.c @@ -2,8 +2,8 @@ /* * Mini more implementation for busybox * - * * Copyright (C) 1995, 1996 by Bruce Perens . + * Copyright (C) 1999-2002 by Erik Andersen * * Latest version blended together by Erik Andersen , * based on the original more implementation by Bruce, and code from the @@ -37,7 +37,7 @@ static FILE *cin; -#ifdef BB_FEATURE_USE_TERMIOS +#ifdef CONFIG_FEATURE_USE_TERMIOS #include #define setTermSettings(fd,argp) tcsetattr(fd,TCSANOW,argp) #define getTermSettings(fd,argp) tcgetattr(fd, argp); @@ -54,7 +54,7 @@ static void gotsig(int sig) putchar('\n'); exit(EXIT_FAILURE); } -#endif /* BB_FEATURE_USE_TERMIOS */ +#endif /* CONFIG_FEATURE_USE_TERMIOS */ static int terminal_width = 79; /* not 80 in case terminal has linefold bug */ @@ -69,7 +69,7 @@ extern int more_main(int argc, char **argv) FILE *file; int len, page_height; -#if defined BB_FEATURE_AUTOWIDTH && defined BB_FEATURE_USE_TERMIOS +#if defined CONFIG_FEATURE_AUTOWIDTH && defined CONFIG_FEATURE_USE_TERMIOS struct winsize win = { 0, 0, 0, 0 }; #endif @@ -83,7 +83,7 @@ extern int more_main(int argc, char **argv) if (!cin) cin = xfopen(CONSOLE_DEV, "r"); please_display_more_prompt = 0; -#ifdef BB_FEATURE_USE_TERMIOS +#ifdef CONFIG_FEATURE_USE_TERMIOS getTermSettings(fileno(cin), &initial_settings); new_settings = initial_settings; new_settings.c_lflag &= ~ICANON; @@ -109,12 +109,13 @@ extern int more_main(int argc, char **argv) if(file==0) goto loop; + st.st_size = 0; fstat(fileno(file), &st); if(please_display_more_prompt>0) please_display_more_prompt = 0; -#if defined BB_FEATURE_AUTOWIDTH && defined BB_FEATURE_USE_TERMIOS +#if defined CONFIG_FEATURE_AUTOWIDTH && defined CONFIG_FEATURE_USE_TERMIOS ioctl(fileno(stdout), TIOCGWINSZ, &win); if (win.ws_row > 4) terminal_height = win.ws_row - 2; @@ -128,7 +129,7 @@ extern int more_main(int argc, char **argv) if (please_display_more_prompt>0) { len = printf("--More-- "); - if (file != stdin) { + if (file != stdin && st.st_size > 0) { #if _FILE_OFFSET_BITS == 64 len += printf("(%d%% of %lld bytes)", (int) (100 * ((double) ftell(file) / @@ -147,7 +148,7 @@ extern int more_main(int argc, char **argv) * to get input from the user. */ input = getc(cin); -#ifndef BB_FEATURE_USE_TERMIOS +#ifndef CONFIG_FEATURE_USE_TERMIOS printf("\033[A"); /* up cursor */ #endif /* Erase the "More" message */