summaryrefslogtreecommitdiff
path: root/ext/mbstring/php_mbregex.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2018-07-06 23:42:16 +0200
committerNikita Popov <nikita.ppv@gmail.com>2018-07-07 11:06:29 +0200
commit41a6625c09071feb22efb0814a9cb208c27698d0 (patch)
treeb3a4661efff547781eca212aeb27464f0e038323 /ext/mbstring/php_mbregex.c
parent8f1782678e9a790cf696da1268a7dfcb38e22312 (diff)
downloadphp-git-41a6625c09071feb22efb0814a9cb208c27698d0.tar.gz
Add UPGRADING for mb_ereg changes
Also some minor code cleanup.
Diffstat (limited to 'ext/mbstring/php_mbregex.c')
-rw-r--r--ext/mbstring/php_mbregex.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index d048376062..3349025491 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -655,7 +655,7 @@ _php_mb_regex_init_options(const char *parg, size_t narg, OnigOptionType *option
typedef struct mb_regex_groups_iter_args {
zval *groups;
char *search_str;
- int search_len;
+ size_t search_len;
OnigRegion *region;
} mb_regex_groups_iter_args;
/* }}} */
@@ -665,25 +665,19 @@ static int
mb_regex_groups_iter(const OnigUChar* name, const OnigUChar* name_end, int ngroup_num, int* group_nums, regex_t* reg, void* parg)
{
mb_regex_groups_iter_args *args = (mb_regex_groups_iter_args *) parg;
- int i, gn, ref, beg, end;
-
- for (i = 0; i < ngroup_num; i++) {
- gn = group_nums[i];
- ref = onig_name_to_backref_number(reg, name, name_end, args->region);
- if (ref != gn) {
- /*
- * In case of duplicate groups, keep only the last suceeding one
- * to be consistent with preg_match with the PCRE_DUPNAMES option.
- */
- continue;
- }
- beg = args->region->beg[gn];
- end = args->region->end[gn];
- if (beg >= 0 && beg < end && end <= args->search_len) {
- add_assoc_stringl_ex(args->groups, (char *)name, name_end - name, &args->search_str[beg], end - beg);
- } else {
- add_assoc_bool_ex(args->groups, (char *)name, name_end - name, 0);
- }
+ int gn, beg, end;
+
+ /*
+ * In case of duplicate groups, keep only the last suceeding one
+ * to be consistent with preg_match with the PCRE_DUPNAMES option.
+ */
+ gn = onig_name_to_backref_number(reg, name, name_end, args->region);
+ beg = args->region->beg[gn];
+ end = args->region->end[gn];
+ if (beg >= 0 && beg < end && end <= args->search_len) {
+ add_assoc_stringl_ex(args->groups, (char *)name, name_end - name, &args->search_str[beg], end - beg);
+ } else {
+ add_assoc_bool_ex(args->groups, (char *)name, name_end - name, 0);
}
return 0;