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

Andrew Gregory andrew.gregory.8 at gmail.com
Sat May 4 09:39:28 EDT 2013


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>
---
 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;
 		}
 
-- 
1.8.2.2



More information about the pacman-dev mailing list