]> granicus.if.org Git - php/commitdiff
preg_match_all() now returns the number of global matches.
authorAndrey Hristov <andrey@php.net>
Sun, 30 May 1999 14:48:39 +0000 (14:48 +0000)
committerAndrey Hristov <andrey@php.net>
Sun, 30 May 1999 14:48:39 +0000 (14:48 +0000)
ext/pcre/pcre.c

index 97749fa46e9438296bf14869ec1a745382123efb..c2415853095e1a636dd2e9936a88b080cce7ccb7 100644 (file)
@@ -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 */