array_init_size(&match_pair, 2);
/* Add (match, offset) to the return value */
- if (unmatched_as_null && offset < 0) {
- ZVAL_NULL(&tmp);
+ if (offset < 0) {
+ if (unmatched_as_null) {
+ ZVAL_NULL(&tmp);
+ } else {
+ ZVAL_EMPTY_STRING(&tmp);
+ }
} else {
ZVAL_STRINGL(&tmp, str, len);
}
}
} else {
for (i = 0; i < count; i++) {
- if (unmatched_as_null && offsets[i<<1] < 0) {
- add_next_index_null(&match_sets[i]);
+ if (offsets[i<<1] < 0) {
+ if (unmatched_as_null) {
+ add_next_index_null(&match_sets[i]);
+ } else {
+ add_next_index_str(&match_sets[i], ZSTR_EMPTY_ALLOC());
+ }
} else {
add_next_index_stringl(&match_sets[i], (char *)stringlist[i],
offsets[(i<<1)+1] - offsets[i<<1]);
if (unmatched_as_null) {
add_next_index_null(&match_sets[i]);
} else {
- add_next_index_string(&match_sets[i], "");
+ add_next_index_str(&match_sets[i], ZSTR_EMPTY_ALLOC());
}
}
}
} else {
for (i = 0; i < count; i++) {
if (subpat_names[i]) {
- if (unmatched_as_null && offsets[i<<1] < 0) {
- add_assoc_null(&result_set, subpat_names[i]);
+ if (offsets[i<<1] < 0) {
+ if (unmatched_as_null) {
+ add_assoc_null(&result_set, subpat_names[i]);
+ } else {
+ add_assoc_str(&result_set, subpat_names[i], ZSTR_EMPTY_ALLOC());
+ }
} else {
add_assoc_stringl(&result_set, subpat_names[i], (char *)stringlist[i],
offsets[(i<<1)+1] - offsets[i<<1]);
}
}
- if (unmatched_as_null && offsets[i<<1] < 0) {
- add_next_index_null(&result_set);
+ if (offsets[i<<1] < 0) {
+ if (unmatched_as_null) {
+ add_next_index_null(&result_set);
+ } else {
+ add_next_index_str(&result_set, ZSTR_EMPTY_ALLOC());
+ }
} else {
add_next_index_stringl(&result_set, (char *)stringlist[i],
offsets[(i<<1)+1] - offsets[i<<1]);
}
} else {
for (i = 0; i < count; i++) {
- if (unmatched_as_null && offsets[i<<1] < 0) {
- add_next_index_null(&result_set);
+ if (offsets[i<<1] < 0) {
+ if (unmatched_as_null) {
+ add_next_index_null(&result_set);
+ } else {
+ add_next_index_str(&result_set, ZSTR_EMPTY_ALLOC());
+ }
} else {
add_next_index_stringl(&result_set, (char *)stringlist[i],
offsets[(i<<1)+1] - offsets[i<<1]);
} else {
for (i = 0; i < count; i++) {
if (subpat_names[i]) {
- if (unmatched_as_null && offsets[i<<1] < 0) {
- add_assoc_null(subpats, subpat_names[i]);
+ if (offsets[i<<1] < 0) {
+ if (unmatched_as_null) {
+ add_assoc_null(subpats, subpat_names[i]);
+ } else {
+ add_assoc_str(subpats, subpat_names[i], ZSTR_EMPTY_ALLOC());
+ }
} else {
add_assoc_stringl(subpats, subpat_names[i], (char *)stringlist[i],
offsets[(i<<1)+1] - offsets[i<<1]);
}
}
- if (unmatched_as_null && offsets[i<<1] < 0) {
- add_next_index_null(subpats);
+ if (offsets[i<<1] < 0) {
+ if (unmatched_as_null) {
+ add_next_index_null(subpats);
+ } else {
+ add_next_index_str(subpats, ZSTR_EMPTY_ALLOC());
+ }
} else {
add_next_index_stringl(subpats, (char *)stringlist[i],
offsets[(i<<1)+1] - offsets[i<<1]);
}
} else {
for (i = 0; i < count; i++) {
- if (unmatched_as_null && offsets[i<<1] < 0) {
- add_next_index_null(subpats);
+ if (offsets[i<<1] < 0) {
+ if (unmatched_as_null) {
+ add_next_index_null(subpats);
+ } else {
+ add_next_index_str(subpats, ZSTR_EMPTY_ALLOC());
+ }
} else {
add_next_index_stringl(subpats, (char *)stringlist[i],
offsets[(i<<1)+1] - offsets[i<<1]);