translate_rule_t *hi = NULL;
translate_rule_t *rule = NULL;
switch_regex_t *re = NULL;
- int proceed = 0, ovector[30];
+ switch_regex_match_t *match_data = NULL;
+ int proceed = 0;
char *substituted = NULL, *subbed = NULL;
uint32_t len = 0;
for (rule = hi; rule; rule = rule->next) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s =~ /%s/\n", number, rule->regex);
- if ((proceed = switch_regex_perform(number, rule->regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
+ if ((proceed = switch_regex_perform(number, rule->regex, &re, &match_data))) {
len = (uint32_t) (strlen(number) + strlen(rule->replace) + 10) * proceed;
if (!(substituted = malloc(len))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+ switch_regex_match_safe_free(match_data);
switch_regex_safe_free(re);
goto end;
}
memset(substituted, 0, len);
- switch_perform_substitution(re, proceed, rule->replace, number, substituted, len, ovector);
+ switch_perform_substitution(match_data, rule->replace, substituted, len);
if ((switch_string_var_check_const(substituted) || switch_string_has_escaped_data(substituted))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "perform variable expansion\n");
switch_safe_free(subbed);
}
+ switch_regex_match_safe_free(match_data);
switch_regex_safe_free(re);
break;
}