diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-03-07 02:01:52 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-03-07 02:01:52 +0100 |
commit | 82e785cf8cc6e78dd84adc1aee298dfa827a019c (patch) | |
tree | 4feed3651eae672c0adcc76992a6951d1293e9bd | |
parent | bff5f3f2b4c568aa516ee3ec9201c887c0f1eca4 (diff) | |
download | busybox-w32-82e785cf8cc6e78dd84adc1aee298dfa827a019c.tar.gz busybox-w32-82e785cf8cc6e78dd84adc1aee298dfa827a019c.tar.bz2 busybox-w32-82e785cf8cc6e78dd84adc1aee298dfa827a019c.zip |
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.c | 9 |
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) | |||
113 | loop_top: | 113 | loop_top: |
114 | if (input != 'r' && please_display_more_prompt) { | 114 | if (input != 'r' && please_display_more_prompt) { |
115 | len = printf("--More-- "); | 115 | len = printf("--More-- "); |
116 | if (st.st_size > 0) { | 116 | if (st.st_size != 0) { |
117 | uoff_t d = (uoff_t)st.st_size / 100; | ||
118 | if (d == 0) | ||
119 | d = 1; | ||
117 | len += printf("(%u%% of %"OFF_FMT"u bytes)", | 120 | len += printf("(%u%% of %"OFF_FMT"u bytes)", |
118 | (int) (ftello(file)*100 / st.st_size), | 121 | (int) ((uoff_t)ftello(file) / d), |
119 | st.st_size); | 122 | st.st_size); |
120 | } | 123 | } |
121 | fflush_all(); | 124 | fflush_all(); |
@@ -159,7 +162,7 @@ int more_main(int argc UNUSED_PARAM, char **argv) | |||
159 | /* Crudely convert tabs into spaces, which are | 162 | /* Crudely convert tabs into spaces, which are |
160 | * a bajillion times easier to deal with. */ | 163 | * a bajillion times easier to deal with. */ |
161 | if (c == '\t') { | 164 | if (c == '\t') { |
162 | spaces = CONVERTED_TAB_SIZE - 1; | 165 | spaces = ((unsigned)~len) % CONVERTED_TAB_SIZE; |
163 | c = ' '; | 166 | c = ' '; |
164 | } | 167 | } |
165 | 168 | ||