Blame SOURCES/0016-report-cli-use-the-Client-API-for-communication-to-u.patch

4b6aa8
From 2886582f6e48258d7b8c941725a4456ed62578e9 Mon Sep 17 00:00:00 2001
4b6aa8
From: Jakub Filak <jfilak@redhat.com>
4b6aa8
Date: Tue, 28 Jan 2014 16:58:04 +0100
4b6aa8
Subject: [LIBREPORT PATCH 16/17] report-cli: use the Client API for
4b6aa8
 communication to user
4b6aa8
4b6aa8
Closes rhbz#1058845
4b6aa8
4b6aa8
Signed-off-by: Jakub Filak <jfilak@redhat.com>
4b6aa8
---
4b6aa8
 src/cli/cli-report.c | 30 ++++--------------------------
4b6aa8
 1 file changed, 4 insertions(+), 26 deletions(-)
4b6aa8
4b6aa8
diff --git a/src/cli/cli-report.c b/src/cli/cli-report.c
4b6aa8
index 5b32fbc..68baa8b 100644
4b6aa8
--- a/src/cli/cli-report.c
4b6aa8
+++ b/src/cli/cli-report.c
4b6aa8
@@ -408,26 +408,6 @@ static int run_report_editor(problem_data_t *problem_data)
4b6aa8
 }
4b6aa8
 
4b6aa8
 /**
4b6aa8
- * Asks user for a text response.
4b6aa8
- * @param question
4b6aa8
- *  Question displayed to user.
4b6aa8
- * @param result
4b6aa8
- *  Output array.
4b6aa8
- * @param result_size
4b6aa8
- *  Maximum byte count to be written.
4b6aa8
- */
4b6aa8
-static void read_from_stdin(const char *question, char *result, int result_size)
4b6aa8
-{
4b6aa8
-    assert(result_size > 1);
4b6aa8
-    printf("%s", question);
4b6aa8
-    fflush(NULL);
4b6aa8
-    if (NULL == fgets(result, result_size, stdin))
4b6aa8
-        result[0] = '\0';
4b6aa8
-    // Remove the trailing newline
4b6aa8
-    strchrnul(result, '\n')[0] = '\0';
4b6aa8
-}
4b6aa8
-
4b6aa8
-/**
4b6aa8
  *  Asks user for missing information
4b6aa8
  */
4b6aa8
 static void ask_for_missing_settings(const char *event_name)
4b6aa8
@@ -731,17 +711,15 @@ static int choose_number_from_range(unsigned min, unsigned max, const char *mess
4b6aa8
     unsigned ii;
4b6aa8
     for (ii = 0; ii < 3; ++ii)
4b6aa8
     {
4b6aa8
-        char answer[16];
4b6aa8
-
4b6aa8
-        read_from_stdin(message, answer, sizeof(answer));
4b6aa8
-        if (!*answer)
4b6aa8
-            continue;
4b6aa8
+        char *answer = ask(message);
4b6aa8
 
4b6aa8
         picked = xatou(answer);
4b6aa8
         if (min <= picked && picked <= max)
4b6aa8
             return picked;
4b6aa8
 
4b6aa8
-        printf("%s (%u - %u)\n", _("You have chosen number out of range"), min, max);
4b6aa8
+        char *msg = xasprintf("%s (%u - %u)\n", _("You have chosen number out of range"), min, max);
4b6aa8
+        alert(msg);
4b6aa8
+        free(msg);
4b6aa8
     }
4b6aa8
 
4b6aa8
     error_msg_and_die(_("Invalid input, exiting."));
4b6aa8
-- 
4b6aa8
1.8.3.1
4b6aa8