summaryrefslogtreecommitdiff
path: root/ext/pcre/php_pcre.c
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2014-02-24 12:07:09 +0800
committerXinchen Hui <laruence@gmail.com>2014-02-24 12:07:09 +0800
commit077b02326a22d14f4970ffc3770e2a85f0728fb0 (patch)
treef887835f5fb83717b2f6f859f3ac8f4fcc3de6ad /ext/pcre/php_pcre.c
parented8691b24be8673c2ab316991bfea885b1717f79 (diff)
downloadphp-git-077b02326a22d14f4970ffc3770e2a85f0728fb0.tar.gz
Refactor php_addslashes using zend_string
Diffstat (limited to 'ext/pcre/php_pcre.c')
-rw-r--r--ext/pcre/php_pcre.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 7a74082b46..d3bdf87bca 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -881,14 +881,13 @@ static int preg_do_eval(char *eval_str, int eval_str_len, char *subject,
zval retval; /* Return value from evaluation */
char *eval_str_end, /* End of eval string */
*match, /* Current match for a backref */
- *esc_match, /* Quote-escaped match */
*walk, /* Used to walk the code string */
*segment, /* Start of segment to append while walking */
walk_last; /* Last walked character */
int match_len; /* Length of the match */
- int esc_match_len; /* Length of the quote-escaped match */
int result_len; /* Length of the result of the evaluation */
int backref; /* Current backref */
+ zend_string *esc_match; /* Quote-escaped match */
char *compiled_string_description;
smart_str code = {0};
@@ -914,22 +913,19 @@ static int preg_do_eval(char *eval_str, int eval_str_len, char *subject,
match = subject + offsets[backref<<1];
match_len = offsets[(backref<<1)+1] - offsets[backref<<1];
if (match_len) {
- esc_match = php_addslashes(match, match_len, &esc_match_len, 0 TSRMLS_CC);
+ esc_match = php_addslashes(match, match_len, 0 TSRMLS_CC);
} else {
- esc_match = match;
- esc_match_len = 0;
+ esc_match = STR_INIT(match, match_len, 0);
}
} else {
- esc_match = "";
- esc_match_len = 0;
+ esc_match = STR_EMPTY_ALLOC();
}
- smart_str_appendl(&code, esc_match, esc_match_len);
+ smart_str_appendl(&code, esc_match->val, esc_match->len);
segment = walk;
/* Clean up and reassign */
- if (esc_match_len)
- efree(esc_match);
+ STR_RELEASE(esc_match);
continue;
}
}