handle empty action strings correctly

This commit is contained in:
Alexey Fedoseev
2024-04-25 15:16:22 +03:00
parent a6502f922d
commit dfe8a06102

View File

@@ -712,6 +712,11 @@ static int cyberiada_decode_edge_action(const char* text, CyberiadaAction** acti
buffer = utf8_encode(text, strlen(text), &buffer_len);
if (!buffer) {
*action = NULL;
return CYBERIADA_NO_ERROR;
}
if ((res = regexec(&cyberiada_edge_action_regexp, buffer,
CYBERIADA_ACTION_REGEXP_MATCHES, pmatch, 0)) != 0) {
if (res == REG_NOMATCH) {
@@ -835,6 +840,10 @@ static int cyberiada_decode_state_actions(const char* text, CyberiadaAction** ac
*actions = NULL;
if (!buffer) {
return CYBERIADA_NO_ERROR;
}
while (*next) {
start = next;
block = strstr(start, CYBERIADA_NEWLINE);
@@ -897,9 +906,12 @@ static int cyberiada_decode_state_actions_yed(const char* text, CyberiadaAction*
buffer = utf8_encode(text, strlen(text), &buffer_len);
next = buffer;
*actions = NULL;
if (!buffer) {
return CYBERIADA_NO_ERROR;
}
while (*next) {
start = next;
while (*start && isspace(*start)) start++;