diff options
Diffstat (limited to 'libbb/progress.c')
-rw-r--r-- | libbb/progress.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/libbb/progress.c b/libbb/progress.c index 74e80a39e..3c7355fee 100644 --- a/libbb/progress.c +++ b/libbb/progress.c | |||
@@ -93,22 +93,9 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p, | |||
93 | 93 | ||
94 | #if ENABLE_UNICODE_SUPPORT | 94 | #if ENABLE_UNICODE_SUPPORT |
95 | init_unicode(); | 95 | init_unicode(); |
96 | /* libbb candidate? */ | ||
97 | { | 96 | { |
98 | wchar_t wbuf21[21]; | 97 | char *buf = unicode_conv_to_printable_fixedwidth(NULL, curfile, 20); |
99 | char *buf = xstrdup(curfile); | 98 | fprintf(stderr, "\r%s%4u%% ", buf, ratio); |
100 | unsigned len; | ||
101 | |||
102 | /* trim to 20 wide chars max (sets wbuf21[20] to 0) | ||
103 | * also, in case mbstowcs fails, we at least | ||
104 | * dont get garbage */ | ||
105 | memset(wbuf21, 0, sizeof(wbuf21)); | ||
106 | /* convert to wide chars, no more than 20 */ | ||
107 | len = mbstowcs(wbuf21, curfile, 20); /* NB: may return -1 */ | ||
108 | /* back to multibyte; cant overflow */ | ||
109 | wcstombs(buf, wbuf21, INT_MAX); | ||
110 | len = (len > 20) ? 0 : 20 - len; | ||
111 | fprintf(stderr, "\r%s%*s%4u%% ", buf, len, "", ratio); | ||
112 | free(buf); | 99 | free(buf); |
113 | } | 100 | } |
114 | #else | 101 | #else |
@@ -158,7 +145,8 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p, | |||
158 | /* (long long helps to have working ETA even if !LFS) */ | 145 | /* (long long helps to have working ETA even if !LFS) */ |
159 | unsigned eta = (unsigned long long)to_download*elapsed/(uoff_t)transferred - elapsed; | 146 | unsigned eta = (unsigned long long)to_download*elapsed/(uoff_t)transferred - elapsed; |
160 | unsigned secs = eta % 3600; | 147 | unsigned secs = eta % 3600; |
161 | fprintf(stderr, "%02u:%02u:%02u ETA", eta / 3600, secs / 60, secs % 60); | 148 | unsigned hours = eta / 3600; |
149 | fprintf(stderr, "%02u:%02u:%02u ETA", hours, secs / 60, secs % 60); | ||
162 | } | 150 | } |
163 | } | 151 | } |
164 | } | 152 | } |