mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-01 02:52:32 +00:00
fix offset in regex expansion
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6588 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
6a0e6060c5
commit
f481f79daa
@ -109,6 +109,7 @@ SWITCH_DECLARE(int) switch_regex_perform(const char *field, const char *expressi
|
|||||||
ovector, /* vector of integers for substring information */
|
ovector, /* vector of integers for substring information */
|
||||||
olen); /* number of elements (NOT size in bytes) */
|
olen); /* number of elements (NOT size in bytes) */
|
||||||
|
|
||||||
|
|
||||||
if (match_count <= 0) {
|
if (match_count <= 0) {
|
||||||
switch_regex_safe_free(re);
|
switch_regex_safe_free(re);
|
||||||
match_count = 0;
|
match_count = 0;
|
||||||
@ -145,7 +146,12 @@ SWITCH_DECLARE(void) switch_perform_substitution(switch_regex_t *re, int match_c
|
|||||||
}
|
}
|
||||||
index[z++] = '\0';
|
index[z++] = '\0';
|
||||||
z = 0;
|
z = 0;
|
||||||
num = atoi(index);
|
if (match_count > 1) {
|
||||||
|
int offset = match_count - 2;
|
||||||
|
num = atoi(index) + offset;
|
||||||
|
} else {
|
||||||
|
num = atoi(index);
|
||||||
|
}
|
||||||
|
|
||||||
if (pcre_copy_substring(field_data, ovector, match_count, num, replace, sizeof(replace)) > 0) {
|
if (pcre_copy_substring(field_data, ovector, match_count, num, replace, sizeof(replace)) > 0) {
|
||||||
switch_size_t r;
|
switch_size_t r;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user