|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patch substr_insert.patch for *General Issues Bug #39962Patch version 2011-08-23 14:05 UTC Return to Bug #39962 | Download this patchThis patch is obsolete Obsoleted by patches:
Developer: datibbaw@php.net
+ if (start) {
+ memcpy(result, str, start);
+ }
+ memcpy((result + start), insert, insert_len);
+ if (start != str_len) {
+ if (from != str_len) {
+ memcpy((result + start + insert_len), (str + start), str_len - start);
+ }
+ result[result_len] = '\0';
+
+
/* {{{ proto string quotemeta(string str)
Quotes meta characters */
PHP_FUNCTION(quotemeta)
@@ -5271,17 +5308,25 @@
{
char *s1, *s2;
int s1_len, s2_len;
- long offset, len=0;
+ long offset, len = 0;
zend_bool cs=0;
uint cmp_len;
+ zval **zlen = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl|lb", &s1, &s1_len, &s2, &s2_len, &offset, &len, &cs) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssl|Zb", &s1, &s1_len, &s2, &s2_len, &offset, &zlen, &cs) == FAILURE) {
RETURN_FALSE;
}
- if (ZEND_NUM_ARGS() >= 4 && len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "The length must be greater than zero");
- RETURN_FALSE;
+ if (ZEND_NUM_ARGS() >= 4 && Z_TYPE_PP(zlen) != IS_NULL) {
+ if (Z_ISREF_PP(zlen)) {
+ SEPARATE_ZVAL(zlen);
+ }
+ convert_to_long_ex(zlen);
+ len = Z_LVAL_PP(zlen);
+ if (len <= 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "The length must be greater than zero");
+ RETURN_FALSE;
+ }
}
if (offset < 0) {
Index: basic_functions.c
===================================================================
--- basic_functions.c (revision 315071)
+++ basic_functions.c (working copy)
|
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sat Jan 17 07:00:01 2026 UTC |