From c6906a78a47e2f4bec49efb13e7c049a5e704f71 Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 24 Apr 2025 11:34:35 -0700 Subject: [PATCH] fuzzer vs do-again Try to exercise ^A more when running the fuzzer. Also ^P, although that is tty-centric. I couldn't notice any difference in behavior so this doesn't seem to be very useful. --- src/cmd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cmd.c b/src/cmd.c index 92eef584c..8b912dc40 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -3284,12 +3284,20 @@ accept_menu_prefix(const struct ext_func_tab *ec) return (ec && ((ec->flags & CMD_M_PREFIX) != 0)); } +/* choose a random character, biased towards movement commands, primarily + for debug-fuzzer testing */ char randomkey(void) { static unsigned i = 0; + static char last_c = '\0'; char c; + /* give ^A and ^P a high probability of being repeated */ + if ((last_c == C('a') || last_c == C('p')) + && program_state.input_state == commandInp && rn2(5)) + return last_c; + switch (rn2(16)) { default: c = '\033'; @@ -3337,6 +3345,8 @@ randomkey(void) break; } + if (program_state.input_state == commandInp) + last_c = c; return c; }