~ubuntu-branches/ubuntu/utopic/busybox/utopic

« back to all changes in this revision

Viewing changes to util-linux/more.c

  • Committer: Package Import Robot
  • Author(s): Steve Langasek
  • Date: 2012-05-01 03:35:20 UTC
  • mfrom: (2.1.29 sid)
  • Revision ID: package-import@ubuntu.com-20120501033520-3nb8wjf4bp524txp
Tags: 1:1.19.3-7ubuntu1
* Merge from Debian unstable, remaining changes:
  - [udeb] Enable chvt, killall, losetup, NFS mount, od, ping, ping6, and
    stat.
  - [deb, static] Enable CGI support for httpd.
  - Enable 'mount -f' and mount helpers for all targets.
  - Add busybox-initramfs.
  - test-bin.patch: Move test and friends to /bin.
  - static-sh-alias.patch: Add static-sh alias name for ash, and install
    /bin/static-sh symlink to busybox in busybox-static.
  - debian/patches/fix-64-bit-permissions.patch: mkdir: fix permissions
    on 64-bit platforms.  Taken from upstream.
  - Filter out -Werror=format-security from CFLAGS passed by
    dpkg-buildpackage, at least for now.
* Dropped changes, included in Debian:
  - [deb] Enable mdev.
  - Add cross-compiling support.
* Disable NFS mount in the static build; needs a newer upstream version of
  busybox for compatibility with glibc 2.15.
* Set V=1 in debian/rules, to get more meaningful build logs.
* Export the dpkg-buildflags to the environment, so we pick up hardening
  now that dpkg doesn't export them for us.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
15
15
 */
16
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"
 
24
 
17
25
#include "libbb.h"
18
26
 
19
27
/* Support for FEATURE_USE_TERMIOS */
113
121
 loop_top:
114
122
                        if (input != 'r' && please_display_more_prompt) {
115
123
                                len = printf("--More-- ");
116
 
                                if (st.st_size > 0) {
 
124
                                if (st.st_size != 0) {
 
125
                                        uoff_t d = (uoff_t)st.st_size / 100;
 
126
                                        if (d == 0)
 
127
                                                d = 1;
117
128
                                        len += printf("(%u%% of %"OFF_FMT"u bytes)",
118
 
                                                (int) (ftello(file)*100 / st.st_size),
 
129
                                                (int) ((uoff_t)ftello(file) / d),
119
130
                                                st.st_size);
120
131
                                }
121
132
                                fflush_all();
159
170
                        /* Crudely convert tabs into spaces, which are
160
171
                         * a bajillion times easier to deal with. */
161
172
                        if (c == '\t') {
162
 
                                spaces = CONVERTED_TAB_SIZE - 1;
 
173
                                spaces = ((unsigned)~len) % CONVERTED_TAB_SIZE;
163
174
                                c = ' ';
164
175
                        }
165
176
 
191
202
                        }
192
203
                        /* My small mind cannot fathom backspaces and UTF-8 */
193
204
                        putchar(c);
 
205
                        die_if_ferror_stdout(); /* if tty was destroyed (closed xterm, etc) */
194
206
                }
195
207
                fclose(file);
196
208
                fflush_all();