This commit is contained in:
Martin Lund 2024-04-19 16:56:30 +02:00
parent 96fafc5fb4
commit 0105346a11

View file

@ -215,8 +215,8 @@ static int send(lua_State *L)
return 1; return 1;
} }
// Function to add a character to the circular buffer // Function to add a character to the circular expect buffer
void add_to_buffer(char c) static void expect_buffer_add(char c)
{ {
if (buffer_size < MAX_BUFFER_SIZE) if (buffer_size < MAX_BUFFER_SIZE)
{ {
@ -230,8 +230,8 @@ void add_to_buffer(char c)
} }
} }
// Function to match against the circular buffer using regex // Function to match against the circular expect buffer using regex
bool match_regex(regex_t *regex) static bool match_regex(regex_t *regex)
{ {
char buffer[MAX_BUFFER_SIZE + 1]; // Temporary buffer for regex matching char buffer[MAX_BUFFER_SIZE + 1]; // Temporary buffer for regex matching
const char *s = circular_buffer; const char *s = circular_buffer;
@ -306,7 +306,7 @@ static int expect(lua_State *L)
if (bytes_read > 0) if (bytes_read > 0)
{ {
putchar(c); putchar(c);
add_to_buffer(c); expect_buffer_add(c);
// Match against the entire buffer // Match against the entire buffer
if (match_regex(&regex)) if (match_regex(&regex))
{ {