]> granicus.if.org Git - php/commitdiff
Not sure that's the right fix, but at least it fixes the symptom
authorZeev Suraski <zeev@php.net>
Sat, 5 Jun 1999 13:56:18 +0000 (13:56 +0000)
committerZeev Suraski <zeev@php.net>
Sat, 5 Jun 1999 13:56:18 +0000 (13:56 +0000)
ext/ereg/ereg.c
ext/standard/reg.c

index 8a7d97c9bbc3401ae1c45bd2cd9493291540689e..6f5a08a981a1a9d885f89963c027f267005c5445 100644 (file)
@@ -564,6 +564,7 @@ PHP_FUNCTION(split)
 
        /* churn through str, generating array entries as we go */
        while ((count == -1 || count > 0) && !(err = regexec(&re, strp, 1, subs, 0))) {
+               printf("In the loop...\n");
                if (subs[0].rm_so == 0 && subs[0].rm_eo) {
                        /* match is at start of string, return empty string */
                        add_next_index_stringl(return_value, empty_string, 0, 1);
@@ -591,7 +592,9 @@ PHP_FUNCTION(split)
 
                /* if we're only looking for a certain number of points,
                   stop looking once we hit it */
-               if (count != -1) count--;
+               if (count != -1) {
+                       count--;
+               }
        }
 
        /* see if we encountered an error */
@@ -604,7 +607,7 @@ PHP_FUNCTION(split)
        }
 
        /* otherwise we just have one last element to add to the array */
-       if (count == -1) {
+       if (count == -1 || err==REG_NOMATCH) {
                size = endp - strp;
        
                add_next_index_stringl(return_value, strp, size, 1);
index 8a7d97c9bbc3401ae1c45bd2cd9493291540689e..6f5a08a981a1a9d885f89963c027f267005c5445 100644 (file)
@@ -564,6 +564,7 @@ PHP_FUNCTION(split)
 
        /* churn through str, generating array entries as we go */
        while ((count == -1 || count > 0) && !(err = regexec(&re, strp, 1, subs, 0))) {
+               printf("In the loop...\n");
                if (subs[0].rm_so == 0 && subs[0].rm_eo) {
                        /* match is at start of string, return empty string */
                        add_next_index_stringl(return_value, empty_string, 0, 1);
@@ -591,7 +592,9 @@ PHP_FUNCTION(split)
 
                /* if we're only looking for a certain number of points,
                   stop looking once we hit it */
-               if (count != -1) count--;
+               if (count != -1) {
+                       count--;
+               }
        }
 
        /* see if we encountered an error */
@@ -604,7 +607,7 @@ PHP_FUNCTION(split)
        }
 
        /* otherwise we just have one last element to add to the array */
-       if (count == -1) {
+       if (count == -1 || err==REG_NOMATCH) {
                size = endp - strp;
        
                add_next_index_stringl(return_value, strp, size, 1);