[pacman-dev] [PATCH] pacman/util.c: fix output flushing in questions

Allan McRae allan at archlinux.org
Sat May 4 17:44:42 EDT 2013


On 04/05/13 23:39, Andrew Gregory wrote:
> Flush stream before taking input in select_question() and only flush
> once during question().  Also fix some tabs inside related fprintf
> statements.
> 
> Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
> ---

Ack -> maint.

>  src/pacman/util.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/pacman/util.c b/src/pacman/util.c
> index 66765b1..351c74d 100644
> --- a/src/pacman/util.c
> +++ b/src/pacman/util.c
> @@ -1391,17 +1391,17 @@ int multiselect_question(char *array, int count)
>  	/* sentinel byte to later see if we filled up the entire string */
>  	*lastchar = 1;
>  
>  	while(1) {
>  		memset(array, 1, count);
>  
>  		fprintf(stream, "\n");
>  		fprintf(stream, _("Enter a selection (default=all)"));
> -		fprintf(stream,	": ");
> +		fprintf(stream, ": ");
>  		fflush(stream);
>  
>  		if(config->noconfirm) {
>  			fprintf(stream, "\n");
>  			break;
>  		}
>  
>  		flush_term_input(fileno(stdin));
> @@ -1455,17 +1455,18 @@ int select_question(int count)
>  	} else {
>  		/* Use stderr so questions are always displayed when redirecting output */
>  		stream = stderr;
>  	}
>  
>  	while(1) {
>  		fprintf(stream, "\n");
>  		fprintf(stream, _("Enter a number (default=%d)"), preset);
> -		fprintf(stream,	": ");
> +		fprintf(stream, ": ");
> +		fflush(stream);
>  
>  		if(config->noconfirm) {
>  			fprintf(stream, "\n");
>  			break;
>  		}
>  
>  		flush_term_input(fileno(stdin));
>  
> @@ -1516,17 +1517,16 @@ static int question(short preset, const char *format, va_list args)
>  	fputs(config->colstr.nocolor, stream);
>  	fflush(stream);
>  
>  	if(config->noconfirm) {
>  		fprintf(stream, "\n");
>  		return preset;
>  	}
>  
> -	fflush(stream);
>  	flush_term_input(fd_in);
>  
>  	if(fgets(response, sizeof(response), stdin)) {
>  		size_t len = strtrim(response);
>  		if(len == 0) {
>  			return preset;
>  		}
>  
> 



More information about the pacman-dev mailing list