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

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