summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>1999-05-30 14:48:39 +0000
committerAndrey Hristov <andrey@php.net>1999-05-30 14:48:39 +0000
commitaba3ea97cdae5832ae1f7057fe481fef00a9a913 (patch)
tree87feb98eaea423208887b3a01ebe7d983f58219b
parent88029643d05a4ea1f60c8856e857ea63802fb136 (diff)
downloadphp-git-aba3ea97cdae5832ae1f7057fe481fef00a9a913.tar.gz
preg_match_all() now returns the number of global matches.
-rw-r--r--ext/pcre/pcre.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/ext/pcre/pcre.c b/ext/pcre/pcre.c
index 97749fa46e..c241585309 100644
--- a/ext/pcre/pcre.c
+++ b/ext/pcre/pcre.c
@@ -380,6 +380,7 @@ void _pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global)
piece = subject->value.str.val;
subject_end = piece + subject->value.str.len;
match = NULL;
+ matched = 0;
do {
/* Execute the regular expression. */
@@ -396,7 +397,7 @@ void _pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global)
/* If something has matched */
if (count >= 0) {
- matched = 1;
+ matched++;
match = piece + offsets[0];
/* If subpatters array has been passed, fill it in with values. */
@@ -445,10 +446,6 @@ void _pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global)
piece += offsets[1];
}
}
- /* If nothing matched */
- else {
- matched = 0;
- }
} while (global && count >= 0);
/* Add the match sets to the output array and clean up */