diff options
author | Tjerk Meesters <datibbaw@php.net> | 2014-08-28 16:41:38 +0800 |
---|---|---|
committer | Tjerk Meesters <datibbaw@php.net> | 2014-09-11 10:22:44 +0800 |
commit | 86de7963fe69638431c0aa8f413d25e01bf99d68 (patch) | |
tree | 4560e915002400c61de33493fc1c06705e046679 /ext/pgsql/pgsql.c | |
parent | e699f654f0c4b00fd4e915829842c43aa9c6f7b9 (diff) | |
download | php-git-86de7963fe69638431c0aa8f413d25e01bf99d68.tar.gz |
Removing ext/ereg and dependencies
Affected extensions:
- opcache (use pcre)
- mbstring (removed ereg functions overloading)
- pgsql (use pcre)
- reflection (test cases using 'ereg')
SAPI:
- apache (header only)
- apache_hooks (header only)
Diffstat (limited to 'ext/pgsql/pgsql.c')
-rw-r--r-- | ext/pgsql/pgsql.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index e3f64e0ed0..1d51b05b9f 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 "ext/standard/php_smart_str.h" -#include "ext/ereg/php_regex.h" +#include "ext/pcre/php_pcre.h" #ifdef PHP_WIN32 # include "win32/time.h" #endif @@ -5637,10 +5637,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 TSRMLS_DC) { - 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 */ @@ -5653,31 +5653,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) { + if ((re = pcre_compile(regex, options, &err_msg, &err_offset, NULL)) == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot compile regex"); - regfree(&re); 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) { + 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 - ret = FAILURE; - } - else if (regerr) { + return FAILURE; + } else if (res) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot exec regex"); - ret = FAILURE; + return FAILURE; } - regfree(&re); - efree(subs); - return ret; + return SUCCESS; } /* }}} */ |