Move flushing 'output' list into separate function
'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> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
aff69f43b1
commit
e578903b60
1 changed files with 11 additions and 7 deletions
|
@ -160,6 +160,16 @@ static void fill_progress(const int bar_percent, const int disp_percent,
|
||||||
fflush(stdout);
|
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)
|
static int number_length(size_t n)
|
||||||
{
|
{
|
||||||
int digits = 1;
|
int digits = 1;
|
||||||
|
@ -610,14 +620,8 @@ void cb_progress(alpm_progress_t event, const char *pkgname, int percent,
|
||||||
fill_progress(percent, percent, cols - infolen);
|
fill_progress(percent, percent, cols - infolen);
|
||||||
|
|
||||||
if(percent == 100) {
|
if(percent == 100) {
|
||||||
alpm_list_t *i = NULL;
|
flush_output_list();
|
||||||
on_progress = 0;
|
on_progress = 0;
|
||||||
fflush(stdout);
|
|
||||||
for(i = output; i; i = i->next) {
|
|
||||||
fputs((const char *)i->data, stderr);
|
|
||||||
}
|
|
||||||
fflush(stderr);
|
|
||||||
FREELIST(output);
|
|
||||||
} else {
|
} else {
|
||||||
on_progress = 1;
|
on_progress = 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue