int r;
// Commands
- if (!parser->regex_command && parser->flags & PAKFIRE_PARSER_FLAGS_EXPAND_COMMANDS) {
+ if (!parser->regex_command && (parser->flags & PAKFIRE_PARSER_FLAGS_EXPAND_COMMANDS)) {
r = pakfire_parser_compile_regex(parser,
- &parser->regex_command, "%\\((.*?)\\)");
+ &parser->regex_command, "%(\\(((?>[^()]|(?1))*)\\))");
if (r)
return r;
}
(PCRE2_UCHAR*)*buffer, strlen(*buffer), 0, 0, match, NULL);
// End loop when we have expanded all variables
- if (r == PCRE2_ERROR_NOMATCH)
+ if (r == PCRE2_ERROR_NOMATCH) {
+ DEBUG(parser->pakfire, "No (more) matches found\n");
break;
+ }
// Extract the command
- r = pcre2_substring_get_bynumber(match, 1, &command, &command_length);
+ r = pcre2_substring_get_bynumber(match, 2, &command, &command_length);
if (r)
goto ERROR;