Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/util-linux/more.c


Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (10 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/util-linux/more.c

    r2725 r3232  
    1414 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    1515 */
     16
     17//usage:#define more_trivial_usage
     18//usage:       "[FILE]..."
     19//usage:#define more_full_usage "\n\n"
     20//usage:       "View FILE (or stdin) one screenful at a time"
     21//usage:
     22//usage:#define more_example_usage
     23//usage:       "$ dmesg | more\n"
    1624
    1725#include "libbb.h"
     
    7886        getTermSettings(cin_fileno, &initial_settings);
    7987        new_settings = initial_settings;
    80         new_settings.c_lflag &= ~ICANON;
    81         new_settings.c_lflag &= ~ECHO;
     88        new_settings.c_lflag &= ~(ICANON | ECHO);
    8289        new_settings.c_cc[VMIN] = 1;
    8390        new_settings.c_cc[VTIME] = 0;
     
    114121            if (input != 'r' && please_display_more_prompt) {
    115122                len = printf("--More-- ");
    116                 if (st.st_size > 0) {
     123                if (st.st_size != 0) {
     124                    uoff_t d = (uoff_t)st.st_size / 100;
     125                    if (d == 0)
     126                        d = 1;
    117127                    len += printf("(%u%% of %"OFF_FMT"u bytes)",
    118                         (int) (ftello(file)*100 / st.st_size),
     128                        (int) ((uoff_t)ftello(file) / d),
    119129                        st.st_size);
    120130                }
     
    160170             * a bajillion times easier to deal with. */
    161171            if (c == '\t') {
    162                 spaces = CONVERTED_TAB_SIZE - 1;
     172                spaces = ((unsigned)~len) % CONVERTED_TAB_SIZE;
    163173                c = ' ';
    164174            }
     
    192202            /* My small mind cannot fathom backspaces and UTF-8 */
    193203            putchar(c);
     204            die_if_ferror_stdout(); /* if tty was destroyed (closed xterm, etc) */
    194205        }
    195206        fclose(file);
Note: See TracChangeset for help on using the changeset viewer.