Message ID | 20200304203853.99118-2-anatol.pomozov@gmail.com |
---|---|
State | Superseded, archived |
Headers | show |
Series | [pacman-dev,1/2] Add config option to specify amount of concurrent download streams | expand |
On 5/3/20 6:38 am, Anatol Pomozov wrote: > 'output' is a list of messages that pacman received but delayed printing > to avoid messing with UI. > > Such functionality is useful for the upcoming multi-line progress bar > UI. Let's move it to a separate function. > > Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com> > --- > src/pacman/callback.c | 19 ++++++++++++------- > 1 file changed, 12 insertions(+), 7 deletions(-) > > diff --git a/src/pacman/callback.c b/src/pacman/callback.c > index 548e2df2..432fc734 100644 > --- a/src/pacman/callback.c > +++ b/src/pacman/callback.c > @@ -160,6 +160,16 @@ static void fill_progress(const int bar_percent, const int disp_percent, > fflush(stdout); > } > > +static void flush_output_list(void) { > + alpm_list_t *i = NULL; > + fflush(stdout); > + for(i = output; i; i = i->next) { > + fputs((const char *)i->data, stderr); > + } > + fflush(stderr); > + FREELIST(output); > +} > + > static int number_length(size_t n) > { > int digits = 1; > @@ -610,14 +620,9 @@ void cb_progress(alpm_progress_t event, const char *pkgname, int percent, > fill_progress(percent, percent, cols - infolen); > > if(percent == 100) { > - alpm_list_t *i = NULL; > + putchar('\n'); New line return added here. Why is that needed? > + flush_output_list(); > on_progress = 0; > - fflush(stdout); > - for(i = output; i; i = i->next) { > - fputs((const char *)i->data, stderr); > - } > - fflush(stderr); > - FREELIST(output); > } else { > on_progress = 1; > } >
Hi On Wed, Mar 4, 2020 at 9:16 PM Allan McRae <allan@archlinux.org> wrote: > > On 5/3/20 6:38 am, Anatol Pomozov wrote: > > 'output' is a list of messages that pacman received but delayed printing > > to avoid messing with UI. > > > > Such functionality is useful for the upcoming multi-line progress bar > > UI. Let's move it to a separate function. > > > > Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com> > > --- > > src/pacman/callback.c | 19 ++++++++++++------- > > 1 file changed, 12 insertions(+), 7 deletions(-) > > > > diff --git a/src/pacman/callback.c b/src/pacman/callback.c > > index 548e2df2..432fc734 100644 > > --- a/src/pacman/callback.c > > +++ b/src/pacman/callback.c > > @@ -160,6 +160,16 @@ static void fill_progress(const int bar_percent, const int disp_percent, > > fflush(stdout); > > } > > > > +static void flush_output_list(void) { > > + alpm_list_t *i = NULL; > > + fflush(stdout); > > + for(i = output; i; i = i->next) { > > + fputs((const char *)i->data, stderr); > > + } > > + fflush(stderr); > > + FREELIST(output); > > +} > > + > > static int number_length(size_t n) > > { > > int digits = 1; > > @@ -610,14 +620,9 @@ void cb_progress(alpm_progress_t event, const char *pkgname, int percent, > > fill_progress(percent, percent, cols - infolen); > > > > if(percent == 100) { > > - alpm_list_t *i = NULL; > > + putchar('\n'); > > New line return added here. Why is that needed? Oops, it leaked from the other (future) change. Will resend an update soon. > > > + flush_output_list(); > > on_progress = 0; > > - fflush(stdout); > > - for(i = output; i; i = i->next) { > > - fputs((const char *)i->data, stderr); > > - } > > - fflush(stderr); > > - FREELIST(output); > > } else { > > on_progress = 1; > > } > >
diff --git a/src/pacman/callback.c b/src/pacman/callback.c index 548e2df2..432fc734 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -160,6 +160,16 @@ static void fill_progress(const int bar_percent, const int disp_percent, fflush(stdout); } +static void flush_output_list(void) { + alpm_list_t *i = NULL; + fflush(stdout); + for(i = output; i; i = i->next) { + fputs((const char *)i->data, stderr); + } + fflush(stderr); + FREELIST(output); +} + static int number_length(size_t n) { int digits = 1; @@ -610,14 +620,9 @@ void cb_progress(alpm_progress_t event, const char *pkgname, int percent, fill_progress(percent, percent, cols - infolen); if(percent == 100) { - alpm_list_t *i = NULL; + putchar('\n'); + flush_output_list(); on_progress = 0; - fflush(stdout); - for(i = output; i; i = i->next) { - fputs((const char *)i->data, stderr); - } - fflush(stderr); - FREELIST(output); } else { on_progress = 1; }
'output' is a list of messages that pacman received but delayed printing to avoid messing with UI. Such functionality is useful for the upcoming multi-line progress bar UI. Let's move it to a separate function. Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com> --- src/pacman/callback.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)