test(old): emulate test_override('char_avail') using FFI

Add a non-static variable for this, otherwise it'll be really hacky.
This avoid having to rewrite many incsearch tests in Lua.
This commit is contained in:
zeertzjq
2025-07-03 21:23:26 +08:00
parent bfffe0d214
commit c925e7b8ba
9 changed files with 106 additions and 107 deletions

View File

@ -1866,6 +1866,9 @@ int vpeekc_any(void)
/// @return true if a character is available, false otherwise.
bool char_avail(void)
{
if (disable_char_avail_for_testing) {
return false;
}
no_mapping++;
int retval = vpeekc();
no_mapping--;

View File

@ -17,6 +17,8 @@ typedef enum {
enum { NSCRIPT = 15, }; ///< Maximum number of streams to read script from
EXTERN bool disable_char_avail_for_testing INIT( = false);
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "getchar.h.generated.h"
#endif