]> granicus.if.org Git - php/commitdiff
Fixed a bug in preg_replace.
authorAndrey Hristov <andrey@php.net>
Wed, 9 Jun 1999 15:02:57 +0000 (15:02 +0000)
committerAndrey Hristov <andrey@php.net>
Wed, 9 Jun 1999 15:02:57 +0000 (15:02 +0000)
ext/ereg/ereg.c
ext/pcre/pcre.c
ext/standard/reg.c

index 137393378049d8c78f50307a54995132e5bc321a..72d3d53cffcc57657c53170cc11d6a71db1ab949 100644 (file)
@@ -318,8 +318,6 @@ char *_php3_regreplace(const char *pattern, const char *replace, const char *str
        int err, copts = 0;
 
        string_len = strlen(string);
-       if (!string_len)
-               return estrndup("", 0);
 
        if (icase)
                copts = REG_ICASE;
index 958355b219c042fb1b028aff8af3b52987eaea8b..eb91b954a1b97c42baf7f46b2f7d4c3e641ba94b 100644 (file)
@@ -485,14 +485,14 @@ PHP_FUNCTION(preg_match_all)
 /* {{{ int _pcre_get_backref(const char *walk, int *backref) */
 static int _pcre_get_backref(const char *walk, int *backref)
 {
-       if (*walk < '0' && *walk > '9')
-               return 0;
-       else
+       if (*walk && *walk >= '0' && *walk <= '9')
                *backref = *walk - '0';
+       else
+               return 0;
        
-       if (walk[1] >= '0' && walk[1] <= '9')
+       if (walk[1] && walk[1] >= '0' && walk[1] <= '9')
                *backref = *backref * 10 + walk[1] - '0';
-
+       
        return 1;       
 }
 /* }}} */
index 137393378049d8c78f50307a54995132e5bc321a..72d3d53cffcc57657c53170cc11d6a71db1ab949 100644 (file)
@@ -318,8 +318,6 @@ char *_php3_regreplace(const char *pattern, const char *replace, const char *str
        int err, copts = 0;
 
        string_len = strlen(string);
-       if (!string_len)
-               return estrndup("", 0);
 
        if (icase)
                copts = REG_ICASE;