[php-src] master: pcre: refactor preg_get_backref()
| From: | Gina Peter Banyard | Date: | Wed, 23 Sep 2026 14:22:29 +0000 |
| Subject: | [php-src] master: pcre: refactor preg_get_backref() | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141475@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/fdd47f13baf0bfea2652c8a3ddc3e083d83d73f4
Raw diff: https://github.com/php/php-src/commit/fdd47f13baf0bfea2652c8a3ddc3e083d83d73f4.diff
pcre: refactor preg_get_backref()
Changed paths:
M ext/pcre/php_pcre.c
Diff:
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index fd5d407b1544..088db5d7bef2 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -1514,17 +1514,17 @@ PHP_FUNCTION(preg_match_all)
}
/* }}} */
-/* {{{ preg_get_backref */
-static int preg_get_backref(char **str, int *backref)
+static bool preg_get_backref(char **str, int *backref)
{
- char in_brace = 0;
+ bool in_brace = false;
char *walk = *str;
- if (walk[1] == 0)
- return 0;
+ if (walk[1] == 0) {
+ return false;
+ }
if (*walk == '$' && walk[1] == '{') {
- in_brace = 1;
+ in_brace = true;
walk++;
}
walk++;
@@ -1532,8 +1532,9 @@ static int preg_get_backref(char **str, int *backref)
if (*walk >= '0' && *walk <= '9') {
*backref = *walk - '0';
walk++;
- } else
- return 0;
+ } else {
+ return false;
+ }
if (*walk && *walk >= '0' && *walk <= '9') {
*backref = *backref * 10 + *walk - '0';
@@ -1541,16 +1542,15 @@ static int preg_get_backref(char **str, int *backref)
}
if (in_brace) {
- if (*walk != '}')
- return 0;
- else
- walk++;
+ if (*walk != '}') {
+ return false;
+ }
+ walk++;
}
*str = walk;
- return 1;
+ return true;
}
-/* }}} */
/* Return NULL if an exception has occurred */
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)