From 72f2a5d4fb0aaa054fb73e30944c10a41c830727 Mon Sep 17 00:00:00 2001 From: J08nY Date: Sun, 25 Mar 2018 00:55:30 +0100 Subject: Make the EOF and error failure message more clear. --- src/exhaustive/exhaustive.c | 6 ++++-- src/io/input.c | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/exhaustive/exhaustive.c b/src/exhaustive/exhaustive.c index 27a5141..53273bc 100644 --- a/src/exhaustive/exhaustive.c +++ b/src/exhaustive/exhaustive.c @@ -428,12 +428,14 @@ int exhaustive_do() { exhaustive_init(&setup); output_o_begin(); + int result = EXIT_SUCCESS; for (unsigned long i = 0; i < cfg->count; ++i) { debug_log_start("Generating new curve"); curve_t *curve = curve_new(); if (!exhaustive_gen(curve, &setup, OFFSET_SEED, OFFSET_END)) { curve_free(&curve); - return EXIT_FAILURE; + result = EXIT_FAILURE; + break; } debug_log_end("Generated new curve"); @@ -447,5 +449,5 @@ int exhaustive_do() { exhaustive_quit(&setup); debug_log_end("Finished Exhaustive method"); - return EXIT_SUCCESS; + return result; } diff --git a/src/io/input.c b/src/io/input.c index 5f7bfa8..971ffdf 100644 --- a/src/io/input.c +++ b/src/io/input.c @@ -19,7 +19,13 @@ static GEN input_i(const char *prompt, unsigned long bits) { ssize_t len = getdelim(&line, &n, delim, in); if (len <= 0) { - fprintf(err, "Couldn't read an integer.\n"); + if (feof(in)) { + fprintf(err, "Couldn't read an integer. Reached EOF!\n"); + } else if (ferror(in)) { + perror("Couldn't read an integer."); + } else { + fprintf(err, "Couldn't read an integer.\n"); + } return gen_m2; } if (len == 1 && !feof(in)) { -- cgit v1.2.3-70-g09d2