From 84f383508d4506632dd456893421405ca81a079f Mon Sep 17 00:00:00 2001 From: Kate F Date: Sat, 24 Aug 2024 13:03:00 +0100 Subject: [PATCH] Wrong exit status for -G. Spotted by @pierreganty (#478), thank you --- src/libfsm/gen.c | 6 +++--- src/re/main.c | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libfsm/gen.c b/src/libfsm/gen.c index 730b40724..790579dc8 100644 --- a/src/libfsm/gen.c +++ b/src/libfsm/gen.c @@ -193,7 +193,7 @@ gen_init_outer(struct fsm *fsm, size_t max_length, fsm_generate_matches_cb *cb, void *opaque, bool randomized, unsigned seed) { - int res = 0; + int res = false; if (fsm == NULL || cb == NULL || max_length == 0) { return false; } @@ -222,11 +222,11 @@ gen_init_outer(struct fsm *fsm, size_t max_length, goto cleanup; } - res = 1; + res = true; while (!ctx.done) { if (!gen_iter(&ctx)) { - res = 0; + res = false; break; } } diff --git a/src/re/main.c b/src/re/main.c index 78bc77a2f..1a0d5cbe1 100644 --- a/src/re/main.c +++ b/src/re/main.c @@ -1047,7 +1047,11 @@ main(int argc, char *argv[]) } if (generate_bounds > 0) { - return fsm_generate_matches(fsm, generate_bounds, fsm_generate_cb_printf_escaped, &opt); + if (!fsm_generate_matches(fsm, generate_bounds, fsm_generate_cb_printf_escaped, &opt)) { + exit(EXIT_FAILURE); + } + + return 0; } if (fsm_lang != FSM_PRINT_NONE) {