diff options
| author | J08nY | 2018-03-25 00:55:30 +0100 |
|---|---|---|
| committer | J08nY | 2018-03-25 00:55:30 +0100 |
| commit | 72f2a5d4fb0aaa054fb73e30944c10a41c830727 (patch) | |
| tree | a7176c117139f9e46baac0450db0e34945e61ca0 /src | |
| parent | f7d64a5b2f6a0ec597e0ee0ad2af1b759833d0dd (diff) | |
| download | ecgen-72f2a5d4fb0aaa054fb73e30944c10a41c830727.tar.gz ecgen-72f2a5d4fb0aaa054fb73e30944c10a41c830727.tar.zst ecgen-72f2a5d4fb0aaa054fb73e30944c10a41c830727.zip | |
Make the EOF and error failure message more clear.
Diffstat (limited to 'src')
| -rw-r--r-- | src/exhaustive/exhaustive.c | 6 | ||||
| -rw-r--r-- | src/io/input.c | 8 |
2 files changed, 11 insertions, 3 deletions
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)) { |
