summaryrefslogtreecommitdiff
path: root/ext/pcre
diff options
context:
space:
mode:
authortwosee <twose@qq.com>2020-06-07 17:01:19 +0800
committerNikita Popov <nikita.ppv@gmail.com>2020-06-08 10:38:45 +0200
commit88355dd338835f7a59415ecb2e7e970658f3867f (patch)
treef203c58d7656c341273565e2d6fb84d89837bad2 /ext/pcre
parentf6db43fec8da3d3c0c7def077e9f493ce6129c45 (diff)
downloadphp-git-88355dd338835f7a59415ecb2e7e970658f3867f.tar.gz
Constify char * arguments of APIs
Closes GH-5676.
Diffstat (limited to 'ext/pcre')
-rw-r--r--ext/pcre/php_pcre.c22
-rw-r--r--ext/pcre/php_pcre.h4
2 files changed, 13 insertions, 13 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 9f67bff14c..55f9d2db7b 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -555,12 +555,12 @@ static zend_string **make_subpats_table(uint32_t num_subpats, pcre_cache_entry *
/* {{{ 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, char *start)
+static zend_always_inline size_t calculate_unit_length(pcre_cache_entry *pce, const char *start)
{
size_t unit_len;
if (pce->compile_options & PCRE2_UTF) {
- char *end = start;
+ const char *end = start;
/* skip continuation bytes */
while ((*++end & 0xC0) == 0x80);
@@ -1038,7 +1038,7 @@ static inline void add_offset_pair(
/* }}} */
static void populate_subpat_array(
- zval *subpats, char *subject, PCRE2_SIZE *offsets, zend_string **subpat_names,
+ zval *subpats, const char *subject, PCRE2_SIZE *offsets, zend_string **subpat_names,
uint32_t num_subpats, int count, const PCRE2_SPTR mark, zend_long flags) {
zend_bool offset_capture = (flags & PREG_OFFSET_CAPTURE) != 0;
zend_bool unmatched_as_null = (flags & PREG_UNMATCHED_AS_NULL) != 0;
@@ -1531,7 +1531,7 @@ static int preg_get_backref(char **str, int *backref)
/* {{{ preg_do_repl_func
*/
-static zend_string *preg_do_repl_func(zend_fcall_info *fci, zend_fcall_info_cache *fcc, char *subject, PCRE2_SIZE *offsets, zend_string **subpat_names, uint32_t num_subpats, int count, const PCRE2_SPTR mark, zend_long flags)
+static zend_string *preg_do_repl_func(zend_fcall_info *fci, zend_fcall_info_cache *fcc, const char *subject, PCRE2_SIZE *offsets, zend_string **subpat_names, uint32_t num_subpats, int count, const PCRE2_SPTR mark, zend_long flags)
{
zend_string *result_str;
zval retval; /* Function return value */
@@ -1570,7 +1570,7 @@ static zend_string *preg_do_repl_func(zend_fcall_info *fci, zend_fcall_info_cach
*/
PHPAPI zend_string *php_pcre_replace(zend_string *regex,
zend_string *subject_str,
- char *subject, size_t subject_len,
+ const char *subject, size_t subject_len,
zend_string *replace_str,
size_t limit, size_t *replace_count)
{
@@ -1596,7 +1596,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, char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count)
+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)
{
uint32_t options; /* Execution options */
int count; /* Count of matched subpatterns */
@@ -1610,10 +1610,10 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su
size_t last_end_offset; /* Where the last search ended */
char *walkbuf, /* Location of current replacement in the result */
*walk, /* Used to walk the replacement string */
- *match, /* The current match */
- *piece, /* The current piece of subject */
- *replace_end, /* End of replacement string */
walk_last; /* Last walked character */
+ const char *match, /* The current match */
+ *piece, /* The current piece of subject */
+ *replace_end; /* End of replacement string */
size_t result_len; /* Length of result */
zend_string *result; /* Result of replacement */
pcre2_match_data *match_data;
@@ -1838,7 +1838,7 @@ error:
/* }}} */
/* {{{ php_pcre_replace_func_impl() */
-static zend_string *php_pcre_replace_func_impl(pcre_cache_entry *pce, zend_string *subject_str, char *subject, size_t subject_len, zend_fcall_info *fci, zend_fcall_info_cache *fcc, size_t limit, size_t *replace_count, zend_long flags)
+static zend_string *php_pcre_replace_func_impl(pcre_cache_entry *pce, zend_string *subject_str, const char *subject, size_t subject_len, zend_fcall_info *fci, zend_fcall_info_cache *fcc, size_t limit, size_t *replace_count, zend_long flags)
{
uint32_t options; /* Execution options */
int count; /* Count of matched subpatterns */
@@ -1849,7 +1849,7 @@ static zend_string *php_pcre_replace_func_impl(pcre_cache_entry *pce, zend_strin
size_t alloc_len; /* Actual allocated length */
PCRE2_SIZE start_offset; /* Where the new search starts */
size_t last_end_offset; /* Where the last search ended */
- char *match, /* The current match */
+ const char *match, /* The current match */
*piece; /* The current piece of subject */
size_t result_len; /* Length of result */
zend_string *result; /* Result of replacement */
diff --git a/ext/pcre/php_pcre.h b/ext/pcre/php_pcre.h
index 4666f11b78..808b671bb8 100644
--- a/ext/pcre/php_pcre.h
+++ b/ext/pcre/php_pcre.h
@@ -25,7 +25,7 @@
#include <locale.h>
-PHPAPI zend_string *php_pcre_replace(zend_string *regex, zend_string *subject_str, char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count);
+PHPAPI zend_string *php_pcre_replace(zend_string *regex, zend_string *subject_str, const char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count);
PHPAPI pcre2_code* pcre_get_compiled_regex(zend_string *regex, uint32_t *capture_count);
PHPAPI pcre2_code* pcre_get_compiled_regex_ex(zend_string *regex, uint32_t *capture_count, uint32_t *preg_options, uint32_t *coptions);
@@ -53,7 +53,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str, zval *return_value,
zval *subpats, int global, int use_flags, zend_long flags, zend_off_t start_offset);
-PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, char *subject, size_t subject_len, zend_string *replace_str,
+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 void php_pcre_split_impl( pcre_cache_entry *pce, zend_string *subject_str, zval *return_value,