summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-03-07 02:01:52 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2011-03-07 02:01:52 +0100
commit82e785cf8cc6e78dd84adc1aee298dfa827a019c (patch)
tree4feed3651eae672c0adcc76992a6951d1293e9bd
parentbff5f3f2b4c568aa516ee3ec9201c887c0f1eca4 (diff)
more: fix tabs handling
function old new delta more_main 837 829 -8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--util-linux/more.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/util-linux/more.c b/util-linux/more.c
index c424a0e4b..7160b8b00 100644
--- a/util-linux/more.c
+++ b/util-linux/more.c
@@ -113,9 +113,12 @@ int more_main(int argc UNUSED_PARAM, char **argv)
loop_top:
if (input != 'r' && please_display_more_prompt) {
len = printf("--More-- ");
- if (st.st_size > 0) {
+ if (st.st_size != 0) {
+ uoff_t d = (uoff_t)st.st_size / 100;
+ if (d == 0)
+ d = 1;
len += printf("(%u%% of %"OFF_FMT"u bytes)",
- (int) (ftello(file)*100 / st.st_size),
+ (int) ((uoff_t)ftello(file) / d),
st.st_size);
}
fflush_all();
@@ -159,7 +162,7 @@ int more_main(int argc UNUSED_PARAM, char **argv)
/* Crudely convert tabs into spaces, which are
* a bajillion times easier to deal with. */
if (c == '\t') {
- spaces = CONVERTED_TAB_SIZE - 1;
+ spaces = ((unsigned)~len) % CONVERTED_TAB_SIZE;
c = ' ';
}