aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/input.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/input.c b/src/input.c
index 9ac68be..65ec3a7 100644
--- a/src/input.c
+++ b/src/input.c
@@ -3,25 +3,24 @@
#include <stdlib.h>
#include <string.h>
+/* stdio must be included before readline */
+#include <readline/readline.h>
+
#include "input.h"
int prompt_yes_no(void)
{
- puts(" [Y/n]");
- fflush(stdout);
- size_t line_size = 3;
- char *line = malloc(line_size);
+ char *line;
int attempts = 0;
do {
- getline(&line, &line_size, stdin);
+ line = readline(" [Y/n] ");
char input = line[0];
if (input == '\n'/*no input*/ || input == 'y' || input == 'Y')
return 1;
else if (input == 'n' || input == 'N')
return 0;
attempts++;
- }
- while(attempts < 3);
+ } while(attempts < 3);
return 0;
}