[pacman-dev] [PATCH] pacman/util.c: flush output once for questions
Convert a couple random tabs inside fprintf to spaces. Signed-off-by: Andrew Gregory <andrew.gregory.8@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 862c8e8..7b7dace 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -1384,15 +1384,15 @@ int multiselect_question(char *array, int count) *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; } @@ -1448,15 +1448,16 @@ int select_question(int count) /* 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)); @@ -1509,15 +1510,14 @@ static int question(short preset, const char *format, va_list args) 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
On 03/04/13 09:53, Andrew Gregory wrote:
Convert a couple random tabs inside fprintf to spaces.
That commit subject and message really made me read through the patch... How about: pacman/util.c: fix issue with flushing output in questions 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@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 862c8e8..7b7dace 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -1384,15 +1384,15 @@ int multiselect_question(char *array, int count) *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; }
@@ -1448,15 +1448,16 @@ int select_question(int count) /* 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)); @@ -1509,15 +1510,14 @@ static int question(short preset, const char *format, va_list args) 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; }
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@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
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@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; }
participants (2)
-
Allan McRae
-
Andrew Gregory