@@ -1045,13 +1045,15 @@ static void _php_mb_free_regex(void *opaque)
1045
1045
/* {{{ _php_mb_compile_regex */
1046
1046
static void * _php_mb_compile_regex (const char * pattern )
1047
1047
{
1048
- pcre * retval ;
1049
- const char * err_str ;
1050
- int err_offset ;
1048
+ pcre2_code * retval ;
1049
+ PCRE2_SIZE err_offset ;
1050
+ int errnum ;
1051
1051
1052
- if (!(retval = pcre_compile (pattern ,
1053
- PCRE_CASELESS , & err_str , & err_offset , NULL ))) {
1054
- php_error_docref (NULL , E_WARNING , "%s (offset=%d): %s" , pattern , err_offset , err_str );
1052
+ if (!(retval = pcre2_compile ((PCRE2_SPTR )pattern , PCRE2_ZERO_TERMINATED ,
1053
+ PCRE2_CASELESS , & errnum , & err_offset , php_pcre_cctx ()))) {
1054
+ PCRE2_UCHAR err_str [256 ];
1055
+ pcre2_get_error_message (errnum , err_str , sizeof (err_str ));
1056
+ php_error_docref (NULL , E_WARNING , "%s (offset=%zu): %s" , pattern , err_offset , err_str );
1055
1057
}
1056
1058
return retval ;
1057
1059
}
@@ -1060,15 +1062,25 @@ static void *_php_mb_compile_regex(const char *pattern)
1060
1062
/* {{{ _php_mb_match_regex */
1061
1063
static int _php_mb_match_regex (void * opaque , const char * str , size_t str_len )
1062
1064
{
1063
- return pcre_exec ((pcre * )opaque , NULL , str , (int )str_len , 0 ,
1064
- 0 , NULL , 0 ) >= 0 ;
1065
+ int res ;
1066
+
1067
+ pcre2_match_data * match_data = php_pcre_create_match_data (0 , opaque );
1068
+ if (NULL == match_data ) {
1069
+ pcre2_code_free (opaque );
1070
+ php_error_docref (NULL , E_WARNING , "Cannot allocate match data" );
1071
+ return FAILURE ;
1072
+ }
1073
+ res = pcre2_match (opaque , (PCRE2_SPTR )str , str_len , 0 , 0 , match_data , php_pcre_mctx ());
1074
+ php_pcre_free_match_data (match_data );
1075
+
1076
+ return res ;
1065
1077
}
1066
1078
/* }}} */
1067
1079
1068
1080
/* {{{ _php_mb_free_regex */
1069
1081
static void _php_mb_free_regex (void * opaque )
1070
1082
{
1071
- pcre_free (opaque );
1083
+ pcre2_code_free (opaque );
1072
1084
}
1073
1085
/* }}} */
1074
1086
#endif
0 commit comments