[php-src] master: pcre: add const qualifiers

From: Date: Wed, 23 Sep 2026 14:22:22 +0000
Subject: [php-src] master: pcre: add const qualifiers
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141474@lists.php.net to get a copy of this message
Author: Gina Peter Banyard (Girgias) Date: 2026-09-23T15:22:04+01:00 Commit: https://github.com/php/php-src/commit/7215ba9501156d3d91310953594fdba00d2c6aa3 Raw diff: https://github.com/php/php-src/commit/7215ba9501156d3d91310953594fdba00d2c6aa3.diff pcre: add const qualifiers Changed paths: M ext/pcre/php_pcre.c M ext/pcre/php_pcre.h Diff: diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 76d99c6e9521..fd5d407b1544 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -517,7 +517,7 @@ static void free_subpats_table(zend_string **subpat_names, uint32_t num_subpats) } /* {{{ static make_subpats_table */ -static zend_string **make_subpats_table(uint32_t name_cnt, pcre_cache_entry *pce) +static zend_string **make_subpats_table(uint32_t name_cnt, const pcre_cache_entry *pce) { uint32_t num_subpats = pce->capture_count + 1; uint32_t name_size, ni = 0; @@ -553,7 +553,7 @@ static zend_string **ensure_subpats_table(uint32_t name_cnt, pcre_cache_entry *p /* {{{ static calculate_unit_length */ /* Calculates the byte length of the next character. Assumes valid UTF-8 for PCRE2_UTF. */ -static zend_always_inline size_t calculate_unit_length(pcre_cache_entry *pce, const char *start) +static zend_always_inline size_t calculate_unit_length(const pcre_cache_entry *pce, const char *start) { size_t unit_len; @@ -1127,7 +1127,7 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, bool global) /* {{{ /* }}} */ static zend_always_inline bool is_known_valid_utf8( - zend_string *subject_str, PCRE2_SIZE start_offset) { + const zend_string *subject_str, PCRE2_SIZE start_offset) { if (!ZSTR_IS_VALID_UTF8(subject_str)) { /* We don't know whether the string is valid UTF-8 or not. */ return false; @@ -1609,7 +1609,7 @@ PHPAPI zend_string *php_pcre_replace(zend_string *regex, /* }}} */ /* {{{ php_pcre_replace_impl() */ -PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, const char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count) +PHPAPI zend_string *php_pcre_replace_impl(const pcre_cache_entry *pce, zend_string *subject_str, const char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count) { uint32_t options; /* Execution options */ int count; /* Count of matched subpatterns */ @@ -2073,8 +2073,8 @@ static zend_always_inline zend_string *php_pcre_replace_func(zend_string *regex, } /* {{{ php_pcre_replace_array */ -static zend_string *php_pcre_replace_array(HashTable *regex, - zend_string *replace_str, HashTable *replace_ht, +static zend_string *php_pcre_replace_array(const HashTable *regex, + zend_string *replace_str, const HashTable *replace_ht, zend_string *subject_str, size_t limit, size_t *replace_count) { zval *regex_entry; @@ -2099,7 +2099,7 @@ static zend_string *php_pcre_replace_array(HashTable *regex, tmp_replace_entry_str = NULL; break; } - zval *zv = ZEND_HASH_ELEMENT(replace_ht, replace_idx); + const zval *zv = ZEND_HASH_ELEMENT(replace_ht, replace_idx); replace_idx++; if (Z_TYPE_P(zv) != IS_UNDEF) { replace_entry_str = zval_get_tmp_string(zv, &tmp_replace_entry_str); @@ -2149,8 +2149,8 @@ static zend_string *php_pcre_replace_array(HashTable *regex, /* {{{ php_replace_in_subject */ static zend_always_inline zend_string *php_replace_in_subject( - zend_string *regex_str, HashTable *regex_ht, - zend_string *replace_str, HashTable *replace_ht, + zend_string *regex_str, const HashTable *regex_ht, + zend_string *replace_str, const HashTable *replace_ht, zend_string *subject, size_t limit, size_t *replace_count) { zend_string *result; @@ -2263,8 +2263,8 @@ static size_t php_preg_replace_func_impl(zval *return_value, static void _preg_replace_common( zval *return_value, HashTable *regex_ht, zend_string *regex_str, - HashTable *replace_ht, zend_string *replace_str, - HashTable *subject_ht, zend_string *subject_str, + const HashTable *replace_ht, zend_string *replace_str, + const HashTable *subject_ht, zend_string *subject_str, zend_long limit, zval *zcount, bool is_filter @@ -2552,7 +2552,7 @@ PHP_FUNCTION(preg_split) /* }}} */ /* {{{ php_pcre_split */ -PHPAPI void php_pcre_split_impl(pcre_cache_entry *pce, zend_string *subject_str, zval *return_value, +PHPAPI void php_pcre_split_impl(const pcre_cache_entry *pce, zend_string *subject_str, zval *return_value, zend_long limit_val, zend_long flags) { uint32_t options; /* Execution options */ @@ -2913,7 +2913,7 @@ PHP_FUNCTION(preg_grep) } /* }}} */ -PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return_value, zend_long flags) /* {{{ */ +PHPAPI void php_pcre_grep_impl(const pcre_cache_entry *pce, zval *input, zval *return_value, zend_long flags) /* {{{ */ { uint32_t num_subpats; /* Number of captured subpatterns */ int count; /* Count of matched subpatterns */ diff --git a/ext/pcre/php_pcre.h b/ext/pcre/php_pcre.h index ebaa686a31c3..8b104f204972 100644 --- a/ext/pcre/php_pcre.h +++ b/ext/pcre/php_pcre.h @@ -50,13 +50,13 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str, zval *return_value, zval *subpats, bool global, zend_long flags, zend_off_t start_offset); -PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, const char *subject, size_t subject_len, zend_string *replace_str, +PHPAPI zend_string *php_pcre_replace_impl(const pcre_cache_entry *pce, zend_string *subject_str, const char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count); -PHPAPI void php_pcre_split_impl( pcre_cache_entry *pce, zend_string *subject_str, zval *return_value, +PHPAPI void php_pcre_split_impl(const pcre_cache_entry *pce, zend_string *subject_str, zval *return_value, zend_long limit_val, zend_long flags); -PHPAPI void php_pcre_grep_impl( pcre_cache_entry *pce, zval *input, zval *return_value, +PHPAPI void php_pcre_grep_impl(const pcre_cache_entry *pce, zval *input, zval *return_value, zend_long flags); PHPAPI pcre2_match_context *php_pcre_mctx(void);

« previous php.cvs (#141474) next »