int size_offsets; /* Size of the offsets array */
int matched; /* Has anything matched */
int g_notempty = 0; /* If the match should not be empty */
- const char **stringlist; /* Holds list of subpatterns */
char **subpat_names; /* Array for named subpatterns */
int i;
int subpats_order; /* Order of subpattern matches */
/* If subpatterns array has been passed, fill it in with values. */
if (subpats != NULL) {
/* Try to get the list of substrings and display a warning if failed. */
- if ((offsets[1] - offsets[0] < 0) || pcre_get_substring_list(subject, offsets, count, &stringlist) < 0) {
+ if (offsets[1] - offsets[0] < 0) {
if (subpat_names) {
efree(subpat_names);
}
/* For each subpattern, insert it into the appropriate array. */
if (offset_capture) {
for (i = 0; i < count; i++) {
- add_offset_pair(&match_sets[i], (char *)stringlist[i],
+ add_offset_pair(&match_sets[i], subject + offsets[i<<1],
offsets[(i<<1)+1] - offsets[i<<1], offsets[i<<1], NULL, unmatched_as_null);
}
} else {
add_next_index_str(&match_sets[i], ZSTR_EMPTY_ALLOC());
}
} else {
- add_next_index_stringl(&match_sets[i], (char *)stringlist[i],
+ add_next_index_stringl(&match_sets[i], subject + offsets[i<<1],
offsets[(i<<1)+1] - offsets[i<<1]);
}
}
if (subpat_names) {
if (offset_capture) {
for (i = 0; i < count; i++) {
- add_offset_pair(&result_set, (char *)stringlist[i],
+ add_offset_pair(&result_set, subject + offsets[i<<1],
offsets[(i<<1)+1] - offsets[i<<1], offsets[i<<1], subpat_names[i], unmatched_as_null);
}
} else {
add_assoc_str(&result_set, subpat_names[i], ZSTR_EMPTY_ALLOC());
}
} else {
- add_assoc_stringl(&result_set, subpat_names[i], (char *)stringlist[i],
+ add_assoc_stringl(&result_set, subpat_names[i], subject + offsets[i<<1],
offsets[(i<<1)+1] - offsets[i<<1]);
}
}
add_next_index_str(&result_set, ZSTR_EMPTY_ALLOC());
}
} else {
- add_next_index_stringl(&result_set, (char *)stringlist[i],
+ add_next_index_stringl(&result_set, subject + offsets[i<<1],
offsets[(i<<1)+1] - offsets[i<<1]);
}
}
} else {
if (offset_capture) {
for (i = 0; i < count; i++) {
- add_offset_pair(&result_set, (char *)stringlist[i],
+ add_offset_pair(&result_set, subject + offsets[i<<1],
offsets[(i<<1)+1] - offsets[i<<1], offsets[i<<1], NULL, unmatched_as_null);
}
} else {
add_next_index_str(&result_set, ZSTR_EMPTY_ALLOC());
}
} else {
- add_next_index_stringl(&result_set, (char *)stringlist[i],
+ add_next_index_stringl(&result_set, subject + offsets[i<<1],
offsets[(i<<1)+1] - offsets[i<<1]);
}
}
if (subpat_names) {
if (offset_capture) {
for (i = 0; i < count; i++) {
- add_offset_pair(subpats, (char *)stringlist[i],
+ add_offset_pair(subpats, subject + offsets[i<<1],
offsets[(i<<1)+1] - offsets[i<<1],
offsets[i<<1], subpat_names[i], unmatched_as_null);
}
add_assoc_str(subpats, subpat_names[i], ZSTR_EMPTY_ALLOC());
}
} else {
- add_assoc_stringl(subpats, subpat_names[i], (char *)stringlist[i],
+ add_assoc_stringl(subpats, subpat_names[i], subject + offsets[i<<1],
offsets[(i<<1)+1] - offsets[i<<1]);
}
}
add_next_index_str(subpats, ZSTR_EMPTY_ALLOC());
}
} else {
- add_next_index_stringl(subpats, (char *)stringlist[i],
+ add_next_index_stringl(subpats, subject + offsets[i<<1],
offsets[(i<<1)+1] - offsets[i<<1]);
}
}
} else {
if (offset_capture) {
for (i = 0; i < count; i++) {
- add_offset_pair(subpats, (char *)stringlist[i],
+ add_offset_pair(subpats, subject + offsets[i<<1],
offsets[(i<<1)+1] - offsets[i<<1],
offsets[i<<1], NULL, unmatched_as_null);
}
add_next_index_str(subpats, ZSTR_EMPTY_ALLOC());
}
} else {
- add_next_index_stringl(subpats, (char *)stringlist[i],
+ add_next_index_stringl(subpats, subject + offsets[i<<1],
offsets[(i<<1)+1] - offsets[i<<1]);
}
}
add_assoc_string_ex(subpats, "MARK", sizeof("MARK") - 1, (char *)mark);
}
}
-
- pcre_free((void *) stringlist);
}
} else if (count == PCRE_ERROR_NOMATCH) {
/* If we previously set PCRE_NOTEMPTY_ATSTART after a null match,