diff options
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;  }  /* }}} */  | 
