summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2015-05-06 10:51:52 +0800
committerXinchen Hui <laruence@php.net>2015-05-06 10:51:52 +0800
commit55d94a453243cafc2292920e9c91bd2bc551f2be (patch)
treec00d368a3c68c2e53167b8da8c6448cdb88801e7 /ext
parent9b3a92a1cad96ff88a61493bf688bc0757933642 (diff)
parent63282d3321044681e880a997a6360d4b99a07d4f (diff)
downloadphp-git-55d94a453243cafc2292920e9c91bd2bc551f2be.tar.gz
Merge branch 'master' of git.php.net:php-src
Diffstat (limited to 'ext')
-rw-r--r--ext/pdo/pdo_stmt.c56
-rw-r--r--ext/pdo/php_pdo_driver.h3
-rw-r--r--ext/pdo_dblib/dblib_stmt.c9
-rw-r--r--ext/pdo_firebird/firebird_statement.c4
-rw-r--r--ext/pdo_mysql/mysql_statement.c7
-rw-r--r--ext/pdo_oci/oci_statement.c3
-rw-r--r--ext/pdo_odbc/odbc_stmt.c3
-rw-r--r--ext/pdo_pgsql/pgsql_statement.c7
-rw-r--r--ext/pdo_sqlite/sqlite_statement.c5
-rw-r--r--ext/reflection/php_reflection.c6
-rw-r--r--ext/simplexml/simplexml.c110
-rw-r--r--ext/standard/formatted_print.c22
-rw-r--r--ext/standard/string.c22
13 files changed, 150 insertions, 107 deletions
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 3387da0f2d..6383abb925 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -209,7 +209,7 @@ int pdo_stmt_describe_columns(pdo_stmt_t *stmt) /* {{{ */
/* if we are applying case conversions on column names, do so now */
if (stmt->dbh->native_case != stmt->dbh->desired_case && stmt->dbh->desired_case != PDO_CASE_NATURAL) {
- char *s = stmt->columns[col].name;
+ char *s = stmt->columns[col].name->val;
switch (stmt->dbh->desired_case) {
case PDO_CASE_UPPER:
@@ -243,8 +243,8 @@ int pdo_stmt_describe_columns(pdo_stmt_t *stmt) /* {{{ */
if (stmt->bound_columns) {
struct pdo_bound_param_data *param;
- if ((param = zend_hash_str_find_ptr(stmt->bound_columns,
- stmt->columns[col].name, stmt->columns[col].namelen)) != NULL) {
+ if ((param = zend_hash_find_ptr(stmt->bound_columns,
+ stmt->columns[col].name)) != NULL) {
param->paramno = col;
}
}
@@ -345,7 +345,8 @@ static int really_register_bound_param(struct pdo_bound_param_data *param, pdo_s
int i;
for (i = 0; i < stmt->column_count; i++) {
- if (strncmp(stmt->columns[i].name, param->name->val, param->name->len + 1) == 0) {
+ if (stmt->columns[i].name->len == param->name->len &&
+ strncmp(stmt->columns[i].name->val, param->name->val, param->name->len + 1) == 0) {
param->paramno = i;
break;
}
@@ -1025,7 +1026,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
switch (how) {
case PDO_FETCH_ASSOC:
- add_assoc_zval(return_value, stmt->columns[i].name, &val);
+ zend_symtable_update(Z_ARRVAL_P(return_value), stmt->columns[i].name, &val);
break;
case PDO_FETCH_KEY_PAIR:
@@ -1046,19 +1047,18 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
case PDO_FETCH_USE_DEFAULT:
case PDO_FETCH_BOTH:
- add_assoc_zval(return_value, stmt->columns[i].name, &val);
+ zend_symtable_update(Z_ARRVAL_P(return_value), stmt->columns[i].name, &val);
if (Z_REFCOUNTED(val)) {
Z_ADDREF(val);
}
- add_next_index_zval(return_value, &val);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &val);
break;
case PDO_FETCH_NAMED:
/* already have an item with this name? */
{
zval *curr_val;
- if ((curr_val = zend_hash_str_find(Z_ARRVAL_P(return_value), stmt->columns[i].name,
- strlen(stmt->columns[i].name)))) {
+ if ((curr_val = zend_hash_find(Z_ARRVAL_P(return_value), stmt->columns[i].name))) {
zval arr;
if (Z_TYPE_P(curr_val) != IS_ARRAY) {
/* a little bit of black magic here:
@@ -1077,33 +1077,33 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
ZVAL_COPY_VALUE(&cur, curr_val);
ZVAL_COPY_VALUE(curr_val, &arr);
- add_next_index_zval(&arr, &cur);
+ zend_hash_next_index_insert_new(Z_ARRVAL(arr), &cur);
} else {
ZVAL_COPY_VALUE(&arr, curr_val);
}
- add_next_index_zval(&arr, &val);
+ zend_hash_next_index_insert_new(Z_ARRVAL(arr), &val);
} else {
- add_assoc_zval(return_value, stmt->columns[i].name, &val);
+ zend_hash_update(Z_ARRVAL_P(return_value), stmt->columns[i].name, &val);
}
}
break;
case PDO_FETCH_NUM:
- add_next_index_zval(return_value, &val);
+ zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &val);
break;
case PDO_FETCH_OBJ:
case PDO_FETCH_INTO:
- zend_update_property(NULL, return_value,
- stmt->columns[i].name, stmt->columns[i].namelen,
+ zend_update_property_ex(NULL, return_value,
+ stmt->columns[i].name,
&val);
zval_ptr_dtor(&val);
break;
case PDO_FETCH_CLASS:
if ((flags & PDO_FETCH_SERIALIZE) == 0 || idx) {
- zend_update_property(ce, return_value,
- stmt->columns[i].name, stmt->columns[i].namelen,
+ zend_update_property_ex(ce, return_value,
+ stmt->columns[i].name,
&val);
zval_ptr_dtor(&val);
} else {
@@ -1194,16 +1194,16 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
if (return_all) {
if ((flags & PDO_FETCH_UNIQUE) == PDO_FETCH_UNIQUE) {
- add_assoc_zval(return_all, Z_STRVAL(grp_val), return_value);
+ zend_symtable_update(Z_ARRVAL_P(return_all), Z_STR(grp_val), return_value);
} else {
zval grp;
if ((pgrp = zend_symtable_find(Z_ARRVAL_P(return_all), Z_STR(grp_val))) == NULL) {
array_init(&grp);
- add_assoc_zval(return_all, Z_STRVAL(grp_val), &grp);
+ zend_symtable_update(Z_ARRVAL_P(return_all), Z_STR(grp_val), &grp);
} else {
ZVAL_COPY_VALUE(&grp, pgrp);
}
- add_next_index_zval(&grp, return_value);
+ zend_hash_next_index_insert(Z_ARRVAL(grp), return_value);
}
zval_dtor(&grp_val);
}
@@ -1518,7 +1518,7 @@ static PHP_METHOD(PDOStatement, fetchAll)
} else {
array_init(return_value);
do {
- add_next_index_zval(return_value, &data);
+ zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &data);
} while (do_fetch(stmt, 1, &data, how | flags, PDO_FETCH_ORI_NEXT, 0, 0));
}
}
@@ -1824,7 +1824,7 @@ static PHP_METHOD(PDOStatement, getColumnMeta)
/* add stock items */
col = &stmt->columns[colno];
- add_assoc_string(return_value, "name", col->name);
+ add_assoc_str(return_value, "name", zend_string_copy(col->name));
add_assoc_long(return_value, "len", col->maxlen); /* FIXME: unsigned ? */
add_assoc_long(return_value, "precision", col->precision);
if (col->param_type != PDO_PARAM_ZVAL) {
@@ -2027,7 +2027,7 @@ static int pdo_stmt_do_next_rowset(pdo_stmt_t *stmt)
struct pdo_column_data *cols = stmt->columns;
for (i = 0; i < stmt->column_count; i++) {
- efree(cols[i].name);
+ zend_string_release(cols[i].name);
}
efree(stmt->columns);
stmt->columns = NULL;
@@ -2329,7 +2329,7 @@ PDO_API void php_pdo_free_statement(pdo_stmt_t *stmt)
for (i = 0; i < stmt->column_count; i++) {
if (cols[i].name) {
- efree(cols[i].name);
+ zend_string_release(cols[i].name);
cols[i].name = NULL;
}
}
@@ -2506,7 +2506,8 @@ static zval *row_prop_read(zval *object, zval *member, int type, void **cache_sl
/* TODO: replace this with a hash of available column names to column
* numbers */
for (colno = 0; colno < stmt->column_count; colno++) {
- if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) {
+ if (stmt->columns[colno].name->len == Z_STRLEN_P(member) &&
+ strncmp(stmt->columns[colno].name->val, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) {
fetch_value(stmt, rv, colno, NULL);
//???
//Z_SET_REFCOUNT_P(rv, 0);
@@ -2565,7 +2566,8 @@ static int row_prop_exists(zval *object, zval *member, int check_empty, void **c
/* TODO: replace this with a hash of available column names to column
* numbers */
for (colno = 0; colno < stmt->column_count; colno++) {
- if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) {
+ if (stmt->columns[colno].name->len == Z_STRLEN_P(member) &&
+ strncmp(stmt->columns[colno].name->val, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) {
return 1;
}
}
@@ -2606,7 +2608,7 @@ static HashTable *row_get_properties(zval *object)
zval val;
fetch_value(stmt, &val, i, NULL);
- zend_hash_str_update(stmt->std.properties, stmt->columns[i].name, stmt->columns[i].namelen, &val);
+ zend_hash_update(stmt->std.properties, stmt->columns[i].name, &val);
}
return stmt->std.properties;
diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h
index 407d1baa82..efa21a4e14 100644
--- a/ext/pdo/php_pdo_driver.h
+++ b/ext/pdo/php_pdo_driver.h
@@ -527,11 +527,10 @@ static inline pdo_dbh_object_t *php_pdo_dbh_fetch_object(zend_object *obj) {
/* describes a column */
struct pdo_column_data {
- char *name;
+ zend_string *name;
size_t maxlen;
zend_ulong precision;
enum pdo_param_type param_type;
- size_t namelen;
/* don't touch this unless your name is dbdo */
void *dbdo_data;
diff --git a/ext/pdo_dblib/dblib_stmt.c b/ext/pdo_dblib/dblib_stmt.c
index 4da5f71531..97776548b2 100644
--- a/ext/pdo_dblib/dblib_stmt.c
+++ b/ext/pdo_dblib/dblib_stmt.c
@@ -191,16 +191,17 @@ static int pdo_dblib_stmt_describe(pdo_stmt_t *stmt, int colno)
{
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
pdo_dblib_db_handle *H = S->H;
+ struct pdo_column_data *col;
+ zend_string *str;
if(colno >= stmt->column_count || colno < 0) {
return FAILURE;
}
- struct pdo_column_data *col = &stmt->columns[colno];
-
- col->name = estrdup(dbcolname(H->link, colno+1));
+ col = &stmt->columns[colno];
+ str = dbcolname(H->link, colno+1);
+ col->name = zend_string_init(str, strlen(str), 0);
col->maxlen = dbcollen(H->link, colno+1);
- col->namelen = strlen(col->name);
col->param_type = PDO_PARAM_STR;
return 1;
diff --git a/ext/pdo_firebird/firebird_statement.c b/ext/pdo_firebird/firebird_statement.c
index 50901841c8..337ce3fb66 100644
--- a/ext/pdo_firebird/firebird_statement.c
+++ b/ext/pdo_firebird/firebird_statement.c
@@ -197,8 +197,8 @@ static int firebird_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */
: (var->aliasname_length);
col->precision = -var->sqlscale;
col->maxlen = var->sqllen;
- col->namelen = colname_len;
- col->name = cp = emalloc(colname_len + 1);
+ col->name = zend_string_alloc(colname_len, 0);
+ cp = col->name->val;
if (colname_len > var->aliasname_length) {
memmove(cp, var->relname, var->relname_length);
cp += var->relname_length;
diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c
index 56728ed92d..551960560e 100644
--- a/ext/pdo_mysql/mysql_statement.c
+++ b/ext/pdo_mysql/mysql_statement.c
@@ -696,14 +696,11 @@ static int pdo_mysql_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */
PDO_DBG_RETURN(1);
}
for (i = 0; i < stmt->column_count; i++) {
- int namelen;
if (S->H->fetch_table_names) {
- namelen = spprintf(&cols[i].name, 0, "%s.%s", S->fields[i].table, S->fields[i].name);
- cols[i].namelen = namelen;
+ cols[i].name = strpprintf(0, "%s.%s", S->fields[i].table, S->fields[i].name);
} else {
- cols[i].namelen = S->fields[i].name_length;
- cols[i].name = estrndup(S->fields[i].name, S->fields[i].name_length);
+ cols[i].name = zend_string_init(S->fields[i].name, S->fields[i].name_length, 0);
}
cols[i].precision = S->fields[i].decimals;
diff --git a/ext/pdo_oci/oci_statement.c b/ext/pdo_oci/oci_statement.c
index e47fba513b..9efb371f6d 100644
--- a/ext/pdo_oci/oci_statement.c
+++ b/ext/pdo_oci/oci_statement.c
@@ -525,8 +525,7 @@ static int oci_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */
col->precision = scale;
col->maxlen = data_size;
- col->namelen = namelen;
- col->name = estrndup((char *)colname, namelen);
+ col->name = zend_string_init((char *)colname, namelen, 0);
S->cols[colno].dtype = dtype;
diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c
index 5d4ff3af96..6421cb6701 100644
--- a/ext/pdo_odbc/odbc_stmt.c
+++ b/ext/pdo_odbc/odbc_stmt.c
@@ -594,8 +594,7 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno)
colsize = displaysize;
col->maxlen = S->cols[colno].datalen = colsize;
- col->namelen = colnamelen;
- col->name = estrdup(S->cols[colno].colname);
+ col->name = zend_string_init(S->cols[colno].colname, colnamelen, 0);
S->cols[colno].is_unicode = pdo_odbc_sqltype_is_unicode(S, S->cols[colno].coltype);
/* returning data as a string */
diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c
index 435781ecf1..60553b36ce 100644
--- a/ext/pdo_pgsql/pgsql_statement.c
+++ b/ext/pdo_pgsql/pgsql_statement.c
@@ -438,13 +438,14 @@ static int pgsql_stmt_describe(pdo_stmt_t *stmt, int colno)
pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data;
struct pdo_column_data *cols = stmt->columns;
struct pdo_bound_param_data *param;
+ char *str;
if (!S->result) {
return 0;
}
- cols[colno].name = estrdup(PQfname(S->result, colno));
- cols[colno].namelen = strlen(cols[colno].name);
+ str = PQfname(S->result, colno);
+ cols[colno].name = zend_string_init(str, strlen(str), 0);
cols[colno].maxlen = PQfsize(S->result, colno);
cols[colno].precision = PQfmod(S->result, colno);
S->cols[colno].pgsql_type = PQftype(S->result, colno);
@@ -459,7 +460,7 @@ static int pgsql_stmt_describe(pdo_stmt_t *stmt, int colno)
/* did the user bind the column as a LOB ? */
if (stmt->bound_columns && (
(param = zend_hash_index_find_ptr(stmt->bound_columns, colno)) != NULL ||
- (param = zend_hash_str_find_ptr(stmt->bound_columns, cols[colno].name, cols[colno].namelen)) != NULL)) {
+ (param = zend_hash_find_ptr(stmt->bound_columns, cols[colno].name)) != NULL)) {
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_LOB) {
cols[colno].param_type = PDO_PARAM_LOB;
diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c
index 29300c198a..f42ad05329 100644
--- a/ext/pdo_sqlite/sqlite_statement.c
+++ b/ext/pdo_sqlite/sqlite_statement.c
@@ -233,6 +233,7 @@ static int pdo_sqlite_stmt_fetch(pdo_stmt_t *stmt,
static int pdo_sqlite_stmt_describe(pdo_stmt_t *stmt, int colno)
{
pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data;
+ char *str;
if(colno >= sqlite3_column_count(S->stmt)) {
/* error invalid column */
@@ -240,8 +241,8 @@ static int pdo_sqlite_stmt_describe(pdo_stmt_t *stmt, int colno)
return 0;
}
- stmt->columns[colno].name = estrdup(sqlite3_column_name(S->stmt, colno));
- stmt->columns[colno].namelen = strlen(stmt->columns[colno].name);
+ str = sqlite3_column_name(S->stmt, colno);
+ stmt->columns[colno].name = zend_string_init(str, strlen(str), 0);
stmt->columns[colno].maxlen = 0xffffffff;
stmt->columns[colno].precision = 0;
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 76159479f2..f7dd5531d0 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -1717,7 +1717,7 @@ ZEND_METHOD(reflection_function, getClosure)
}
GET_REFLECTION_OBJECT_PTR(fptr);
- zend_create_closure(return_value, fptr, NULL, NULL);
+ zend_create_closure(return_value, fptr, NULL, NULL, NULL);
}
/* }}} */
@@ -2827,7 +2827,7 @@ ZEND_METHOD(reflection_method, getClosure)
GET_REFLECTION_OBJECT_PTR(mptr);
if (mptr->common.fn_flags & ZEND_ACC_STATIC) {
- zend_create_closure(return_value, mptr, mptr->common.scope, NULL);
+ zend_create_closure(return_value, mptr, mptr->common.scope, mptr->common.scope, NULL);
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &obj) == FAILURE) {
return;
@@ -2844,7 +2844,7 @@ ZEND_METHOD(reflection_method, getClosure)
{
RETURN_ZVAL(obj, 1, 0);
} else {
- zend_create_closure(return_value, mptr, mptr->common.scope, obj);
+ zend_create_closure(return_value, mptr, mptr->common.scope, Z_OBJCE_P(obj), obj);
}
}
}
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index d2ed7da008..7a9775b752 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -64,7 +64,7 @@ static void php_sxe_iterator_rewind(zend_object_iterator *iter);
/* {{{ _node_as_zval()
*/
-static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, SXE_ITER itertype, char *name, const xmlChar *nsprefix, int isprefix)
+static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, SXE_ITER itertype, char *name, const char *nsprefix, int isprefix)
{
php_sxe_object *subnode;
@@ -73,10 +73,10 @@ static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, SXE
subnode->document->refcount++;
subnode->iter.type = itertype;
if (name) {
- subnode->iter.name = xmlStrdup((xmlChar *)name);
+ subnode->iter.name = (xmlChar*)estrdup(name);
}
if (nsprefix && *nsprefix) {
- subnode->iter.nsprefix = xmlStrdup(nsprefix);
+ subnode->iter.nsprefix = (xmlChar*)estrdup(nsprefix);
subnode->iter.isprefix = isprefix;
}
@@ -978,7 +978,7 @@ static inline zend_string *sxe_xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr li
/* {{{ _get_base_node_value()
*/
-static void _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval *value, xmlChar *nsprefix, int isprefix)
+static void _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval *value, char *nsprefix, int isprefix)
{
php_sxe_object *subnode;
xmlChar *contents;
@@ -994,7 +994,7 @@ static void _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval
subnode->document = sxe_ref->document;
subnode->document->refcount++;
if (nsprefix && *nsprefix) {
- subnode->iter.nsprefix = xmlStrdup((xmlChar *)nsprefix);
+ subnode->iter.nsprefix = (xmlChar*)estrdup(nsprefix);
subnode->iter.isprefix = isprefix;
}
php_libxml_increment_node_ptr((php_libxml_node_object *)subnode, node, NULL);
@@ -1007,26 +1007,24 @@ static void _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval
static void sxe_properties_add(HashTable *rv, char *name, int namelen, zval *value) /* {{{ */
{
+ zend_string *key;
zval *data_ptr;
zval newptr;
- if ((data_ptr = zend_hash_str_find(rv, name, namelen)) != NULL) {
+ key = zend_string_init(name, namelen, 0);
+ if ((data_ptr = zend_hash_find(rv, key)) != NULL) {
if (Z_TYPE_P(data_ptr) == IS_ARRAY) {
- zend_hash_next_index_insert(Z_ARRVAL_P(data_ptr), value);
+ zend_hash_next_index_insert_new(Z_ARRVAL_P(data_ptr), value);
} else {
array_init(&newptr);
-
- if (Z_REFCOUNTED_P(data_ptr)) {
- Z_ADDREF_P(data_ptr);
- }
- zend_hash_next_index_insert(Z_ARRVAL(newptr), data_ptr);
- zend_hash_next_index_insert(Z_ARRVAL(newptr), value);
-
- zend_hash_str_update(rv, name, namelen, &newptr);
+ zend_hash_next_index_insert_new(Z_ARRVAL(newptr), data_ptr);
+ zend_hash_next_index_insert_new(Z_ARRVAL(newptr), value);
+ ZVAL_ARR(data_ptr, Z_ARR(newptr));
}
} else {
- zend_hash_str_update(rv, name, namelen, value);
+ zend_hash_add_new(rv, key, value);
}
+ zend_string_release(key);
}
/* }}} */
@@ -1499,9 +1497,14 @@ SXE_METHOD(asXML)
static inline void sxe_add_namespace_name(zval *return_value, xmlNsPtr ns) /* {{{ */
{
char *prefix = SXE_NS_PREFIX(ns);
- if (zend_hash_str_exists(Z_ARRVAL_P(return_value), prefix, strlen(prefix)) == 0) {
- add_assoc_string(return_value, prefix, (char*)ns->href);
+ zend_string *key = zend_string_init(prefix, strlen(prefix), 0);
+ zval zv;
+
+ if (!zend_hash_exists(Z_ARRVAL_P(return_value), key)) {
+ ZVAL_STRING(&zv, (char*)ns->href);
+ zend_hash_add_new(Z_ARRVAL_P(return_value), key, &zv);
}
+ zend_string_release(key);
}
/* }}} */
@@ -2061,10 +2064,10 @@ sxe_object_clone(zval *object)
clone->iter.isprefix = sxe->iter.isprefix;
if (sxe->iter.name != NULL) {
- clone->iter.name = xmlStrdup((xmlChar *)sxe->iter.name);
+ clone->iter.name = (xmlChar*)estrdup((char*)sxe->iter.name);
}
if (sxe->iter.nsprefix != NULL) {
- clone->iter.nsprefix = xmlStrdup((xmlChar *)sxe->iter.nsprefix);
+ clone->iter.nsprefix = (xmlChar*)estrdup((char*)sxe->iter.nsprefix);
}
clone->iter.type = sxe->iter.type;
@@ -2093,11 +2096,11 @@ static void sxe_object_dtor(zend_object *object)
}
if (sxe->iter.name) {
- xmlFree(sxe->iter.name);
+ efree(sxe->iter.name);
sxe->iter.name = NULL;
}
if (sxe->iter.nsprefix) {
- xmlFree(sxe->iter.nsprefix);
+ efree(sxe->iter.nsprefix);
sxe->iter.nsprefix = NULL;
}
if (!Z_ISUNDEF(sxe->tmp)) {
@@ -2136,17 +2139,21 @@ static zend_function* php_sxe_find_fptr_count(zend_class_entry *ce)
{
zend_function *fptr_count = NULL;
zend_class_entry *parent = ce;
+ int inherited = 0;
while (parent) {
if (parent == sxe_class_entry) {
break;
}
parent = parent->parent;
+ inherited = 1;
}
- fptr_count = zend_hash_str_find_ptr(&ce->function_table, "count", sizeof("count") - 1);
- if (fptr_count->common.scope == parent) {
- fptr_count = NULL;
+ if (inherited) {
+ fptr_count = zend_hash_str_find_ptr(&ce->function_table, "count", sizeof("count") - 1);
+ if (fptr_count->common.scope == parent) {
+ fptr_count = NULL;
+ }
}
return fptr_count;
@@ -2218,7 +2225,7 @@ PHP_FUNCTION(simplexml_load_file)
fptr_count = php_sxe_find_fptr_count(ce);
}
sxe = php_sxe_object_new(ce, fptr_count);
- sxe->iter.nsprefix = ns_len ? xmlStrdup((xmlChar *)ns) : NULL;
+ sxe->iter.nsprefix = ns_len ? (xmlChar*)estrdup(ns) : NULL;
sxe->iter.isprefix = isprefix;
php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp);
php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, xmlDocGetRootElement(docp), NULL);
@@ -2259,7 +2266,7 @@ PHP_FUNCTION(simplexml_load_string)
fptr_count = php_sxe_find_fptr_count(ce);
}
sxe = php_sxe_object_new(ce, fptr_count);
- sxe->iter.nsprefix = ns_len ? xmlStrdup((xmlChar *)ns) : NULL;
+ sxe->iter.nsprefix = ns_len ? (xmlChar*)estrdup(ns) : NULL;
sxe->iter.isprefix = isprefix;
php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp);
php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, xmlDocGetRootElement(docp), NULL);
@@ -2291,7 +2298,7 @@ SXE_METHOD(__construct)
return;
}
- sxe->iter.nsprefix = ns_len ? xmlStrdup((xmlChar *)ns) : NULL;
+ sxe->iter.nsprefix = ns_len ? (xmlChar*)estrdup(ns) : NULL;
sxe->iter.isprefix = isprefix;
php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp);
php_libxml_increment_node_ptr((php_libxml_node_object *)sxe, xmlDocGetRootElement(docp), NULL);
@@ -2312,22 +2319,45 @@ static xmlNodePtr php_sxe_iterator_fetch(php_sxe_object *sxe, xmlNodePtr node, i
{
xmlChar *prefix = sxe->iter.nsprefix;
int isprefix = sxe->iter.isprefix;
- int test_elem = sxe->iter.type == SXE_ITER_ELEMENT && sxe->iter.name;
- int test_attr = sxe->iter.type == SXE_ITER_ATTRLIST && sxe->iter.name;
- while (node) {
- SKIP_TEXT(node);
- if (sxe->iter.type != SXE_ITER_ATTRLIST && node->type == XML_ELEMENT_NODE) {
- if ((!test_elem || !xmlStrcmp(node->name, sxe->iter.name)) && match_ns(sxe, node, prefix, isprefix)) {
- break;
+ if (sxe->iter.type == SXE_ITER_ATTRLIST) {
+ if (sxe->iter.name) {
+ while (node) {
+ if (node->type == XML_ATTRIBUTE_NODE) {
+ if (!xmlStrcmp(node->name, sxe->iter.name) && match_ns(sxe, node, prefix, isprefix)) {
+ break;
+ }
+ }
+ node = node->next;
}
- } else if (node->type == XML_ATTRIBUTE_NODE) {
- if ((!test_attr || !xmlStrcmp(node->name, sxe->iter.name)) && match_ns(sxe, node, prefix, isprefix)) {
- break;
+ } else {
+ while (node) {
+ if (node->type == XML_ATTRIBUTE_NODE) {
+ if (match_ns(sxe, node, prefix, isprefix)) {
+ break;
+ }
+ }
+ node = node->next;
}
}
-next_iter:
- node = node->next;
+ } else if (sxe->iter.type == SXE_ITER_ELEMENT && sxe->iter.name) {
+ while (node) {
+ if (node->type == XML_ELEMENT_NODE) {
+ if (!xmlStrcmp(node->name, sxe->iter.name) && match_ns(sxe, node, prefix, isprefix)) {
+ break;
+ }
+ }
+ node = node->next;
+ }
+ } else {
+ while (node) {
+ if (node->type == XML_ELEMENT_NODE) {
+ if (match_ns(sxe, node, prefix, isprefix)) {
+ break;
+ }
+ }
+ node = node->next;
+ }
}
if (node && use_data) {
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c
index 4c0eeeebb9..1c381cdb00 100644
--- a/ext/standard/formatted_print.c
+++ b/ext/standard/formatted_print.c
@@ -383,7 +383,7 @@ php_sprintf_getnumber(char *buffer, size_t *pos)
*
*/
static zend_string *
-php_formatted_print(int param_count, int use_array, int format_offset)
+php_formatted_print(zend_execute_data *execute_data, int use_array, int format_offset)
{
zval *newargs = NULL;
zval *args, *z_format;
@@ -395,9 +395,15 @@ php_formatted_print(int param_count, int use_array, int format_offset)
int always_sign;
size_t format_len;
- if (zend_parse_parameters(param_count, "+", &args, &argc) == FAILURE) {
+#ifndef FAST_ZPP
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "+", &args, &argc) == FAILURE) {
return NULL;
}
+#else
+ ZEND_PARSE_PARAMETERS_START(1, -1)
+ Z_PARAM_VARIADIC('+', args, argc)
+ ZEND_PARSE_PARAMETERS_END_EX(return NULL);
+#endif
/* verify the number of args */
if ((use_array && argc != (2 + format_offset))
@@ -670,7 +676,7 @@ PHP_FUNCTION(user_sprintf)
{
zend_string *result;
- if ((result=php_formatted_print(ZEND_NUM_ARGS(), 0, 0))==NULL) {
+ if ((result=php_formatted_print(execute_data, 0, 0))==NULL) {
RETURN_FALSE;
}
RETVAL_STR(result);
@@ -683,7 +689,7 @@ PHP_FUNCTION(vsprintf)
{
zend_string *result;
- if ((result=php_formatted_print(ZEND_NUM_ARGS(), 1, 0))==NULL) {
+ if ((result=php_formatted_print(execute_data, 1, 0))==NULL) {
RETURN_FALSE;
}
RETVAL_STR(result);
@@ -697,7 +703,7 @@ PHP_FUNCTION(user_printf)
zend_string *result;
size_t rlen;
- if ((result=php_formatted_print(ZEND_NUM_ARGS(), 0, 0))==NULL) {
+ if ((result=php_formatted_print(execute_data, 0, 0))==NULL) {
RETURN_FALSE;
}
rlen = PHPWRITE(result->val, result->len);
@@ -713,7 +719,7 @@ PHP_FUNCTION(vprintf)
zend_string *result;
size_t rlen;
- if ((result=php_formatted_print(ZEND_NUM_ARGS(), 1, 0))==NULL) {
+ if ((result=php_formatted_print(execute_data, 1, 0))==NULL) {
RETURN_FALSE;
}
rlen = PHPWRITE(result->val, result->len);
@@ -740,7 +746,7 @@ PHP_FUNCTION(fprintf)
php_stream_from_zval(stream, arg1);
- if ((result=php_formatted_print(ZEND_NUM_ARGS(), 0, 1))==NULL) {
+ if ((result=php_formatted_print(execute_data, 0, 1))==NULL) {
RETURN_FALSE;
}
@@ -769,7 +775,7 @@ PHP_FUNCTION(vfprintf)
php_stream_from_zval(stream, arg1);
- if ((result=php_formatted_print(ZEND_NUM_ARGS(), 1, 1))==NULL) {
+ if ((result=php_formatted_print(execute_data, 1, 1))==NULL) {
RETURN_FALSE;
}
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 686fa19536..ee66e8a2af 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -1082,18 +1082,22 @@ PHPAPI void php_explode(const zend_string *delim, zend_string *str, zval *return
char *p1 = str->val;
char *endp = str->val + str->len;
char *p2 = (char *) php_memnstr(str->val, delim->val, delim->len, endp);
+ zval tmp;
if (p2 == NULL) {
- add_next_index_str(return_value, zend_string_copy(str));
+ ZVAL_STR_COPY(&tmp, str);
+ zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp);
} else {
do {
- add_next_index_stringl(return_value, p1, p2 - p1);
+ ZVAL_STRINGL(&tmp, p1, p2 - p1);
+ zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp);
p1 = p2 + delim->len;
p2 = (char *) php_memnstr(p1, delim->val, delim->len, endp);
} while (p2 != NULL && --limit > 1);
if (p1 <= endp) {
- add_next_index_stringl(return_value, p1, endp - p1);
+ ZVAL_STRINGL(&tmp, p1, endp - p1);
+ zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp);
}
}
}
@@ -1107,6 +1111,7 @@ PHPAPI void php_explode_negative_limit(const zend_string *delim, zend_string *st
char *p1 = str->val;
char *endp = str->val + str->len;
char *p2 = (char *) php_memnstr(str->val, delim->val, delim->len, endp);
+ zval tmp;
if (p2 == NULL) {
/*
@@ -1131,8 +1136,8 @@ PHPAPI void php_explode_negative_limit(const zend_string *delim, zend_string *st
to_return = limit + found;
/* limit is at least -1 therefore no need of bounds checking : i will be always less than found */
for (i = 0; i < to_return; i++) { /* this checks also for to_return > 0 */
- add_next_index_stringl(return_value, positions[i],
- (positions[i+1] - delim->len) - positions[i]);
+ ZVAL_STRINGL(&tmp, positions[i], (positions[i+1] - delim->len) - positions[i]);
+ zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp);
}
efree(positions);
}
@@ -1146,6 +1151,7 @@ PHP_FUNCTION(explode)
{
zend_string *str, *delim;
zend_long limit = ZEND_LONG_MAX; /* No limit */
+ zval tmp;
#ifndef FAST_ZPP
if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|l", &delim, &str, &limit) == FAILURE) {
@@ -1169,7 +1175,8 @@ PHP_FUNCTION(explode)
if (str->len == 0) {
if (limit >= 0) {
- add_next_index_str(return_value, STR_EMPTY_ALLOC());
+ ZVAL_EMPTY_STRING(&tmp);
+ zend_hash_index_add_new(Z_ARRVAL_P(return_value), 0, &tmp);
}
return;
}
@@ -1179,7 +1186,8 @@ PHP_FUNCTION(explode)
} else if (limit < 0) {
php_explode_negative_limit(delim, str, return_value, limit);
} else {
- add_index_stringl(return_value, 0, str->val, str->len);
+ ZVAL_STR_COPY(&tmp, str);
+ zend_hash_index_add_new(Z_ARRVAL_P(return_value), 0, &tmp);
}
}
/* }}} */