This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=cd84b0f9e69ba0c409a87295143a0498c5d6a38a

commit cd84b0f9e69ba0c409a87295143a0498c5d6a38a
Author: Guillem Jover <[email protected]>
AuthorDate: Wed Apr 26 23:52:06 2023 +0200

    libdpkg: Simplify progress output by using fputs() and putchar()
    
    Instead of doing a full printf(), when we know that we do not need to
    actually format the strings, use the more efficient fputs() and
    putchar() functions.
    
    This also decouples the percentage printing which is locale sensitive
    from the general format of the output, which we will then be able to
    mark for translation independently of the other text.
---
 lib/dpkg/progress.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/dpkg/progress.c b/lib/dpkg/progress.c
index 1bf2512ae..bbf972c8b 100644
--- a/lib/dpkg/progress.c
+++ b/lib/dpkg/progress.c
@@ -39,10 +39,9 @@ progress_init(struct progress *progress, const char *text, 
int max)
 
        progress->on_tty = isatty(1);
 
+       fputs(text, stdout);
        if (progress->on_tty)
-               printf("%s\r", text);
-       else
-               printf("%s", text);
+               putchar('\r');
 }
 
 void
@@ -63,12 +62,14 @@ progress_step(struct progress *progress)
 
        progress->last_percent = cur_percent;
 
-       printf("%s%d%%\r", progress->text, cur_percent);
+       fputs(progress->text, stdout);
+       printf("%d%%", cur_percent);
+       putchar('\r');
 }
 
 void
 progress_done(struct progress *progress)
 {
        if (progress->on_tty)
-               printf("%s", progress->text);
+               fputs(progress->text, stdout);
 }

-- 
Dpkg.Org's dpkg

Reply via email to