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.
This commit is contained in:
PatR
2025-04-24 11:34:35 -07:00
parent 81e72dd0cc
commit c6906a78a4

View File

@@ -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;
}