]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/pretty-print: use strrepa where appropriate 31586/head
authorMike Yuan <me@yhndnzj.com>
Sat, 2 Mar 2024 03:33:29 +0000 (11:33 +0800)
committerMike Yuan <me@yhndnzj.com>
Sat, 2 Mar 2024 03:50:34 +0000 (11:50 +0800)
src/shared/pretty-print.c

index af44bb2ca2e010f94b577d421e7e102d49deaeb1..b81d1eb40c2739477ad30440b03a5876659b7559 100644 (file)
@@ -522,13 +522,10 @@ void clear_progress_bar(const char *prefix) {
 
         fputc('\r', stderr);
 
-        if (terminal_is_dumb()) {
-                size_t l = strlen_ptr(prefix);
-                for (size_t i = 0; i < l; i ++)
-                        fputc(' ', stderr);
-
-                fputs("    ", stderr);
-        } else
+        if (terminal_is_dumb())
+                fputs(strrepa(" ", strlen_ptr(prefix) + 4), /* 4: %3.0f%% */
+                      stderr);
+        else
                 fputs(ANSI_ERASE_TO_END_OF_LINE, stderr);
 
         fputc('\r', stderr);