summaryrefslogtreecommitdiff
path: root/ext/pgsql/pgsql.c
diff options
context:
space:
mode:
authorAdam Harvey <aharvey@php.net>2015-03-05 00:21:38 +0000
committerAdam Harvey <aharvey@php.net>2015-03-05 00:21:38 +0000
commitfea9a6fc7702c53df5e9f4c16857dc921d8b5997 (patch)
treeda608158cb83f5be92a760c5191c6028dfb171df /ext/pgsql/pgsql.c
parentfd1578c196575c7e120a84ee030bb87c14a199b0 (diff)
parentfcb1ab1b0e9a2d89ec52f321de184c558d97d0c1 (diff)
downloadphp-git-fea9a6fc7702c53df5e9f4c16857dc921d8b5997.tar.gz
Merge remote-tracking branch 'datibbaw/kill-ereg'
Conflicts: ext/ereg/config.w32 ext/ereg/config0.m4 ext/ereg/ereg.c ext/ereg/php_ereg.h ext/ereg/php_regex.h ext/ereg/regex/engine.c ext/ereg/regex/main.c ext/ereg/regex/regcomp.c ext/ereg/regex/regerror.c ext/ereg/tests/split_error_002.phpt ext/ereg/tests/split_variation_003.phpt ext/ereg/tests/spliti_error_002.phpt ext/ereg/tests/spliti_variation_003.phpt ext/pgsql/pgsql.c sapi/apache/php_apache_http.h sapi/apache_hooks/php_apache_http.h
Diffstat (limited to 'ext/pgsql/pgsql.c')
-rw-r--r--ext/pgsql/pgsql.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index f0e4532237..e54e8adbbc 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -36,7 +36,7 @@
#include "php_ini.h"
#include "ext/standard/php_standard.h"
#include "zend_smart_str.h"
-#include "ext/ereg/php_regex.h"
+#include "ext/pcre/php_pcre.h"
#ifdef PHP_WIN32
# include "win32/time.h"
#endif
@@ -5717,10 +5717,10 @@ static php_pgsql_data_type php_pgsql_get_data_type(const char *type_name, size_t
*/
static int php_pgsql_convert_match(const char *str, size_t str_len, const char *regex , int icase)
{
- regex_t re;
- regmatch_t *subs;
- int regopt = REG_EXTENDED;
- int regerr, ret = SUCCESS;
+ pcre *re;
+ const char *err_msg;
+ int err_offset;
+ int options = PCRE_NO_AUTO_CAPTURE, res;
size_t i;
/* Check invalid chars for POSIX regex */
@@ -5733,28 +5733,27 @@ static int php_pgsql_convert_match(const char *str, size_t str_len, const char *
}
if (icase) {
- regopt |= REG_ICASE;
+ options |= PCRE_CASELESS;
}
- regerr = regcomp(&re, regex, regopt);
- if (regerr) {
- php_error_docref(NULL, E_WARNING, "Cannot compile regex");
- regfree(&re);
+ if ((re = pcre_compile(regex, options, &err_msg, &err_offset, NULL)) == NULL) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot compile regex");
return FAILURE;
}
- subs = (regmatch_t *)ecalloc(sizeof(regmatch_t), re.re_nsub+1);
- regerr = regexec(&re, str, re.re_nsub+1, subs, 0);
- if (regerr == REG_NOMATCH) {
- ret = FAILURE;
- }
- else if (regerr) {
- php_error_docref(NULL, E_WARNING, "Cannot exec regex");
- ret = FAILURE;
+ res = pcre_exec(re, NULL, str, str_len, 0, 0, NULL, 0);
+ pcre_free(re);
+
+ if (res == PCRE_ERROR_NOMATCH) {
+#ifdef PHP_DEBUG
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "'%s' does not match with '%s'", str, regex);
+#endif
+ return FAILURE;
+ } else if (res) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot exec regex");
+ return FAILURE;
}
- regfree(&re);
- efree(subs);
- return ret;
+ return SUCCESS;
}
/* }}} */