From 2a64925a6767dcc000d8d63c2fd717c83b239e9d Mon Sep 17 00:00:00 2001 From: Andrey Hristov Date: Wed, 9 Jun 1999 15:02:57 +0000 Subject: [PATCH] Fixed a bug in preg_replace. --- ext/ereg/ereg.c | 2 -- ext/pcre/pcre.c | 10 +++++----- ext/standard/reg.c | 2 -- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/ext/ereg/ereg.c b/ext/ereg/ereg.c index 1373933780..72d3d53cff 100644 --- a/ext/ereg/ereg.c +++ b/ext/ereg/ereg.c @@ -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; diff --git a/ext/pcre/pcre.c b/ext/pcre/pcre.c index 958355b219..eb91b954a1 100644 --- a/ext/pcre/pcre.c +++ b/ext/pcre/pcre.c @@ -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; } /* }}} */ diff --git a/ext/standard/reg.c b/ext/standard/reg.c index 1373933780..72d3d53cff 100644 --- a/ext/standard/reg.c +++ b/ext/standard/reg.c @@ -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; -- 2.50.1