diff options
author | Dmitry Stogov <dmitry@zend.com> | 2015-06-30 04:05:24 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2015-06-30 04:05:24 +0300 |
commit | 4a2e40bb861bc3cf5fb6863e57486ed60316e97c (patch) | |
tree | 6579660b282fdd1bc50095e48d702913a0b6aa97 /ext | |
parent | 8cce5b2641fb91c3073018b59f6f044b843041a8 (diff) | |
download | php-git-4a2e40bb861bc3cf5fb6863e57486ed60316e97c.tar.gz |
Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes).
Diffstat (limited to 'ext')
163 files changed, 3248 insertions, 3129 deletions
diff --git a/ext/bcmath/libbcmath/src/num2str.c b/ext/bcmath/libbcmath/src/num2str.c index 5f3911e47c..c72a924933 100644 --- a/ext/bcmath/libbcmath/src/num2str.c +++ b/ext/bcmath/libbcmath/src/num2str.c @@ -58,7 +58,7 @@ zend_string if (str == NULL) bc_out_of_memory(); /* The negative sign if needed. */ - sptr = str->val; + sptr = ZSTR_VAL(str); if (signch) *sptr++ = '-'; /* Load the whole number. */ @@ -76,6 +76,6 @@ zend_string /* Terminate the string and return it! */ *sptr = '\0'; - str->len = sptr - (char *)str->val; + ZSTR_LEN(str) = sptr - (char *)ZSTR_VAL(str); return str; } diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c index d4175c724a..50a4faac50 100644 --- a/ext/bz2/bz2.c +++ b/ext/bz2/bz2.c @@ -291,7 +291,7 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, * failed. */ if (opened_path && !bz_file && mode[0] == 'w') { - VCWD_UNLINK((*opened_path)->val); + VCWD_UNLINK(ZSTR_VAL(*opened_path)); } } @@ -379,8 +379,8 @@ static PHP_FUNCTION(bzread) RETURN_FALSE; } data = zend_string_alloc(len, 0); - data->len = php_stream_read(stream, data->val, data->len); - data->val[data->len] = '\0'; + ZSTR_LEN(data) = php_stream_read(stream, ZSTR_VAL(data), ZSTR_LEN(data)); + ZSTR_VAL(data)[ZSTR_LEN(data)] = '\0'; RETURN_NEW_STR(data); } @@ -539,15 +539,15 @@ static PHP_FUNCTION(bzcompress) work_factor = zwork_factor; } - error = BZ2_bzBuffToBuffCompress(dest->val, &dest_len, source, source_len, block_size, 0, work_factor); + error = BZ2_bzBuffToBuffCompress(ZSTR_VAL(dest), &dest_len, source, source_len, block_size, 0, work_factor); if (error != BZ_OK) { zend_string_free(dest); RETURN_LONG(error); } else { /* Copy the buffer, we have perhaps allocate a lot more than we need, so we erealloc() the buffer to the proper size */ - dest->len = dest_len; - dest->val[dest->len] = '\0'; + ZSTR_LEN(dest) = dest_len; + ZSTR_VAL(dest)[ZSTR_LEN(dest)] = '\0'; RETURN_NEW_STR(dest); } } diff --git a/ext/curl/interface.c b/ext/curl/interface.c index ea64294d0e..676c6adb81 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -2243,7 +2243,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ #endif { zend_string *str = zval_get_string(zvalue); - int ret = php_curl_option_str(ch, option, str->val, str->len, 0); + int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 0); zend_string_release(str); return ret; } @@ -2268,7 +2268,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ error = curl_easy_setopt(ch->cp, option, NULL); } else { zend_string *str = zval_get_string(zvalue); - int ret = php_curl_option_str(ch, option, str->val, str->len, 0); + int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 0); zend_string_release(str); return ret; } @@ -2279,7 +2279,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ case CURLOPT_PRIVATE: { zend_string *str = zval_get_string(zvalue); - int ret = php_curl_option_str(ch, option, str->val, str->len, 1); + int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 1); zend_string_release(str); return ret; } @@ -2288,7 +2288,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ case CURLOPT_URL: { zend_string *str = zval_get_string(zvalue); - int ret = php_curl_option_url(ch, str->val, str->len); + int ret = php_curl_option_url(ch, ZSTR_VAL(str), ZSTR_LEN(str)); zend_string_release(str); return ret; } @@ -2448,7 +2448,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ ZEND_HASH_FOREACH_VAL(ph, current) { val = zval_get_string(current); - slist = curl_slist_append(slist, val->val); + slist = curl_slist_append(slist, ZSTR_VAL(val)); zend_string_release(val); if (!slist) { php_error_docref(NULL, E_WARNING, "Could not build curl_slist"); @@ -2522,11 +2522,11 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ prop = zend_read_property(curl_CURLFile_class, current, "name", sizeof("name")-1, 0, &rv); if (Z_TYPE_P(prop) != IS_STRING) { - php_error_docref(NULL, E_WARNING, "Invalid filename for key %s", string_key->val); + php_error_docref(NULL, E_WARNING, "Invalid filename for key %s", ZSTR_VAL(string_key)); } else { postval = Z_STR_P(prop); - if (php_check_open_basedir(postval->val)) { + if (php_check_open_basedir(ZSTR_VAL(postval))) { return 1; } @@ -2539,11 +2539,11 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ filename = Z_STRVAL_P(prop); } form_error = curl_formadd(&first, &last, - CURLFORM_COPYNAME, string_key->val, - CURLFORM_NAMELENGTH, string_key->len, - CURLFORM_FILENAME, filename ? filename : postval->val, + CURLFORM_COPYNAME, ZSTR_VAL(string_key), + CURLFORM_NAMELENGTH, ZSTR_LEN(string_key), + CURLFORM_FILENAME, filename ? filename : ZSTR_VAL(postval), CURLFORM_CONTENTTYPE, type ? type : "application/octet-stream", - CURLFORM_FILE, postval->val, + CURLFORM_FILE, ZSTR_VAL(postval), CURLFORM_END); if (form_error != CURL_FORMADD_OK) { /* Not nice to convert between enums but we only have place for one error type */ @@ -2561,10 +2561,10 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ * must be explicitly cast to long in curl_formadd * use since curl needs a long not an int. */ form_error = curl_formadd(&first, &last, - CURLFORM_COPYNAME, string_key->val, - CURLFORM_NAMELENGTH, string_key->len, - CURLFORM_COPYCONTENTS, postval->val, - CURLFORM_CONTENTSLENGTH, postval->len, + CURLFORM_COPYNAME, ZSTR_VAL(string_key), + CURLFORM_NAMELENGTH, ZSTR_LEN(string_key), + CURLFORM_COPYCONTENTS, ZSTR_VAL(postval), + CURLFORM_CONTENTSLENGTH, ZSTR_LEN(postval), CURLFORM_END); if (form_error != CURL_FORMADD_OK) { @@ -2589,18 +2589,18 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ #if LIBCURL_VERSION_NUM >= 0x071101 zend_string *str = zval_get_string(zvalue); /* with curl 7.17.0 and later, we can use COPYPOSTFIELDS, but we have to provide size before */ - error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, str->len); - error = curl_easy_setopt(ch->cp, CURLOPT_COPYPOSTFIELDS, str->val); + error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, ZSTR_LEN(str)); + error = curl_easy_setopt(ch->cp, CURLOPT_COPYPOSTFIELDS, ZSTR_VAL(str)); zend_string_release(str); #else char *post = NULL; zend_string *str = zval_get_string(zvalue); - post = estrndup(str->val, str->len); + post = estrndup(ZSTR_VAL(str), ZSTR_LEN(str)); zend_llist_add_element(&ch->to_free->str, &post); curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDS, post); - error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, str->len); + error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, ZSTR_LEN(str)); zend_string_release(str); #endif } @@ -2695,12 +2695,12 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ zend_string *str = zval_get_string(zvalue); int ret; - if (str->len && php_check_open_basedir(str->val)) { + if (ZSTR_LEN(str) && php_check_open_basedir(ZSTR_VAL(str))) { zend_string_release(str); return FAILURE; } - ret = php_curl_option_str(ch, option, str->val, str->len, 0); + ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 0); zend_string_release(str); return ret; } diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 3702e8e6d1..2f52353ce2 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -1663,7 +1663,7 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt) initial buffer is too small. See http://connect.microsoft.com/VisualStudio/feedback/details/759720/vs2012-strftime-crash-with-z-formatting-code */ buf = zend_string_alloc(buf_len, 0); - while ((real_len = strftime(buf->val, buf_len, format, &ta)) == buf_len || real_len == 0) { + while ((real_len = strftime(ZSTR_VAL(buf), buf_len, format, &ta)) == buf_len || real_len == 0) { buf_len *= 2; buf = zend_string_extend(buf, buf_len, 0); if (!--max_reallocs) { @@ -2191,7 +2191,7 @@ static HashTable *date_object_get_properties(zval *object) /* {{{ */ zend_string *tmpstr = zend_string_alloc(sizeof("UTC+05:00")-1, 0); timelib_sll utc_offset = dateobj->time->z; - tmpstr->len = snprintf(tmpstr->val, sizeof("+05:00"), "%c%02d:%02d", + ZSTR_LEN(tmpstr) = snprintf(ZSTR_VAL(tmpstr), sizeof("+05:00"), "%c%02d:%02d", utc_offset > 0 ? '-' : '+', abs(utc_offset / 60), abs((utc_offset % 60))); @@ -2283,7 +2283,7 @@ static HashTable *date_object_get_properties_timezone(zval *object) /* {{{ */ case TIMELIB_ZONETYPE_OFFSET: { zend_string *tmpstr = zend_string_alloc(sizeof("UTC+05:00")-1, 0); - tmpstr->len = snprintf(tmpstr->val, sizeof("+05:00"), "%c%02d:%02d", + ZSTR_LEN(tmpstr) = snprintf(ZSTR_VAL(tmpstr), sizeof("+05:00"), "%c%02d:%02d", tzobj->tzi.utc_offset > 0 ? '-' : '+', abs(tzobj->tzi.utc_offset / 60), abs((tzobj->tzi.utc_offset % 60))); @@ -3744,7 +3744,7 @@ PHP_FUNCTION(timezone_name_get) zend_string *tmpstr = zend_string_alloc(sizeof("UTC+05:00")-1, 0); timelib_sll utc_offset = tzobj->tzi.utc_offset; - tmpstr->len = snprintf(tmpstr->val, sizeof("+05:00"), "%c%02d:%02d", + ZSTR_LEN(tmpstr) = snprintf(ZSTR_VAL(tmpstr), sizeof("+05:00"), "%c%02d:%02d", utc_offset > 0 ? '-' : '+', abs(utc_offset / 60), abs((utc_offset % 60))); @@ -4115,7 +4115,7 @@ static int php_date_interval_initialize_from_hash(zval **return_value, php_inter zval *z_arg = zend_hash_str_find(myht, element, sizeof(element) - 1); \ if (z_arg) { \ zend_string *str = zval_get_string(z_arg); \ - DATE_A64I((*intobj)->diff->member, str->val); \ + DATE_A64I((*intobj)->diff->member, ZSTR_VAL(str)); \ zend_string_release(str); \ } else { \ (*intobj)->diff->member = -1LL; \ diff --git a/ext/dom/attr.c b/ext/dom/attr.c index 66f677058e..e1896ce56d 100644 --- a/ext/dom/attr.c +++ b/ext/dom/attr.c @@ -169,7 +169,7 @@ int dom_attr_value_write(dom_object *obj, zval *newval) str = zval_get_string(newval); - xmlNodeSetContentLen((xmlNodePtr) attrp, (xmlChar *) str->val, str->len + 1); + xmlNodeSetContentLen((xmlNodePtr) attrp, (xmlChar *) ZSTR_VAL(str), ZSTR_LEN(str) + 1); zend_string_release(str); return SUCCESS; diff --git a/ext/dom/characterdata.c b/ext/dom/characterdata.c index 28dbb4d091..9daa24dbe6 100644 --- a/ext/dom/characterdata.c +++ b/ext/dom/characterdata.c @@ -108,7 +108,7 @@ int dom_characterdata_data_write(dom_object *obj, zval *newval) str = zval_get_string(newval); - xmlNodeSetContentLen(nodep, (xmlChar *) str->val, str->len + 1); + xmlNodeSetContentLen(nodep, (xmlChar *) ZSTR_VAL(str), ZSTR_LEN(str) + 1); zend_string_release(str); return SUCCESS; diff --git a/ext/dom/document.c b/ext/dom/document.c index 9e18d7fcba..0ab0e498c8 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -347,7 +347,7 @@ int dom_document_encoding_write(dom_object *obj, zval *newval) if (docp->encoding != NULL) { xmlFree((xmlChar *)docp->encoding); } - docp->encoding = xmlStrdup((const xmlChar *) str->val); + docp->encoding = xmlStrdup((const xmlChar *) ZSTR_VAL(str)); } else { php_error_docref(NULL, E_WARNING, "Invalid Document Encoding"); } @@ -438,7 +438,7 @@ int dom_document_version_write(dom_object *obj, zval *newval) str = zval_get_string(newval); - docp->version = xmlStrdup((const xmlChar *) str->val); + docp->version = xmlStrdup((const xmlChar *) ZSTR_VAL(str)); zend_string_release(str); return SUCCESS; @@ -666,7 +666,7 @@ int dom_document_document_uri_write(dom_object *obj, zval *newval) str = zval_get_string(newval); - docp->URL = xmlStrdup((const xmlChar *) str->val); + docp->URL = xmlStrdup((const xmlChar *) ZSTR_VAL(str)); zend_string_release(str); return SUCCESS; @@ -2223,11 +2223,11 @@ PHP_METHOD(domdocument, registerNodeClass) DOM_GET_OBJ(docp, id, xmlDocPtr, intern); if (dom_set_doc_classmap(intern->document, basece, ce) == FAILURE) { - php_error_docref(NULL, E_ERROR, "Class %s could not be registered.", ce->name->val); + php_error_docref(NULL, E_ERROR, "Class %s could not be registered.", ZSTR_VAL(ce->name)); } RETURN_TRUE; } else { - php_error_docref(NULL, E_ERROR, "Class %s is not derived from %s.", ce->name->val, basece->name->val); + php_error_docref(NULL, E_ERROR, "Class %s is not derived from %s.", ZSTR_VAL(ce->name), ZSTR_VAL(basece->name)); } RETURN_FALSE; diff --git a/ext/dom/node.c b/ext/dom/node.c index 971c727b58..2023073705 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -344,7 +344,7 @@ int dom_node_node_value_write(dom_object *obj, zval *newval) case XML_PI_NODE: { zend_string *str = zval_get_string(newval); - xmlNodeSetContentLen(nodep, (xmlChar *) str->val, str->len + 1); + xmlNodeSetContentLen(nodep, (xmlChar *) ZSTR_VAL(str), ZSTR_LEN(str) + 1); zend_string_release(str); break; } @@ -721,7 +721,7 @@ int dom_node_prefix_write(dom_object *obj, zval *newval) } } str = zval_get_string(newval); - prefix = str->val; + prefix = ZSTR_VAL(str); if (nsnode && nodep->ns != NULL && !xmlStrEqual(nodep->ns->prefix, (xmlChar *)prefix)) { strURI = (char *) nodep->ns->href; if (strURI == NULL || @@ -855,7 +855,7 @@ int dom_node_text_content_write(dom_object *obj, zval *newval) } str = zval_get_string(newval); - enc_str = xmlEncodeEntitiesReentrant(nodep->doc, (xmlChar *) str->val); + enc_str = xmlEncodeEntitiesReentrant(nodep->doc, (xmlChar *) ZSTR_VAL(str)); xmlNodeSetContent(nodep, enc_str); xmlFree(enc_str); zend_string_release(str); @@ -1746,7 +1746,7 @@ static void dom_canonicalization(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(tmp), prefix, tmpns) { if (Z_TYPE_P(tmpns) == IS_STRING) { if (prefix) { - xmlXPathRegisterNs(ctxp, (xmlChar *) prefix->val, (xmlChar *) Z_STRVAL_P(tmpns)); + xmlXPathRegisterNs(ctxp, (xmlChar *) ZSTR_VAL(prefix), (xmlChar *) Z_STRVAL_P(tmpns)); } } } ZEND_HASH_FOREACH_END(); diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 40109010f2..795dff21d7 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -337,7 +337,7 @@ zval *dom_read_property(zval *object, zval *member, int type, void **cache_slot, if (obj->prop_handler != NULL) { hnd = zend_hash_find_ptr(obj->prop_handler, member_str); } else if (instanceof_function(obj->std.ce, dom_node_class_entry)) { - php_error(E_WARNING, "Couldn't fetch %s. Node no longer exists", obj->std.ce->name->val); + php_error(E_WARNING, "Couldn't fetch %s. Node no longer exists", ZSTR_VAL(obj->std.ce->name)); } if (hnd) { diff --git a/ext/dom/php_dom.h b/ext/dom/php_dom.h index 65534b19d4..fdba616363 100644 --- a/ext/dom/php_dom.h +++ b/ext/dom/php_dom.h @@ -137,7 +137,7 @@ entry = zend_register_internal_class_ex(&ce, parent_ce); #define DOM_GET_OBJ(__ptr, __id, __prtype, __intern) { \ __intern = Z_DOMOBJ_P(__id); \ if (__intern->ptr == NULL || !(__ptr = (__prtype)((php_libxml_node_ptr *)__intern->ptr)->node)) { \ - php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", __intern->std.ce->name->val);\ + php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(__intern->std.ce->name));\ RETURN_NULL();\ } \ } diff --git a/ext/dom/processinginstruction.c b/ext/dom/processinginstruction.c index 38b934d011..7a0285f313 100644 --- a/ext/dom/processinginstruction.c +++ b/ext/dom/processinginstruction.c @@ -143,7 +143,7 @@ int dom_processinginstruction_data_write(dom_object *obj, zval *newval) str = zval_get_string(newval); - xmlNodeSetContentLen(nodep, (xmlChar *) str->val, str->len + 1); + xmlNodeSetContentLen(nodep, (xmlChar *) ZSTR_VAL(str), ZSTR_LEN(str) + 1); zend_string_release(str); return SUCCESS; diff --git a/ext/dom/xml_common.h b/ext/dom/xml_common.h index eb7b7e8909..325a5d9ef2 100644 --- a/ext/dom/xml_common.h +++ b/ext/dom/xml_common.h @@ -67,7 +67,7 @@ PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj); __intern = Z_LIBXML_NODE_P(__id); \ if (__intern->node == NULL || !(__ptr = (__prtype)__intern->node->node)) { \ php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", \ - __intern->std.ce->name->val);\ + ZSTR_VAL(__intern->std.ce->name));\ RETURN_NULL();\ } \ } diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index 63a877b3a1..6e7d7519c7 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -194,9 +194,9 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, fci.no_separation = 0; if (!zend_make_callable(&fci.function_name, &callable)) { - php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", callable->val); + php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", ZSTR_VAL(callable)); } else if (intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable) == 0) { - php_error_docref(NULL, E_WARNING, "Not allowed to call handler '%s()'.", callable->val); + php_error_docref(NULL, E_WARNING, "Not allowed to call handler '%s()'.", ZSTR_VAL(callable)); /* Push an empty string, so that we at least have an xslt result... */ valuePush(ctxt, xmlXPathNewString((xmlChar *)"")); } else { @@ -221,7 +221,7 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, valuePush(ctxt, xmlXPathNewString((xmlChar *)"")); } else { zend_string *str = zval_get_string(&retval); - valuePush(ctxt, xmlXPathNewString((xmlChar *) str->val)); + valuePush(ctxt, xmlXPathNewString((xmlChar *) ZSTR_VAL(str))); zend_string_release(str); } zval_ptr_dtor(&retval); diff --git a/ext/exif/exif.c b/ext/exif/exif.c index 0d7d99e5f9..2cd54eb875 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -167,12 +167,12 @@ ZEND_TSRMLS_CACHE_DEFINE(); ZEND_INI_MH(OnUpdateEncode) { - if (new_value && new_value->len) { + if (new_value && ZSTR_LEN(new_value)) { const zend_encoding **return_list; size_t return_size; - if (FAILURE == zend_multibyte_parse_encoding_list(new_value->val, new_value->len, + if (FAILURE == zend_multibyte_parse_encoding_list(ZSTR_VAL(new_value), ZSTR_LEN(new_value), &return_list, &return_size, 0)) { - php_error_docref(NULL, E_WARNING, "Illegal encoding ignored: '%s'", new_value->val); + php_error_docref(NULL, E_WARNING, "Illegal encoding ignored: '%s'", ZSTR_VAL(new_value)); return FAILURE; } efree(return_list); @@ -185,9 +185,9 @@ ZEND_INI_MH(OnUpdateDecode) if (new_value) { const zend_encoding **return_list; size_t return_size; - if (FAILURE == zend_multibyte_parse_encoding_list(new_value->val, new_value->len, + if (FAILURE == zend_multibyte_parse_encoding_list(ZSTR_VAL(new_value), ZSTR_LEN(new_value), &return_list, &return_size, 0)) { - php_error_docref(NULL, E_WARNING, "Illegal encoding ignored: '%s'", new_value->val); + php_error_docref(NULL, E_WARNING, "Illegal encoding ignored: '%s'", ZSTR_VAL(new_value)); return FAILURE; } efree(return_list); @@ -3881,7 +3881,7 @@ static int exif_read_file(image_info_type *ImageInfo, char *FileName, int read_t } base = php_basename(FileName, strlen(FileName), NULL, 0); - ImageInfo->FileName = estrndup(base->val, base->len); + ImageInfo->FileName = estrndup(ZSTR_VAL(base), ZSTR_LEN(base)); zend_string_release(base); ImageInfo->read_thumbnail = read_thumbnail; ImageInfo->read_all = read_all; diff --git a/ext/fileinfo/libmagic/funcs.c b/ext/fileinfo/libmagic/funcs.c index 44c3e7648d..91e9906dcd 100644 --- a/ext/fileinfo/libmagic/funcs.c +++ b/ext/fileinfo/libmagic/funcs.c @@ -455,8 +455,8 @@ file_replace(struct magic_set *ms, const char *pat, const char *rep) goto out; } - strncpy(ms->o.buf, res->val, res->len); - ms->o.buf[res->len] = '\0'; + strncpy(ms->o.buf, ZSTR_VAL(res), ZSTR_LEN(res)); + ms->o.buf[ZSTR_LEN(res)] = '\0'; zend_string_release(res); diff --git a/ext/fileinfo/libmagic/softmagic.c b/ext/fileinfo/libmagic/softmagic.c index 3fd30ff42c..88c80a5434 100644 --- a/ext/fileinfo/libmagic/softmagic.c +++ b/ext/fileinfo/libmagic/softmagic.c @@ -1812,29 +1812,29 @@ convert_libmagic_pattern(zval *pattern, char *val, int len, int options) t = zend_string_alloc(len * 2 + 4, 0); - t->val[j++] = '~'; + ZSTR_VAL(t)[j++] = '~'; for (i = 0; i < len; i++, j++) { switch (val[i]) { case '~': - t->val[j++] = '\\'; - t->val[j] = '~'; + ZSTR_VAL(t)[j++] = '\\'; + ZSTR_VAL(t)[j] = '~'; break; default: - t->val[j] = val[i]; + ZSTR_VAL(t)[j] = val[i]; break; } } - t->val[j++] = '~'; + ZSTR_VAL(t)[j++] = '~'; if (options & PCRE_CASELESS) - t->val[j++] = 'i'; + ZSTR_VAL(t)[j++] = 'i'; if (options & PCRE_MULTILINE) - t->val[j++] = 'm'; + ZSTR_VAL(t)[j++] = 'm'; - t->val[j]='\0'; - t->len = j; + ZSTR_VAL(t)[j]='\0'; + ZSTR_LEN(t) = j; ZVAL_NEW_STR(pattern, t); } diff --git a/ext/filter/filter.c b/ext/filter/filter.c index a2e22e7ed7..6f8a7a5f8b 100644 --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@ -162,7 +162,7 @@ static PHP_INI_MH(UpdateDefaultFilter) /* {{{ */ int i, size = sizeof(filter_list) / sizeof(filter_list_entry); for (i = 0; i < size; ++i) { - if ((strcasecmp(new_value->val, filter_list[i].name) == 0)) { + if ((strcasecmp(ZSTR_VAL(new_value), filter_list[i].name) == 0)) { IF_G(default_filter) = filter_list[i].id; return SUCCESS; } @@ -180,7 +180,7 @@ static PHP_INI_MH(OnUpdateFlags) if (!new_value) { IF_G(default_filter_flags) = FILTER_FLAG_NO_ENCODE_QUOTES; } else { - IF_G(default_filter_flags) = atoi(new_value->val); + IF_G(default_filter_flags) = atoi(ZSTR_VAL(new_value)); } return SUCCESS; } @@ -685,14 +685,14 @@ static void php_filter_array_handler(zval *input, zval *op, zval *return_value, zval_ptr_dtor(return_value); RETURN_FALSE; } - if (arg_key->len == 0) { + if (ZSTR_LEN(arg_key) == 0) { php_error_docref(NULL, E_WARNING, "Empty keys are not allowed in the definition array"); zval_ptr_dtor(return_value); RETURN_FALSE; } if ((tmp = zend_hash_find(Z_ARRVAL_P(input), arg_key)) == NULL) { if (add_empty) { - add_assoc_null_ex(return_value, arg_key->val, arg_key->len); + add_assoc_null_ex(return_value, ZSTR_VAL(arg_key), ZSTR_LEN(arg_key)); } } else { zval nval; diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters.c index 73bf92ed0b..f55cd21181 100644 --- a/ext/filter/sanitizing_filters.c +++ b/ext/filter/sanitizing_filters.c @@ -88,7 +88,7 @@ static void php_filter_encode_url(zval *value, const unsigned char* chars, const } */ str = zend_string_alloc(3 * Z_STRLEN_P(value), 0); - p = (unsigned char *) str->val; + p = (unsigned char *) ZSTR_VAL(str); s = (unsigned char *) Z_STRVAL_P(value); e = s + Z_STRLEN_P(value); @@ -103,7 +103,7 @@ static void php_filter_encode_url(zval *value, const unsigned char* chars, const s++; } *p = '\0'; - str->len = p - (unsigned char *)str->val; + ZSTR_LEN(str) = p - (unsigned char *)ZSTR_VAL(str); zval_ptr_dtor(value); ZVAL_NEW_STR(value, str); } @@ -127,13 +127,13 @@ static void php_filter_strip(zval *value, zend_long flags) } else if ((str[i] < 32) && (flags & FILTER_FLAG_STRIP_LOW)) { } else if ((str[i] == '`') && (flags & FILTER_FLAG_STRIP_BACKTICK)) { } else { - buf->val[c] = str[i]; + ZSTR_VAL(buf)[c] = str[i]; ++c; } } /* update zval string data */ - buf->val[c] = '\0'; - buf->len = c; + ZSTR_VAL(buf)[c] = '\0'; + ZSTR_LEN(buf) = c; zval_ptr_dtor(value); ZVAL_NEW_STR(value, buf); } @@ -166,13 +166,13 @@ static void filter_map_apply(zval *value, filter_map *map) c = 0; for (i = 0; i < Z_STRLEN_P(value); i++) { if ((*map)[str[i]]) { - buf->val[c] = str[i]; + ZSTR_VAL(buf)[c] = str[i]; ++c; } } /* update zval string data */ - buf->val[c] = '\0'; - buf->len = c; + ZSTR_VAL(buf)[c] = '\0'; + ZSTR_LEN(buf) = c; zval_ptr_dtor(value); ZVAL_NEW_STR(value, buf); } diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 8004585fe0..9fcbb176c0 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -1326,7 +1326,7 @@ PHP_FUNCTION(imageloadfont) return; } - stream = php_stream_open_wrapper(file->val, "rb", IGNORE_PATH | IGNORE_URL_WIN | REPORT_ERRORS, NULL); + stream = php_stream_open_wrapper(ZSTR_VAL(file), "rb", IGNORE_PATH | IGNORE_URL_WIN | REPORT_ERRORS, NULL); if (stream == NULL) { RETURN_FALSE; } @@ -2333,8 +2333,8 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, } /* needs to be malloc (persistent) - GD will free() it later */ - pstr = pestrndup(buff->val, buff->len, 1); - io_ctx = gdNewDynamicCtxEx(buff->len, pstr, 0); + pstr = pestrndup(ZSTR_VAL(buff), ZSTR_LEN(buff), 1); + io_ctx = gdNewDynamicCtxEx(ZSTR_LEN(buff), pstr, 0); if (!io_ctx) { pefree(pstr, 1); zend_string_release(buff); @@ -2635,7 +2635,7 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char } fclose(tmp); - VCWD_UNLINK((const char *)path->val); /* make sure that the temporary file is removed */ + VCWD_UNLINK((const char *)ZSTR_VAL(path)); /* make sure that the temporary file is removed */ zend_string_release(path); } RETURN_TRUE; @@ -3859,7 +3859,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int if (key == NULL) { continue; } - if (strcmp("linespacing", key->val) == 0) { + if (strcmp("linespacing", ZSTR_VAL(key)) == 0) { strex.flags |= gdFTEX_LINESPACE; strex.linespacing = zval_get_double(item); } diff --git a/ext/gettext/gettext.c b/ext/gettext/gettext.c index 44502729e5..dfe94c7a27 100644 --- a/ext/gettext/gettext.c +++ b/ext/gettext/gettext.c @@ -199,8 +199,8 @@ PHP_NAMED_FUNCTION(zif_gettext) ZEND_PARSE_PARAMETERS_END(); #endif - PHP_GETTEXT_LENGTH_CHECK("msgid", msgid->len) - msgstr = gettext(msgid->val); + PHP_GETTEXT_LENGTH_CHECK("msgid", ZSTR_LEN(msgid)) + msgstr = gettext(ZSTR_VAL(msgid)); RETURN_STRING(msgstr); } diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 663bbc96e4..0cac3dee4c 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -573,8 +573,8 @@ static int gmp_serialize(zval *object, unsigned char **buffer, size_t *buf_len, php_var_serialize(&buf, &zv, &serialize_data); PHP_VAR_SERIALIZE_DESTROY(serialize_data); - *buffer = (unsigned char *) estrndup(buf.s->val, buf.s->len); - *buf_len = buf.s->len; + *buffer = (unsigned char *) estrndup(ZSTR_VAL(buf.s), ZSTR_LEN(buf.s)); + *buf_len = ZSTR_LEN(buf.s); zend_string_release(buf.s); return SUCCESS; @@ -760,7 +760,7 @@ static void gmp_strval(zval *result, mpz_t gmpnum, int base) /* {{{ */ } str = zend_string_alloc(num_len, 0); - mpz_get_str(str->val, base, gmpnum); + mpz_get_str(ZSTR_VAL(str), base, gmpnum); /* * From GMP documentation for mpz_sizeinbase(): @@ -770,10 +770,10 @@ static void gmp_strval(zval *result, mpz_t gmpnum, int base) /* {{{ */ * So let's check to see if we already have a \0 byte... */ - if (str->val[str->len - 1] == '\0') { - str->len--; + if (ZSTR_VAL(str)[ZSTR_LEN(str) - 1] == '\0') { + ZSTR_LEN(str)--; } else { - str->val[str->len] = '\0'; + ZSTR_VAL(str)[ZSTR_LEN(str)] = '\0'; } ZVAL_NEW_STR(result, str); @@ -1149,8 +1149,8 @@ ZEND_FUNCTION(gmp_export) size_t out_len = count * size; zend_string *out_string = zend_string_alloc(out_len, 0); - mpz_export(out_string->val, NULL, order, size, endian, 0, gmpnumber); - out_string->val[out_len] = '\0'; + mpz_export(ZSTR_VAL(out_string), NULL, order, size, endian, 0, gmpnumber); + ZSTR_VAL(out_string)[out_len] = '\0'; RETURN_NEW_STR(out_string); } diff --git a/ext/hash/hash.c b/ext/hash/hash.c index d72b88c879..325c9b9230 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -163,17 +163,17 @@ static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_ } digest = zend_string_alloc(ops->digest_size, 0); - ops->hash_final((unsigned char *) digest->val, context); + ops->hash_final((unsigned char *) ZSTR_VAL(digest), context); efree(context); if (raw_output) { - digest->val[ops->digest_size] = 0; + ZSTR_VAL(digest)[ops->digest_size] = 0; RETURN_NEW_STR(digest); } else { zend_string *hex_digest = zend_string_safe_alloc(ops->digest_size, 2, 0, 0); - php_hash_bin2hex(hex_digest->val, (unsigned char *) digest->val, ops->digest_size); - hex_digest->val[2 * ops->digest_size] = 0; + php_hash_bin2hex(ZSTR_VAL(hex_digest), (unsigned char *) ZSTR_VAL(digest), ops->digest_size); + ZSTR_VAL(hex_digest)[2 * ops->digest_size] = 0; zend_string_release(digest); RETURN_NEW_STR(hex_digest); } @@ -282,14 +282,14 @@ static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename, ops->hash_update(context, (unsigned char *) buf, n); } php_stream_close(stream); - ops->hash_final((unsigned char *) digest->val, context); + ops->hash_final((unsigned char *) ZSTR_VAL(digest), context); } else { - php_hash_hmac_round((unsigned char *) digest->val, ops, context, K, (unsigned char *) data, data_len); + php_hash_hmac_round((unsigned char *) ZSTR_VAL(digest), ops, context, K, (unsigned char *) data, data_len); } php_hash_string_xor_char(K, K, 0x6A, ops->block_size); - php_hash_hmac_round((unsigned char *) digest->val, ops, context, K, (unsigned char *) digest->val, ops->digest_size); + php_hash_hmac_round((unsigned char *) ZSTR_VAL(digest), ops, context, K, (unsigned char *) ZSTR_VAL(digest), ops->digest_size); /* Zero the key */ ZEND_SECURE_ZERO(K, ops->block_size); @@ -297,13 +297,13 @@ static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename, efree(context); if (raw_output) { - digest->val[ops->digest_size] = 0; + ZSTR_VAL(digest)[ops->digest_size] = 0; RETURN_NEW_STR(digest); } else { zend_string *hex_digest = zend_string_safe_alloc(ops->digest_size, 2, 0, 0); - php_hash_bin2hex(hex_digest->val, (unsigned char *) digest->val, ops->digest_size); - hex_digest->val[2 * ops->digest_size] = 0; + php_hash_bin2hex(ZSTR_VAL(hex_digest), (unsigned char *) ZSTR_VAL(digest), ops->digest_size); + ZSTR_VAL(hex_digest)[2 * ops->digest_size] = 0; zend_string_release(digest); RETURN_NEW_STR(hex_digest); } @@ -513,7 +513,7 @@ PHP_FUNCTION(hash_final) digest_len = hash->ops->digest_size; digest = zend_string_alloc(digest_len, 0); - hash->ops->hash_final((unsigned char *) digest->val, hash->context); + hash->ops->hash_final((unsigned char *) ZSTR_VAL(digest), hash->context); if (hash->options & PHP_HASH_HMAC) { int i; @@ -525,15 +525,15 @@ PHP_FUNCTION(hash_final) /* Feed this result into the outter hash */ hash->ops->hash_init(hash->context); hash->ops->hash_update(hash->context, hash->key, hash->ops->block_size); - hash->ops->hash_update(hash->context, (unsigned char *) digest->val, hash->ops->digest_size); - hash->ops->hash_final((unsigned char *) digest->val, hash->context); + hash->ops->hash_update(hash->context, (unsigned char *) ZSTR_VAL(digest), hash->ops->digest_size); + hash->ops->hash_final((unsigned char *) ZSTR_VAL(digest), hash->context); /* Zero the key */ ZEND_SECURE_ZERO(hash->key, hash->ops->block_size); efree(hash->key); hash->key = NULL; } - digest->val[digest_len] = 0; + ZSTR_VAL(digest)[digest_len] = 0; efree(hash->context); hash->context = NULL; zend_list_close(Z_RES_P(zhash)); @@ -543,8 +543,8 @@ PHP_FUNCTION(hash_final) } else { zend_string *hex_digest = zend_string_safe_alloc(digest_len, 2, 0, 0); - php_hash_bin2hex(hex_digest->val, (unsigned char *) digest->val, digest_len); - hex_digest->val[2 * digest_len] = 0; + php_hash_bin2hex(ZSTR_VAL(hex_digest), (unsigned char *) ZSTR_VAL(digest), digest_len); + ZSTR_VAL(hex_digest)[2 * digest_len] = 0; zend_string_release(digest); RETURN_NEW_STR(hex_digest); } @@ -718,11 +718,11 @@ PHP_FUNCTION(hash_pbkdf2) returnval = zend_string_alloc(length, 0); if (raw_output) { - memcpy(returnval->val, result, length); + memcpy(ZSTR_VAL(returnval), result, length); } else { - php_hash_bin2hex(returnval->val, result, digest_length); + php_hash_bin2hex(ZSTR_VAL(returnval), result, digest_length); } - returnval->val[length] = 0; + ZSTR_VAL(returnval)[length] = 0; efree(result); RETURN_NEW_STR(returnval); } @@ -1087,7 +1087,7 @@ PHP_MINFO_FUNCTION(hash) char *s = buffer, *e = s + sizeof(buffer); ZEND_HASH_FOREACH_STR_KEY(&php_hash_hashtable, str) { - s += slprintf(s, e - s, "%s ", str->val); + s += slprintf(s, e - s, "%s ", ZSTR_VAL(str)); } ZEND_HASH_FOREACH_END(); *s = 0; diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 8fcc43dd92..8699174b3a 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -229,7 +229,7 @@ static char _generic_superset_name[] = ICONV_UCS4_ENCODING; static PHP_INI_MH(OnUpdateInputEncoding) { - if (new_value->len >= ICONV_CSNMAXLEN) { + if (ZSTR_LEN(new_value) >= ICONV_CSNMAXLEN) { return FAILURE; } if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) { @@ -242,7 +242,7 @@ static PHP_INI_MH(OnUpdateInputEncoding) static PHP_INI_MH(OnUpdateOutputEncoding) { - if(new_value->len >= ICONV_CSNMAXLEN) { + if (ZSTR_LEN(new_value) >= ICONV_CSNMAXLEN) { return FAILURE; } if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) { @@ -255,7 +255,7 @@ static PHP_INI_MH(OnUpdateOutputEncoding) static PHP_INI_MH(OnUpdateInternalEncoding) { - if(new_value->len >= ICONV_CSNMAXLEN) { + if (ZSTR_LEN(new_value) >= ICONV_CSNMAXLEN) { return FAILURE; } if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) { @@ -441,8 +441,8 @@ static int php_iconv_output_handler(void **nothing, php_output_context *output_c output_context->out.free = 1; _php_iconv_show_error(php_iconv_string(output_context->in.data, output_context->in.used, &out, get_output_encoding(), get_internal_encoding()), get_output_encoding(), get_internal_encoding()); if (out) { - output_context->out.data = estrndup(out->val, out->len); - output_context->out.used = out->len; + output_context->out.data = estrndup(ZSTR_VAL(out), ZSTR_LEN(out)); + output_context->out.used = ZSTR_LEN(out); zend_string_free(out); } else { output_context->out.data = NULL; @@ -470,7 +470,7 @@ static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l, out_left = buf_growth - out_left; smart_str_alloc(d, out_left, 0); - out_p = (d)->s->val + (d)->s->len; + out_p = ZSTR_VAL((d)->s) + ZSTR_LEN((d)->s); if (iconv(cd, (char **)&in_p, &in_left, (char **) &out_p, &out_left) == (size_t)-1) { #if ICONV_SUPPORTS_ERRNO @@ -496,7 +496,7 @@ static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l, #if !ICONV_SUPPORTS_ERRNO prev_in_left = in_left; #endif - (d)->s->len += (buf_growth - out_left); + ZSTR_LEN((d)->s) += (buf_growth - out_left); buf_growth <<= 1; } } else { @@ -504,10 +504,10 @@ static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l, out_left = buf_growth - out_left; smart_str_alloc(d, out_left, 0); - out_p = (d)->s->val + (d)->s->len; + out_p = ZSTR_VAL((d)->s) + ZSTR_LEN((d)->s); if (iconv(cd, NULL, NULL, (char **) &out_p, &out_left) == (size_t)0) { - (d)->s->len += (buf_growth - out_left); + ZSTR_LEN((d)->s) += (buf_growth - out_left); break; } else { #if ICONV_SUPPORTS_ERRNO @@ -520,7 +520,7 @@ static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l, } #endif } - (d)->s->len += (buf_growth - out_left); + ZSTR_LEN((d)->s) += (buf_growth - out_left); buf_growth <<= 1; } } @@ -583,7 +583,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len, } out_buffer = zend_string_alloc(out_size, 0); - out_p = out_buffer->val; + out_p = ZSTR_VAL(out_buffer); #ifdef NETWARE result = iconv(cd, (char **) &in_p, &in_size, (char **) @@ -598,9 +598,9 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len, } if (out_left < 8) { - size_t pos = out_p - out_buffer->val; + size_t pos = out_p - ZSTR_VAL(out_buffer); out_buffer = zend_string_extend(out_buffer, out_size + 8, 0); - out_p = out_buffer->val + pos; + out_p = ZSTR_VAL(out_buffer) + pos; out_size += 7; out_left += 7; } @@ -613,8 +613,8 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len, return PHP_ICONV_ERR_UNKNOWN; } - out_buffer->val[out_size - out_left] = '\0'; - out_buffer->len = out_size - out_left; + ZSTR_VAL(out_buffer)[out_size - out_left] = '\0'; + ZSTR_LEN(out_buffer) = out_size - out_left; iconv_close(cd); @@ -649,7 +649,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len, out_size = 0; bsz = out_left; out_buf = zend_string_alloc(bsz, 0); - out_p = out_buf->val; + out_p = ZSTR_VAL(out_buf); while (in_left > 0) { result = iconv(cd, (char **) &in_p, &in_left, (char **) &out_p, &out_left); @@ -671,7 +671,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len, bsz += in_len; out_buf = zend_string_extend(out_buf, bsz, 0); - out_p = out_buf->val; + out_p = ZSTR_VAL(out_buf); out_p += out_size; out_left = bsz - out_size; continue; @@ -693,7 +693,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len, if (errno == E2BIG) { bsz += 16; out_buf = zend_string_extend(out_buf, bsz, 0); - out_p = out_buf->val; + out_p = ZSTR_VAL(out_buf); out_p += out_size; out_left = bsz - out_size; } else { @@ -727,7 +727,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len, } } *out_p = '\0'; - out_buf->len = out_size; + ZSTR_LEN(out_buf) = out_size; *out = out_buf; return retval; #endif @@ -1018,8 +1018,8 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval, #endif } - ndl_buf_p = ndl_buf->val; - ndl_buf_left = ndl_buf->len; + ndl_buf_p = ZSTR_VAL(ndl_buf); + ndl_buf_left = ZSTR_LEN(ndl_buf); match_ofs = (size_t)-1; for (in_p = haystk, in_left = haystk_nbytes, cnt = 0; in_left > 0; ++cnt) { @@ -1069,10 +1069,10 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval, i = 0; j = GENERIC_SUPERSET_NBYTES; - lim = (size_t)(ndl_buf_p - ndl_buf->val); + lim = (size_t)(ndl_buf_p - ZSTR_VAL(ndl_buf)); while (j < lim) { - if (_php_iconv_memequal(&ndl_buf->val[j], &ndl_buf->val[i], + if (_php_iconv_memequal(&ZSTR_VAL(ndl_buf)[j], &ZSTR_VAL(ndl_buf)[i], GENERIC_SUPERSET_NBYTES)) { i += GENERIC_SUPERSET_NBYTES; } else { @@ -1082,15 +1082,15 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval, j += GENERIC_SUPERSET_NBYTES; } - if (_php_iconv_memequal(buf, &ndl_buf->val[i], sizeof(buf))) { + if (_php_iconv_memequal(buf, &ZSTR_VAL(ndl_buf)[i], sizeof(buf))) { match_ofs += (lim - i) / GENERIC_SUPERSET_NBYTES; i += GENERIC_SUPERSET_NBYTES; - ndl_buf_p = &ndl_buf->val[i]; - ndl_buf_left = ndl_buf->len - i; + ndl_buf_p = &ZSTR_VAL(ndl_buf)[i]; + ndl_buf_left = ZSTR_LEN(ndl_buf) - i; } else { match_ofs = (size_t)-1; - ndl_buf_p = ndl_buf->val; - ndl_buf_left = ndl_buf->len; + ndl_buf_p = ZSTR_VAL(ndl_buf); + ndl_buf_left = ZSTR_LEN(ndl_buf); } } } @@ -1103,8 +1103,8 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval, ndl_buf_left -= GENERIC_SUPERSET_NBYTES; if (ndl_buf_left == 0) { *pretval = match_ofs; - ndl_buf_p = ndl_buf->val; - ndl_buf_left = ndl_buf->len; + ndl_buf_p = ZSTR_VAL(ndl_buf); + ndl_buf_left = ZSTR_LEN(ndl_buf); match_ofs = -1; } } else { @@ -1112,10 +1112,10 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval, i = 0; j = GENERIC_SUPERSET_NBYTES; - lim = (size_t)(ndl_buf_p - ndl_buf->val); + lim = (size_t)(ndl_buf_p - ZSTR_VAL(ndl_buf)); while (j < lim) { - if (_php_iconv_memequal(&ndl_buf->val[j], &ndl_buf->val[i], + if (_php_iconv_memequal(&ZSTR_VAL(ndl_buf)[j], &ZSTR_VAL(ndl_buf)[i], GENERIC_SUPERSET_NBYTES)) { i += GENERIC_SUPERSET_NBYTES; } else { @@ -1125,15 +1125,15 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval, j += GENERIC_SUPERSET_NBYTES; } - if (_php_iconv_memequal(buf, &ndl_buf->val[i], sizeof(buf))) { + if (_php_iconv_memequal(buf, &ZSTR_VAL(ndl_buf)[i], sizeof(buf))) { match_ofs += (lim - i) / GENERIC_SUPERSET_NBYTES; i += GENERIC_SUPERSET_NBYTES; - ndl_buf_p = &ndl_buf->val[i]; - ndl_buf_left = ndl_buf->len - i; + ndl_buf_p = &ZSTR_VAL(ndl_buf)[i]; + ndl_buf_left = ZSTR_LEN(ndl_buf) - i; } else { match_ofs = (size_t)-1; - ndl_buf_p = ndl_buf->val; - ndl_buf_left = ndl_buf->len; + ndl_buf_p = ZSTR_VAL(ndl_buf); + ndl_buf_left = ZSTR_LEN(ndl_buf); } } } @@ -1338,14 +1338,14 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn encoded = php_base64_encode((unsigned char *) buf, (out_size - out_left)); - if (char_cnt < encoded->len) { + if (char_cnt < ZSTR_LEN(encoded)) { /* something went wrong! */ err = PHP_ICONV_ERR_UNKNOWN; goto out; } - smart_str_appendl(pretval, encoded->val, encoded->len); - char_cnt -= encoded->len; + smart_str_appendl(pretval, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); + char_cnt -= ZSTR_LEN(encoded); smart_str_appendl(pretval, "?=", sizeof("?=") - 1); char_cnt -= 2; @@ -1852,7 +1852,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st } } - err = _php_iconv_appendl(pretval, decoded_text->val, decoded_text->len, cd); + err = _php_iconv_appendl(pretval, ZSTR_VAL(decoded_text), ZSTR_LEN(decoded_text), cd); zend_string_release(decoded_text); if (err != PHP_ICONV_ERR_SUCCESS) { @@ -2068,7 +2068,7 @@ PHP_FUNCTION(iconv_strlen) RETURN_FALSE; } - err = _php_iconv_strlen(&retval, str->val, str->len, charset); + err = _php_iconv_strlen(&retval, ZSTR_VAL(str), ZSTR_LEN(str), charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset); if (err == PHP_ICONV_ERR_SUCCESS) { RETVAL_LONG(retval); @@ -2103,13 +2103,13 @@ PHP_FUNCTION(iconv_substr) } if (ZEND_NUM_ARGS() < 3) { - length = str->len; + length = ZSTR_LEN(str); } - err = _php_iconv_substr(&retval, str->val, str->len, offset, length, charset); + err = _php_iconv_substr(&retval, ZSTR_VAL(str), ZSTR_LEN(str), offset, length, charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset); - if (err == PHP_ICONV_ERR_SUCCESS && str->len > 0 && retval.s != NULL) { + if (err == PHP_ICONV_ERR_SUCCESS && ZSTR_LEN(str) > 0 && retval.s != NULL) { RETURN_NEW_STR(retval.s); } smart_str_free(&retval); @@ -2147,11 +2147,11 @@ PHP_FUNCTION(iconv_strpos) RETURN_FALSE; } - if (ndl->len < 1) { + if (ZSTR_LEN(ndl) < 1) { RETURN_FALSE; } - err = _php_iconv_strpos(&retval, haystk->val, haystk->len, ndl->val, ndl->len, + err = _php_iconv_strpos(&retval, ZSTR_VAL(haystk), ZSTR_LEN(haystk), ZSTR_VAL(ndl), ZSTR_LEN(ndl), offset, charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset); @@ -2182,7 +2182,7 @@ PHP_FUNCTION(iconv_strrpos) RETURN_FALSE; } - if (ndl->len < 1) { + if (ZSTR_LEN(ndl) < 1) { RETURN_FALSE; } @@ -2191,7 +2191,7 @@ PHP_FUNCTION(iconv_strrpos) RETURN_FALSE; } - err = _php_iconv_strpos(&retval, haystk->val, haystk->len, ndl->val, ndl->len, + err = _php_iconv_strpos(&retval, ZSTR_VAL(haystk), ZSTR_LEN(haystk), ZSTR_VAL(ndl), ZSTR_LEN(ndl), -1, charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset); @@ -2274,15 +2274,15 @@ PHP_FUNCTION(iconv_mime_encode) if ((pzval = zend_hash_str_find(Z_ARRVAL_P(pref), "line-break-chars", sizeof("line-break-chars") - 1)) != NULL) { if (Z_TYPE_P(pzval) != IS_STRING) { tmp_str = zval_get_string(pzval); - lfchars = tmp_str->val; + lfchars = ZSTR_VAL(tmp_str); } else { lfchars = Z_STRVAL_P(pzval); } } } - err = _php_iconv_mime_encode(&retval, field_name->val, field_name->len, - field_value->val, field_value->len, line_len, lfchars, scheme_id, + err = _php_iconv_mime_encode(&retval, ZSTR_VAL(field_name), ZSTR_LEN(field_name), + ZSTR_VAL(field_value), ZSTR_LEN(field_value), line_len, lfchars, scheme_id, out_charset, in_charset); _php_iconv_show_error(err, out_charset, in_charset); @@ -2327,7 +2327,7 @@ PHP_FUNCTION(iconv_mime_decode) RETURN_FALSE; } - err = _php_iconv_mime_decode(&retval, encoded_str->val, encoded_str->len, charset, NULL, (int)mode); + err = _php_iconv_mime_decode(&retval, ZSTR_VAL(encoded_str), ZSTR_LEN(encoded_str), charset, NULL, (int)mode); _php_iconv_show_error(err, charset, "???"); if (err == PHP_ICONV_ERR_SUCCESS) { @@ -2369,8 +2369,8 @@ PHP_FUNCTION(iconv_mime_decode_headers) array_init(return_value); - enc_str_tmp = encoded_str->val; - enc_str_len_tmp = encoded_str->len; + enc_str_tmp = ZSTR_VAL(encoded_str); + enc_str_len_tmp = ZSTR_LEN(encoded_str); while (enc_str_len_tmp > 0) { smart_str decoded_header = {0}; char *header_name = NULL; @@ -2389,12 +2389,12 @@ PHP_FUNCTION(iconv_mime_decode_headers) break; } - limit = decoded_header.s->val + decoded_header.s->len; - for (p = decoded_header.s->val; p < limit; p++) { + limit = ZSTR_VAL(decoded_header.s) + ZSTR_LEN(decoded_header.s); + for (p = ZSTR_VAL(decoded_header.s); p < limit; p++) { if (*p == ':') { *p = '\0'; - header_name = decoded_header.s->val; - header_name_len = p - decoded_header.s->val; + header_name = ZSTR_VAL(decoded_header.s); + header_name_len = p - ZSTR_VAL(decoded_header.s); while (++p < limit) { if (*p != ' ' && *p != '\t') { @@ -2460,7 +2460,7 @@ PHP_NAMED_FUNCTION(php_if_iconv) RETURN_FALSE; } - err = php_iconv_string(in_buffer->val, (size_t)in_buffer->len, &out_buffer, out_charset, in_charset); + err = php_iconv_string(ZSTR_VAL(in_buffer), (size_t)ZSTR_LEN(in_buffer), &out_buffer, out_charset, in_charset); _php_iconv_show_error(err, out_charset, in_charset); if (err == PHP_ICONV_ERR_SUCCESS && out_buffer != NULL) { RETVAL_STR(out_buffer); @@ -2485,7 +2485,7 @@ PHP_FUNCTION(iconv_set_encoding) if (zend_parse_parameters(ZEND_NUM_ARGS(), "sS", &type, &type_len, &charset) == FAILURE) return; - if (charset->len >= ICONV_CSNMAXLEN) { + if (ZSTR_LEN(charset) >= ICONV_CSNMAXLEN) { php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN); RETURN_FALSE; } diff --git a/ext/intl/breakiterator/breakiterator_class.cpp b/ext/intl/breakiterator/breakiterator_class.cpp index 813204cd21..db99ad09cf 100644 --- a/ext/intl/breakiterator/breakiterator_class.cpp +++ b/ext/intl/breakiterator/breakiterator_class.cpp @@ -120,7 +120,7 @@ static zend_object *BreakIterator_clone_obj(zval *object) intl_errors_set_custom_msg(BREAKITER_ERROR_P(bio_orig), "Could not clone BreakIterator", 0); err_msg = intl_error_get_message(BREAKITER_ERROR_P(bio_orig)); - zend_throw_exception(NULL, err_msg->val, 0); + zend_throw_exception(NULL, ZSTR_VAL(err_msg), 0); zend_string_free(err_msg); } else { bio_new->biter = new_biter; diff --git a/ext/intl/breakiterator/breakiterator_iterators.cpp b/ext/intl/breakiterator/breakiterator_iterators.cpp index aa2f92763b..bdf1b3e53f 100644 --- a/ext/intl/breakiterator/breakiterator_iterators.cpp +++ b/ext/intl/breakiterator/breakiterator_iterators.cpp @@ -177,8 +177,8 @@ static void _breakiterator_parts_move_forward(zend_object_iterator *iter) assert(next <= slen && next >= cur); res = zend_string_alloc(next - cur, 0); - memcpy(res->val, &s[cur], res->len); - res->val[res->len] = '\0'; + memcpy(ZSTR_VAL(res), &s[cur], ZSTR_LEN(res)); + ZSTR_VAL(res)[ZSTR_LEN(res)] = '\0'; ZVAL_STR(&zoi_bit->zoi_cur.current, res); } @@ -249,14 +249,14 @@ U_CFUNC zend_function *IntlPartsIterator_get_method(zend_object **object_ptr, ze ALLOCA_FLAG(use_heap); if (key == NULL) { - ZSTR_ALLOCA_ALLOC(lc_method_name, method->len, use_heap); - zend_str_tolower_copy(lc_method_name->val, method->val, method->len); + ZSTR_ALLOCA_ALLOC(lc_method_name, ZSTR_LEN(method), use_heap); + zend_str_tolower_copy(ZSTR_VAL(lc_method_name), ZSTR_VAL(method), ZSTR_LEN(method)); } else { lc_method_name = Z_STR_P(key); } - if (method->len == sizeof("getrulestatus") - 1 - && memcmp("getrulestatus", lc_method_name->val, lc_method_name->len) == 0) { + if (ZSTR_LEN(method) == sizeof("getrulestatus") - 1 + && memcmp("getrulestatus", ZSTR_VAL(lc_method_name), ZSTR_LEN(lc_method_name)) == 0) { IntlIterator_object *obj = php_intl_iterator_fetch_object(*object_ptr); if (obj->iterator && !Z_ISUNDEF(obj->iterator->data)) { zval *break_iter_zv = &obj->iterator->data; diff --git a/ext/intl/breakiterator/breakiterator_methods.cpp b/ext/intl/breakiterator/breakiterator_methods.cpp index ce855ebacd..0363198f06 100644 --- a/ext/intl/breakiterator/breakiterator_methods.cpp +++ b/ext/intl/breakiterator/breakiterator_methods.cpp @@ -161,7 +161,7 @@ U_CFUNC PHP_FUNCTION(breakiter_set_text) BREAKITER_METHOD_FETCH_OBJECT; - ut = utext_openUTF8(ut, text->val, text->len, BREAKITER_ERROR_CODE_P(bio)); + ut = utext_openUTF8(ut, ZSTR_VAL(text), ZSTR_LEN(text), BREAKITER_ERROR_CODE_P(bio)); INTL_METHOD_CHECK_STATUS_OR_NULL(bio, "breakiter_set_text: error opening UText"); bio->biter->setText(ut, BREAKITER_ERROR_CODE(bio)); diff --git a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp index 8acf128b2c..1988e7477d 100644 --- a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp +++ b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp @@ -66,7 +66,7 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS) smart_str parse_error_str; parse_error_str = intl_parse_error_to_string(&parseError); spprintf(&msg, 0, "rbbi_create_instance: unable to create " - "RuleBasedBreakIterator from rules (%s)", parse_error_str.s? parse_error_str.s->val : ""); + "RuleBasedBreakIterator from rules (%s)", parse_error_str.s? ZSTR_VAL(parse_error_str.s) : ""); smart_str_free(&parse_error_str); intl_error_set_custom_msg(NULL, msg, 1); efree(msg); @@ -211,8 +211,8 @@ U_CFUNC PHP_FUNCTION(rbbi_get_binary_rules) } zend_string *ret_rules = zend_string_alloc(rules_len, 0); - memcpy(ret_rules->val, rules, rules_len); - ret_rules->val[rules_len] = '\0'; + memcpy(ZSTR_VAL(ret_rules), rules, rules_len); + ZSTR_VAL(ret_rules)[rules_len] = '\0'; RETURN_STR(ret_rules); } diff --git a/ext/intl/calendar/calendar_class.cpp b/ext/intl/calendar/calendar_class.cpp index 8af48d9726..6b6feef8d9 100644 --- a/ext/intl/calendar/calendar_class.cpp +++ b/ext/intl/calendar/calendar_class.cpp @@ -101,7 +101,7 @@ static zend_object *Calendar_clone_obj(zval *object) intl_errors_set_custom_msg(CALENDAR_ERROR_P(co_orig), "Could not clone IntlCalendar", 0); err_msg = intl_error_get_message(CALENDAR_ERROR_P(co_orig)); - zend_throw_exception(NULL, err_msg->val, 0); + zend_throw_exception(NULL, ZSTR_VAL(err_msg), 0); zend_string_free(err_msg); } else { co_new->ucal = newCalendar; diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c index 621d0ead12..fe8c32be6f 100644 --- a/ext/intl/converter/converter.c +++ b/ext/intl/converter/converter.c @@ -1068,7 +1068,7 @@ static zend_object *php_converter_clone_object(zval *object) { THROW_UFAILURE(oldobj, "ucnv_safeClone", error); err_msg = intl_error_get_message(&oldobj->error); - zend_throw_exception(NULL, err_msg->val, 0); + zend_throw_exception(NULL, ZSTR_VAL(err_msg), 0); zend_string_release(err_msg); return retval; diff --git a/ext/intl/idn/idn.c b/ext/intl/idn/idn.c index c0773e8c0c..5dd742b87e 100644 --- a/ext/intl/idn/idn.c +++ b/ext/intl/idn/idn.c @@ -153,10 +153,10 @@ static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS, if (mode == INTL_IDN_TO_ASCII) { len = uidna_nameToASCII_UTF8(uts46, domain, domain_len, - buffer->val, buffer_capac, &info, &status); + ZSTR_VAL(buffer), buffer_capac, &info, &status); } else { len = uidna_nameToUnicodeUTF8(uts46, domain, domain_len, - buffer->val, buffer_capac, &info, &status); + ZSTR_VAL(buffer), buffer_capac, &info, &status); } if (php_intl_idn_check_status(status, "failed to convert name", mode) == FAILURE) { @@ -168,8 +168,8 @@ static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS, php_error_docref(NULL, E_ERROR, "ICU returned an unexpected length"); } - buffer->val[len] = '\0'; - buffer->len = len; + ZSTR_VAL(buffer)[len] = '\0'; + ZSTR_LEN(buffer) = len; if (info.errors == 0) { RETVAL_STR(buffer); diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c index 536792e853..7b36d61c02 100644 --- a/ext/intl/locale/locale_methods.c +++ b/ext/intl/locale/locale_methods.c @@ -235,7 +235,7 @@ PHP_NAMED_FUNCTION(zif_locale_set_default) RETURN_FALSE; } - if (locale_name->len == 0) { + if (ZSTR_LEN(locale_name) == 0) { default_locale = (char *)uloc_getDefault(); locale_name = zend_string_init(default_locale, strlen(default_locale), 0); } diff --git a/ext/intl/msgformat/msgformat_helpers.cpp b/ext/intl/msgformat/msgformat_helpers.cpp index d6839cbed0..a2bede910a 100644 --- a/ext/intl/msgformat/msgformat_helpers.cpp +++ b/ext/intl/msgformat/msgformat_helpers.cpp @@ -413,12 +413,12 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, storedArgType = (Formattable::Type*)zend_hash_index_find_ptr(types, (zend_ulong)num_index); } else { //string; assumed to be in UTF-8 - intl_stringFromChar(key, str_index->val, str_index->len, &err.code); + intl_stringFromChar(key, ZSTR_VAL(str_index), ZSTR_LEN(str_index), &err.code); if (U_FAILURE(err.code)) { char *message; spprintf(&message, 0, - "Invalid UTF-8 data in argument key: '%s'", str_index->val); + "Invalid UTF-8 data in argument key: '%s'", ZSTR_VAL(str_index)); intl_errors_set(&err, err.code, message, 1); efree(message); continue; diff --git a/ext/intl/timezone/timezone_class.cpp b/ext/intl/timezone/timezone_class.cpp index 8b4d6ef127..77569c09e2 100644 --- a/ext/intl/timezone/timezone_class.cpp +++ b/ext/intl/timezone/timezone_class.cpp @@ -248,7 +248,7 @@ static zend_object *TimeZone_clone_obj(zval *object) intl_errors_set_custom_msg(TIMEZONE_ERROR_P(to_orig), "Could not clone IntlTimeZone", 0); err_msg = intl_error_get_message(TIMEZONE_ERROR_P(to_orig)); - zend_throw_exception(NULL, err_msg->val, 0); + zend_throw_exception(NULL, ZSTR_VAL(err_msg), 0); zend_string_free(err_msg); } else { to_new->utimezone = newTimeZone; diff --git a/ext/intl/transliterator/transliterator_class.c b/ext/intl/transliterator/transliterator_class.c index 4395cc086a..f2cb9f42e4 100644 --- a/ext/intl/transliterator/transliterator_class.c +++ b/ext/intl/transliterator/transliterator_class.c @@ -182,7 +182,7 @@ err: "Could not clone transliterator", 0 ); err_msg = intl_error_get_message( TRANSLITERATOR_ERROR_P( to_orig ) ); - php_error_docref( NULL, E_ERROR, "%s", err_msg->val ); + php_error_docref( NULL, E_ERROR, "%s", ZSTR_VAL(err_msg) ); zend_string_free( err_msg ); /* if it's changed into a warning */ /* do not destroy tempz; we need to return something */ } diff --git a/ext/intl/transliterator/transliterator_methods.c b/ext/intl/transliterator/transliterator_methods.c index ced84a0c60..4fcdf3dea2 100644 --- a/ext/intl/transliterator/transliterator_methods.c +++ b/ext/intl/transliterator/transliterator_methods.c @@ -185,7 +185,7 @@ PHP_FUNCTION( transliterator_create_from_rules ) smart_str parse_error_str; parse_error_str = intl_parse_error_to_string( &parse_error ); spprintf( &msg, 0, "transliterator_create_from_rules: unable to " - "create ICU transliterator from rules (%s)", parse_error_str.s? parse_error_str.s->val : "" ); + "create ICU transliterator from rules (%s)", parse_error_str.s? ZSTR_VAL(parse_error_str.s) : "" ); smart_str_free( &parse_error_str ); if( msg != NULL ) { @@ -348,7 +348,7 @@ PHP_FUNCTION( transliterator_transliterate ) { zend_string *message = intl_error_get_message( NULL ); php_error_docref0( NULL, E_WARNING, "Could not create " - "transliterator with ID \"%s\" (%s)", Z_STRVAL_P( arg1 ), message->val ); + "transliterator with ID \"%s\" (%s)", Z_STRVAL_P( arg1 ), ZSTR_VAL(message) ); zend_string_free( message ); ZVAL_UNDEF(&tmp_object); /* don't set U_ILLEGAL_ARGUMENT_ERROR to allow fetching of inner error */ diff --git a/ext/intl/uchar/uchar.c b/ext/intl/uchar/uchar.c index 98d92e44d7..a38723ea9c 100644 --- a/ext/intl/uchar/uchar.c +++ b/ext/intl/uchar/uchar.c @@ -247,7 +247,7 @@ IC_METHOD(charName) { buffer_len = u_charName(cp, (UCharNameChoice)nameChoice, NULL, 0, &error); buffer = zend_string_alloc(buffer_len, 0); error = U_ZERO_ERROR; - buffer_len = u_charName(cp, (UCharNameChoice)nameChoice, buffer->val, buffer->len + 1, &error); + buffer_len = u_charName(cp, (UCharNameChoice)nameChoice, ZSTR_VAL(buffer), ZSTR_LEN(buffer) + 1, &error); if (U_FAILURE(error)) { zend_string_free(buffer); INTL_CHECK_STATUS(error, "Failure getting character name"); diff --git a/ext/json/json_encoder.c b/ext/json/json_encoder.c index d9bfb16e5b..c3aa348626 100644 --- a/ext/json/json_encoder.c +++ b/ext/json/json_encoder.c @@ -169,7 +169,7 @@ static void php_json_encode_array(smart_str *buf, zval *val, int options) /* {{{ php_json_encode(buf, data, options); } else if (r == PHP_JSON_OUTPUT_OBJECT) { if (key) { - if (key->val[0] == '\0' && Z_TYPE_P(val) == IS_OBJECT) { + if (ZSTR_VAL(key)[0] == '\0' && Z_TYPE_P(val) == IS_OBJECT) { /* Skip protected and private members. */ if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) { ZEND_HASH_DEC_APPLY_COUNT(tmp_ht); @@ -186,7 +186,7 @@ static void php_json_encode_array(smart_str *buf, zval *val, int options) /* {{{ php_json_pretty_print_char(buf, options, '\n'); php_json_pretty_print_indent(buf, options); - php_json_escape_string(buf, key->val, key->len, options & ~PHP_JSON_NUMERIC_CHECK); + php_json_escape_string(buf, ZSTR_VAL(key), ZSTR_LEN(key), options & ~PHP_JSON_NUMERIC_CHECK); smart_str_appendc(buf, ':'); php_json_pretty_print_char(buf, options, ' '); @@ -313,7 +313,7 @@ static void php_json_escape_string(smart_str *buf, char *s, size_t len, int opti } pos = 0; - checkpoint = buf->s ? buf->s->len : 0; + checkpoint = buf->s ? ZSTR_LEN(buf->s) : 0; /* pre-allocate for string length plus 2 quotes */ smart_str_alloc(buf, len+2, 0); @@ -326,7 +326,7 @@ static void php_json_escape_string(smart_str *buf, char *s, size_t len, int opti us = php_next_utf8_char((const unsigned char *)s, len, &pos, &status); if (status != SUCCESS) { if (buf->s) { - buf->s->len = checkpoint; + ZSTR_LEN(buf->s) = checkpoint; } JSON_G(error_code) = PHP_JSON_ERROR_UTF8; smart_str_appendl(buf, "null", 4); @@ -464,7 +464,7 @@ static void php_json_encode_serializable_object(smart_str *buf, zval *val, int o ZVAL_STRING(&fname, "jsonSerialize"); if (FAILURE == call_user_function_ex(EG(function_table), val, &fname, &retval, 0, NULL, 1, NULL) || Z_TYPE(retval) == IS_UNDEF) { - zend_throw_exception_ex(NULL, 0, "Failed calling %s::jsonSerialize()", ce->name->val); + zend_throw_exception_ex(NULL, 0, "Failed calling %s::jsonSerialize()", ZSTR_VAL(ce->name)); smart_str_appendl(buf, "null", sizeof("null") - 1); zval_ptr_dtor(&fname); return; diff --git a/ext/json/json_parser.tab.c b/ext/json/json_parser.tab.c index 052fc17137..ad19e4fa10 100644 --- a/ext/json/json_parser.tab.c +++ b/ext/json/json_parser.tab.c @@ -1,19 +1,19 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 2.6.5. */ /* Bison implementation for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. - + + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -26,7 +26,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0.4" +#define YYBISON_VERSION "2.6.5" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -101,23 +101,25 @@ int json_yydebug = 1; + /* Substitute the variable and function names. */ #define yyparse php_json_yyparse #define yylex php_json_yylex #define yyerror php_json_yyerror +#define yylval php_json_yylval +#define yychar php_json_yychar #define yydebug php_json_yydebug #define yynerrs php_json_yynerrs - /* Copy the first part of user declarations. */ -# ifndef YY_NULLPTR +# ifndef YY_NULL # if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# define YY_NULL nullptr # else -# define YY_NULLPTR 0 +# define YY_NULL 0 # endif # endif @@ -131,9 +133,9 @@ int json_yydebug = 1; /* In a future release of Bison, this section will be replaced by #include "json_parser.tab.h". */ -#ifndef YY_PHP_JSON_YY_HOME_JAKUB_PROG_PHP_MASTER_EXT_JSON_JSON_PARSER_TAB_H_INCLUDED -# define YY_PHP_JSON_YY_HOME_JAKUB_PROG_PHP_MASTER_EXT_JSON_JSON_PARSER_TAB_H_INCLUDED -/* Debug traces. */ +#ifndef YY_PHP_JSON_YY_HOME_DMITRY_PHP_PHP_MASTER_EXT_JSON_JSON_PARSER_TAB_H_INCLUDED +# define YY_PHP_JSON_YY_HOME_DMITRY_PHP_PHP_MASTER_EXT_JSON_JSON_PARSER_TAB_H_INCLUDED +/* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif @@ -141,21 +143,22 @@ int json_yydebug = 1; extern int php_json_yydebug; #endif -/* Token type. */ +/* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - enum yytokentype - { - PHP_JSON_T_NUL = 258, - PHP_JSON_T_TRUE = 259, - PHP_JSON_T_FALSE = 260, - PHP_JSON_T_INT = 261, - PHP_JSON_T_DOUBLE = 262, - PHP_JSON_T_STRING = 263, - PHP_JSON_T_ESTRING = 264, - PHP_JSON_T_EOI = 265, - PHP_JSON_T_ERROR = 266 - }; + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + PHP_JSON_T_NUL = 258, + PHP_JSON_T_TRUE = 259, + PHP_JSON_T_FALSE = 260, + PHP_JSON_T_INT = 261, + PHP_JSON_T_DOUBLE = 262, + PHP_JSON_T_STRING = 263, + PHP_JSON_T_ESTRING = 264, + PHP_JSON_T_EOI = 265, + PHP_JSON_T_ERROR = 266 + }; #endif /* Tokens. */ #define PHP_JSON_T_NUL 258 @@ -168,10 +171,10 @@ extern int php_json_yydebug; #define PHP_JSON_T_EOI 265 #define PHP_JSON_T_ERROR 266 -/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -union YYSTYPE + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE { @@ -182,18 +185,29 @@ union YYSTYPE } pair; -}; -typedef union YYSTYPE YYSTYPE; +} YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif - +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int php_json_yyparse (void *YYPARSE_PARAM); +#else +int php_json_yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus int php_json_yyparse (php_json_parser *parser); +#else +int php_json_yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ -#endif /* !YY_PHP_JSON_YY_HOME_JAKUB_PROG_PHP_MASTER_EXT_JSON_JSON_PARSER_TAB_H_INCLUDED */ +#endif /* !YY_PHP_JSON_YY_HOME_DMITRY_PHP_PHP_MASTER_EXT_JSON_JSON_PARSER_TAB_H_INCLUDED */ /* Copy the second part of user declarations. */ @@ -218,6 +232,7 @@ void php_json_parser_array_append(zval *array, zval *zvalue); + #ifdef short # undef short #endif @@ -230,8 +245,11 @@ typedef unsigned char yytype_uint8; #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; -#else +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) typedef signed char yytype_int8; +#else +typedef short int yytype_int8; #endif #ifdef YYTYPE_UINT16 @@ -251,7 +269,8 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else @@ -273,33 +292,6 @@ typedef short int yytype_int16; # endif #endif -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) -# else -# define YY_ATTRIBUTE(Spec) /* empty */ -# endif -#endif - -#ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) -#endif - -#ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) -#endif - -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) -# else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) -# endif -#endif - /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) @@ -307,26 +299,24 @@ typedef short int yytype_int16; # define YYUSE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ -/* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ - _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ - _Pragma ("GCC diagnostic pop") +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(N) (N) #else -# define YY_INITIAL_VALUE(Value) Value -#endif -#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int yyi) +#else +static int +YYID (yyi) + int yyi; #endif -#ifndef YY_INITIAL_VALUE -# define YY_INITIAL_VALUE(Value) /* Nothing. */ +{ + return yyi; +} #endif - #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -344,7 +334,8 @@ typedef short int yytype_int16; # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS @@ -356,8 +347,8 @@ typedef short int yytype_int16; # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's 'empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely @@ -373,7 +364,7 @@ typedef short int yytype_int16; # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) + && (defined YYFREE || defined free))) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 @@ -381,13 +372,15 @@ typedef short int yytype_int16; # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS +# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS +# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif @@ -397,7 +390,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc @@ -422,16 +415,16 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) #endif @@ -450,7 +443,7 @@ union yyalloc for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ - while (0) + while (YYID (0)) # endif # endif #endif /* !YYCOPY_NEEDED */ @@ -466,19 +459,17 @@ union yyalloc #define YYNNTS 16 /* YYNRULES -- Number of rules. */ #define YYNRULES 36 -/* YYNSTATES -- Number of states. */ +/* YYNRULES -- Number of states. */ #define YYNSTATES 45 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 266 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) -/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -511,7 +502,31 @@ static const yytype_uint8 yytranslate[] = }; #if YYDEBUG - /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 6, 9, 10, 15, 17, 19, 20, + 22, 24, 28, 31, 35, 38, 39, 44, 46, 48, + 49, 51, 53, 57, 60, 62, 64, 66, 68, 70, + 72, 74, 76, 78, 80, 82, 84 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 19, 0, -1, 32, 10, -1, 32, 33, -1, -1, + 12, 21, 23, 22, -1, 13, -1, 14, -1, -1, + 24, -1, 25, -1, 24, 15, 25, -1, 24, 33, + -1, 31, 16, 32, -1, 31, 33, -1, -1, 17, + 27, 29, 28, -1, 14, -1, 13, -1, -1, 30, + -1, 32, -1, 30, 15, 32, -1, 30, 33, -1, + 8, -1, 9, -1, 20, -1, 26, -1, 8, -1, + 9, -1, 6, -1, 7, -1, 3, -1, 4, -1, + 5, -1, 33, -1, 11, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { 0, 92, 92, 98, 105, 105, 113, 114, 123, 126, @@ -532,13 +547,13 @@ static const char *const yytname[] = "PHP_JSON_T_ERROR", "'{'", "'}'", "']'", "','", "':'", "'['", "$accept", "start", "object", "$@1", "object_end", "members", "member", "pair", "array", "$@2", "array_end", "elements", "element", "key", "value", - "errlex", YY_NULLPTR + "errlex", YY_NULL }; #endif # ifdef YYPRINT -/* YYTOKNUM[NUM] -- (External) token number corresponding to the - (internal) symbol number NUM (which must be that of a token). */ +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, @@ -546,30 +561,27 @@ static const yytype_uint16 yytoknum[] = }; # endif -#define YYPACT_NINF -18 - -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-18))) - -#define YYTABLE_NINF -1 - -#define yytable_value_is_error(Yytable_value) \ - 0 +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 18, 19, 19, 21, 20, 22, 22, 23, 23, + 24, 24, 24, 25, 25, 27, 26, 28, 28, 29, + 29, 30, 30, 30, 31, 31, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 33 +}; - /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -static const yytype_int8 yypact[] = +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = { - -2, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, 11, -18, -18, 9, -18, 21, -2, -18, -18, - -18, -18, -18, 18, 1, -18, -3, 20, 6, -18, - -18, -18, -18, 21, -18, -2, -18, -18, -18, -18, - -2, -18, -18, -18, -18 + 0, 2, 2, 2, 0, 4, 1, 1, 0, 1, + 1, 3, 2, 3, 2, 0, 4, 1, 1, 0, + 1, 1, 3, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1 }; - /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE does not specify something else to do. Zero - means the default is an error. */ +/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ static const yytype_uint8 yydefact[] = { 0, 32, 33, 34, 30, 31, 28, 29, 36, 4, @@ -579,23 +591,36 @@ static const yytype_uint8 yydefact[] = 0, 23, 11, 13, 22 }; - /* YYPGOTO[NTERM-NUM]. */ -static const yytype_int8 yypgoto[] = -{ - -18, -18, -18, -18, -18, -18, -18, -11, -18, -18, - -18, -18, -18, -18, -17, 0 -}; - - /* YYDEFGOTO[NTERM-NUM]. */ +/* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { -1, 11, 12, 16, 32, 23, 24, 25, 13, 17, 39, 27, 28, 26, 14, 15 }; - /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule whose - number is the opposite. If YYTABLE_NINF, syntax error. */ +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -18 +static const yytype_int8 yypact[] = +{ + -2, -18, -18, -18, -18, -18, -18, -18, -18, -18, + -18, 11, -18, -18, 9, -18, 21, -2, -18, -18, + -18, -18, -18, 18, 1, -18, -3, 20, 6, -18, + -18, -18, -18, 21, -18, -2, -18, -18, -18, -18, + -2, -18, -18, -18, -18 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -18, -18, -18, -18, -18, -18, -18, -11, -18, -18, + -18, -18, -18, -18, -17, 0 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { 29, 1, 2, 3, 4, 5, 6, 7, 8, 8, @@ -604,6 +629,12 @@ static const yytype_uint8 yytable[] = 22, 30, 31, 37, 38 }; +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-18))) + +#define yytable_value_is_error(Yytable_value) \ + YYID (0) + static const yytype_int8 yycheck[] = { 17, 3, 4, 5, 6, 7, 8, 9, 11, 11, @@ -612,8 +643,8 @@ static const yytype_int8 yycheck[] = 9, 13, 14, 13, 14 }; - /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 3, 4, 5, 6, 7, 8, 9, 11, 12, @@ -623,34 +654,30 @@ static const yytype_uint8 yystos[] = 15, 33, 25, 32, 32 }; - /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 18, 19, 19, 21, 20, 22, 22, 23, 23, - 24, 24, 24, 25, 25, 27, 26, 28, 28, 29, - 29, 30, 30, 30, 31, 31, 32, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 33 -}; - - /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 2, 2, 0, 4, 1, 1, 0, 1, - 1, 3, 2, 3, 2, 0, 4, 1, 1, 0, - 1, 1, 3, 2, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1 -}; - - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ + +#define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif #define YYRECOVERING() (!!yyerrstatus) @@ -667,16 +694,28 @@ do \ else \ { \ yyerror (parser, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) + YYERROR; \ + } \ +while (YYID (0)) /* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 +#define YYTERROR 1 +#define YYERRCODE 256 + +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif +/* YYLEX -- calling `yylex' with the right arguments. */ +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, parser) +#endif + /* Enable debugging if requested. */ #if YYDEBUG @@ -685,47 +724,58 @@ while (0) # define YYFPRINTF fprintf # endif -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) -/* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif - - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value, parser); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, parser); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, php_json_parser *parser) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, parser) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + php_json_parser *parser; +#endif { FILE *yyo = yyoutput; YYUSE (yyo); - YYUSE (parser); if (!yyvaluep) return; + YYUSE (parser); # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); # endif - YYUSE (yytype); + switch (yytype) + { + default: + break; + } } @@ -733,11 +783,23 @@ yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvalue | Print this symbol on YYOUTPUT. | `--------------------------------*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, php_json_parser *parser) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, parser) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + php_json_parser *parser; +#endif { - YYFPRINTF (yyoutput, "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep, parser); YYFPRINTF (yyoutput, ")"); @@ -748,8 +810,16 @@ yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, php | TOP (included). | `------------------------------------------------------------------*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +#else +static void +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; +#endif { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -760,42 +830,50 @@ yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) YYFPRINTF (stderr, "\n"); } -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, php_json_parser *parser) +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, php_json_parser *parser) +#else +static void +yy_reduce_print (yyvsp, yyrule, parser) + YYSTYPE *yyvsp; + int yyrule; + php_json_parser *parser; +#endif { - unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; + unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); + yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, - yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) - , parser); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , parser); YYFPRINTF (stderr, "\n"); } } -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyssp, yyvsp, Rule, parser); \ -} while (0) +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, parser); \ +} while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -809,7 +887,7 @@ int yydebug; /* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH +#ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif @@ -832,8 +910,15 @@ int yydebug; # define yystrlen strlen # else /* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) @@ -849,8 +934,16 @@ yystrlen (const char *yystr) # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif { char *yyd = yydest; const char *yys = yysrc; @@ -880,27 +973,27 @@ yytnamerr (char *yyres, const char *yystr) char const *yyp = yystr; for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } do_not_strip_quotes: ; } @@ -923,11 +1016,12 @@ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; + const char *yyformat = YY_NULL; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -935,6 +1029,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, int yycount = 0; /* There are many possibilities here to consider: + - Assume YYFAIL is not used. It's too flawed to consider. See + <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html> + for details. YYERROR is fine as it does not invoke this + function. - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected @@ -983,13 +1081,11 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, break; } yyarg[yycount++] = yytname[yyx]; - { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } + yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; } } } @@ -1009,12 +1105,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, # undef YYCASE_ } - { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } + yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; if (*yymsg_alloc < yysize) { @@ -1051,143 +1145,133 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, | Release the memory associated to this symbol. | `-----------------------------------------------*/ +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, php_json_parser *parser) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, parser) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + php_json_parser *parser; +#endif { YYUSE (yyvaluep); YYUSE (parser); + if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN switch (yytype) { - case 3: /* PHP_JSON_T_NUL */ - - { zval_dtor(&((*yyvaluep).value)); } - - break; - - case 4: /* PHP_JSON_T_TRUE */ - - { zval_dtor(&((*yyvaluep).value)); } - - break; - - case 5: /* PHP_JSON_T_FALSE */ - - { zval_dtor(&((*yyvaluep).value)); } - - break; - - case 6: /* PHP_JSON_T_INT */ - - { zval_dtor(&((*yyvaluep).value)); } - - break; - - case 7: /* PHP_JSON_T_DOUBLE */ - - { zval_dtor(&((*yyvaluep).value)); } + case 3: /* PHP_JSON_T_NUL */ - break; + { zval_dtor(&((*yyvaluep).value)); }; - case 8: /* PHP_JSON_T_STRING */ + break; + case 4: /* PHP_JSON_T_TRUE */ - { zval_dtor(&((*yyvaluep).value)); } + { zval_dtor(&((*yyvaluep).value)); }; - break; + break; + case 5: /* PHP_JSON_T_FALSE */ - case 9: /* PHP_JSON_T_ESTRING */ + { zval_dtor(&((*yyvaluep).value)); }; - { zval_dtor(&((*yyvaluep).value)); } + break; + case 6: /* PHP_JSON_T_INT */ - break; + { zval_dtor(&((*yyvaluep).value)); }; - case 10: /* PHP_JSON_T_EOI */ + break; + case 7: /* PHP_JSON_T_DOUBLE */ - { zval_dtor(&((*yyvaluep).value)); } + { zval_dtor(&((*yyvaluep).value)); }; - break; + break; + case 8: /* PHP_JSON_T_STRING */ - case 11: /* PHP_JSON_T_ERROR */ + { zval_dtor(&((*yyvaluep).value)); }; - { zval_dtor(&((*yyvaluep).value)); } + break; + case 9: /* PHP_JSON_T_ESTRING */ - break; + { zval_dtor(&((*yyvaluep).value)); }; - case 19: /* start */ + break; + case 10: /* PHP_JSON_T_EOI */ - { zval_dtor(&((*yyvaluep).value)); } + { zval_dtor(&((*yyvaluep).value)); }; - break; + break; + case 11: /* PHP_JSON_T_ERROR */ - case 20: /* object */ + { zval_dtor(&((*yyvaluep).value)); }; - { zval_dtor(&((*yyvaluep).value)); } + break; + case 19: /* start */ - break; + { zval_dtor(&((*yyvaluep).value)); }; - case 23: /* members */ + break; + case 20: /* object */ - { zval_dtor(&((*yyvaluep).value)); } + { zval_dtor(&((*yyvaluep).value)); }; - break; + break; + case 23: /* members */ - case 24: /* member */ + { zval_dtor(&((*yyvaluep).value)); }; - { zval_dtor(&((*yyvaluep).value)); } + break; + case 24: /* member */ - break; + { zval_dtor(&((*yyvaluep).value)); }; - case 25: /* pair */ + break; + case 25: /* pair */ - { zend_string_release(((*yyvaluep).pair).key); zval_dtor(&((*yyvaluep).pair).val); } + { zend_string_release(((*yyvaluep).pair).key); zval_dtor(&((*yyvaluep).pair).val); }; - break; + break; + case 26: /* array */ - case 26: /* array */ + { zval_dtor(&((*yyvaluep).value)); }; - { zval_dtor(&((*yyvaluep).value)); } + break; + case 29: /* elements */ - break; + { zval_dtor(&((*yyvaluep).value)); }; - case 29: /* elements */ + break; + case 30: /* element */ - { zval_dtor(&((*yyvaluep).value)); } + { zval_dtor(&((*yyvaluep).value)); }; - break; + break; + case 31: /* key */ - case 30: /* element */ + { zval_dtor(&((*yyvaluep).value)); }; - { zval_dtor(&((*yyvaluep).value)); } + break; + case 32: /* value */ - break; + { zval_dtor(&((*yyvaluep).value)); }; - case 31: /* key */ + break; + case 33: /* errlex */ - { zval_dtor(&((*yyvaluep).value)); } - - break; - - case 32: /* value */ - - { zval_dtor(&((*yyvaluep).value)); } - - break; - - case 33: /* errlex */ - - { zval_dtor(&((*yyvaluep).value)); } - - break; + { zval_dtor(&((*yyvaluep).value)); }; + break; default: - break; + break; } - YY_IGNORE_MAYBE_UNINITIALIZED_END } @@ -1197,18 +1281,56 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, php_json_parser *p | yyparse. | `----------*/ +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) int yyparse (php_json_parser *parser) +#else +int +yyparse (parser) + php_json_parser *parser; +#endif +#endif { /* The lookahead symbol. */ int yychar; -/* The semantic value of the lookahead symbol. */ +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else /* Default value used for initialization, for pacifying older GCCs or non-GCC compilers. */ -YY_INITIAL_VALUE (static YYSTYPE yyval_default;) -YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); +static YYSTYPE yyval_default; +# define YY_INITIAL_VALUE(Value) = Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); /* Number of syntax errors so far. */ int yynerrs; @@ -1218,8 +1340,8 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); int yyerrstatus; /* The stacks and their tools: - 'yyss': related to states. - 'yyvs': related to semantic values. + `yyss': related to states. + `yyvs': related to semantic values. Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ @@ -1287,23 +1409,23 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE @@ -1311,22 +1433,22 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; + yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ @@ -1335,10 +1457,10 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) - YYABORT; + YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); @@ -1367,7 +1489,7 @@ yybackup: if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); - yychar = yylex (&yylval, parser); + yychar = YYLEX; } if (yychar <= YYEOF) @@ -1432,7 +1554,7 @@ yyreduce: yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: - '$$ = $1'. + `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison @@ -1448,34 +1570,30 @@ yyreduce: case 2: { - ZVAL_COPY_VALUE(&(yyval.value), &(yyvsp[-1].value)); - ZVAL_COPY_VALUE(parser->return_value, &(yyvsp[-1].value)); - PHP_JSON_USE((yyvsp[0].value)); YYACCEPT; + ZVAL_COPY_VALUE(&(yyval.value), &(yyvsp[(1) - (2)].value)); + ZVAL_COPY_VALUE(parser->return_value, &(yyvsp[(1) - (2)].value)); + PHP_JSON_USE((yyvsp[(2) - (2)].value)); YYACCEPT; } - break; case 3: { - PHP_JSON_USE_2((yyval.value), (yyvsp[-1].value), (yyvsp[0].value)); + PHP_JSON_USE_2((yyval.value), (yyvsp[(1) - (2)].value), (yyvsp[(2) - (2)].value)); } - break; case 4: { PHP_JSON_DEPTH_INC; } - break; case 5: { PHP_JSON_DEPTH_DEC; - (yyval.value) = (yyvsp[-1].value); + (yyval.value) = (yyvsp[(3) - (4)].value); } - break; case 7: @@ -1484,7 +1602,6 @@ yyreduce: parser->scanner.errcode = PHP_JSON_ERROR_STATE_MISMATCH; YYERROR; } - break; case 8: @@ -1492,67 +1609,59 @@ yyreduce: { php_json_parser_object_init(parser, &(yyval.value)); } - break; case 10: { php_json_parser_object_init(parser, &(yyval.value)); - if (php_json_parser_object_update(parser, &(yyval.value), (yyvsp[0].pair).key, &(yyvsp[0].pair).val) == FAILURE) + if (php_json_parser_object_update(parser, &(yyval.value), (yyvsp[(1) - (1)].pair).key, &(yyvsp[(1) - (1)].pair).val) == FAILURE) YYERROR; } - break; case 11: { - if (php_json_parser_object_update(parser, &(yyvsp[-2].value), (yyvsp[0].pair).key, &(yyvsp[0].pair).val) == FAILURE) + if (php_json_parser_object_update(parser, &(yyvsp[(1) - (3)].value), (yyvsp[(3) - (3)].pair).key, &(yyvsp[(3) - (3)].pair).val) == FAILURE) YYERROR; - ZVAL_COPY_VALUE(&(yyval.value), &(yyvsp[-2].value)); + ZVAL_COPY_VALUE(&(yyval.value), &(yyvsp[(1) - (3)].value)); } - break; case 12: { - PHP_JSON_USE_2((yyval.value), (yyvsp[-1].value), (yyvsp[0].value)); + PHP_JSON_USE_2((yyval.value), (yyvsp[(1) - (2)].value), (yyvsp[(2) - (2)].value)); } - break; case 13: { - (yyval.pair).key = Z_STR((yyvsp[-2].value)); - ZVAL_COPY_VALUE(&(yyval.pair).val, &(yyvsp[0].value)); + (yyval.pair).key = Z_STR((yyvsp[(1) - (3)].value)); + ZVAL_COPY_VALUE(&(yyval.pair).val, &(yyvsp[(3) - (3)].value)); } - break; case 14: { - PHP_JSON_USE_2((yyval.pair), (yyvsp[-1].value), (yyvsp[0].value)); + PHP_JSON_USE_2((yyval.pair), (yyvsp[(1) - (2)].value), (yyvsp[(2) - (2)].value)); } - break; case 15: { PHP_JSON_DEPTH_INC; } - break; case 16: { PHP_JSON_DEPTH_DEC; - ZVAL_COPY_VALUE(&(yyval.value), &(yyvsp[-1].value)); + ZVAL_COPY_VALUE(&(yyval.value), &(yyvsp[(3) - (4)].value)); } - break; case 18: @@ -1561,7 +1670,6 @@ yyreduce: parser->scanner.errcode = PHP_JSON_ERROR_STATE_MISMATCH; YYERROR; } - break; case 19: @@ -1569,42 +1677,37 @@ yyreduce: { php_json_parser_array_init(&(yyval.value)); } - break; case 21: { php_json_parser_array_init(&(yyval.value)); - php_json_parser_array_append(&(yyval.value), &(yyvsp[0].value)); + php_json_parser_array_append(&(yyval.value), &(yyvsp[(1) - (1)].value)); } - break; case 22: { - php_json_parser_array_append(&(yyvsp[-2].value), &(yyvsp[0].value)); - ZVAL_COPY_VALUE(&(yyval.value), &(yyvsp[-2].value)); + php_json_parser_array_append(&(yyvsp[(1) - (3)].value), &(yyvsp[(3) - (3)].value)); + ZVAL_COPY_VALUE(&(yyval.value), &(yyvsp[(1) - (3)].value)); } - break; case 23: { - PHP_JSON_USE_2((yyval.value), (yyvsp[-1].value), (yyvsp[0].value)); + PHP_JSON_USE_2((yyval.value), (yyvsp[(1) - (2)].value), (yyvsp[(2) - (2)].value)); } - break; case 36: { - PHP_JSON_USE_1((yyval.value), (yyvsp[0].value)); + PHP_JSON_USE_1((yyval.value), (yyvsp[(1) - (1)].value)); YYERROR; } - break; @@ -1630,7 +1733,7 @@ yyreduce: *++yyvsp = yyval; - /* Now 'shift' the result of the reduction. Determine what state + /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -1645,9 +1748,9 @@ yyreduce: goto yynewstate; -/*--------------------------------------. -| yyerrlab -- here on detecting error. | -`--------------------------------------*/ +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ @@ -1698,20 +1801,20 @@ yyerrlab: if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an - error, discard it. */ + error, discard it. */ if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } else - { - yydestruct ("Error: discarding", - yytoken, &yylval, parser); - yychar = YYEMPTY; - } + { + yydestruct ("Error: discarding", + yytoken, &yylval, parser); + yychar = YYEMPTY; + } } /* Else will try to reuse lookahead token after shifting the error @@ -1730,7 +1833,7 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - /* Do not reclaim the symbols of the rule whose action triggered + /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; @@ -1743,29 +1846,29 @@ yyerrorlab: | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ + yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) - YYABORT; + YYABORT; yydestruct ("Error: popping", - yystos[yystate], yyvsp, parser); + yystos[yystate], yyvsp, parser); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -1816,14 +1919,14 @@ yyreturn: yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, parser); } - /* Do not reclaim the symbols of the rule whose action triggered + /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp, parser); + yystos[*yyssp], yyvsp, parser); YYPOPSTACK (1); } #ifndef yyoverflow @@ -1834,9 +1937,12 @@ yyreturn: if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif - return yyresult; + /* Make sure YYID is used. */ + return YYID (yyresult); } + + /* Functions */ void php_json_parser_init(php_json_parser *parser, zval *return_value, char *str, size_t str_len, int options, int max_depth) @@ -1869,10 +1975,10 @@ int php_json_parser_object_update(php_json_parser *parser, zval *object, zend_st zend_symtable_update(Z_ARRVAL_P(object), key, zvalue); } else { zval zkey; - if (key->len == 0) { + if (ZSTR_LEN(key) == 0) { zend_string_release(key); key = zend_string_init("_empty_", sizeof("_empty_") - 1, 0); - } else if (key->val[0] == '\0') { + } else if (ZSTR_VAL(key)[0] == '\0') { parser->scanner.errcode = PHP_JSON_ERROR_INVALID_PROPERTY_NAME; zend_string_release(key); zval_dtor(zvalue); diff --git a/ext/json/json_parser.tab.h b/ext/json/json_parser.tab.h index 56bc2c40c9..20651ce8fb 100644 --- a/ext/json/json_parser.tab.h +++ b/ext/json/json_parser.tab.h @@ -1,19 +1,19 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 2.6.5. */ /* Bison interface for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. - + + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -26,13 +26,13 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ -#ifndef YY_PHP_JSON_YY_HOME_JAKUB_PROG_PHP_MASTER_EXT_JSON_JSON_PARSER_TAB_H_INCLUDED -# define YY_PHP_JSON_YY_HOME_JAKUB_PROG_PHP_MASTER_EXT_JSON_JSON_PARSER_TAB_H_INCLUDED -/* Debug traces. */ +#ifndef YY_PHP_JSON_YY_HOME_DMITRY_PHP_PHP_MASTER_EXT_JSON_JSON_PARSER_TAB_H_INCLUDED +# define YY_PHP_JSON_YY_HOME_DMITRY_PHP_PHP_MASTER_EXT_JSON_JSON_PARSER_TAB_H_INCLUDED +/* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif @@ -40,21 +40,22 @@ extern int php_json_yydebug; #endif -/* Token type. */ +/* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - enum yytokentype - { - PHP_JSON_T_NUL = 258, - PHP_JSON_T_TRUE = 259, - PHP_JSON_T_FALSE = 260, - PHP_JSON_T_INT = 261, - PHP_JSON_T_DOUBLE = 262, - PHP_JSON_T_STRING = 263, - PHP_JSON_T_ESTRING = 264, - PHP_JSON_T_EOI = 265, - PHP_JSON_T_ERROR = 266 - }; + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + PHP_JSON_T_NUL = 258, + PHP_JSON_T_TRUE = 259, + PHP_JSON_T_FALSE = 260, + PHP_JSON_T_INT = 261, + PHP_JSON_T_DOUBLE = 262, + PHP_JSON_T_STRING = 263, + PHP_JSON_T_ESTRING = 264, + PHP_JSON_T_EOI = 265, + PHP_JSON_T_ERROR = 266 + }; #endif /* Tokens. */ #define PHP_JSON_T_NUL 258 @@ -67,10 +68,10 @@ extern int php_json_yydebug; #define PHP_JSON_T_EOI 265 #define PHP_JSON_T_ERROR 266 -/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -union YYSTYPE + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE { @@ -81,15 +82,26 @@ union YYSTYPE } pair; -}; -typedef union YYSTYPE YYSTYPE; +} YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif - +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int php_json_yyparse (void *YYPARSE_PARAM); +#else +int php_json_yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus int php_json_yyparse (php_json_parser *parser); +#else +int php_json_yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ -#endif /* !YY_PHP_JSON_YY_HOME_JAKUB_PROG_PHP_MASTER_EXT_JSON_JSON_PARSER_TAB_H_INCLUDED */ +#endif /* !YY_PHP_JSON_YY_HOME_DMITRY_PHP_PHP_MASTER_EXT_JSON_JSON_PARSER_TAB_H_INCLUDED */ diff --git a/ext/json/json_parser.y b/ext/json/json_parser.y index 1521be69b8..8e9809c99d 100644 --- a/ext/json/json_parser.y +++ b/ext/json/json_parser.y @@ -257,10 +257,10 @@ int php_json_parser_object_update(php_json_parser *parser, zval *object, zend_st zend_symtable_update(Z_ARRVAL_P(object), key, zvalue); } else { zval zkey; - if (key->len == 0) { + if (ZSTR_LEN(key) == 0) { zend_string_release(key); key = zend_string_init("_empty_", sizeof("_empty_") - 1, 0); - } else if (key->val[0] == '\0') { + } else if (ZSTR_VAL(key)[0] == '\0') { parser->scanner.errcode = PHP_JSON_ERROR_INVALID_PROPERTY_NAME; zend_string_release(key); zval_dtor(zvalue); diff --git a/ext/json/json_scanner.c b/ext/json/json_scanner.c index 70662b5c31..7e8ee8b933 100644 --- a/ext/json/json_scanner.c +++ b/ext/json/json_scanner.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.14.3 */ +/* Generated by re2c 0.13.5 */ /* +----------------------------------------------------------------------+ | PHP Version 7 | @@ -147,46 +147,47 @@ yyc_JS: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; + yych = *YYCURSOR; if (yych <= ']') { if (yych <= '"') { if (yych <= '\f') { if (yych <= 0x08) { - if (yych >= 0x01) goto yy5; + if (yych >= 0x01) goto yy4; } else { - if (yych <= '\t') goto yy7; - if (yych <= '\n') goto yy9; - goto yy5; + if (yych <= '\t') goto yy6; + if (yych <= '\n') goto yy8; + goto yy4; } } else { if (yych <= 0x1F) { - if (yych <= '\r') goto yy10; - goto yy5; + if (yych <= '\r') goto yy9; + goto yy4; } else { - if (yych <= ' ') goto yy11; - if (yych <= '!') goto yy12; - goto yy14; + if (yych <= ' ') goto yy10; + if (yych <= '!') goto yy11; + goto yy13; } } } else { if (yych <= '0') { if (yych <= ',') { - if (yych <= '+') goto yy12; - goto yy16; + if (yych <= '+') goto yy11; + goto yy15; } else { - if (yych <= '-') goto yy18; - if (yych <= '/') goto yy12; - goto yy19; + if (yych <= '-') goto yy17; + if (yych <= '/') goto yy11; + goto yy18; } } else { if (yych <= 'Z') { - if (yych <= '9') goto yy21; - if (yych <= ':') goto yy22; - goto yy12; + if (yych <= '9') goto yy20; + if (yych <= ':') goto yy21; + goto yy11; } else { - if (yych <= '[') goto yy24; - if (yych <= '\\') goto yy12; - goto yy26; + if (yych <= '[') goto yy23; + if (yych <= '\\') goto yy11; + goto yy25; } } } @@ -194,41 +195,41 @@ yyc_JS: if (yych <= '}') { if (yych <= 's') { if (yych <= 'f') { - if (yych <= 'e') goto yy12; - goto yy28; + if (yych <= 'e') goto yy11; + goto yy27; } else { - if (yych == 'n') goto yy29; - goto yy12; + if (yych == 'n') goto yy28; + goto yy11; } } else { if (yych <= 'z') { - if (yych <= 't') goto yy30; - goto yy12; + if (yych <= 't') goto yy29; + goto yy11; } else { - if (yych <= '{') goto yy31; - if (yych <= '|') goto yy12; - goto yy33; + if (yych <= '{') goto yy30; + if (yych <= '|') goto yy11; + goto yy32; } } } else { if (yych <= 0xEC) { if (yych <= 0xC1) { - if (yych <= 0x7F) goto yy12; - goto yy35; + if (yych <= 0x7F) goto yy11; + goto yy34; } else { - if (yych <= 0xDF) goto yy37; - if (yych <= 0xE0) goto yy38; - goto yy39; + if (yych <= 0xDF) goto yy36; + if (yych <= 0xE0) goto yy37; + goto yy38; } } else { if (yych <= 0xF0) { - if (yych <= 0xED) goto yy40; - if (yych <= 0xEF) goto yy41; - goto yy42; + if (yych <= 0xED) goto yy39; + if (yych <= 0xEF) goto yy40; + goto yy41; } else { - if (yych <= 0xF3) goto yy43; - if (yych <= 0xF4) goto yy44; - goto yy35; + if (yych <= 0xF3) goto yy42; + if (yych <= 0xF4) goto yy43; + goto yy34; } } } @@ -242,36 +243,36 @@ yyc_JS: return PHP_JSON_T_ERROR; } } -yy5: +yy4: ++YYCURSOR; { s->errcode = PHP_JSON_ERROR_CTRL_CHAR; return PHP_JSON_T_ERROR; } -yy7: +yy6: ++YYCURSOR; yych = *YYCURSOR; - goto yy82; -yy8: + goto yy81; +yy7: { goto std; } +yy8: + yych = *++YYCURSOR; + goto yy7; yy9: yych = *++YYCURSOR; - goto yy8; + if (yych == '\n') goto yy82; + goto yy81; yy10: yych = *++YYCURSOR; - if (yych == '\n') goto yy83; - goto yy82; + goto yy81; yy11: - yych = *++YYCURSOR; - goto yy82; -yy12: ++YYCURSOR; -yy13: +yy12: { s->errcode = PHP_JSON_ERROR_SYNTAX; return PHP_JSON_T_ERROR; } -yy14: +yy13: ++YYCURSOR; { s->str_start = s->cursor; @@ -279,25 +280,25 @@ yy14: PHP_JSON_CONDITION_SET(STR_P1); PHP_JSON_CONDITION_GOTO(STR_P1); } -yy16: +yy15: ++YYCURSOR; { return ','; } -yy18: +yy17: yych = *++YYCURSOR; - if (yych <= '/') goto yy13; - if (yych <= '0') goto yy80; - if (yych <= '9') goto yy70; - goto yy13; -yy19: + if (yych <= '/') goto yy12; + if (yych <= '0') goto yy79; + if (yych <= '9') goto yy69; + goto yy12; +yy18: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yych <= 'D') { - if (yych == '.') goto yy72; + if (yych == '.') goto yy71; } else { - if (yych <= 'E') goto yy73; - if (yych == 'e') goto yy73; + if (yych <= 'E') goto yy72; + if (yych == 'e') goto yy72; } -yy20: +yy19: { zend_bool bigint = 0, negative = s->token[0] == '-'; size_t digits = (size_t) (s->cursor - s->token - negative); @@ -322,305 +323,305 @@ yy20: return PHP_JSON_T_DOUBLE; } } -yy21: +yy20: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - goto yy71; -yy22: + goto yy70; +yy21: ++YYCURSOR; { return ':'; } -yy24: +yy23: ++YYCURSOR; { return '['; } -yy26: +yy25: ++YYCURSOR; { return ']'; } +yy27: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'a') goto yy64; + goto yy12; yy28: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'a') goto yy65; - goto yy13; + if (yych == 'u') goto yy60; + goto yy12; yy29: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'u') goto yy61; - goto yy13; + if (yych == 'r') goto yy56; + goto yy12; yy30: - yyaccept = 1; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'r') goto yy57; - goto yy13; -yy31: ++YYCURSOR; { return '{'; } -yy33: +yy32: ++YYCURSOR; { return '}'; } -yy35: +yy34: ++YYCURSOR; -yy36: +yy35: { s->errcode = PHP_JSON_ERROR_UTF8; return PHP_JSON_T_ERROR; } -yy37: +yy36: yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy36; - if (yych <= 0xBF) goto yy48; - goto yy36; + if (yych <= 0x7F) goto yy35; + if (yych <= 0xBF) goto yy47; + goto yy35; +yy37: + yyaccept = 2; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 0x9F) goto yy35; + if (yych <= 0xBF) goto yy55; + goto yy35; yy38: yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x9F) goto yy36; - if (yych <= 0xBF) goto yy56; - goto yy36; + if (yych <= 0x7F) goto yy35; + if (yych <= 0xBF) goto yy54; + goto yy35; yy39: yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x7F) goto yy36; - if (yych <= 0xBF) goto yy55; - goto yy36; + if (yych <= 0x7F) goto yy35; + if (yych <= 0x9F) goto yy53; + goto yy35; yy40: yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x7F) goto yy36; - if (yych <= 0x9F) goto yy54; - goto yy36; + if (yych <= 0x7F) goto yy35; + if (yych <= 0xBF) goto yy52; + goto yy35; yy41: yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x7F) goto yy36; - if (yych <= 0xBF) goto yy53; - goto yy36; + if (yych <= 0x8F) goto yy35; + if (yych <= 0xBF) goto yy50; + goto yy35; yy42: yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x8F) goto yy36; - if (yych <= 0xBF) goto yy51; - goto yy36; + if (yych <= 0x7F) goto yy35; + if (yych <= 0xBF) goto yy48; + goto yy35; yy43: yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x7F) goto yy36; - if (yych <= 0xBF) goto yy49; - goto yy36; -yy44: - yyaccept = 2; - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x7F) goto yy36; - if (yych >= 0x90) goto yy36; + if (yych <= 0x7F) goto yy35; + if (yych >= 0x90) goto yy35; yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy46; - if (yych <= 0xBF) goto yy47; -yy46: + if (yych <= 0x7F) goto yy45; + if (yych <= 0xBF) goto yy46; +yy45: YYCURSOR = YYMARKER; if (yyaccept <= 1) { - if (yyaccept == 0) { - goto yy20; + if (yyaccept <= 0) { + goto yy19; } else { - goto yy13; + goto yy12; } } else { - if (yyaccept == 2) { - goto yy36; + if (yyaccept <= 2) { + goto yy35; } else { - goto yy77; + goto yy76; } } +yy46: + yych = *++YYCURSOR; + if (yych <= 0x7F) goto yy45; + if (yych >= 0xC0) goto yy45; yy47: yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy46; - if (yych >= 0xC0) goto yy46; + goto yy12; yy48: yych = *++YYCURSOR; - goto yy13; -yy49: + if (yych <= 0x7F) goto yy45; + if (yych >= 0xC0) goto yy45; yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy46; - if (yych >= 0xC0) goto yy46; + if (yych <= 0x7F) goto yy45; + if (yych <= 0xBF) goto yy47; + goto yy45; +yy50: yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy46; - if (yych <= 0xBF) goto yy48; - goto yy46; -yy51: + if (yych <= 0x7F) goto yy45; + if (yych >= 0xC0) goto yy45; yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy46; - if (yych >= 0xC0) goto yy46; + if (yych <= 0x7F) goto yy45; + if (yych <= 0xBF) goto yy47; + goto yy45; +yy52: yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy46; - if (yych <= 0xBF) goto yy48; - goto yy46; + if (yych <= 0x7F) goto yy45; + if (yych <= 0xBF) goto yy47; + goto yy45; yy53: yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy46; - if (yych <= 0xBF) goto yy48; - goto yy46; + if (yych <= 0x7F) goto yy45; + if (yych <= 0xBF) goto yy47; + goto yy45; yy54: yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy46; - if (yych <= 0xBF) goto yy48; - goto yy46; + if (yych <= 0x7F) goto yy45; + if (yych <= 0xBF) goto yy47; + goto yy45; yy55: yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy46; - if (yych <= 0xBF) goto yy48; - goto yy46; + if (yych <= 0x7F) goto yy45; + if (yych <= 0xBF) goto yy47; + goto yy45; yy56: yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy46; - if (yych <= 0xBF) goto yy48; - goto yy46; -yy57: + if (yych != 'u') goto yy45; yych = *++YYCURSOR; - if (yych != 'u') goto yy46; - yych = *++YYCURSOR; - if (yych != 'e') goto yy46; + if (yych != 'e') goto yy45; ++YYCURSOR; { ZVAL_TRUE(&s->value); return PHP_JSON_T_TRUE; } -yy61: +yy60: yych = *++YYCURSOR; - if (yych != 'l') goto yy46; + if (yych != 'l') goto yy45; yych = *++YYCURSOR; - if (yych != 'l') goto yy46; + if (yych != 'l') goto yy45; ++YYCURSOR; { ZVAL_NULL(&s->value); return PHP_JSON_T_NUL; } -yy65: +yy64: yych = *++YYCURSOR; - if (yych != 'l') goto yy46; + if (yych != 'l') goto yy45; yych = *++YYCURSOR; - if (yych != 's') goto yy46; + if (yych != 's') goto yy45; yych = *++YYCURSOR; - if (yych != 'e') goto yy46; + if (yych != 'e') goto yy45; ++YYCURSOR; { ZVAL_FALSE(&s->value); return PHP_JSON_T_FALSE; } -yy70: +yy69: yyaccept = 0; YYMARKER = ++YYCURSOR; yych = *YYCURSOR; -yy71: +yy70: if (yybm[0+yych] & 64) { - goto yy70; + goto yy69; } if (yych <= 'D') { - if (yych != '.') goto yy20; + if (yych != '.') goto yy19; } else { - if (yych <= 'E') goto yy73; - if (yych == 'e') goto yy73; - goto yy20; + if (yych <= 'E') goto yy72; + if (yych == 'e') goto yy72; + goto yy19; } -yy72: +yy71: yych = *++YYCURSOR; - if (yych <= '/') goto yy46; - if (yych <= '9') goto yy78; - goto yy46; -yy73: + if (yych <= '/') goto yy45; + if (yych <= '9') goto yy77; + goto yy45; +yy72: yych = *++YYCURSOR; if (yych <= ',') { - if (yych != '+') goto yy46; + if (yych != '+') goto yy45; } else { - if (yych <= '-') goto yy74; - if (yych <= '/') goto yy46; - if (yych <= '9') goto yy75; - goto yy46; + if (yych <= '-') goto yy73; + if (yych <= '/') goto yy45; + if (yych <= '9') goto yy74; + goto yy45; } -yy74: +yy73: yych = *++YYCURSOR; - if (yych <= '/') goto yy46; - if (yych >= ':') goto yy46; -yy75: + if (yych <= '/') goto yy45; + if (yych >= ':') goto yy45; +yy74: ++YYCURSOR; yych = *YYCURSOR; - if (yych <= '/') goto yy77; - if (yych <= '9') goto yy75; -yy77: + if (yych <= '/') goto yy76; + if (yych <= '9') goto yy74; +yy76: { ZVAL_DOUBLE(&s->value, zend_strtod((char *) s->token, NULL)); return PHP_JSON_T_DOUBLE; } -yy78: +yy77: yyaccept = 3; YYMARKER = ++YYCURSOR; yych = *YYCURSOR; if (yych <= 'D') { - if (yych <= '/') goto yy77; - if (yych <= '9') goto yy78; - goto yy77; + if (yych <= '/') goto yy76; + if (yych <= '9') goto yy77; + goto yy76; } else { - if (yych <= 'E') goto yy73; - if (yych == 'e') goto yy73; - goto yy77; + if (yych <= 'E') goto yy72; + if (yych == 'e') goto yy72; + goto yy76; } -yy80: +yy79: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yych <= 'D') { - if (yych == '.') goto yy72; - goto yy20; + if (yych == '.') goto yy71; + goto yy19; } else { - if (yych <= 'E') goto yy73; - if (yych == 'e') goto yy73; - goto yy20; + if (yych <= 'E') goto yy72; + if (yych == 'e') goto yy72; + goto yy19; } -yy81: +yy80: ++YYCURSOR; yych = *YYCURSOR; -yy82: +yy81: if (yybm[0+yych] & 128) { - goto yy81; + goto yy80; } - goto yy8; -yy83: + goto yy7; +yy82: ++YYCURSOR; yych = *YYCURSOR; - goto yy8; + goto yy7; } /* *********************************** */ yyc_STR_P1: yych = *YYCURSOR; if (yych <= 0xDF) { if (yych <= '[') { - if (yych <= 0x1F) goto yy86; - if (yych == '"') goto yy90; - goto yy88; + if (yych <= 0x1F) goto yy85; + if (yych == '"') goto yy89; + goto yy87; } else { - if (yych <= '\\') goto yy92; - if (yych <= 0x7F) goto yy88; - if (yych <= 0xC1) goto yy94; - goto yy96; + if (yych <= '\\') goto yy91; + if (yych <= 0x7F) goto yy87; + if (yych <= 0xC1) goto yy93; + goto yy95; } } else { if (yych <= 0xEF) { - if (yych <= 0xE0) goto yy97; - if (yych <= 0xEC) goto yy98; - if (yych <= 0xED) goto yy99; - goto yy100; + if (yych <= 0xE0) goto yy96; + if (yych <= 0xEC) goto yy97; + if (yych <= 0xED) goto yy98; + goto yy99; } else { - if (yych <= 0xF0) goto yy101; - if (yych <= 0xF3) goto yy102; - if (yych <= 0xF4) goto yy103; - goto yy94; + if (yych <= 0xF0) goto yy100; + if (yych <= 0xF3) goto yy101; + if (yych <= 0xF4) goto yy102; + goto yy93; } } -yy86: +yy85: ++YYCURSOR; { s->errcode = PHP_JSON_ERROR_CTRL_CHAR; return PHP_JSON_T_ERROR; } -yy88: +yy87: ++YYCURSOR; -yy89: +yy88: { PHP_JSON_CONDITION_GOTO(STR_P1); } -yy90: +yy89: ++YYCURSOR; { zend_string *str; @@ -631,7 +632,7 @@ yy90: return PHP_JSON_T_ESTRING; } str = zend_string_alloc(len, 0); - str->val[len] = '\0'; + ZSTR_VAL(str)[len] = '\0'; ZVAL_STR(&s->value, str); if (s->str_esc) { s->pstr = (php_json_ctype *) Z_STRVAL(s->value); @@ -644,392 +645,392 @@ yy90: return PHP_JSON_T_STRING; } } -yy92: +yy91: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yych <= 'e') { if (yych <= '/') { - if (yych == '"') goto yy116; - if (yych >= '/') goto yy116; + if (yych == '"') goto yy115; + if (yych >= '/') goto yy115; } else { if (yych <= '\\') { - if (yych >= '\\') goto yy116; + if (yych >= '\\') goto yy115; } else { - if (yych == 'b') goto yy116; + if (yych == 'b') goto yy115; } } } else { if (yych <= 'q') { - if (yych <= 'f') goto yy116; - if (yych == 'n') goto yy116; + if (yych <= 'f') goto yy115; + if (yych == 'n') goto yy115; } else { if (yych <= 's') { - if (yych <= 'r') goto yy116; + if (yych <= 'r') goto yy115; } else { - if (yych <= 't') goto yy116; - if (yych <= 'u') goto yy118; + if (yych <= 't') goto yy115; + if (yych <= 'u') goto yy117; } } } -yy93: +yy92: { s->errcode = PHP_JSON_ERROR_SYNTAX; return PHP_JSON_T_ERROR; } -yy94: +yy93: ++YYCURSOR; -yy95: +yy94: { s->errcode = PHP_JSON_ERROR_UTF8; return PHP_JSON_T_ERROR; } -yy96: +yy95: yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy95; - if (yych <= 0xBF) goto yy107; - goto yy95; + if (yych <= 0x7F) goto yy94; + if (yych <= 0xBF) goto yy106; + goto yy94; +yy96: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 0x9F) goto yy94; + if (yych <= 0xBF) goto yy114; + goto yy94; yy97: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x9F) goto yy95; - if (yych <= 0xBF) goto yy115; - goto yy95; + if (yych <= 0x7F) goto yy94; + if (yych <= 0xBF) goto yy113; + goto yy94; yy98: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x7F) goto yy95; - if (yych <= 0xBF) goto yy114; - goto yy95; + if (yych <= 0x7F) goto yy94; + if (yych <= 0x9F) goto yy112; + goto yy94; yy99: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x7F) goto yy95; - if (yych <= 0x9F) goto yy113; - goto yy95; + if (yych <= 0x7F) goto yy94; + if (yych <= 0xBF) goto yy111; + goto yy94; yy100: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x7F) goto yy95; - if (yych <= 0xBF) goto yy112; - goto yy95; + if (yych <= 0x8F) goto yy94; + if (yych <= 0xBF) goto yy109; + goto yy94; yy101: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x8F) goto yy95; - if (yych <= 0xBF) goto yy110; - goto yy95; + if (yych <= 0x7F) goto yy94; + if (yych <= 0xBF) goto yy107; + goto yy94; yy102: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x7F) goto yy95; - if (yych <= 0xBF) goto yy108; - goto yy95; -yy103: - yyaccept = 1; - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x7F) goto yy95; - if (yych >= 0x90) goto yy95; + if (yych <= 0x7F) goto yy94; + if (yych >= 0x90) goto yy94; yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy105; - if (yych <= 0xBF) goto yy106; -yy105: + if (yych <= 0x7F) goto yy104; + if (yych <= 0xBF) goto yy105; +yy104: YYCURSOR = YYMARKER; if (yyaccept <= 1) { - if (yyaccept == 0) { - goto yy93; + if (yyaccept <= 0) { + goto yy92; } else { - goto yy95; + goto yy94; } } else { - goto yy127; + goto yy126; } +yy105: + yych = *++YYCURSOR; + if (yych <= 0x7F) goto yy104; + if (yych >= 0xC0) goto yy104; yy106: yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy105; - if (yych >= 0xC0) goto yy105; + goto yy88; yy107: yych = *++YYCURSOR; - goto yy89; -yy108: + if (yych <= 0x7F) goto yy104; + if (yych >= 0xC0) goto yy104; yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy105; - if (yych >= 0xC0) goto yy105; + if (yych <= 0x7F) goto yy104; + if (yych <= 0xBF) goto yy106; + goto yy104; +yy109: yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy105; - if (yych <= 0xBF) goto yy107; - goto yy105; -yy110: + if (yych <= 0x7F) goto yy104; + if (yych >= 0xC0) goto yy104; yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy105; - if (yych >= 0xC0) goto yy105; + if (yych <= 0x7F) goto yy104; + if (yych <= 0xBF) goto yy106; + goto yy104; +yy111: yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy105; - if (yych <= 0xBF) goto yy107; - goto yy105; + if (yych <= 0x7F) goto yy104; + if (yych <= 0xBF) goto yy106; + goto yy104; yy112: yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy105; - if (yych <= 0xBF) goto yy107; - goto yy105; + if (yych <= 0x7F) goto yy104; + if (yych <= 0xBF) goto yy106; + goto yy104; yy113: yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy105; - if (yych <= 0xBF) goto yy107; - goto yy105; + if (yych <= 0x7F) goto yy104; + if (yych <= 0xBF) goto yy106; + goto yy104; yy114: yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy105; - if (yych <= 0xBF) goto yy107; - goto yy105; + if (yych <= 0x7F) goto yy104; + if (yych <= 0xBF) goto yy106; + goto yy104; yy115: - yych = *++YYCURSOR; - if (yych <= 0x7F) goto yy105; - if (yych <= 0xBF) goto yy107; - goto yy105; -yy116: ++YYCURSOR; { s->str_esc++; PHP_JSON_CONDITION_GOTO(STR_P1); } -yy118: +yy117: yych = *++YYCURSOR; if (yych <= 'D') { if (yych <= '9') { - if (yych <= '/') goto yy105; - if (yych >= '1') goto yy120; + if (yych <= '/') goto yy104; + if (yych >= '1') goto yy119; } else { - if (yych <= '@') goto yy105; - if (yych <= 'C') goto yy120; - goto yy121; + if (yych <= '@') goto yy104; + if (yych <= 'C') goto yy119; + goto yy120; } } else { if (yych <= 'c') { - if (yych <= 'F') goto yy120; - if (yych <= '`') goto yy105; - goto yy120; + if (yych <= 'F') goto yy119; + if (yych <= '`') goto yy104; + goto yy119; } else { - if (yych <= 'd') goto yy121; - if (yych <= 'f') goto yy120; - goto yy105; + if (yych <= 'd') goto yy120; + if (yych <= 'f') goto yy119; + goto yy104; } } yych = *++YYCURSOR; if (yych <= '9') { - if (yych <= '/') goto yy105; - if (yych <= '0') goto yy140; - if (yych <= '7') goto yy141; - goto yy122; + if (yych <= '/') goto yy104; + if (yych <= '0') goto yy139; + if (yych <= '7') goto yy140; + goto yy121; } else { if (yych <= 'F') { - if (yych <= '@') goto yy105; - goto yy122; + if (yych <= '@') goto yy104; + goto yy121; } else { - if (yych <= '`') goto yy105; - if (yych <= 'f') goto yy122; - goto yy105; + if (yych <= '`') goto yy104; + if (yych <= 'f') goto yy121; + goto yy104; } } -yy120: +yy119: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy105; - if (yych <= '9') goto yy122; - goto yy105; + if (yych <= '/') goto yy104; + if (yych <= '9') goto yy121; + goto yy104; } else { - if (yych <= 'F') goto yy122; - if (yych <= '`') goto yy105; - if (yych <= 'f') goto yy122; - goto yy105; + if (yych <= 'F') goto yy121; + if (yych <= '`') goto yy104; + if (yych <= 'f') goto yy121; + goto yy104; } -yy121: +yy120: yych = *++YYCURSOR; if (yych <= 'B') { if (yych <= '7') { - if (yych <= '/') goto yy105; + if (yych <= '/') goto yy104; } else { - if (yych <= '9') goto yy123; - if (yych <= '@') goto yy105; - goto yy123; + if (yych <= '9') goto yy122; + if (yych <= '@') goto yy104; + goto yy122; } } else { if (yych <= '`') { - if (yych <= 'F') goto yy124; - goto yy105; + if (yych <= 'F') goto yy123; + goto yy104; } else { - if (yych <= 'b') goto yy123; - if (yych <= 'f') goto yy124; - goto yy105; + if (yych <= 'b') goto yy122; + if (yych <= 'f') goto yy123; + goto yy104; } } +yy121: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy104; + if (yych <= '9') goto yy136; + goto yy104; + } else { + if (yych <= 'F') goto yy136; + if (yych <= '`') goto yy104; + if (yych <= 'f') goto yy136; + goto yy104; + } yy122: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy105; - if (yych <= '9') goto yy137; - goto yy105; + if (yych <= '/') goto yy104; + if (yych <= '9') goto yy127; + goto yy104; } else { - if (yych <= 'F') goto yy137; - if (yych <= '`') goto yy105; - if (yych <= 'f') goto yy137; - goto yy105; + if (yych <= 'F') goto yy127; + if (yych <= '`') goto yy104; + if (yych <= 'f') goto yy127; + goto yy104; } yy123: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy105; - if (yych <= '9') goto yy128; - goto yy105; + if (yych <= '/') goto yy104; + if (yych >= ':') goto yy104; } else { - if (yych <= 'F') goto yy128; - if (yych <= '`') goto yy105; - if (yych <= 'f') goto yy128; - goto yy105; + if (yych <= 'F') goto yy124; + if (yych <= '`') goto yy104; + if (yych >= 'g') goto yy104; } yy124: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy105; - if (yych >= ':') goto yy105; + if (yych <= '/') goto yy104; + if (yych >= ':') goto yy104; } else { if (yych <= 'F') goto yy125; - if (yych <= '`') goto yy105; - if (yych >= 'g') goto yy105; + if (yych <= '`') goto yy104; + if (yych >= 'g') goto yy104; } yy125: - yych = *++YYCURSOR; - if (yych <= '@') { - if (yych <= '/') goto yy105; - if (yych >= ':') goto yy105; - } else { - if (yych <= 'F') goto yy126; - if (yych <= '`') goto yy105; - if (yych >= 'g') goto yy105; - } -yy126: ++YYCURSOR; -yy127: +yy126: { s->errcode = PHP_JSON_ERROR_UTF16; return PHP_JSON_T_ERROR; } -yy128: +yy127: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy105; - if (yych >= ':') goto yy105; + if (yych <= '/') goto yy104; + if (yych >= ':') goto yy104; } else { - if (yych <= 'F') goto yy129; - if (yych <= '`') goto yy105; - if (yych >= 'g') goto yy105; + if (yych <= 'F') goto yy128; + if (yych <= '`') goto yy104; + if (yych >= 'g') goto yy104; } -yy129: +yy128: yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); - if (yych != '\\') goto yy127; + if (yych != '\\') goto yy126; yych = *++YYCURSOR; - if (yych != 'u') goto yy105; + if (yych != 'u') goto yy104; yych = *++YYCURSOR; - if (yych == 'D') goto yy132; - if (yych != 'd') goto yy105; -yy132: + if (yych == 'D') goto yy131; + if (yych != 'd') goto yy104; +yy131: yych = *++YYCURSOR; - if (yych <= 'B') goto yy105; - if (yych <= 'F') goto yy133; - if (yych <= 'b') goto yy105; - if (yych >= 'g') goto yy105; -yy133: + if (yych <= 'B') goto yy104; + if (yych <= 'F') goto yy132; + if (yych <= 'b') goto yy104; + if (yych >= 'g') goto yy104; +yy132: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy105; - if (yych >= ':') goto yy105; + if (yych <= '/') goto yy104; + if (yych >= ':') goto yy104; } else { - if (yych <= 'F') goto yy134; - if (yych <= '`') goto yy105; - if (yych >= 'g') goto yy105; + if (yych <= 'F') goto yy133; + if (yych <= '`') goto yy104; + if (yych >= 'g') goto yy104; } -yy134: +yy133: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy105; - if (yych >= ':') goto yy105; + if (yych <= '/') goto yy104; + if (yych >= ':') goto yy104; } else { - if (yych <= 'F') goto yy135; - if (yych <= '`') goto yy105; - if (yych >= 'g') goto yy105; + if (yych <= 'F') goto yy134; + if (yych <= '`') goto yy104; + if (yych >= 'g') goto yy104; } -yy135: +yy134: ++YYCURSOR; { s->str_esc += 8; PHP_JSON_CONDITION_GOTO(STR_P1); } -yy137: +yy136: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy105; - if (yych >= ':') goto yy105; + if (yych <= '/') goto yy104; + if (yych >= ':') goto yy104; } else { - if (yych <= 'F') goto yy138; - if (yych <= '`') goto yy105; - if (yych >= 'g') goto yy105; + if (yych <= 'F') goto yy137; + if (yych <= '`') goto yy104; + if (yych >= 'g') goto yy104; } -yy138: +yy137: ++YYCURSOR; { s->str_esc += 3; PHP_JSON_CONDITION_GOTO(STR_P1); } -yy140: +yy139: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy105; - if (yych <= '7') goto yy145; - if (yych <= '9') goto yy142; - goto yy105; + if (yych <= '/') goto yy104; + if (yych <= '7') goto yy144; + if (yych <= '9') goto yy141; + goto yy104; } else { - if (yych <= 'F') goto yy142; - if (yych <= '`') goto yy105; - if (yych <= 'f') goto yy142; - goto yy105; + if (yych <= 'F') goto yy141; + if (yych <= '`') goto yy104; + if (yych <= 'f') goto yy141; + goto yy104; } -yy141: +yy140: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy105; - if (yych >= ':') goto yy105; + if (yych <= '/') goto yy104; + if (yych >= ':') goto yy104; } else { - if (yych <= 'F') goto yy142; - if (yych <= '`') goto yy105; - if (yych >= 'g') goto yy105; + if (yych <= 'F') goto yy141; + if (yych <= '`') goto yy104; + if (yych >= 'g') goto yy104; } -yy142: +yy141: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy105; - if (yych >= ':') goto yy105; + if (yych <= '/') goto yy104; + if (yych >= ':') goto yy104; } else { - if (yych <= 'F') goto yy143; - if (yych <= '`') goto yy105; - if (yych >= 'g') goto yy105; + if (yych <= 'F') goto yy142; + if (yych <= '`') goto yy104; + if (yych >= 'g') goto yy104; } -yy143: +yy142: ++YYCURSOR; { s->str_esc += 4; PHP_JSON_CONDITION_GOTO(STR_P1); } -yy145: +yy144: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy105; - if (yych >= ':') goto yy105; + if (yych <= '/') goto yy104; + if (yych >= ':') goto yy104; } else { - if (yych <= 'F') goto yy146; - if (yych <= '`') goto yy105; - if (yych >= 'g') goto yy105; + if (yych <= 'F') goto yy145; + if (yych <= '`') goto yy104; + if (yych >= 'g') goto yy104; } -yy146: +yy145: ++YYCURSOR; { s->str_esc += 5; @@ -1038,22 +1039,22 @@ yy146: /* *********************************** */ yyc_STR_P2: yych = *YYCURSOR; - if (yych == '"') goto yy152; - if (yych == '\\') goto yy154; + if (yych == '"') goto yy151; + if (yych == '\\') goto yy153; ++YYCURSOR; { PHP_JSON_CONDITION_GOTO(STR_P2); } -yy152: +yy151: ++YYCURSOR; YYSETCONDITION(yycJS); { PHP_JSON_SCANNER_COPY_ESC(); return PHP_JSON_T_STRING; } -yy154: +yy153: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'u') goto yy156; -yy155: + if (yych == 'u') goto yy155; +yy154: { char esc; PHP_JSON_SCANNER_COPY_ESC(); @@ -1087,103 +1088,103 @@ yy155: s->str_start = s->cursor; PHP_JSON_CONDITION_GOTO(STR_P2); } -yy156: +yy155: yych = *++YYCURSOR; if (yych <= 'D') { if (yych <= '9') { - if (yych <= '/') goto yy157; - if (yych <= '0') goto yy158; - goto yy159; + if (yych <= '/') goto yy156; + if (yych <= '0') goto yy157; + goto yy158; } else { - if (yych <= '@') goto yy157; - if (yych <= 'C') goto yy159; - goto yy160; + if (yych <= '@') goto yy156; + if (yych <= 'C') goto yy158; + goto yy159; } } else { if (yych <= 'c') { - if (yych <= 'F') goto yy159; - if (yych >= 'a') goto yy159; + if (yych <= 'F') goto yy158; + if (yych >= 'a') goto yy158; } else { - if (yych <= 'd') goto yy160; - if (yych <= 'f') goto yy159; + if (yych <= 'd') goto yy159; + if (yych <= 'f') goto yy158; } } -yy157: +yy156: YYCURSOR = YYMARKER; - goto yy155; -yy158: + goto yy154; +yy157: yych = *++YYCURSOR; if (yych <= '9') { - if (yych <= '/') goto yy157; - if (yych <= '0') goto yy175; - if (yych <= '7') goto yy176; - goto yy162; + if (yych <= '/') goto yy156; + if (yych <= '0') goto yy174; + if (yych <= '7') goto yy175; + goto yy161; } else { if (yych <= 'F') { - if (yych <= '@') goto yy157; - goto yy162; + if (yych <= '@') goto yy156; + goto yy161; } else { - if (yych <= '`') goto yy157; - if (yych <= 'f') goto yy162; - goto yy157; + if (yych <= '`') goto yy156; + if (yych <= 'f') goto yy161; + goto yy156; } } +yy158: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy156; + if (yych <= '9') goto yy161; + goto yy156; + } else { + if (yych <= 'F') goto yy161; + if (yych <= '`') goto yy156; + if (yych <= 'f') goto yy161; + goto yy156; + } yy159: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy157; - if (yych <= '9') goto yy162; - goto yy157; + if (yych <= '/') goto yy156; + if (yych <= '7') goto yy161; + if (yych >= ':') goto yy156; } else { - if (yych <= 'F') goto yy162; - if (yych <= '`') goto yy157; - if (yych <= 'f') goto yy162; - goto yy157; + if (yych <= 'B') goto yy160; + if (yych <= '`') goto yy156; + if (yych >= 'c') goto yy156; } yy160: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy157; - if (yych <= '7') goto yy162; - if (yych >= ':') goto yy157; + if (yych <= '/') goto yy156; + if (yych <= '9') goto yy165; + goto yy156; } else { - if (yych <= 'B') goto yy161; - if (yych <= '`') goto yy157; - if (yych >= 'c') goto yy157; + if (yych <= 'F') goto yy165; + if (yych <= '`') goto yy156; + if (yych <= 'f') goto yy165; + goto yy156; } yy161: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy157; - if (yych <= '9') goto yy166; - goto yy157; + if (yych <= '/') goto yy156; + if (yych >= ':') goto yy156; } else { - if (yych <= 'F') goto yy166; - if (yych <= '`') goto yy157; - if (yych <= 'f') goto yy166; - goto yy157; + if (yych <= 'F') goto yy162; + if (yych <= '`') goto yy156; + if (yych >= 'g') goto yy156; } yy162: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy157; - if (yych >= ':') goto yy157; + if (yych <= '/') goto yy156; + if (yych >= ':') goto yy156; } else { if (yych <= 'F') goto yy163; - if (yych <= '`') goto yy157; - if (yych >= 'g') goto yy157; + if (yych <= '`') goto yy156; + if (yych >= 'g') goto yy156; } yy163: - yych = *++YYCURSOR; - if (yych <= '@') { - if (yych <= '/') goto yy157; - if (yych >= ':') goto yy157; - } else { - if (yych <= 'F') goto yy164; - if (yych <= '`') goto yy157; - if (yych >= 'g') goto yy157; - } -yy164: ++YYCURSOR; { int utf16 = php_json_ucs2_to_int(s, 4); @@ -1194,51 +1195,51 @@ yy164: s->str_start = s->cursor; PHP_JSON_CONDITION_GOTO(STR_P2); } -yy166: +yy165: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy157; - if (yych >= ':') goto yy157; + if (yych <= '/') goto yy156; + if (yych >= ':') goto yy156; } else { - if (yych <= 'F') goto yy167; - if (yych <= '`') goto yy157; - if (yych >= 'g') goto yy157; + if (yych <= 'F') goto yy166; + if (yych <= '`') goto yy156; + if (yych >= 'g') goto yy156; } -yy167: +yy166: yych = *++YYCURSOR; - if (yych != '\\') goto yy157; + if (yych != '\\') goto yy156; yych = *++YYCURSOR; - if (yych != 'u') goto yy157; + if (yych != 'u') goto yy156; yych = *++YYCURSOR; - if (yych == 'D') goto yy170; - if (yych != 'd') goto yy157; -yy170: + if (yych == 'D') goto yy169; + if (yych != 'd') goto yy156; +yy169: yych = *++YYCURSOR; - if (yych <= 'B') goto yy157; - if (yych <= 'F') goto yy171; - if (yych <= 'b') goto yy157; - if (yych >= 'g') goto yy157; -yy171: + if (yych <= 'B') goto yy156; + if (yych <= 'F') goto yy170; + if (yych <= 'b') goto yy156; + if (yych >= 'g') goto yy156; +yy170: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy157; - if (yych >= ':') goto yy157; + if (yych <= '/') goto yy156; + if (yych >= ':') goto yy156; } else { - if (yych <= 'F') goto yy172; - if (yych <= '`') goto yy157; - if (yych >= 'g') goto yy157; + if (yych <= 'F') goto yy171; + if (yych <= '`') goto yy156; + if (yych >= 'g') goto yy156; } -yy172: +yy171: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy157; - if (yych >= ':') goto yy157; + if (yych <= '/') goto yy156; + if (yych >= ':') goto yy156; } else { - if (yych <= 'F') goto yy173; - if (yych <= '`') goto yy157; - if (yych >= 'g') goto yy157; + if (yych <= 'F') goto yy172; + if (yych <= '`') goto yy156; + if (yych >= 'g') goto yy156; } -yy173: +yy172: ++YYCURSOR; { int utf32, utf16_hi, utf16_lo; @@ -1253,40 +1254,40 @@ yy173: s->str_start = s->cursor; PHP_JSON_CONDITION_GOTO(STR_P2); } -yy175: +yy174: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy157; - if (yych <= '7') goto yy180; - if (yych <= '9') goto yy177; - goto yy157; + if (yych <= '/') goto yy156; + if (yych <= '7') goto yy179; + if (yych <= '9') goto yy176; + goto yy156; } else { - if (yych <= 'F') goto yy177; - if (yych <= '`') goto yy157; - if (yych <= 'f') goto yy177; - goto yy157; + if (yych <= 'F') goto yy176; + if (yych <= '`') goto yy156; + if (yych <= 'f') goto yy176; + goto yy156; } -yy176: +yy175: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy157; - if (yych >= ':') goto yy157; + if (yych <= '/') goto yy156; + if (yych >= ':') goto yy156; } else { - if (yych <= 'F') goto yy177; - if (yych <= '`') goto yy157; - if (yych >= 'g') goto yy157; + if (yych <= 'F') goto yy176; + if (yych <= '`') goto yy156; + if (yych >= 'g') goto yy156; } -yy177: +yy176: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy157; - if (yych >= ':') goto yy157; + if (yych <= '/') goto yy156; + if (yych >= ':') goto yy156; } else { - if (yych <= 'F') goto yy178; - if (yych <= '`') goto yy157; - if (yych >= 'g') goto yy157; + if (yych <= 'F') goto yy177; + if (yych <= '`') goto yy156; + if (yych >= 'g') goto yy156; } -yy178: +yy177: ++YYCURSOR; { int utf16 = php_json_ucs2_to_int(s, 3); @@ -1296,17 +1297,17 @@ yy178: s->str_start = s->cursor; PHP_JSON_CONDITION_GOTO(STR_P2); } -yy180: +yy179: yych = *++YYCURSOR; if (yych <= '@') { - if (yych <= '/') goto yy157; - if (yych >= ':') goto yy157; + if (yych <= '/') goto yy156; + if (yych >= ':') goto yy156; } else { - if (yych <= 'F') goto yy181; - if (yych <= '`') goto yy157; - if (yych >= 'g') goto yy157; + if (yych <= 'F') goto yy180; + if (yych <= '`') goto yy156; + if (yych >= 'g') goto yy156; } -yy181: +yy180: ++YYCURSOR; { int utf16 = php_json_ucs2_to_int(s, 2); diff --git a/ext/json/json_scanner.re b/ext/json/json_scanner.re index 1a8a68dca8..eae6325f0a 100644 --- a/ext/json/json_scanner.re +++ b/ext/json/json_scanner.re @@ -254,7 +254,7 @@ std: return PHP_JSON_T_ESTRING; } str = zend_string_alloc(len, 0); - str->val[len] = '\0'; + ZSTR_VAL(str)[len] = '\0'; ZVAL_STR(&s->value, str); if (s->str_esc) { s->pstr = (php_json_ctype *) Z_STRVAL(s->value); diff --git a/ext/json/php_json_scanner_defs.h b/ext/json/php_json_scanner_defs.h index a75e766a65..b3867433a7 100644 --- a/ext/json/php_json_scanner_defs.h +++ b/ext/json/php_json_scanner_defs.h @@ -1,4 +1,4 @@ -/* Generated by re2c 0.14.3 */ +/* Generated by re2c 0.13.5 */ enum YYCONDTYPE { yycJS, diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index bb87a389b4..edb1d3119a 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -551,17 +551,17 @@ static void php_libxml_internal_error_handler(int error_type, void *ctx, const c if (output == 1) { if (LIBXML(error_list)) { - _php_list_set_error_structure(NULL, LIBXML(error_buffer).s->val); + _php_list_set_error_structure(NULL, ZSTR_VAL(LIBXML(error_buffer).s)); } else { switch (error_type) { case PHP_LIBXML_CTX_ERROR: - php_libxml_ctx_error_level(E_WARNING, ctx, LIBXML(error_buffer).s->val); + php_libxml_ctx_error_level(E_WARNING, ctx, ZSTR_VAL(LIBXML(error_buffer).s)); break; case PHP_LIBXML_CTX_WARNING: - php_libxml_ctx_error_level(E_NOTICE, ctx, LIBXML(error_buffer).s->val); + php_libxml_ctx_error_level(E_NOTICE, ctx, ZSTR_VAL(LIBXML(error_buffer).s)); break; default: - php_error_docref(NULL, E_WARNING, "%s", LIBXML(error_buffer).s->val); + php_error_docref(NULL, E_WARNING, "%s", ZSTR_VAL(LIBXML(error_buffer).s)); } } smart_str_free(&LIBXML(error_buffer)); diff --git a/ext/mbstring/mb_gpc.c b/ext/mbstring/mb_gpc.c index fd1cdc505d..db6b5c47cd 100644 --- a/ext/mbstring/mb_gpc.c +++ b/ext/mbstring/mb_gpc.c @@ -377,7 +377,7 @@ SAPI_POST_HANDLER_FUNC(php_mb_post_handler) php_stream_rewind(SG(request_info).request_body); post_data_str = php_stream_copy_to_mem(SG(request_info).request_body, PHP_STREAM_COPY_ALL, 0); - detected = _php_mb_encoding_handler_ex(&info, arg, post_data_str->val); + detected = _php_mb_encoding_handler_ex(&info, arg, ZSTR_VAL(post_data_str)); zend_string_release(post_data_str); MBSTRG(http_input_identify) = detected; diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 8ade984ffb..ea753b9406 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -1205,7 +1205,7 @@ static PHP_INI_MH(OnUpdate_mbstring_language) { enum mbfl_no_language no_language; - no_language = mbfl_name2no_language(new_value->val); + no_language = mbfl_name2no_language(ZSTR_VAL(new_value)); if (no_language == mbfl_no_language_invalid) { MBSTRG(language) = mbfl_no_language_neutral; return FAILURE; @@ -1231,7 +1231,7 @@ static PHP_INI_MH(OnUpdate_mbstring_detect_order) return SUCCESS; } - if (FAILURE == php_mb_parse_encoding_list(new_value->val, new_value->len, &list, &size, 1)) { + if (FAILURE == php_mb_parse_encoding_list(ZSTR_VAL(new_value), ZSTR_LEN(new_value), &list, &size, 1)) { return FAILURE; } @@ -1264,7 +1264,7 @@ static PHP_INI_MH(OnUpdate_mbstring_http_input) return SUCCESS; } - if (FAILURE == php_mb_parse_encoding_list(new_value->val, new_value->len, &list, &size, 1)) { + if (FAILURE == php_mb_parse_encoding_list(ZSTR_VAL(new_value), ZSTR_LEN(new_value), &list, &size, 1)) { return FAILURE; } @@ -1287,7 +1287,7 @@ static PHP_INI_MH(OnUpdate_mbstring_http_output) { const mbfl_encoding *encoding; - if (new_value == NULL || new_value->len == 0) { + if (new_value == NULL || ZSTR_LEN(new_value) == 0) { encoding = mbfl_name2encoding(get_output_encoding()); if (!encoding) { MBSTRG(http_output_encoding) = &mbfl_encoding_pass; @@ -1295,7 +1295,7 @@ static PHP_INI_MH(OnUpdate_mbstring_http_output) return SUCCESS; } } else { - encoding = mbfl_name2encoding(new_value->val); + encoding = mbfl_name2encoding(ZSTR_VAL(new_value)); if (!encoding) { MBSTRG(http_output_encoding) = &mbfl_encoding_pass; MBSTRG(current_http_output_encoding) = &mbfl_encoding_pass; @@ -1351,8 +1351,8 @@ static PHP_INI_MH(OnUpdate_mbstring_internal_encoding) } if (stage & (PHP_INI_STAGE_STARTUP | PHP_INI_STAGE_SHUTDOWN | PHP_INI_STAGE_RUNTIME)) { - if (new_value && new_value->len) { - return _php_mb_ini_mbstring_internal_encoding_set(new_value->val, new_value->len); + if (new_value && ZSTR_LEN(new_value)) { + return _php_mb_ini_mbstring_internal_encoding_set(ZSTR_VAL(new_value), ZSTR_LEN(new_value)); } else { return _php_mb_ini_mbstring_internal_encoding_set(get_internal_encoding(), strlen(get_internal_encoding())+1); } @@ -1375,20 +1375,20 @@ static PHP_INI_MH(OnUpdate_mbstring_substitute_character) char *endptr = NULL; if (new_value != NULL) { - if (strcasecmp("none", new_value->val) == 0) { + if (strcasecmp("none", ZSTR_VAL(new_value)) == 0) { MBSTRG(filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE; MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE; - } else if (strcasecmp("long", new_value->val) == 0) { + } else if (strcasecmp("long", ZSTR_VAL(new_value)) == 0) { MBSTRG(filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG; MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG; - } else if (strcasecmp("entity", new_value->val) == 0) { + } else if (strcasecmp("entity", ZSTR_VAL(new_value)) == 0) { MBSTRG(filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY; MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY; } else { MBSTRG(filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR; MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR; - if (new_value->len >0) { - c = strtol(new_value->val, &endptr, 0); + if (ZSTR_LEN(new_value) > 0) { + c = strtol(ZSTR_VAL(new_value), &endptr, 0); if (*endptr == '\0') { MBSTRG(filter_illegal_substchar) = c; MBSTRG(current_filter_illegal_substchar) = c; @@ -1438,8 +1438,8 @@ static PHP_INI_MH(OnUpdate_mbstring_http_output_conv_mimetypes) } tmp = php_trim(new_value, NULL, 0, 3); - if (tmp->len > 0) { - if (!(re = _php_mb_compile_regex(tmp->val))) { + if (ZSTR_LEN(tmp) > 0) { + if (!(re = _php_mb_compile_regex(ZSTR_VAL(tmp)))) { zend_string_release(tmp); return FAILURE; } @@ -1751,7 +1751,7 @@ PHP_FUNCTION(mb_language) } else { zend_string *ini_name = zend_string_init("mbstring.language", sizeof("mbstring.language") - 1, 0); if (FAILURE == zend_alter_ini_entry(ini_name, name, PHP_INI_USER, PHP_INI_STAGE_RUNTIME)) { - php_error_docref(NULL, E_WARNING, "Unknown language \"%s\"", name->val); + php_error_docref(NULL, E_WARNING, "Unknown language \"%s\"", ZSTR_VAL(name)); RETVAL_FALSE; } else { RETVAL_TRUE; @@ -3994,7 +3994,7 @@ static int _php_mbstr_parse_mail_headers(HashTable *ht, const char *str, size_t zval val; /* FIXME: some locale free implementation is * really required here,,, */ - php_strtoupper(fld_name->val, fld_name->len); + php_strtoupper(ZSTR_VAL(fld_name), ZSTR_LEN(fld_name)); ZVAL_STR(&val, fld_val); zend_hash_update(ht, fld_name, &val); @@ -4042,7 +4042,7 @@ out: zval val; /* FIXME: some locale free implementation is * really required here,,, */ - php_strtoupper(fld_name->val, fld_name->len); + php_strtoupper(ZSTR_VAL(fld_name), ZSTR_LEN(fld_name)); ZVAL_STR(&val, fld_val); zend_hash_update(ht, fld_name, &val); @@ -4116,7 +4116,7 @@ PHP_FUNCTION(mb_send_mail) MAIL_ASCIIZ_CHECK_MBSTRING(headers, headers_len); } if (extra_cmd) { - MAIL_ASCIIZ_CHECK_MBSTRING(extra_cmd->val, extra_cmd->len); + MAIL_ASCIIZ_CHECK_MBSTRING(ZSTR_VAL(extra_cmd), ZSTR_LEN(extra_cmd)); } zend_hash_init(&ht_headers, 0, NULL, ZVAL_PTR_DTOR, 0); @@ -4304,10 +4304,10 @@ PHP_FUNCTION(mb_send_mail) if (force_extra_parameters) { extra_cmd = php_escape_shell_cmd(force_extra_parameters); } else if (extra_cmd) { - extra_cmd = php_escape_shell_cmd(extra_cmd->val); + extra_cmd = php_escape_shell_cmd(ZSTR_VAL(extra_cmd)); } - if (!err && php_mail(to_r, subject, message, headers, extra_cmd ? extra_cmd->val : NULL)) { + if (!err && php_mail(to_r, subject, message, headers, extra_cmd ? ZSTR_VAL(extra_cmd) : NULL)) { RETVAL_TRUE; } else { RETVAL_FALSE; diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 783a8c98a5..88f8772d34 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -941,9 +941,9 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp /* null terminate buffer */ smart_str_0(&eval_buf); /* do eval */ - if (zend_eval_stringl(eval_buf.s->val, eval_buf.s->len, &v, description) == FAILURE) { + if (zend_eval_stringl(ZSTR_VAL(eval_buf.s), ZSTR_LEN(eval_buf.s), &v, description) == FAILURE) { efree(description); - php_error_docref(NULL,E_ERROR, "Failed evaluating code: %s%s", PHP_EOL, eval_buf.s->val); + php_error_docref(NULL,E_ERROR, "Failed evaluating code: %s%s", PHP_EOL, ZSTR_VAL(eval_buf.s)); /* zend_error() does not return in this case */ } @@ -951,7 +951,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp convert_to_string(&v); smart_str_appendl(&out_buf, Z_STRVAL(v), Z_STRLEN(v)); /* Clean up */ - eval_buf.s->len = 0; + ZSTR_LEN(eval_buf.s) = 0; zval_dtor(&v); } else if (is_callable) { zval args[1]; @@ -975,7 +975,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp convert_to_string_ex(&retval); smart_str_appendl(&out_buf, Z_STRVAL(retval), Z_STRLEN(retval)); if (eval_buf.s) { - eval_buf.s->len = 0; + ZSTR_LEN(eval_buf.s) = 0; } zval_ptr_dtor(&retval); } else { diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index 3efe5d2f78..ede27414f4 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -467,8 +467,8 @@ PHP_MINFO_FUNCTION(mcrypt) /* {{{ */ php_info_print_table_header(2, "mcrypt_filter support", "enabled"); php_info_print_table_row(2, "Version", LIBMCRYPT_VERSION); php_info_print_table_row(2, "Api No", mcrypt_api_no); - php_info_print_table_row(2, "Supported ciphers", tmp1.s->val); - php_info_print_table_row(2, "Supported modes", tmp2.s->val); + php_info_print_table_row(2, "Supported ciphers", ZSTR_VAL(tmp1.s)); + php_info_print_table_row(2, "Supported modes", ZSTR_VAL(tmp2.s)); smart_str_free(&tmp1); smart_str_free(&tmp2); @@ -1140,7 +1140,7 @@ static char *php_mcrypt_get_key_size_str( smart_str_appends(&str, " supported"); smart_str_0(&str); - result = estrndup(str.s->val, str.s->len); + result = estrndup(ZSTR_VAL(str.s), ZSTR_LEN(str.s)); smart_str_free(&str); return result; diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index d076614418..c7f7ed061b 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -496,7 +496,7 @@ static MYSQLND *mysqli_convert_zv_to_mysqlnd(zval * zv) mysqli_object *intern = Z_MYSQLI_P(zv); if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) { /* We know that we have a mysqli object, so this failure should be emitted */ - php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", intern->zo.ce->name->val); + php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(intern->zo.ce->name)); return NULL; } mysql = (MY_MYSQL *)(my_res->ptr); @@ -1245,7 +1245,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags ce = zend_fetch_class(class_name, ZEND_FETCH_CLASS_AUTO); } if (!ce) { - php_error_docref(NULL, E_WARNING, "Could not find class '%s'", class_name->val); + php_error_docref(NULL, E_WARNING, "Could not find class '%s'", ZSTR_VAL(class_name)); return; } fetchtype = MYSQLI_ASSOC; @@ -1319,7 +1319,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags fcc.object = Z_OBJ_P(return_value); if (zend_call_function(&fci, &fcc) == FAILURE) { - zend_throw_exception_ex(zend_exception_get_default(), 0, "Could not execute %s::%s()", ce->name->val, ce->constructor->common.function_name->val); + zend_throw_exception_ex(zend_exception_get_default(), 0, "Could not execute %s::%s()", ZSTR_VAL(ce->name), ZSTR_VAL(ce->constructor->common.function_name)); } else { zval_ptr_dtor(&retval); } @@ -1327,7 +1327,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags efree(fci.params); } } else if (ctor_params) { - zend_throw_exception_ex(zend_exception_get_default(), 0, "Class %s does not have a constructor hence you cannot use ctor_params", ce->name->val); + zend_throw_exception_ex(zend_exception_get_default(), 0, "Class %s does not have a constructor hence you cannot use ctor_params", ZSTR_VAL(ce->name)); } } } diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index f52884f12c..365e37cc20 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -1967,8 +1967,8 @@ PHP_FUNCTION(mysqli_real_escape_string) { MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID); newstr = zend_string_alloc(2 * escapestr_len, 0); - newstr->len = mysql_real_escape_string(mysql->mysql, newstr->val, escapestr, escapestr_len); - newstr = zend_string_truncate(newstr, newstr->len, 0); + ZSTR_LEN(newstr) = mysql_real_escape_string(mysql->mysql, ZSTR_VAL(newstr), escapestr, escapestr_len); + newstr = zend_string_truncate(newstr, ZSTR_LEN(newstr), 0); RETURN_NEW_STR(newstr); } diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index 05d6ef7c7c..99e7006b1a 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -195,7 +195,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne le.ptr = plist = calloc(1, sizeof(mysqli_plist_entry)); zend_ptr_stack_init_ex(&plist->free_links, 1); - zend_hash_str_update_mem(&EG(persistent_list), hash_key->val, hash_key->len, &le, sizeof(le)); + zend_hash_str_update_mem(&EG(persistent_list), ZSTR_VAL(hash_key), ZSTR_LEN(hash_key), &le, sizeof(le)); } } } @@ -653,12 +653,12 @@ static int mysqlnd_zval_array_to_mysqlnd_array(zval *in_array, MYSQLND ***out_ar MYSQLI_RESOURCE *my_res; mysqli_object *intern = Z_MYSQLI_P(elem); if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) { - php_error_docref(NULL, E_WARNING, "[%d] Couldn't fetch %s", i, intern->zo.ce->name->val); + php_error_docref(NULL, E_WARNING, "[%d] Couldn't fetch %s", i, ZSTR_VAL(intern->zo.ce->name)); continue; } mysql = (MY_MYSQL*) my_res->ptr; if (MYSQLI_STATUS_VALID && my_res->status < MYSQLI_STATUS_VALID) { - php_error_docref(NULL, E_WARNING, "Invalid object %d or resource %s", i, intern->zo.ce->name->val); + php_error_docref(NULL, E_WARNING, "Invalid object %d or resource %s", i, ZSTR_VAL(intern->zo.ce->name)); continue; } (*out_array)[current++] = mysql->mysql; @@ -689,7 +689,7 @@ static int mysqlnd_zval_array_from_mysqlnd_array(MYSQLND **in_array, zval *out_a MYSQLI_RESOURCE *my_res; mysqli_object *intern = Z_MYSQLI_P(elem); if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) { - php_error_docref(NULL, E_WARNING, "[%d] Couldn't fetch %s", i, intern->zo.ce->name->val); + php_error_docref(NULL, E_WARNING, "[%d] Couldn't fetch %s", i, ZSTR_VAL(intern->zo.ce->name)); continue; } mysql = (MY_MYSQL *) my_res->ptr; @@ -1055,7 +1055,7 @@ static int mysqli_begin_transaction_libmysql(MYSQL * conn, const unsigned int mo char * name_esc = mysqli_escape_string_for_tx_name_in_comment(name); char * query; unsigned int query_len = spprintf(&query, 0, "START TRANSACTION%s %s", - name_esc? name_esc:"", tmp_str.s? tmp_str.s->val:""); + name_esc? name_esc:"", tmp_str.s? ZSTR_VAL(tmp_str.s):""); smart_str_free(&tmp_str); if (name_esc) { diff --git a/ext/mysqli/mysqli_prop.c b/ext/mysqli/mysqli_prop.c index 95ef07cb0a..11f136e603 100644 --- a/ext/mysqli/mysqli_prop.c +++ b/ext/mysqli/mysqli_prop.c @@ -41,7 +41,7 @@ #define MYSQLI_GET_MYSQL(statusval) \ MYSQL *p; \ if (!obj->ptr || !(MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr) { \ - php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name->val);\ + php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));\ ZVAL_NULL(retval);\ return retval; \ } else { \ @@ -52,7 +52,7 @@ if (!obj->ptr || !(MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr) { \ #define MYSQLI_GET_RESULT(statusval) \ MYSQL_RES *p; \ if (!obj->ptr) { \ - php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name->val);\ + php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));\ ZVAL_NULL(retval);\ return retval; \ } else { \ @@ -64,7 +64,7 @@ if (!obj->ptr) { \ #define MYSQLI_GET_STMT(statusval) \ MYSQL_STMT *p; \ if (!obj->ptr) { \ - php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name->val);\ + php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));\ ZVAL_NULL(retval);\ return retval; \ } else { \ diff --git a/ext/mysqli/php_mysqli_structs.h b/ext/mysqli/php_mysqli_structs.h index 055765197d..5d4bb049f8 100644 --- a/ext/mysqli/php_mysqli_structs.h +++ b/ext/mysqli/php_mysqli_structs.h @@ -259,12 +259,12 @@ extern PHPAPI zend_class_entry *spl_ce_RuntimeException; MYSQLI_RESOURCE *my_res; \ mysqli_object *intern = Z_MYSQLI_P(__id); \ if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) {\ - php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", intern->zo.ce->name->val);\ + php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(intern->zo.ce->name));\ RETURN_NULL();\ }\ __ptr = (__type)my_res->ptr; \ if (__check && my_res->status < __check) { \ - php_error_docref(NULL, E_WARNING, "invalid object or resource %s\n", intern->zo.ce->name->val); \ + php_error_docref(NULL, E_WARNING, "invalid object or resource %s\n", ZSTR_VAL(intern->zo.ce->name)); \ RETURN_NULL();\ }\ } @@ -273,12 +273,12 @@ extern PHPAPI zend_class_entry *spl_ce_RuntimeException; { \ MYSQLI_RESOURCE *my_res; \ if (!(my_res = (MYSQLI_RESOURCE *)(__obj->ptr))) {\ - php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", intern->zo.ce->name->val);\ + php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(intern->zo.ce->name));\ return;\ }\ __ptr = (__type)my_res->ptr; \ if (__check && my_res->status < __check) { \ - php_error_docref(NULL, E_WARNING, "invalid object or resource %s\n", intern->zo.ce->name->val); \ + php_error_docref(NULL, E_WARNING, "invalid object or resource %s\n", ZSTR_VAL(intern->zo.ce->name)); \ return;\ }\ } @@ -288,7 +288,7 @@ extern PHPAPI zend_class_entry *spl_ce_RuntimeException; MYSQLI_FETCH_RESOURCE((__ptr), MY_MYSQL *, (__id), "mysqli_link", (__check)); \ if (!(__ptr)->mysql) { \ mysqli_object *intern = Z_MYSQLI_P(__id); \ - php_error_docref(NULL, E_WARNING, "invalid object or resource %s\n", intern->zo.ce->name->val); \ + php_error_docref(NULL, E_WARNING, "invalid object or resource %s\n", ZSTR_VAL(intern->zo.ce->name)); \ RETURN_NULL(); \ } \ } @@ -298,7 +298,7 @@ extern PHPAPI zend_class_entry *spl_ce_RuntimeException; MYSQLI_FETCH_RESOURCE((__ptr), MY_STMT *, (__id), "mysqli_stmt", (__check)); \ if (!(__ptr)->stmt) { \ mysqli_object *intern = Z_MYSQLI_P(__id); \ - php_error_docref(NULL, E_WARNING, "invalid object or resource %s\n", intern->zo.ce->name->val); \ + php_error_docref(NULL, E_WARNING, "invalid object or resource %s\n", ZSTR_VAL(intern->zo.ce->name)); \ RETURN_NULL();\ } \ } diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index 227c420d16..0a81d0bb96 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -1750,7 +1750,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, statistic)(MYSQLND_CONN_DATA * conn, zend_stri if (PASS == (ret = PACKET_READ(stats_header, conn))) { /* will be freed by Zend, thus don't use the mnd_ allocator */ *message = zend_string_init(stats_header->message, stats_header->message_len, 0); - DBG_INF((*message)->val); + DBG_INF(ZSTR_VAL(*message)); } PACKET_FREE(stats_header); } while (0); @@ -2665,24 +2665,24 @@ static void MYSQLND_METHOD(mysqlnd_conn_data, tx_cor_options_to_string)(const MYSQLND_CONN_DATA * const conn, smart_str * str, const unsigned int mode) { if (mode & TRANS_COR_AND_CHAIN && !(mode & TRANS_COR_AND_NO_CHAIN)) { - if (str->s && str->s->len) { + if (str->s && ZSTR_LEN(str->s)) { smart_str_appendl(str, " ", sizeof(" ") - 1); } smart_str_appendl(str, "AND CHAIN", sizeof("AND CHAIN") - 1); } else if (mode & TRANS_COR_AND_NO_CHAIN && !(mode & TRANS_COR_AND_CHAIN)) { - if (str->s && str->s->len) { + if (str->s && ZSTR_LEN(str->s)) { smart_str_appendl(str, " ", sizeof(" ") - 1); } smart_str_appendl(str, "AND NO CHAIN", sizeof("AND NO CHAIN") - 1); } if (mode & TRANS_COR_RELEASE && !(mode & TRANS_COR_NO_RELEASE)) { - if (str->s && str->s->len) { + if (str->s && ZSTR_LEN(str->s)) { smart_str_appendl(str, " ", sizeof(" ") - 1); } smart_str_appendl(str, "RELEASE", sizeof("RELEASE") - 1); } else if (mode & TRANS_COR_NO_RELEASE && !(mode & TRANS_COR_RELEASE)) { - if (str->s && str->s->len) { + if (str->s && ZSTR_LEN(str->s)) { smart_str_appendl(str, " ", sizeof(" ") - 1); } smart_str_appendl(str, "NO RELEASE", sizeof("NO RELEASE") - 1); @@ -2756,7 +2756,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, tx_commit_or_rollback)(MYSQLND_CONN_DATA * con char * name_esc = mysqlnd_escape_string_for_tx_name_in_comment(name); query_len = mnd_sprintf(&query, 0, (commit? "COMMIT%s %s":"ROLLBACK%s %s"), - name_esc? name_esc:"", tmp_str.s? tmp_str.s->val:""); + name_esc? name_esc:"", tmp_str.s? ZSTR_VAL(tmp_str.s):""); smart_str_free(&tmp_str); if (name_esc) { mnd_efree(name_esc); @@ -2803,12 +2803,12 @@ MYSQLND_METHOD(mysqlnd_conn_data, tx_begin)(MYSQLND_CONN_DATA * conn, const unsi smart_str_free(&tmp_str); break; } else if (mode & TRANS_START_READ_WRITE) { - if (tmp_str.s && tmp_str.s->len) { + if (tmp_str.s && ZSTR_LEN(tmp_str.s)) { smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1); } smart_str_appendl(&tmp_str, "READ WRITE", sizeof("READ WRITE") - 1); } else if (mode & TRANS_START_READ_ONLY) { - if (tmp_str.s && tmp_str.s->len) { + if (tmp_str.s && ZSTR_LEN(tmp_str.s)) { smart_str_appendl(&tmp_str, ", ", sizeof(", ") - 1); } smart_str_appendl(&tmp_str, "READ ONLY", sizeof("READ ONLY") - 1); @@ -2819,7 +2819,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, tx_begin)(MYSQLND_CONN_DATA * conn, const unsi { char * name_esc = mysqlnd_escape_string_for_tx_name_in_comment(name); char * query; - unsigned int query_len = mnd_sprintf(&query, 0, "START TRANSACTION%s %s", name_esc? name_esc:"", tmp_str.s? tmp_str.s->val:""); + unsigned int query_len = mnd_sprintf(&query, 0, "START TRANSACTION%s %s", name_esc? name_esc:"", tmp_str.s? ZSTR_VAL(tmp_str.s):""); smart_str_free(&tmp_str); if (name_esc) { mnd_efree(name_esc); diff --git a/ext/mysqlnd/mysqlnd_alloc.c b/ext/mysqlnd/mysqlnd_alloc.c index 7be3ba79b8..c28044ca7f 100644 --- a/ext/mysqlnd/mysqlnd_alloc.c +++ b/ext/mysqlnd/mysqlnd_alloc.c @@ -597,11 +597,11 @@ char * _mysqlnd_pestrdup(const char * const ptr, zend_bool persistent MYSQLND_ME smart_str_appendc(&tmp_str, *p); } while (*p++); - ret = (persistent) ? __zend_malloc(tmp_str.s->len + sizeof(size_t)) : _emalloc(REAL_SIZE(tmp_str.s->len + sizeof(size_t)) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC); - memcpy(FAKE_PTR(ret), tmp_str.s->val, tmp_str.s->len); + ret = (persistent) ? __zend_malloc(ZSTR_LEN(tmp_str.s) + sizeof(size_t)) : _emalloc(REAL_SIZE(ZSTR_LEN(tmp_str.s) + sizeof(size_t)) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC); + memcpy(FAKE_PTR(ret), ZSTR_VAL(tmp_str.s), ZSTR_LEN(tmp_str.s)); if (ret && collect_memory_statistics) { - *(size_t *) ret = tmp_str.s->len; + *(size_t *) ret = ZSTR_LEN(tmp_str.s); MYSQLND_INC_GLOBAL_STATISTIC(persistent? STAT_MEM_STRDUP_COUNT : STAT_MEM_ESTRDUP_COUNT); } smart_str_free(&tmp_str); diff --git a/ext/mysqlnd/mysqlnd_auth.c b/ext/mysqlnd/mysqlnd_auth.c index 2ecdd95ede..e4632496f9 100644 --- a/ext/mysqlnd/mysqlnd_auth.c +++ b/ext/mysqlnd/mysqlnd_auth.c @@ -548,11 +548,11 @@ mysqlnd_sha256_get_rsa_key(MYSQLND_CONN_DATA * conn, if (stream) { if ((key_str = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0)) != NULL) { - BIO * bio = BIO_new_mem_buf(key_str->val, key_str->len); + BIO * bio = BIO_new_mem_buf(ZSTR_VAL(key_str), ZSTR_LEN(key_str)); ret = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL); BIO_free(bio); DBG_INF("Successfully loaded"); - DBG_INF_FMT("Public key:%*.s", key_str->len, key_str->val); + DBG_INF_FMT("Public key:%*.s", ZSTR_LEN(key_str), ZSTR_VAL(key_str)); zend_string_release(key_str); } php_stream_close(stream); diff --git a/ext/mysqlnd/mysqlnd_debug.c b/ext/mysqlnd/mysqlnd_debug.c index 790ac00cec..886a6d8ac6 100644 --- a/ext/mysqlnd/mysqlnd_debug.c +++ b/ext/mysqlnd/mysqlnd_debug.c @@ -440,7 +440,7 @@ MYSQLND_METHOD(mysqlnd_debug, close)(MYSQLND_DEBUG * self) " min_own=%5llu max_own=%7llu avg_own=%7llu " " min_in_calls=%5llu max_in_calls=%7llu avg_in_calls=%7llu" " min_total=%5llu max_total=%7llu avg_total=%7llu" - ,string_key->val + ,ZSTR_VAL(string_key) ,(uint64_t) f_profile->calls ,(uint64_t) f_profile->own_underporm_calls ,(uint64_t) f_profile->in_calls_underporm_calls diff --git a/ext/mysqlnd/mysqlnd_net.c b/ext/mysqlnd/mysqlnd_net.c index b837f880f6..bcd40d7ab6 100644 --- a/ext/mysqlnd/mysqlnd_net.c +++ b/ext/mysqlnd/mysqlnd_net.c @@ -190,7 +190,7 @@ MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix)(MYSQLND_NET * const net, const cha mnd_sprintf_free(hashed_details); } errcode = CR_CONNECTION_ERROR; - SET_CLIENT_ERROR(*error_info, errcode? errcode:CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, errstr->val); + SET_CLIENT_ERROR(*error_info, errcode? errcode:CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, ZSTR_VAL(errstr)); if (errstr) { /* no mnd_ since we don't allocate it */ zend_string_release(errstr); diff --git a/ext/mysqlnd/mysqlnd_result_meta.c b/ext/mysqlnd/mysqlnd_result_meta.c index d0ac30b7ad..154d05357f 100644 --- a/ext/mysqlnd/mysqlnd_result_meta.c +++ b/ext/mysqlnd/mysqlnd_result_meta.c @@ -227,8 +227,8 @@ MYSQLND_METHOD(mysqlnd_res_meta, clone_metadata)(const MYSQLND_RES_METADATA * co if (orig_fields[i].sname) { new_fields[i].sname = zend_string_copy(orig_fields[i].sname); - new_fields[i].name = new_fields[i].sname->val; - new_fields[i].name_length = new_fields[i].sname->len; + new_fields[i].name = ZSTR_VAL(new_fields[i].sname); + new_fields[i].name_length = ZSTR_LEN(new_fields[i].sname); } if (orig_fields[i].org_name && orig_fields[i].org_name != mysqlnd_empty_string) { diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c index 5e9c68d380..70e0cf3d55 100644 --- a/ext/mysqlnd/mysqlnd_wireprotocol.c +++ b/ext/mysqlnd/mysqlnd_wireprotocol.c @@ -588,8 +588,8 @@ size_t php_mysqlnd_auth_write(void * _packet, MYSQLND_CONN_DATA * conn) if (key) { /* HASH_KEY_IS_STRING */ size_t value_len = Z_STRLEN_P(entry_value); - ca_payload_len += php_mysqlnd_net_store_length_size(key->len); - ca_payload_len += key->len; + ca_payload_len += php_mysqlnd_net_store_length_size(ZSTR_LEN(key)); + ca_payload_len += ZSTR_LEN(key); ca_payload_len += php_mysqlnd_net_store_length_size(value_len); ca_payload_len += value_len; } @@ -628,9 +628,9 @@ size_t php_mysqlnd_auth_write(void * _packet, MYSQLND_CONN_DATA * conn) size_t value_len = Z_STRLEN_P(entry_value); /* copy key */ - p = php_mysqlnd_net_store_length(p, key->len); - memcpy(p, key->val, key->len); - p+= key->len; + p = php_mysqlnd_net_store_length(p, ZSTR_LEN(key)); + memcpy(p, ZSTR_VAL(key), ZSTR_LEN(key)); + p+= ZSTR_LEN(key); /* copy value */ p = php_mysqlnd_net_store_length(p, value_len); memcpy(p, Z_STRVAL_P(entry_value), value_len); @@ -1360,8 +1360,8 @@ php_mysqlnd_rset_field_read(void * _packet, MYSQLND_CONN_DATA * conn) } else { meta->sname = ZSTR_EMPTY_ALLOC(); } - meta->name = meta->sname->val; - meta->name_length = meta->sname->len; + meta->name = ZSTR_VAL(meta->sname); + meta->name_length = ZSTR_LEN(meta->sname); /* Now do allocs */ if (meta->catalog && meta->catalog != mysqlnd_empty_string) { diff --git a/ext/mysqlnd/php_mysqlnd.c b/ext/mysqlnd/php_mysqlnd.c index f90f31980e..5f1bf05217 100644 --- a/ext/mysqlnd/php_mysqlnd.c +++ b/ext/mysqlnd/php_mysqlnd.c @@ -48,7 +48,7 @@ mysqlnd_minfo_print_hash(zval *values) ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(values), string_key, values_entry) { convert_to_string(values_entry); - php_info_print_table_row(2, string_key->val, Z_STRVAL_P(values_entry)); + php_info_print_table_row(2, ZSTR_VAL(string_key), Z_STRVAL_P(values_entry)); } ZEND_HASH_FOREACH_END(); } /* }}} */ @@ -154,12 +154,12 @@ PHP_MINFO_FUNCTION(mysqlnd) smart_str tmp_str = {0}; mysqlnd_plugin_apply_with_argument(mysqlnd_minfo_dump_loaded_plugins, &tmp_str); smart_str_0(&tmp_str); - php_info_print_table_row(2, "Loaded plugins", tmp_str.s? tmp_str.s->val : ""); + php_info_print_table_row(2, "Loaded plugins", tmp_str.s? ZSTR_VAL(tmp_str.s) : ""); smart_str_free(&tmp_str); mysqlnd_minfo_dump_api_plugins(&tmp_str); smart_str_0(&tmp_str); - php_info_print_table_row(2, "API Extensions", tmp_str.s? tmp_str.s->val : ""); + php_info_print_table_row(2, "API Extensions", tmp_str.s? ZSTR_VAL(tmp_str.s) : ""); smart_str_free(&tmp_str); } @@ -211,7 +211,7 @@ static PHP_INI_MH(OnUpdateNetCmdBufferSize) { zend_long long_value; - ZEND_ATOL(long_value, new_value->val); + ZEND_ATOL(long_value, ZSTR_VAL(new_value)); if (long_value < MYSQLND_NET_CMD_BUFFER_MIN_SIZE) { return FAILURE; } diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c index 8b85422d2f..f4753ed080 100644 --- a/ext/opcache/Optimizer/block_pass.c +++ b/ext/opcache/Optimizer/block_pass.c @@ -38,11 +38,11 @@ int zend_optimizer_get_persistent_constant(zend_string *name, zval *result, int ALLOCA_FLAG(use_heap); if ((c = zend_hash_find_ptr(EG(zend_constants), name)) == NULL) { - lookup_name = DO_ALLOCA(name->len + 1); - memcpy(lookup_name, name->val, name->len + 1); - zend_str_tolower(lookup_name, name->len); + lookup_name = DO_ALLOCA(ZSTR_LEN(name) + 1); + memcpy(lookup_name, ZSTR_VAL(name), ZSTR_LEN(name) + 1); + zend_str_tolower(lookup_name, ZSTR_LEN(name)); - if ((c = zend_hash_str_find_ptr(EG(zend_constants), lookup_name, name->len)) != NULL) { + if ((c = zend_hash_str_find_ptr(EG(zend_constants), lookup_name, ZSTR_LEN(name))) != NULL) { if (!(c->flags & CONST_CT_SUBST) || (c->flags & CONST_CS)) { retval = 0; } @@ -906,7 +906,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array, l = old_len + Z_STRLEN(ZEND_OP1_LITERAL(opline)); if (!Z_REFCOUNTED(ZEND_OP1_LITERAL(last_op))) { zend_string *tmp = zend_string_alloc(l, 0); - memcpy(tmp->val, Z_STRVAL(ZEND_OP1_LITERAL(last_op)), old_len); + memcpy(ZSTR_VAL(tmp), Z_STRVAL(ZEND_OP1_LITERAL(last_op)), old_len); Z_STR(ZEND_OP1_LITERAL(last_op)) = tmp; } else { Z_STR(ZEND_OP1_LITERAL(last_op)) = zend_string_extend(Z_STR(ZEND_OP1_LITERAL(last_op)), l, 0); @@ -946,7 +946,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array, l = old_len + Z_STRLEN(ZEND_OP2_LITERAL(opline)); if (!Z_REFCOUNTED(ZEND_OP2_LITERAL(src))) { zend_string *tmp = zend_string_alloc(l, 0); - memcpy(tmp->val, Z_STRVAL(ZEND_OP2_LITERAL(src)), old_len); + memcpy(ZSTR_VAL(tmp), Z_STRVAL(ZEND_OP2_LITERAL(src)), old_len); Z_STR(ZEND_OP2_LITERAL(last_op)) = tmp; } else { Z_STR(ZEND_OP2_LITERAL(src)) = zend_string_extend(Z_STR(ZEND_OP2_LITERAL(src)), l, 0); diff --git a/ext/opcache/Optimizer/compact_literals.c b/ext/opcache/Optimizer/compact_literals.c index deae12cdbb..812f24fe8f 100644 --- a/ext/opcache/Optimizer/compact_literals.c +++ b/ext/opcache/Optimizer/compact_literals.c @@ -422,22 +422,22 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx if (info[i].flags & LITERAL_EX_OBJ) { int key_len = MAX_LENGTH_OF_LONG + sizeof("->") + Z_STRLEN(op_array->literals[i]); key = zend_string_alloc(key_len, 0); - key->len = snprintf(key->val, key->len-1, "%d->%s", info[i].u.num, Z_STRVAL(op_array->literals[i])); + ZSTR_LEN(key) = snprintf(ZSTR_VAL(key), ZSTR_LEN(key)-1, "%d->%s", info[i].u.num, Z_STRVAL(op_array->literals[i])); } else if (info[i].flags & LITERAL_EX_CLASS) { int key_len; zval *class_name = &op_array->literals[(info[i].u.num < i) ? map[info[i].u.num] : info[i].u.num]; key_len = Z_STRLEN_P(class_name) + sizeof("::") + Z_STRLEN(op_array->literals[i]); key = zend_string_alloc(key_len, 0); - memcpy(key->val, Z_STRVAL_P(class_name), Z_STRLEN_P(class_name)); - memcpy(key->val + Z_STRLEN_P(class_name), "::", sizeof("::") - 1); - memcpy(key->val + Z_STRLEN_P(class_name) + sizeof("::") - 1, + memcpy(ZSTR_VAL(key), Z_STRVAL_P(class_name), Z_STRLEN_P(class_name)); + memcpy(ZSTR_VAL(key) + Z_STRLEN_P(class_name), "::", sizeof("::") - 1); + memcpy(ZSTR_VAL(key) + Z_STRLEN_P(class_name) + sizeof("::") - 1, Z_STRVAL(op_array->literals[i]), Z_STRLEN(op_array->literals[i]) + 1); } else { key = zend_string_init(Z_STRVAL(op_array->literals[i]), Z_STRLEN(op_array->literals[i]), 0); } - key->h = zend_hash_func(key->val, key->len); - key->h += info[i].flags; + ZSTR_H(key) = zend_hash_func(ZSTR_VAL(key), ZSTR_LEN(key)); + ZSTR_H(key) += info[i].flags; } if ((info[i].flags & LITERAL_MAY_MERGE) && (pos = zend_hash_find(&hash, key)) != NULL && diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c index 2ae6b79b50..6fcdc3e47a 100644 --- a/ext/opcache/Optimizer/pass1_5.c +++ b/ext/opcache/Optimizer/pass1_5.c @@ -296,7 +296,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) /* for A::B */ if (op_array->scope && !strncasecmp(Z_STRVAL(ZEND_OP1_LITERAL(opline)), - op_array->scope->name->val, Z_STRLEN(ZEND_OP1_LITERAL(opline)) + 1)) { + ZSTR_VAL(op_array->scope->name), Z_STRLEN(ZEND_OP1_LITERAL(opline)) + 1)) { ce = op_array->scope; } else { if ((ce = zend_hash_find_ptr(EG(class_table), @@ -562,8 +562,8 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) !zend_optimizer_is_disabled_func("dirname", sizeof("dirname") - 1) && IS_ABSOLUTE_PATH(Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)), Z_STRLEN(ZEND_OP1_LITERAL(send1_opline)))) { zend_string *dirname = zend_string_init(Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)), Z_STRLEN(ZEND_OP1_LITERAL(send1_opline)), 0); - dirname->len = zend_dirname(dirname->val, dirname->len); - if (IS_ABSOLUTE_PATH(dirname->val, dirname->len)) { + ZSTR_LEN(dirname) = zend_dirname(ZSTR_VAL(dirname), ZSTR_LEN(dirname)); + if (IS_ABSOLUTE_PATH(ZSTR_VAL(dirname), ZSTR_LEN(dirname))) { zval t; ZVAL_STR(&t, dirname); diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c index e0dfbfa541..9ae718ede2 100644 --- a/ext/opcache/Optimizer/zend_optimizer.c +++ b/ext/opcache/Optimizer/zend_optimizer.c @@ -62,9 +62,9 @@ int zend_optimizer_lookup_cv(zend_op_array *op_array, zend_string* name) while (i < op_array->last_var) { if (op_array->vars[i] == name || - (op_array->vars[i]->h == hash_value && - op_array->vars[i]->len == name->len && - memcmp(op_array->vars[i]->val, name->val, name->len) == 0)) { + (ZSTR_H(op_array->vars[i]) == hash_value && + ZSTR_LEN(op_array->vars[i]) == ZSTR_LEN(name) && + memcmp(ZSTR_VAL(op_array->vars[i]), ZSTR_VAL(name), ZSTR_LEN(name)) == 0)) { return (int)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, i); } i++; diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index dfcc32008d..2234d5ee56 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -295,8 +295,8 @@ static zend_string *accel_find_interned_string(zend_string *str) arData = ZCSG(interned_strings).arData; while (idx != HT_INVALID_IDX) { p = HT_HASH_TO_BUCKET_EX(arData, idx); - if ((p->h == h) && (p->key->len == str->len)) { - if (!memcmp(p->key->val, str->val, str->len)) { + if ((p->h == h) && (ZSTR_LEN(p->key) == ZSTR_LEN(str))) { + if (!memcmp(ZSTR_VAL(p->key), ZSTR_VAL(str), ZSTR_LEN(str))) { return p->key; } } @@ -334,8 +334,8 @@ zend_string *accel_new_interned_string(zend_string *str) idx = HT_HASH(&ZCSG(interned_strings), nIndex); while (idx != HT_INVALID_IDX) { p = HT_HASH_TO_BUCKET(&ZCSG(interned_strings), idx); - if ((p->h == h) && (p->key->len == str->len)) { - if (!memcmp(p->key->val, str->val, str->len)) { + if ((p->h == h) && (ZSTR_LEN(p->key) == ZSTR_LEN(str))) { + if (!memcmp(ZSTR_VAL(p->key), ZSTR_VAL(str), ZSTR_LEN(str))) { zend_string_release(str); return p->key; } @@ -366,9 +366,9 @@ zend_string *accel_new_interned_string(zend_string *str) GC_TYPE(p->key) = IS_STRING; GC_FLAGS(p->key) = IS_STR_INTERNED | IS_STR_PERMANENT; #endif - p->key->h = str->h; - p->key->len = str->len; - memcpy(p->key->val, str->val, str->len); + ZSTR_H(p->key) = ZSTR_H(str); + ZSTR_LEN(p->key) = ZSTR_LEN(str); + memcpy(ZSTR_VAL(p->key), ZSTR_VAL(str), ZSTR_LEN(str)); ZVAL_INTERNED_STR(&p->val, p->key); Z_NEXT(p->val) = HT_HASH(&ZCSG(interned_strings), nIndex); HT_HASH(&ZCSG(interned_strings), nIndex) = HT_IDX_TO_HASH(idx); @@ -782,7 +782,7 @@ accel_time_t zend_get_file_handle_timestamp(zend_file_handle *file_handle, size_ case ZEND_HANDLE_FILENAME: case ZEND_HANDLE_MAPPED: if (file_handle->opened_path) { - char *file_path = file_handle->opened_path->val; + char *file_path = ZSTR_VAL(file_handle->opened_path); if (is_stream_path(file_path)) { if (zend_get_stream_timestamp(file_path, &statbuf) == SUCCESS) { @@ -847,16 +847,16 @@ static inline int do_validate_timestamps(zend_persistent_script *persistent_scri */ if (file_handle->opened_path) { if (persistent_script->full_path != file_handle->opened_path && - (persistent_script->full_path->len != file_handle->opened_path->len || - memcmp(persistent_script->full_path->val, file_handle->opened_path->val, file_handle->opened_path->len) != 0)) { + (ZSTR_LEN(persistent_script->full_path) != ZSTR_LEN(file_handle->opened_path) || + memcmp(ZSTR_VAL(persistent_script->full_path), ZSTR_VAL(file_handle->opened_path), ZSTR_LEN(file_handle->opened_path)) != 0)) { return FAILURE; } } else { full_path_ptr = accelerator_orig_zend_resolve_path(file_handle->filename, strlen(file_handle->filename)); if (full_path_ptr && persistent_script->full_path != full_path_ptr && - (persistent_script->full_path->len != full_path_ptr->len || - memcmp(persistent_script->full_path->val, full_path_ptr->val, full_path_ptr->len) != 0)) { + (ZSTR_LEN(persistent_script->full_path) != ZSTR_LEN(full_path_ptr) || + memcmp(ZSTR_VAL(persistent_script->full_path), ZSTR_VAL(full_path_ptr), ZSTR_LEN(full_path_ptr)) != 0)) { zend_string_release(full_path_ptr); return FAILURE; } @@ -884,7 +884,7 @@ static inline int do_validate_timestamps(zend_persistent_script *persistent_scri } ps_handle.type = ZEND_HANDLE_FILENAME; - ps_handle.filename = persistent_script->full_path->val; + ps_handle.filename = ZSTR_VAL(persistent_script->full_path); ps_handle.opened_path = persistent_script->full_path; if (zend_get_file_handle_timestamp(&ps_handle, NULL) == persistent_script->timestamp) { @@ -941,8 +941,8 @@ char *accel_make_persistent_key(const char *path, int path_length, int *key_len) zend_accel_error(ACCEL_LOG_INFO, "getcwd() failed for '%s' (%d), please try to set opcache.use_cwd to 0 in ini file", path, errno); return NULL; } - cwd = cwd_str->val; - cwd_len = cwd_str->len; + cwd = ZSTR_VAL(cwd_str); + cwd_len = ZSTR_LEN(cwd_str); #ifndef ZTS if (ZCG(cwd_check)) { ZCG(cwd_check) = 0; @@ -961,7 +961,7 @@ char *accel_make_persistent_key(const char *path, int path_length, int *key_len) } if (str) { char buf[32]; - char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, str->val - ZCSG(interned_strings_start)); + char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, ZSTR_VAL(str) - ZCSG(interned_strings_start)); cwd_len = ZCG(cwd_key_len) = buf + sizeof(buf) - 1 - res; cwd = ZCG(cwd_key); @@ -975,12 +975,12 @@ char *accel_make_persistent_key(const char *path, int path_length, int *key_len) if (EXPECTED(ZCG(include_path_key_len))) { include_path = ZCG(include_path_key); include_path_len = ZCG(include_path_key_len); - } else if (!ZCG(include_path) || ZCG(include_path)->len == 0) { + } else if (!ZCG(include_path) || ZSTR_LEN(ZCG(include_path)) == 0) { include_path = ""; include_path_len = 0; } else { - include_path = ZCG(include_path)->val; - include_path_len = ZCG(include_path)->len; + include_path = ZSTR_VAL(ZCG(include_path)); + include_path_len = ZSTR_LEN(ZCG(include_path)); #ifndef ZTS if (ZCG(include_path_check)) { @@ -1000,7 +1000,7 @@ char *accel_make_persistent_key(const char *path, int path_length, int *key_len) } if (str) { char buf[32]; - char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, str->val - ZCSG(interned_strings_start)); + char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, ZSTR_VAL(str) - ZCSG(interned_strings_start)); include_path_len = ZCG(include_path_key_len) = buf + sizeof(buf) - 1 - res; include_path = ZCG(include_path_key); @@ -1041,15 +1041,15 @@ char *accel_make_persistent_key(const char *path, int path_length, int *key_len) if (EXPECTED(EG(current_execute_data)) && EXPECTED((parent_script = zend_get_executed_filename_ex()) != NULL)) { - parent_script_len = parent_script->len; - while ((--parent_script_len > 0) && !IS_SLASH(parent_script->val[parent_script_len])); + parent_script_len = ZSTR_LEN(parent_script); + while ((--parent_script_len > 0) && !IS_SLASH(ZSTR_VAL(parent_script)[parent_script_len])); if (UNEXPECTED((size_t)(key_length + parent_script_len + 1) >= sizeof(ZCG(key)))) { return NULL; } ZCG(key)[key_length] = ':'; key_length += 1; - memcpy(ZCG(key) + key_length, parent_script->val, parent_script_len); + memcpy(ZCG(key) + key_length, ZSTR_VAL(parent_script), parent_script_len); key_length += parent_script_len; } ZCG(key)[key_length] = '\0'; @@ -1097,7 +1097,7 @@ int zend_accel_invalidate(const char *filename, int filename_len, zend_bool forc zend_file_handle file_handle; file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.filename = realpath->val; + file_handle.filename = ZSTR_VAL(realpath); file_handle.opened_path = realpath; if (force || @@ -1183,15 +1183,15 @@ static zend_persistent_script *cache_script_in_file_cache(zend_persistent_script new_persistent_script->is_phar = new_persistent_script->full_path && - strstr(new_persistent_script->full_path->val, ".phar") && - !strstr(new_persistent_script->full_path->val, "://"); + strstr(ZSTR_VAL(new_persistent_script->full_path), ".phar") && + !strstr(ZSTR_VAL(new_persistent_script->full_path), "://"); /* Consistency check */ if ((char*)new_persistent_script->mem + new_persistent_script->size != (char*)ZCG(mem)) { zend_accel_error( ((char*)new_persistent_script->mem + new_persistent_script->size < (char*)ZCG(mem)) ? ACCEL_LOG_ERROR : ACCEL_LOG_WARNING, "Internal error: wrong size calculation: %s start=0x%08x, end=0x%08x, real=0x%08x\n", - new_persistent_script->full_path->val, + ZSTR_VAL(new_persistent_script->full_path), new_persistent_script->mem, (char *)new_persistent_script->mem + new_persistent_script->size, ZCG(mem)); @@ -1277,15 +1277,15 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr new_persistent_script->is_phar = new_persistent_script->full_path && - strstr(new_persistent_script->full_path->val, ".phar") && - !strstr(new_persistent_script->full_path->val, "://"); + strstr(ZSTR_VAL(new_persistent_script->full_path), ".phar") && + !strstr(ZSTR_VAL(new_persistent_script->full_path), "://"); /* Consistency check */ if ((char*)new_persistent_script->mem + new_persistent_script->size != (char*)ZCG(mem)) { zend_accel_error( ((char*)new_persistent_script->mem + new_persistent_script->size < (char*)ZCG(mem)) ? ACCEL_LOG_ERROR : ACCEL_LOG_WARNING, "Internal error: wrong size calculation: %s start=0x%08x, end=0x%08x, real=0x%08x\n", - new_persistent_script->full_path->val, + ZSTR_VAL(new_persistent_script->full_path), new_persistent_script->mem, (char *)new_persistent_script->mem + new_persistent_script->size, ZCG(mem)); @@ -1294,14 +1294,14 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr new_persistent_script->dynamic_members.checksum = zend_accel_script_checksum(new_persistent_script); /* store script structure in the hash table */ - bucket = zend_accel_hash_update(&ZCSG(hash), new_persistent_script->full_path->val, new_persistent_script->full_path->len, 0, new_persistent_script); + bucket = zend_accel_hash_update(&ZCSG(hash), ZSTR_VAL(new_persistent_script->full_path), ZSTR_LEN(new_persistent_script->full_path), 0, new_persistent_script); if (bucket) { zend_accel_error(ACCEL_LOG_INFO, "Cached script '%s'", new_persistent_script->full_path); if (key && /* key may contain non-persistent PHAR aliases (see issues #115 and #149) */ memcmp(key, "phar://", sizeof("phar://") - 1) != 0 && - (new_persistent_script->full_path->len != key_length || - memcmp(new_persistent_script->full_path->val, key, key_length) != 0)) { + (ZSTR_LEN(new_persistent_script->full_path) != key_length || + memcmp(ZSTR_VAL(new_persistent_script->full_path), key, key_length) != 0)) { /* link key to the same persistent script in hash table */ if (zend_accel_hash_update(&ZCSG(hash), key, key_length, 1, bucket)) { zend_accel_error(ACCEL_LOG_INFO, "Added key '%s'", key); @@ -1421,7 +1421,7 @@ static zend_persistent_script *opcache_compile_file(zend_file_handle *file_handl } /* check blacklist right after ensuring that file was opened */ - if (file_handle->opened_path && zend_accel_blacklist_is_blacklisted(&accel_blacklist, file_handle->opened_path->val)) { + if (file_handle->opened_path && zend_accel_blacklist_is_blacklisted(&accel_blacklist, ZSTR_VAL(file_handle->opened_path))) { ZCSG(blacklist_misses)++; *op_array_p = accelerator_orig_compile_file(file_handle, type); return NULL; @@ -1577,10 +1577,10 @@ zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int type) /* ext/phar has to load phar's metadata into memory */ if (persistent_script->is_phar) { php_stream_statbuf ssb; - char *fname = emalloc(sizeof("phar://") + persistent_script->full_path->len); + char *fname = emalloc(sizeof("phar://") + ZSTR_LEN(persistent_script->full_path)); memcpy(fname, "phar://", sizeof("phar://") - 1); - memcpy(fname + sizeof("phar://") - 1, persistent_script->full_path->val, persistent_script->full_path->len + 1); + memcpy(fname + sizeof("phar://") - 1, ZSTR_VAL(persistent_script->full_path), ZSTR_LEN(persistent_script->full_path) + 1); php_stream_stat_path(fname, &ssb); efree(fname); } @@ -1826,10 +1826,10 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type) /* ext/phar has to load phar's metadata into memory */ if (persistent_script->is_phar) { php_stream_statbuf ssb; - char *fname = emalloc(sizeof("phar://") + persistent_script->full_path->len); + char *fname = emalloc(sizeof("phar://") + ZSTR_LEN(persistent_script->full_path)); memcpy(fname, "phar://", sizeof("phar://") - 1); - memcpy(fname + sizeof("phar://") - 1, persistent_script->full_path->val, persistent_script->full_path->len + 1); + memcpy(fname + sizeof("phar://") - 1, ZSTR_VAL(persistent_script->full_path), ZSTR_LEN(persistent_script->full_path) + 1); php_stream_stat_path(fname, &ssb); efree(fname); } diff --git a/ext/opcache/zend_accelerator_hash.c b/ext/opcache/zend_accelerator_hash.c index dd52de3dc5..a1fadd46c9 100644 --- a/ext/opcache/zend_accelerator_hash.c +++ b/ext/opcache/zend_accelerator_hash.c @@ -172,8 +172,8 @@ void* zend_accel_hash_find(zend_accel_hash *accel_hash, zend_string *key) { return zend_accel_hash_find_ex( accel_hash, - key->val, - key->len, + ZSTR_VAL(key), + ZSTR_LEN(key), zend_string_hash_val(key), 1); } @@ -185,8 +185,8 @@ zend_accel_hash_entry* zend_accel_hash_find_entry(zend_accel_hash *accel_hash, z { return (zend_accel_hash_entry *)zend_accel_hash_find_ex( accel_hash, - key->val, - key->len, + ZSTR_VAL(key), + ZSTR_LEN(key), zend_string_hash_val(key), 0); } diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 531ea6e9ed..eb93f59413 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -112,7 +112,7 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption) (void)entry; (void)mh_arg2; (void)mh_arg3; (void)stage; p = (zend_long *) (base + (size_t)mh_arg1); - memsize = atoi(new_value->val); + memsize = atoi(ZSTR_VAL(new_value)); /* sanity check we must use at least 8 MB */ if (memsize < 8) { const char *new_new_value = "8"; @@ -148,7 +148,7 @@ static ZEND_INI_MH(OnUpdateMaxAcceleratedFiles) (void)entry; (void)mh_arg2; (void)mh_arg3; (void)stage; p = (zend_long *) (base + (size_t)mh_arg1); - size = atoi(new_value->val); + size = atoi(ZSTR_VAL(new_value)); /* sanity check we must use a value between MIN_ACCEL_FILES and MAX_ACCEL_FILES */ if (size < MIN_ACCEL_FILES || size > MAX_ACCEL_FILES) { @@ -192,7 +192,7 @@ static ZEND_INI_MH(OnUpdateMaxWastedPercentage) (void)entry; (void)mh_arg2; (void)mh_arg3; (void)stage; p = (double *) (base + (size_t)mh_arg1); - percentage = atoi(new_value->val); + percentage = atoi(ZSTR_VAL(new_value)); if (percentage <= 0 || percentage > 50) { const char *new_new_value = "5"; @@ -228,10 +228,10 @@ static ZEND_INI_MH(OnEnable) #endif p = (zend_bool *) (base+(size_t) mh_arg1); - if ((new_value->len == 2 && strcasecmp("on", new_value->val) == 0) || - (new_value->len == 3 && strcasecmp("yes", new_value->val) == 0) || - (new_value->len == 4 && strcasecmp("true", new_value->val) == 0) || - atoi(new_value->val) != 0) { + if ((ZSTR_LEN(new_value) == 2 && strcasecmp("on", ZSTR_VAL(new_value)) == 0) || + (ZSTR_LEN(new_value) == 3 && strcasecmp("yes", ZSTR_VAL(new_value)) == 0) || + (ZSTR_LEN(new_value) == 4 && strcasecmp("true", ZSTR_VAL(new_value)) == 0) || + atoi(ZSTR_VAL(new_value)) != 0) { zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME " can't be temporary enabled (it may be only disabled till the end of request)"); return FAILURE; } else { @@ -246,18 +246,18 @@ static ZEND_INI_MH(OnEnable) static ZEND_INI_MH(OnUpdateFileCache) { if (new_value) { - if (!new_value->len) { + if (!ZSTR_LEN(new_value)) { new_value = NULL; } else { zend_stat_t buf; - if (!IS_ABSOLUTE_PATH(new_value->val, new_value->len) || - zend_stat(new_value->val, &buf) != 0 || + if (!IS_ABSOLUTE_PATH(ZSTR_VAL(new_value), ZSTR_LEN(new_value)) || + zend_stat(ZSTR_VAL(new_value), &buf) != 0 || !S_ISDIR(buf.st_mode) || #ifndef ZEND_WIN32 - access(new_value->val, R_OK | W_OK | X_OK) != 0) { + access(ZSTR_VAL(new_value), R_OK | W_OK | X_OK) != 0) { #else - _access(new_value->val, 06) != 0) { + _access(ZSTR_VAL(new_value), 06) != 0) { #endif zend_accel_error(ACCEL_LOG_WARNING, "opcache.file_cache must be a full path of accessable directory.\n"); new_value = NULL; @@ -316,13 +316,13 @@ static int filename_is_in_cache(zend_string *filename) char *key; int key_length; - key = accel_make_persistent_key(filename->val, filename->len, &key_length); + key = accel_make_persistent_key(ZSTR_VAL(filename), ZSTR_LEN(filename), &key_length); if (key != NULL) { zend_persistent_script *persistent_script = zend_accel_hash_str_find(&ZCSG(hash), key, key_length); if (persistent_script && !persistent_script->corrupted) { zend_file_handle handle = {{0}, NULL, NULL, 0, 0}; - handle.filename = filename->val; + handle.filename = ZSTR_VAL(filename); handle.type = ZEND_HANDLE_FILENAME; if (ZCG(accel_directives).validate_timestamps) { diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c index 996deecbb2..a737e8db6b 100644 --- a/ext/opcache/zend_accelerator_util_funcs.c +++ b/ext/opcache/zend_accelerator_util_funcs.c @@ -534,7 +534,7 @@ static void zend_accel_function_hash_copy(HashTable *target, HashTable *source) ZEND_ASSERT(p->key); t = zend_hash_find(target, p->key); if (UNEXPECTED(t != NULL)) { - if (EXPECTED(p->key->len > 0) && EXPECTED(p->key->val[0] == 0)) { + if (EXPECTED(ZSTR_LEN(p->key) > 0) && EXPECTED(ZSTR_VAL(p->key)[0] == 0)) { /* Mangled key */ t = zend_hash_update(target, p->key, &p->val); } else { @@ -556,11 +556,11 @@ failure: if (function2->type == ZEND_USER_FUNCTION && function2->op_array.last > 0) { zend_error(E_ERROR, "Cannot redeclare %s() (previously declared in %s:%d)", - function1->common.function_name->val, - function2->op_array.filename->val, + ZSTR_VAL(function1->common.function_name), + ZSTR_VAL(function2->op_array.filename), (int)function2->op_array.opcodes[0].lineno); } else { - zend_error(E_ERROR, "Cannot redeclare %s()", function1->common.function_name->val); + zend_error(E_ERROR, "Cannot redeclare %s()", ZSTR_VAL(function1->common.function_name)); } } @@ -578,7 +578,7 @@ static void zend_accel_function_hash_copy_from_shm(HashTable *target, HashTable ZEND_ASSERT(p->key); t = zend_hash_find(target, p->key); if (UNEXPECTED(t != NULL)) { - if (EXPECTED(p->key->len > 0) && EXPECTED(p->key->val[0] == 0)) { + if (EXPECTED(ZSTR_LEN(p->key) > 0) && EXPECTED(ZSTR_VAL(p->key)[0] == 0)) { /* Mangled key */ zend_hash_update_ptr(target, p->key, ARENA_REALLOC(Z_PTR(p->val))); } else { @@ -600,11 +600,11 @@ failure: if (function2->type == ZEND_USER_FUNCTION && function2->op_array.last > 0) { zend_error(E_ERROR, "Cannot redeclare %s() (previously declared in %s:%d)", - function1->common.function_name->val, - function2->op_array.filename->val, + ZSTR_VAL(function1->common.function_name), + ZSTR_VAL(function2->op_array.filename), (int)function2->op_array.opcodes[0].lineno); } else { - zend_error(E_ERROR, "Cannot redeclare %s()", function1->common.function_name->val); + zend_error(E_ERROR, "Cannot redeclare %s()", ZSTR_VAL(function1->common.function_name)); } } @@ -622,7 +622,7 @@ static void zend_accel_class_hash_copy(HashTable *target, HashTable *source, uni ZEND_ASSERT(p->key); t = zend_hash_find(target, p->key); if (UNEXPECTED(t != NULL)) { - if (EXPECTED(p->key->len > 0) && EXPECTED(p->key->val[0] == 0)) { + if (EXPECTED(ZSTR_LEN(p->key) > 0) && EXPECTED(ZSTR_VAL(p->key)[0] == 0)) { /* Mangled key - ignore and wait for runtime */ continue; } else if (UNEXPECTED(!ZCG(accel_directives).ignore_dups)) { @@ -643,7 +643,7 @@ failure: CG(in_compilation) = 1; zend_set_compiled_filename(ce1->info.user.filename); CG(zend_lineno) = ce1->info.user.line_start; - zend_error(E_ERROR, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce1), ce1->name->val); + zend_error(E_ERROR, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce1), ZSTR_VAL(ce1->name)); } #ifdef __SSE2__ @@ -713,9 +713,9 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, zend_string *name; char haltoff[] = "__COMPILER_HALT_OFFSET__"; - name = zend_mangle_property_name(haltoff, sizeof(haltoff) - 1, persistent_script->full_path->val, persistent_script->full_path->len, 0); + name = zend_mangle_property_name(haltoff, sizeof(haltoff) - 1, ZSTR_VAL(persistent_script->full_path), ZSTR_LEN(persistent_script->full_path), 0); if (!zend_hash_exists(EG(zend_constants), name)) { - zend_register_long_constant(name->val, name->len, persistent_script->compiler_halt_offset, CONST_CS, 0); + zend_register_long_constant(ZSTR_VAL(name), ZSTR_LEN(name), persistent_script->compiler_halt_offset, CONST_CS, 0); } zend_string_release(name); } diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c index 598e52a73d..0781b91c9d 100644 --- a/ext/opcache/zend_file_cache.c +++ b/ext/opcache/zend_file_cache.c @@ -202,14 +202,14 @@ static void *zend_file_cache_serialize_interned(zend_string *str, len = ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(ZSTR_LEN(str))); ret = (void*)(info->str_size | Z_UL(1)); zend_shared_alloc_register_xlat_entry(str, ret); - if (info->str_size + len > ((zend_string*)ZCG(mem))->len) { + if (info->str_size + len > ZSTR_LEN((zend_string*)ZCG(mem))) { size_t new_len = info->str_size + len; ZCG(mem) = (void*)zend_string_realloc( (zend_string*)ZCG(mem), ((_ZSTR_HEADER_SIZE + 1 + new_len + 4095) & ~0xfff) - (_ZSTR_HEADER_SIZE + 1), 0); } - memcpy(((zend_string*)ZCG(mem))->val + info->str_size, str, len); + memcpy(ZSTR_VAL((zend_string*)ZCG(mem)) + info->str_size, str, len); info->str_size += len; return ret; } @@ -677,12 +677,12 @@ int zend_file_cache_script_store(zend_persistent_script *script, int in_shm) void *mem, *buf; len = strlen(ZCG(accel_directives).file_cache); - filename = emalloc(len + 33 + script->full_path->len + sizeof(SUFFIX)); + filename = emalloc(len + 33 + ZSTR_LEN(script->full_path) + sizeof(SUFFIX)); memcpy(filename, ZCG(accel_directives).file_cache, len); filename[len] = '/'; memcpy(filename + len + 1, ZCG(system_id), 32); - memcpy(filename + len + 33, script->full_path->val, script->full_path->len); - memcpy(filename + len + 33 + script->full_path->len, SUFFIX, sizeof(SUFFIX)); + memcpy(filename + len + 33, ZSTR_VAL(script->full_path), ZSTR_LEN(script->full_path)); + memcpy(filename + len + 33 + ZSTR_LEN(script->full_path), SUFFIX, sizeof(SUFFIX)); if (zend_file_cache_mkdir(filename, len) != SUCCESS) { zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot create directory for file '%s'\n", filename); @@ -730,14 +730,14 @@ int zend_file_cache_script_store(zend_persistent_script *script, int in_shm) zend_shared_alloc_destroy_xlat_table(); info.checksum = zend_adler32(ADLER32_INIT, buf, script->size); - info.checksum = zend_adler32(info.checksum, (signed char*)((zend_string*)ZCG(mem))->val, info.str_size); + info.checksum = zend_adler32(info.checksum, (signed char*)ZSTR_VAL((zend_string*)ZCG(mem)), info.str_size); #ifndef ZEND_WIN32 vec[0].iov_base = &info; vec[0].iov_len = sizeof(info); vec[1].iov_base = buf; vec[1].iov_len = script->size; - vec[2].iov_base = ((zend_string*)ZCG(mem))->val; + vec[2].iov_base = ZSTR_VAL((zend_string*)ZCG(mem)); vec[2].iov_len = info.str_size; if (writev(fd, vec, 3) != (ssize_t)(sizeof(info) + script->size + info.str_size)) { @@ -1177,12 +1177,12 @@ zend_persistent_script *zend_file_cache_script_load(zend_file_handle *file_handl return NULL; } len = strlen(ZCG(accel_directives).file_cache); - filename = emalloc(len + 33 + full_path->len + sizeof(SUFFIX)); + filename = emalloc(len + 33 + ZSTR_LEN(full_path) + sizeof(SUFFIX)); memcpy(filename, ZCG(accel_directives).file_cache, len); filename[len] = '/'; memcpy(filename + len + 1, ZCG(system_id), 32); - memcpy(filename + len + 33, full_path->val, full_path->len); - memcpy(filename + len + 33 + full_path->len, SUFFIX, sizeof(SUFFIX)); + memcpy(filename + len + 33, ZSTR_VAL(full_path), ZSTR_LEN(full_path)); + memcpy(filename + len + 33 + ZSTR_LEN(full_path), SUFFIX, sizeof(SUFFIX)); fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) { @@ -1316,7 +1316,7 @@ use_process_mem: if (cache_it) { script->dynamic_members.checksum = zend_accel_script_checksum(script); - zend_accel_hash_update(&ZCSG(hash), script->full_path->val, script->full_path->len, 0, script); + zend_accel_hash_update(&ZCSG(hash), ZSTR_VAL(script->full_path), ZSTR_LEN(script->full_path), 0, script); zend_shared_alloc_unlock(); zend_arena_release(&CG(arena), checkpoint); @@ -1332,12 +1332,12 @@ void zend_file_cache_invalidate(zend_string *full_path) char *filename; len = strlen(ZCG(accel_directives).file_cache); - filename = emalloc(len + 33 + full_path->len + sizeof(SUFFIX)); + filename = emalloc(len + 33 + ZSTR_LEN(full_path) + sizeof(SUFFIX)); memcpy(filename, ZCG(accel_directives).file_cache, len); filename[len] = '/'; memcpy(filename + len + 1, ZCG(system_id), 32); - memcpy(filename + len + 33, full_path->val, full_path->len); - memcpy(filename + len + 33 + full_path->len, SUFFIX, sizeof(SUFFIX)); + memcpy(filename + len + 33, ZSTR_VAL(full_path), ZSTR_LEN(full_path)); + memcpy(filename + len + 33 + ZSTR_LEN(full_path), SUFFIX, sizeof(SUFFIX)); unlink(filename); efree(filename); diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 28029a476e..ebbc877c43 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -1538,8 +1538,8 @@ PHP_FUNCTION(openssl_spki_new) } s = zend_string_alloc(strlen(spkac) + strlen(spkstr), 0); - sprintf(s->val, "%s%s", spkac, spkstr); - s->len = strlen(s->val); + sprintf(ZSTR_VAL(s), "%s%s", spkac, spkstr); + ZSTR_LEN(s) = strlen(ZSTR_VAL(s)); RETVAL_STR(s); goto cleanup; @@ -1556,7 +1556,7 @@ cleanup: efree(spkstr); } - if (s && s->len <= 0) { + if (s && ZSTR_LEN(s) <= 0) { RETVAL_FALSE; } @@ -1798,8 +1798,8 @@ zend_string* php_openssl_x509_fingerprint(X509 *peer, const char *method, zend_b ret = zend_string_init((char*)md, n, 0); } else { ret = zend_string_alloc(n * 2, 0); - make_digest_ex(ret->val, md, n); - ret->val[n * 2] = '\0'; + make_digest_ex(ZSTR_VAL(ret), md, n); + ZSTR_VAL(ret)[n * 2] = '\0'; } return ret; @@ -2663,7 +2663,7 @@ static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, z convert_to_string_ex(item); - nid = OBJ_txt2nid(strindex->val); + nid = OBJ_txt2nid(ZSTR_VAL(strindex)); if (nid != NID_undef) { if (!X509_NAME_add_entry_by_NID(subj, nid, MBSTRING_UTF8, (unsigned char*)Z_STRVAL_P(item), -1, -1, 0)) @@ -2676,7 +2676,7 @@ static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, z return FAILURE; } } else { - php_error_docref(NULL, E_WARNING, "dn: %s is not a recognized name", strindex->val); + php_error_docref(NULL, E_WARNING, "dn: %s is not a recognized name", ZSTR_VAL(strindex)); } } } ZEND_HASH_FOREACH_END(); @@ -2735,14 +2735,14 @@ static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, z convert_to_string_ex(item); - nid = OBJ_txt2nid(strindex->val); + nid = OBJ_txt2nid(ZSTR_VAL(strindex)); if (nid != NID_undef) { if (!X509_NAME_add_entry_by_NID(subj, nid, MBSTRING_UTF8, (unsigned char*)Z_STRVAL_P(item), -1, -1, 0)) { php_error_docref(NULL, E_WARNING, "attribs: add_entry_by_NID %d -> %s (failed)", nid, Z_STRVAL_P(item)); return FAILURE; } } else { - php_error_docref(NULL, E_WARNING, "dn: %s is not a recognized name", strindex->val); + php_error_docref(NULL, E_WARNING, "dn: %s is not a recognized name", ZSTR_VAL(strindex)); } } ZEND_HASH_FOREACH_END(); for (i = 0; i < sk_CONF_VALUE_num(attr_sk); i++) { @@ -3511,9 +3511,9 @@ static int php_openssl_is_private_key(EVP_PKEY* pkey) #define OPENSSL_PKEY_GET_BN(_type, _name) do { \ if (pkey->pkey._type->_name != NULL) { \ int len = BN_num_bytes(pkey->pkey._type->_name); \ - zend_string *str = zend_string_alloc(len, 0); \ - BN_bn2bin(pkey->pkey._type->_name, (unsigned char*)str->val); \ - str->val[len] = 0; \ + zend_string *str = zend_string_alloc(len, 0); \ + BN_bn2bin(pkey->pkey._type->_name, (unsigned char*)ZSTR_VAL(str)); \ + ZSTR_VAL(str)[len] = 0; \ add_assoc_str(&_type, #_name, str); \ } \ } while (0) @@ -4020,8 +4020,8 @@ PHP_FUNCTION(openssl_pbkdf2) out_buffer = zend_string_alloc(key_length, 0); - if (PKCS5_PBKDF2_HMAC(password, (int)password_len, (unsigned char *)salt, (int)salt_len, (int)iterations, digest, (int)key_length, (unsigned char*)out_buffer->val) == 1) { - out_buffer->val[key_length] = 0; + if (PKCS5_PBKDF2_HMAC(password, (int)password_len, (unsigned char *)salt, (int)salt_len, (int)iterations, digest, (int)key_length, (unsigned char*)ZSTR_VAL(out_buffer)) == 1) { + ZSTR_VAL(out_buffer)[key_length] = 0; RETURN_NEW_STR(out_buffer); } else { zend_string_release(out_buffer); @@ -4249,7 +4249,7 @@ PHP_FUNCTION(openssl_pkcs7_encrypt) convert_to_string_ex(zcertval); if (strindex) { - BIO_printf(outfile, "%s: %s\n", strindex->val, Z_STRVAL_P(zcertval)); + BIO_printf(outfile, "%s: %s\n", ZSTR_VAL(strindex), Z_STRVAL_P(zcertval)); } else { BIO_printf(outfile, "%s\n", Z_STRVAL_P(zcertval)); } @@ -4353,7 +4353,7 @@ PHP_FUNCTION(openssl_pkcs7_sign) convert_to_string_ex(hval); if (strindex) { - BIO_printf(outfile, "%s: %s\n", strindex->val, Z_STRVAL_P(hval)); + BIO_printf(outfile, "%s: %s\n", ZSTR_VAL(strindex), Z_STRVAL_P(hval)); } else { BIO_printf(outfile, "%s\n", Z_STRVAL_P(hval)); } @@ -4489,7 +4489,7 @@ PHP_FUNCTION(openssl_private_encrypt) case EVP_PKEY_RSA2: successful = (RSA_private_encrypt((int)data_len, (unsigned char *)data, - (unsigned char *)cryptedbuf->val, + (unsigned char *)ZSTR_VAL(cryptedbuf), pkey->pkey.rsa, (int)padding) == cryptedlen); break; @@ -4499,7 +4499,7 @@ PHP_FUNCTION(openssl_private_encrypt) if (successful) { zval_dtor(crypted); - cryptedbuf->val[cryptedlen] = '\0'; + ZSTR_VAL(cryptedbuf)[cryptedlen] = '\0'; ZVAL_NEW_STR(crypted, cryptedbuf); cryptedbuf = NULL; RETVAL_TRUE; @@ -4555,7 +4555,7 @@ PHP_FUNCTION(openssl_private_decrypt) (int)padding); if (cryptedlen != -1) { cryptedbuf = zend_string_alloc(cryptedlen, 0); - memcpy(cryptedbuf->val, crypttemp, cryptedlen); + memcpy(ZSTR_VAL(cryptedbuf), crypttemp, cryptedlen); successful = 1; } break; @@ -4567,7 +4567,7 @@ PHP_FUNCTION(openssl_private_decrypt) if (successful) { zval_dtor(crypted); - cryptedbuf->val[cryptedlen] = '\0'; + ZSTR_VAL(cryptedbuf)[cryptedlen] = '\0'; ZVAL_NEW_STR(crypted, cryptedbuf); cryptedbuf = NULL; RETVAL_TRUE; @@ -4617,7 +4617,7 @@ PHP_FUNCTION(openssl_public_encrypt) case EVP_PKEY_RSA2: successful = (RSA_public_encrypt((int)data_len, (unsigned char *)data, - (unsigned char *)cryptedbuf->val, + (unsigned char *)ZSTR_VAL(cryptedbuf), pkey->pkey.rsa, (int)padding) == cryptedlen); break; @@ -4628,7 +4628,7 @@ PHP_FUNCTION(openssl_public_encrypt) if (successful) { zval_dtor(crypted); - cryptedbuf->val[cryptedlen] = '\0'; + ZSTR_VAL(cryptedbuf)[cryptedlen] = '\0'; ZVAL_NEW_STR(crypted, cryptedbuf); cryptedbuf = NULL; RETVAL_TRUE; @@ -4684,7 +4684,7 @@ PHP_FUNCTION(openssl_public_decrypt) (int)padding); if (cryptedlen != -1) { cryptedbuf = zend_string_alloc(cryptedlen, 0); - memcpy(cryptedbuf->val, crypttemp, cryptedlen); + memcpy(ZSTR_VAL(cryptedbuf), crypttemp, cryptedlen); successful = 1; } break; @@ -4698,7 +4698,7 @@ PHP_FUNCTION(openssl_public_decrypt) if (successful) { zval_dtor(crypted); - cryptedbuf->val[cryptedlen] = '\0'; + ZSTR_VAL(cryptedbuf)[cryptedlen] = '\0'; ZVAL_NEW_STR(crypted, cryptedbuf); cryptedbuf = NULL; RETVAL_TRUE; @@ -4779,10 +4779,10 @@ PHP_FUNCTION(openssl_sign) EVP_SignInit(&md_ctx, mdtype); EVP_SignUpdate(&md_ctx, data, data_len); - if (EVP_SignFinal (&md_ctx, (unsigned char*)sigbuf->val, &siglen, pkey)) { + if (EVP_SignFinal (&md_ctx, (unsigned char*)ZSTR_VAL(sigbuf), &siglen, pkey)) { zval_dtor(signature); - sigbuf->val[siglen] = '\0'; - sigbuf->len = siglen; + ZSTR_VAL(sigbuf)[siglen] = '\0'; + ZSTR_LEN(sigbuf) = siglen; ZVAL_NEW_STR(signature, sigbuf); RETVAL_TRUE; } else { @@ -5122,17 +5122,17 @@ PHP_FUNCTION(openssl_digest) EVP_DigestInit(&md_ctx, mdtype); EVP_DigestUpdate(&md_ctx, (unsigned char *)data, data_len); - if (EVP_DigestFinal (&md_ctx, (unsigned char *)sigbuf->val, &siglen)) { + if (EVP_DigestFinal (&md_ctx, (unsigned char *)ZSTR_VAL(sigbuf), &siglen)) { if (raw_output) { - sigbuf->val[siglen] = '\0'; - sigbuf->len = siglen; + ZSTR_VAL(sigbuf)[siglen] = '\0'; + ZSTR_LEN(sigbuf) = siglen; RETVAL_STR(sigbuf); } else { int digest_str_len = siglen * 2; zend_string *digest_str = zend_string_alloc(digest_str_len, 0); - make_digest_ex(digest_str->val, (unsigned char*)sigbuf->val, siglen); - digest_str->val[digest_str_len] = '\0'; + make_digest_ex(ZSTR_VAL(digest_str), (unsigned char*)ZSTR_VAL(sigbuf), siglen); + ZSTR_VAL(digest_str)[digest_str_len] = '\0'; zend_string_release(sigbuf); RETVAL_STR(digest_str); } @@ -5230,19 +5230,19 @@ PHP_FUNCTION(openssl_encrypt) EVP_CIPHER_CTX_set_padding(&cipher_ctx, 0); } if (data_len > 0) { - EVP_EncryptUpdate(&cipher_ctx, (unsigned char*)outbuf->val, &i, (unsigned char *)data, (int)data_len); + EVP_EncryptUpdate(&cipher_ctx, (unsigned char*)ZSTR_VAL(outbuf), &i, (unsigned char *)data, (int)data_len); } outlen = i; - if (EVP_EncryptFinal(&cipher_ctx, (unsigned char *)outbuf->val + i, &i)) { + if (EVP_EncryptFinal(&cipher_ctx, (unsigned char *)ZSTR_VAL(outbuf) + i, &i)) { outlen += i; if (options & OPENSSL_RAW_DATA) { - outbuf->val[outlen] = '\0'; - outbuf->len = outlen; + ZSTR_VAL(outbuf)[outlen] = '\0'; + ZSTR_LEN(outbuf) = outlen; RETVAL_STR(outbuf); } else { zend_string *base64_str; - base64_str = php_base64_encode((unsigned char*)outbuf->val, outlen); + base64_str = php_base64_encode((unsigned char*)ZSTR_VAL(outbuf), outlen); zend_string_release(outbuf); RETVAL_STR(base64_str); } @@ -5299,8 +5299,8 @@ PHP_FUNCTION(openssl_decrypt) php_error_docref(NULL, E_WARNING, "Failed to base64 decode the input"); RETURN_FALSE; } - data_len = base64_str->len; - data = base64_str->val; + data_len = ZSTR_LEN(base64_str); + data = ZSTR_VAL(base64_str); } keylen = EVP_CIPHER_key_length(cipher_type); @@ -5325,12 +5325,12 @@ PHP_FUNCTION(openssl_decrypt) if (options & OPENSSL_ZERO_PADDING) { EVP_CIPHER_CTX_set_padding(&cipher_ctx, 0); } - EVP_DecryptUpdate(&cipher_ctx, (unsigned char*)outbuf->val, &i, (unsigned char *)data, (int)data_len); + EVP_DecryptUpdate(&cipher_ctx, (unsigned char*)ZSTR_VAL(outbuf), &i, (unsigned char *)data, (int)data_len); outlen = i; - if (EVP_DecryptFinal(&cipher_ctx, (unsigned char *)outbuf->val + i, &i)) { + if (EVP_DecryptFinal(&cipher_ctx, (unsigned char *)ZSTR_VAL(outbuf) + i, &i)) { outlen += i; - outbuf->val[outlen] = '\0'; - outbuf->len = outlen; + ZSTR_VAL(outbuf)[outlen] = '\0'; + ZSTR_LEN(outbuf) = outlen; RETVAL_STR(outbuf); } else { zend_string_release(outbuf); @@ -5401,11 +5401,11 @@ PHP_FUNCTION(openssl_dh_compute_key) pub = BN_bin2bn((unsigned char*)pub_str, (int)pub_len, NULL); data = zend_string_alloc(DH_size(pkey->pkey.dh), 0); - len = DH_compute_key((unsigned char*)data->val, pub, pkey->pkey.dh); + len = DH_compute_key((unsigned char*)ZSTR_VAL(data), pub, pkey->pkey.dh); if (len >= 0) { - data->len = len; - data->val[len] = 0; + ZSTR_LEN(data) = len; + ZSTR_VAL(data)[len] = 0; RETVAL_STR(data); } else { zend_string_release(data); @@ -5451,7 +5451,7 @@ PHP_FUNCTION(openssl_random_pseudo_bytes) RETURN_FALSE; } #else - if ((strong_result = RAND_pseudo_bytes((unsigned char*)buffer->val, buffer_length)) < 0) { + if ((strong_result = RAND_pseudo_bytes((unsigned char*)ZSTR_VAL(buffer), buffer_length)) < 0) { zend_string_release(buffer); if (zstrong_result_returned) { ZVAL_FALSE(zstrong_result_returned); @@ -5460,7 +5460,7 @@ PHP_FUNCTION(openssl_random_pseudo_bytes) } #endif - buffer->val[buffer_length] = 0; + ZSTR_VAL(buffer)[buffer_length] = 0; RETVAL_STR(buffer); if (zstrong_result_returned) { diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index 1d340af8cb..41d6a0a8d1 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -255,7 +255,7 @@ static int handle_ssl_error(php_stream *stream, int nr_bytes, zend_bool is_init) "SSL operation failed with code %d. %s%s", err, ebuf.s ? "OpenSSL Error messages:\n" : "", - ebuf.s ? ebuf.s->val : ""); + ebuf.s ? ZSTR_VAL(ebuf.s) : ""); if (ebuf.s) { smart_str_free(&ebuf); } @@ -313,7 +313,7 @@ static int php_x509_fingerprint_cmp(X509 *peer, const char *method, const char * fingerprint = php_openssl_x509_fingerprint(peer, method, 0); if (fingerprint) { - result = strcasecmp(expected, fingerprint->val); + result = strcasecmp(expected, ZSTR_VAL(fingerprint)); zend_string_release(fingerprint); } @@ -350,7 +350,7 @@ static zend_bool php_x509_fingerprint_match(X509 *peer, zval *val) php_error_docref(NULL, E_WARNING, "Invalid peer_fingerprint array; [algo => fingerprint] form required"); return 0; } - if (php_x509_fingerprint_cmp(peer, key->val, Z_STRVAL_P(current)) != 0) { + if (php_x509_fingerprint_cmp(peer, ZSTR_VAL(key), Z_STRVAL_P(current)) != 0) { return 0; } } ZEND_HASH_FOREACH_END(); @@ -1389,7 +1389,7 @@ static int enable_server_sni(php_stream *stream, php_openssl_netstream_data_t *s SSL_CTX_free(ctx); return FAILURE; } else { - sslsock->sni_certs[i].name = pestrdup(key->val, php_stream_is_persistent(stream)); + sslsock->sni_certs[i].name = pestrdup(ZSTR_VAL(key), php_stream_is_persistent(stream)); sslsock->sni_certs[i].ctx = ctx; ++i; } diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index bf2fcfe525..6661c2a715 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -908,9 +908,9 @@ PHP_FUNCTION(pcntl_exec) convert_to_string_ex(element); /* Length of element + equal sign + length of key + null */ - pair_length = Z_STRLEN_P(element) + key->len + 2; + pair_length = Z_STRLEN_P(element) + ZSTR_LEN(key) + 2; *pair = emalloc(pair_length); - strlcpy(*pair, key->val, key->len + 1); + strlcpy(*pair, ZSTR_VAL(key), ZSTR_LEN(key) + 1); strlcat(*pair, "=", pair_length); strlcat(*pair, Z_STRVAL_P(element), pair_length); @@ -991,7 +991,7 @@ PHP_FUNCTION(pcntl_signal) if (!zend_is_callable(handle, 0, &func_name)) { PCNTL_G(last_error) = EINVAL; - php_error_docref(NULL, E_WARNING, "%s is not a callable function name error", func_name->val); + php_error_docref(NULL, E_WARNING, "%s is not a callable function name error", ZSTR_VAL(func_name)); zend_string_release(func_name); RETURN_FALSE; } diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 90c60f1b6f..8e40f84673 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -281,14 +281,14 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex) #if HAVE_SETLOCALE if (pce->locale == BG(locale_string) || (pce->locale && BG(locale_string) && - pce->locale->len == BG(locale_string)->len && - !memcmp(pce->locale->val, BG(locale_string)->val, pce->locale->len)) || + ZSTR_LEN(pce->locale) == ZSTR_LEN(BG(locale_string)) && + !memcmp(ZSTR_VAL(pce->locale), ZSTR_VAL(BG(locale_string)), ZSTR_LEN(pce->locale))) || (!pce->locale && - BG(locale_string)->len == 1 && - BG(locale_string)->val[0] == 'C') || + ZSTR_LEN(BG(locale_string)) == 1 && + ZSTR_VAL(BG(locale_string))[0] == 'C') || (!BG(locale_string) && - pce->locale->len == 1 && - pce->locale->val[0] == 'C')) { + ZSTR_LEN(pce->locale) == 1 && + ZSTR_VAL(pce->locale)[0] == 'C')) { return pce; } #else @@ -296,14 +296,14 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex) #endif } - p = regex->val; + p = ZSTR_VAL(regex); /* Parse through the leading whitespace, and display a warning if we get to the end without encountering a delimiter. */ while (isspace((int)*(unsigned char *)p)) p++; if (*p == 0) { php_error_docref(NULL, E_WARNING, - p < regex->val + regex->len ? "Null byte in regex" : "Empty regular expression"); + p < ZSTR_VAL(regex) + ZSTR_LEN(regex) ? "Null byte in regex" : "Empty regular expression"); return NULL; } @@ -350,7 +350,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex) } if (*pp == 0) { - if (pp < regex->val + regex->len) { + if (pp < ZSTR_VAL(regex) + ZSTR_LEN(regex)) { php_error_docref(NULL,E_WARNING, "Null byte in regex"); } else if (start_delimiter == end_delimiter) { php_error_docref(NULL,E_WARNING, "No ending delimiter '%c' found", delimiter); @@ -368,7 +368,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex) /* Parse through the options, setting appropriate flags. Display a warning if we encounter an unknown modifier. */ - while (pp < regex->val + regex->len) { + while (pp < ZSTR_VAL(regex) + ZSTR_LEN(regex)) { switch (*pp++) { /* Perl compatible options */ case 'i': coptions |= PCRE_CASELESS; break; @@ -411,7 +411,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex) #if HAVE_SETLOCALE if (BG(locale_string) && - (BG(locale_string)->len != 1 || BG(locale_string)->val[0] != 'C')) { + (ZSTR_LEN(BG(locale_string)) != 1 || ZSTR_VAL(BG(locale_string))[0] != 'C')) { tables = pcre_maketables(); } #endif @@ -477,7 +477,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex) new_entry.locale = BG(locale_string) ? ((GC_FLAGS(BG(locale_string)) & IS_STR_PERSISTENT) ? zend_string_copy(BG(locale_string)) : - zend_string_init(BG(locale_string)->val, BG(locale_string)->len, 1)) : + zend_string_init(ZSTR_VAL(BG(locale_string)), ZSTR_LEN(BG(locale_string)), 1)) : NULL; new_entry.tables = tables; #endif @@ -504,9 +504,9 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex) * See bug #63180 */ if (!ZSTR_IS_INTERNED(regex) || !(GC_FLAGS(regex) & IS_STR_PERMANENT)) { - zend_string *str = zend_string_init(regex->val, regex->len, 1); + zend_string *str = zend_string_init(ZSTR_VAL(regex), ZSTR_LEN(regex), 1); GC_REFCOUNT(str) = 0; /* will be incremented by zend_hash_update_mem() */ - str->h = regex->h; + ZSTR_H(str) = ZSTR_H(regex); regex = str; } @@ -606,7 +606,7 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* {{{ * } pce->refcount++; - php_pcre_match_impl(pce, subject->val, (int)subject->len, return_value, subpats, + php_pcre_match_impl(pce, ZSTR_VAL(subject), (int)ZSTR_LEN(subject), return_value, subpats, global, ZEND_NUM_ARGS() >= 4, flags, start_offset); pce->refcount--; } @@ -1203,11 +1203,11 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su } /* copy the part of the string before the match */ - memcpy(&result->val[result_len], piece, match-piece); + memcpy(&ZSTR_VAL(result)[result_len], piece, match-piece); result_len += (int)(match-piece); /* copy replacement and backrefs */ - walkbuf = result->val + result_len; + walkbuf = ZSTR_VAL(result) + result_len; walk = replace; walk_last = 0; @@ -1232,12 +1232,12 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su } *walkbuf = '\0'; /* increment the result length by how much we've added to the string */ - result_len += (int)(walkbuf - (result->val + result_len)); + result_len += (int)(walkbuf - (ZSTR_VAL(result) + result_len)); } else { /* Use custom function to get replacement string and its length. */ eval_result = preg_do_repl_func(replace_val, subject, offsets, subpat_names, count, mark); ZEND_ASSERT(eval_result); - new_len += (int)eval_result->len; + new_len += (int)ZSTR_LEN(eval_result); if (new_len >= alloc_len) { alloc_len = alloc_len + 2 * new_len; if (result == NULL) { @@ -1247,15 +1247,15 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su } } /* copy the part of the string before the match */ - memcpy(&result->val[result_len], piece, match-piece); + memcpy(ZSTR_VAL(result) + result_len, piece, match-piece); result_len += (int)(match-piece); /* copy replacement and backrefs */ - walkbuf = result->val + result_len; + walkbuf = ZSTR_VAL(result) + result_len; /* If using custom function, copy result to the buffer and clean up. */ - memcpy(walkbuf, eval_result->val, eval_result->len); - result_len += (int)eval_result->len; + memcpy(walkbuf, ZSTR_VAL(eval_result), ZSTR_LEN(eval_result)); + result_len += (int)ZSTR_LEN(eval_result); zend_string_release(eval_result); } @@ -1272,7 +1272,7 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su offsets[0] = start_offset; offsets[1] = start_offset + unit_len; - memcpy(&result->val[result_len], piece, unit_len); + memcpy(ZSTR_VAL(result) + result_len, piece, unit_len); result_len += unit_len; } else { if (!result && subject_str) { @@ -1289,10 +1289,10 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su } } /* stick that last bit of string on our output */ - memcpy(&result->val[result_len], piece, subject_len - start_offset); + memcpy(ZSTR_VAL(result) + result_len, piece, subject_len - start_offset); result_len += subject_len - start_offset; - result->val[result_len] = '\0'; - result->len = result_len; + ZSTR_VAL(result)[result_len] = '\0'; + ZSTR_LEN(result) = result_len; break; } } else { @@ -1379,8 +1379,8 @@ static zend_string *php_replace_in_subject(zval *regex, zval *replace, zval *sub for further replacements. */ if ((result = php_pcre_replace(regex_str, subject_str, - subject_str->val, - (int)subject_str->len, + ZSTR_VAL(subject_str), + (int)ZSTR_LEN(subject_str), replace_value, is_callable_replace, limit, @@ -1400,8 +1400,8 @@ static zend_string *php_replace_in_subject(zval *regex, zval *replace, zval *sub } else { result = php_pcre_replace(Z_STR_P(regex), subject_str, - subject_str->val, - (int)subject_str->len, + ZSTR_VAL(subject_str), + (int)ZSTR_LEN(subject_str), replace, is_callable_replace, limit, @@ -1535,7 +1535,7 @@ static PHP_FUNCTION(preg_replace_callback) #endif if (!zend_is_callable(replace, 0, &callback_name)) { - php_error_docref(NULL, E_WARNING, "Requires argument 2, '%s', to be a valid callback", callback_name->val); + php_error_docref(NULL, E_WARNING, "Requires argument 2, '%s', to be a valid callback", ZSTR_VAL(callback_name)); zend_string_release(callback_name); ZVAL_COPY(return_value, subject); return; @@ -1586,7 +1586,7 @@ static PHP_FUNCTION(preg_replace_callback_array) } if (!zend_is_callable(replace, 0, &callback_name)) { - php_error_docref(NULL, E_WARNING, "'%s' is not a valid callback", callback_name->val); + php_error_docref(NULL, E_WARNING, "'%s' is not a valid callback", ZSTR_VAL(callback_name)); zend_string_release(callback_name); zval_ptr_dtor(®ex); zval_ptr_dtor(return_value); @@ -1692,7 +1692,7 @@ static PHP_FUNCTION(preg_split) } pce->refcount++; - php_pcre_split_impl(pce, subject->val, (int)subject->len, return_value, (int)limit_val, flags); + php_pcre_split_impl(pce, ZSTR_VAL(subject), (int)ZSTR_LEN(subject), return_value, (int)limit_val, flags); pce->refcount--; } /* }}} */ @@ -1922,7 +1922,7 @@ static PHP_FUNCTION(preg_quote) out_str = zend_string_safe_alloc(4, in_str_len, 0, 0); /* Go through the string and quote necessary characters */ - for (p = in_str, q = out_str->val; p != in_str_end; p++) { + for (p = in_str, q = ZSTR_VAL(out_str); p != in_str_end; p++) { c = *p; switch(c) { case '.': @@ -1966,7 +1966,7 @@ static PHP_FUNCTION(preg_quote) *q = '\0'; /* Reallocate string and return it */ - out_str = zend_string_truncate(out_str, q - out_str->val, 0); + out_str = zend_string_truncate(out_str, q - ZSTR_VAL(out_str), 0); RETURN_NEW_STR(out_str); } /* }}} */ @@ -2050,8 +2050,8 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return zend_string *subject_str = zval_get_string(entry); /* Perform the match */ - count = pcre_exec(pce->re, extra, subject_str->val, - (int)subject_str->len, 0, + count = pcre_exec(pce->re, extra, ZSTR_VAL(subject_str), + (int)ZSTR_LEN(subject_str), 0, 0, offsets, size_offsets); /* Check for too many substrings condition. */ diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 76a5eb4520..70a8bd2ea5 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -147,7 +147,7 @@ PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt) /* {{{ */ } if (dbh->error_mode == PDO_ERRMODE_WARNING) { - php_error_docref(NULL, E_WARNING, "%s", message->val); + php_error_docref(NULL, E_WARNING, "%s", ZSTR_VAL(message)); } else if (EG(exception) == NULL) { zval ex; zend_class_entry *def_ex = php_pdo_get_exception_base(1), *pdo_ex = php_pdo_get_exception(); @@ -1337,8 +1337,8 @@ static union _zend_function *dbh_method_get(zend_object **object, zend_string *m pdo_dbh_object_t *dbh_obj = php_pdo_dbh_fetch_object(*object); zend_string *lc_method_name; - lc_method_name = zend_string_init(method_name->val, method_name->len, 0); - zend_str_tolower_copy(lc_method_name->val, method_name->val, method_name->len); + lc_method_name = zend_string_init(ZSTR_VAL(method_name), ZSTR_LEN(method_name), 0); + zend_str_tolower_copy(ZSTR_VAL(lc_method_name), ZSTR_VAL(method_name), ZSTR_LEN(method_name)); if ((fbc = std_object_handlers.get_method(object, method_name, key)) == NULL) { /* not a pre-defined method, nor a user-defined method; check diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c index 9e1d4185d5..155ca95c1c 100644 --- a/ext/pdo/pdo_sql_parser.c +++ b/ext/pdo/pdo_sql_parser.c @@ -506,7 +506,7 @@ PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, size_t inquery_len if (stmt->named_rewrite_template) { /* magic/hack. - * We pretend that the query was positional even if + * We we pretend that the query was positional even if * it was named so that we fall into the * named rewrite case below. Not too pretty, * but it works. */ @@ -575,7 +575,7 @@ safe: zend_string *buf; buf = php_stream_copy_to_mem(stm, PHP_STREAM_COPY_ALL, 0); - if (!stmt->dbh->methods->quoter(stmt->dbh, buf->val, buf->len, &plc->quoted, &plc->qlen, + if (!stmt->dbh->methods->quoter(stmt->dbh, ZSTR_VAL(buf), ZSTR_LEN(buf), &plc->quoted, &plc->qlen, param->param_type)) { /* bork */ ret = -1; diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re index cc774e1a02..9922e03690 100644 --- a/ext/pdo/pdo_sql_parser.re +++ b/ext/pdo/pdo_sql_parser.re @@ -217,7 +217,7 @@ safe: zend_string *buf; buf = php_stream_copy_to_mem(stm, PHP_STREAM_COPY_ALL, 0); - if (!stmt->dbh->methods->quoter(stmt->dbh, buf->val, buf->len, &plc->quoted, &plc->qlen, + if (!stmt->dbh->methods->quoter(stmt->dbh, ZSTR_VAL(buf), ZSTR_LEN(buf), &plc->quoted, &plc->qlen, param->param_type)) { /* bork */ ret = -1; diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 6383abb925..78cee77230 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -146,7 +146,7 @@ static inline int rewrite_name_to_position(pdo_stmt_t *stmt, struct pdo_bound_pa } ZEND_HASH_FOREACH_PTR(stmt->bound_param_map, name) { - if (strncmp(name, param->name->val, param->name->len + 1)) { + if (strncmp(name, ZSTR_VAL(param->name), ZSTR_LEN(param->name) + 1)) { position++; continue; } @@ -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->val; + char *s = ZSTR_VAL(stmt->columns[col].name); switch (stmt->dbh->desired_case) { case PDO_CASE_UPPER: @@ -345,8 +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 (stmt->columns[i].name->len == param->name->len && - strncmp(stmt->columns[i].name->val, param->name->val, param->name->len + 1) == 0) { + if (ZSTR_LEN(stmt->columns[i].name) == ZSTR_LEN(param->name) && + strncmp(ZSTR_VAL(stmt->columns[i].name), ZSTR_VAL(param->name), ZSTR_LEN(param->name) + 1) == 0) { param->paramno = i; break; } @@ -356,20 +356,20 @@ static int really_register_bound_param(struct pdo_bound_param_data *param, pdo_s * then this will trigger, and we don't want that */ if (param->paramno == -1) { char *tmp; - spprintf(&tmp, 0, "Did not find column name '%s' in the defined columns; it will not be bound", param->name->val); + spprintf(&tmp, 0, "Did not find column name '%s' in the defined columns; it will not be bound", ZSTR_VAL(param->name)); pdo_raise_impl_error(stmt->dbh, stmt, "HY000", tmp); efree(tmp); } } if (param->name) { - if (is_param && param->name->val[0] != ':') { - zend_string *temp = zend_string_alloc(param->name->len + 1, 0); - temp->val[0] = ':'; - memmove(temp->val + 1, param->name->val, param->name->len + 1); + if (is_param && ZSTR_VAL(param->name)[0] != ':') { + zend_string *temp = zend_string_alloc(ZSTR_LEN(param->name) + 1, 0); + ZSTR_VAL(temp)[0] = ':'; + memmove(ZSTR_VAL(temp) + 1, ZSTR_VAL(param->name), ZSTR_LEN(param->name) + 1); param->name = temp; } else { - param->name = zend_string_init(param->name->val, param->name->len, 0); + param->name = zend_string_init(ZSTR_VAL(param->name), ZSTR_LEN(param->name), 0); } } @@ -2124,14 +2124,14 @@ static PHP_METHOD(PDOStatement, debugDumpParams) zend_string *key = NULL; ZEND_HASH_FOREACH_KEY_PTR(stmt->bound_params, num, key, param) { if (key) { - php_stream_printf(out, "Key: Name: [%d] %.*s\n", key->len, key->len, key->val); + php_stream_printf(out, "Key: Name: [%d] %.*s\n", ZSTR_LEN(key), ZSTR_LEN(key), ZSTR_VAL(key)); } else { php_stream_printf(out, "Key: Position #%pd:\n", num); } php_stream_printf(out, "paramno=%pd\nname=[%d] \"%.*s\"\nis_param=%d\nparam_type=%d\n", - param->paramno, param->name? param->name->len : 0, param->name? param->name->len : 0, - param->name ? param->name->val : "", + param->paramno, param->name? ZSTR_LEN(param->name) : 0, param->name? ZSTR_LEN(param->name) : 0, + param->name ? ZSTR_VAL(param->name) : "", param->is_param, param->param_type); @@ -2216,8 +2216,8 @@ static union _zend_function *dbstmt_method_get(zend_object **object_pp, zend_str zend_string *lc_method_name; zend_object *object = *object_pp; - lc_method_name = zend_string_alloc(method_name->len, 0); - zend_str_tolower_copy(lc_method_name->val, method_name->val, method_name->len); + lc_method_name = zend_string_alloc(ZSTR_LEN(method_name), 0); + zend_str_tolower_copy(ZSTR_VAL(lc_method_name), ZSTR_VAL(method_name), ZSTR_LEN(method_name)); if ((fbc = zend_hash_find_ptr(&object->ce->function_table, lc_method_name)) == NULL) { pdo_stmt_t *stmt = php_pdo_stmt_fetch_object(object); @@ -2506,8 +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 (stmt->columns[colno].name->len == Z_STRLEN_P(member) && - strncmp(stmt->columns[colno].name->val, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) { + if (ZSTR_LEN(stmt->columns[colno].name) == Z_STRLEN_P(member) && + strncmp(ZSTR_VAL(stmt->columns[colno].name), Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) { fetch_value(stmt, rv, colno, NULL); //??? //Z_SET_REFCOUNT_P(rv, 0); @@ -2566,8 +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 (stmt->columns[colno].name->len == Z_STRLEN_P(member) && - strncmp(stmt->columns[colno].name->val, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) { + if (ZSTR_LEN(stmt->columns[colno].name) == Z_STRLEN_P(member) && + strncmp(ZSTR_VAL(stmt->columns[colno].name), Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) { return 1; } } @@ -2621,8 +2621,8 @@ static union _zend_function *row_method_get( zend_function *fbc; zend_string *lc_method_name; - lc_method_name = zend_string_alloc(method_name->len, 0); - zend_str_tolower_copy(lc_method_name->val, method_name->val, method_name->len); + lc_method_name = zend_string_alloc(ZSTR_LEN(method_name), 0); + zend_str_tolower_copy(ZSTR_VAL(lc_method_name), ZSTR_VAL(method_name), ZSTR_LEN(method_name)); if ((fbc = zend_hash_find_ptr(&pdo_row_ce->function_table, lc_method_name)) == NULL) { zend_string_release(lc_method_name); diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 9fa78e0cb1..9f75f17cfe 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -1219,11 +1219,11 @@ static int pdo_pgsql_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{ /* support both full connection string & connection string + login and/or password */ if (tmp_user && tmp_pass) { - spprintf(&conn_str, 0, "%s user='%s' password='%s' connect_timeout=%pd", (char *) dbh->data_source, tmp_user->val, tmp_pass->val, connect_timeout); + spprintf(&conn_str, 0, "%s user='%s' password='%s' connect_timeout=%pd", (char *) dbh->data_source, ZSTR_VAL(tmp_user), ZSTR_VAL(tmp_pass), connect_timeout); } else if (tmp_user) { - spprintf(&conn_str, 0, "%s user='%s' connect_timeout=%pd", (char *) dbh->data_source, tmp_user->val, connect_timeout); + spprintf(&conn_str, 0, "%s user='%s' connect_timeout=%pd", (char *) dbh->data_source, ZSTR_VAL(tmp_user), connect_timeout); } else if (tmp_pass) { - spprintf(&conn_str, 0, "%s password='%s' connect_timeout=%pd", (char *) dbh->data_source, tmp_pass->val, connect_timeout); + spprintf(&conn_str, 0, "%s password='%s' connect_timeout=%pd", (char *) dbh->data_source, ZSTR_VAL(tmp_pass), connect_timeout); } else { spprintf(&conn_str, 0, "%s connect_timeout=%pd", (char *) dbh->data_source, connect_timeout); } diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c index 9c2a0e2efd..1e211733e7 100644 --- a/ext/pdo_pgsql/pgsql_statement.c +++ b/ext/pdo_pgsql/pgsql_statement.c @@ -255,8 +255,8 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data * case PDO_PARAM_EVT_NORMALIZE: /* decode name from $1, $2 into 0, 1 etc. */ if (param->name) { - if (param->name->val[0] == '$') { - ZEND_ATOL(param->paramno, param->name->val + 1); + if (ZSTR_VAL(param->name)[0] == '$') { + ZEND_ATOL(param->paramno, ZSTR_VAL(param->name) + 1); } else { /* resolve parameter name to rewritten name */ char *namevar; @@ -266,7 +266,7 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data * ZEND_ATOL(param->paramno, namevar + 1); param->paramno--; } else { - pdo_raise_impl_error(stmt->dbh, stmt, "HY093", param->name->val); + pdo_raise_impl_error(stmt->dbh, stmt, "HY093", ZSTR_VAL(param->name)); return 0; } } diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c index decc9dc438..6dff114c01 100644 --- a/ext/pdo_sqlite/sqlite_driver.c +++ b/ext/pdo_sqlite/sqlite_driver.c @@ -533,7 +533,7 @@ static PHP_METHOD(SQLite, sqliteCreateFunction) PDO_CONSTRUCT_CHECK; if (!zend_is_callable(callback, 0, &cbname)) { - php_error_docref(NULL, E_WARNING, "function '%s' is not callable", cbname->val); + php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname)); zend_string_release(cbname); RETURN_FALSE; } @@ -603,13 +603,13 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate) PDO_CONSTRUCT_CHECK; if (!zend_is_callable(step_callback, 0, &cbname)) { - php_error_docref(NULL, E_WARNING, "function '%s' is not callable", cbname->val); + php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname)); zend_string_release(cbname); RETURN_FALSE; } zend_string_release(cbname); if (!zend_is_callable(fini_callback, 0, &cbname)) { - php_error_docref(NULL, E_WARNING, "function '%s' is not callable", cbname->val); + php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname)); zend_string_release(cbname); RETURN_FALSE; } @@ -663,7 +663,7 @@ static PHP_METHOD(SQLite, sqliteCreateCollation) PDO_CONSTRUCT_CHECK; if (!zend_is_callable(callback, 0, &cbname)) { - php_error_docref(NULL, E_WARNING, "function '%s' is not callable", cbname->val); + php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname)); zend_string_release(cbname); RETURN_FALSE; } diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c index f42ad05329..53d12a719d 100644 --- a/ext/pdo_sqlite/sqlite_statement.c +++ b/ext/pdo_sqlite/sqlite_statement.c @@ -91,7 +91,7 @@ static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_d if (param->is_param) { if (param->paramno == -1) { - param->paramno = sqlite3_bind_parameter_index(S->stmt, param->name->val) - 1; + param->paramno = sqlite3_bind_parameter_index(S->stmt, ZSTR_VAL(param->name)) - 1; } switch (PDO_PARAM_TYPE(param->param_type)) { diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 704a919712..5681d2f2a8 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -1364,7 +1364,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) /* hash it up */ new_le.type = le_plink; new_le.ptr = pgsql; - if (zend_hash_str_update_mem(&EG(persistent_list), str.s->val, str.s->len, &new_le, sizeof(zend_resource)) == NULL) { + if (zend_hash_str_update_mem(&EG(persistent_list), ZSTR_VAL(str.s), ZSTR_LEN(str.s), &new_le, sizeof(zend_resource)) == NULL) { goto err; } PGG(num_links)++; @@ -2368,7 +2368,7 @@ static char *get_field_name(PGconn *pgsql, Oid oid, HashTable *list) continue; } - str.s->len = 0; + ZSTR_LEN(str.s) = 0; smart_str_appends(&str, "pgsql_oid_"); smart_str_appends(&str, tmp_oid); smart_str_0(&str); @@ -2453,7 +2453,7 @@ PHP_FUNCTION(pg_field_table) smart_str_append_unsigned(&querystr, oid); smart_str_0(&querystr); - if ((tmp_res = PQexec(pg_result->conn, querystr.s->val)) == NULL || PQresultStatus(tmp_res) != PGRES_TUPLES_OK) { + if ((tmp_res = PQexec(pg_result->conn, ZSTR_VAL(querystr.s))) == NULL || PQresultStatus(tmp_res) != PGRES_TUPLES_OK) { if (tmp_res) { PQclear(tmp_res); } @@ -2696,7 +2696,7 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_ ce = zend_fetch_class(class_name, ZEND_FETCH_CLASS_AUTO); } if (!ce) { - php_error_docref(NULL, E_WARNING, "Could not find class '%s'", class_name->val); + php_error_docref(NULL, E_WARNING, "Could not find class '%s'", ZSTR_VAL(class_name)); return; } result_type = PGSQL_ASSOC; @@ -3507,13 +3507,13 @@ PHP_FUNCTION(pg_lo_read) } buf = zend_string_alloc(buf_len, 0); - if ((nbytes = lo_read((PGconn *)pgsql->conn, pgsql->lofd, buf->val, buf->len))<0) { + if ((nbytes = lo_read((PGconn *)pgsql->conn, pgsql->lofd, ZSTR_VAL(buf), ZSTR_LEN(buf)))<0) { zend_string_free(buf); RETURN_FALSE; } - buf->len = nbytes; - buf->val[buf->len] = '\0'; + ZSTR_LEN(buf) = nbytes; + ZSTR_VAL(buf)[ZSTR_LEN(buf)] = '\0'; RETURN_NEW_STR(buf); } /* }}} */ @@ -4348,20 +4348,20 @@ PHP_FUNCTION(pg_escape_string) break; } - to = zend_string_alloc(from->len * 2, 0); + to = zend_string_alloc(ZSTR_LEN(from) * 2, 0); #ifdef HAVE_PQESCAPE_CONN if (link) { if ((pgsql = (PGconn *)zend_fetch_resource2(link, "PostgreSQL link", le_link, le_plink)) == NULL) { RETURN_FALSE; } - to->len = PQescapeStringConn(pgsql, to->val, from->val, from->len, NULL); + ZSTR_LEN(to) = PQescapeStringConn(pgsql, ZSTR_VAL(to), ZSTR_VAL(from), ZSTR_LEN(from), NULL); } else #endif { - to->len = PQescapeString(to->val, from->val, from->len); + ZSTR_LEN(to) = PQescapeString(ZSTR_VAL(to), ZSTR_VAL(from), ZSTR_LEN(from)); } - to = zend_string_truncate(to, to->len, 0); + to = zend_string_truncate(to, ZSTR_LEN(to), 0); RETURN_NEW_STR(to); } /* }}} */ @@ -5553,7 +5553,7 @@ PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, z smart_str_0(&querystr); efree(src); - pg_result = PQexec(pg_link, querystr.s->val); + pg_result = PQexec(pg_link, ZSTR_VAL(querystr.s)); if (PQresultStatus(pg_result) != PGRES_TUPLES_OK || (num_rows = PQntuples(pg_result)) == 0) { php_error_docref(NULL, E_WARNING, "Table '%s' doesn't exists", table_name); smart_str_free(&querystr); @@ -5792,7 +5792,7 @@ static int php_pgsql_add_quotes(zval *src, zend_bool should_free) } \ /* raise error if it's not null and cannot be ignored */ \ else if (!(opt & PGSQL_CONV_IGNORE_NOT_NULL) && Z_TYPE_P(not_null) == IS_TRUE) { \ - php_error_docref(NULL, E_NOTICE, "Detected NULL for 'NOT NULL' field '%s'", field->val); \ + php_error_docref(NULL, E_NOTICE, "Detected NULL for 'NOT NULL' field '%s'", ZSTR_VAL(field)); \ err = 1; \ } \ } @@ -5834,7 +5834,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } if (!err && (def = zend_hash_find(Z_ARRVAL(meta), field)) == NULL) { - php_error_docref(NULL, E_NOTICE, "Invalid field name (%s) in values", field->val); + php_error_docref(NULL, E_NOTICE, "Invalid field name (%s) in values", ZSTR_VAL(field)); err = 1; } if (!err && (type = zend_hash_str_find(Z_ARRVAL_P(def), "type", sizeof("type") - 1)) == NULL) { @@ -5893,7 +5893,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con ZVAL_STRINGL(&new_val, "'f'", sizeof("'f'")-1); } else { - php_error_docref(NULL, E_NOTICE, "Detected invalid value (%s) for PostgreSQL %s field (%s)", Z_STRVAL_P(val), Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Detected invalid value (%s) for PostgreSQL %s field (%s)", Z_STRVAL_P(val), Z_STRVAL_P(type), ZSTR_VAL(field)); err = 1; } } @@ -5925,7 +5925,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects string, null, long or boolelan value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects string, null, long or boolelan value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -5967,7 +5967,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for pgsql '%s' (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for pgsql '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6013,7 +6013,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6050,8 +6050,8 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con /* PostgreSQL ignores \0 */ str = zend_string_alloc(Z_STRLEN_P(val) * 2, 0); /* better to use PGSQLescapeLiteral since PGescapeStringConn does not handle special \ */ - str->len = PQescapeStringConn(pg_link, str->val, Z_STRVAL_P(val), Z_STRLEN_P(val), NULL); - str = zend_string_truncate(str, str->len, 0); + ZSTR_LEN(str) = PQescapeStringConn(pg_link, ZSTR_VAL(str), Z_STRVAL_P(val), Z_STRLEN_P(val), NULL); + str = zend_string_truncate(str, ZSTR_LEN(str), 0); ZVAL_NEW_STR(&new_val, str); php_pgsql_add_quotes(&new_val, 1); } @@ -6076,7 +6076,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6118,7 +6118,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for '%s' (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6150,7 +6150,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL or string for '%s' (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL or string for '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6183,7 +6183,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6214,7 +6214,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6245,7 +6245,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6324,7 +6324,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; #ifdef HAVE_PQESCAPE @@ -6372,7 +6372,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; @@ -6403,13 +6403,13 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; default: /* should not happen */ - php_error_docref(NULL, E_NOTICE, "Unknown or system data type '%s' for '%s'. Report error", Z_STRVAL_P(type), field->val); + php_error_docref(NULL, E_NOTICE, "Unknown or system data type '%s' for '%s'. Report error", Z_STRVAL_P(type), ZSTR_VAL(field)); err = 1; break; } /* switch */ @@ -6422,10 +6422,10 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con if (!skip_field) { char *escaped; - if (_php_pgsql_detect_identifier_escape(field->val, field->len) == SUCCESS) { + if (_php_pgsql_detect_identifier_escape(ZSTR_VAL(field), ZSTR_LEN(field)) == SUCCESS) { zend_hash_update(Z_ARRVAL_P(result), field, &new_val); } else { - escaped = PGSQLescapeIdentifier(pg_link, field->val, field->len); + escaped = PGSQLescapeIdentifier(pg_link, ZSTR_VAL(field), ZSTR_LEN(field)); add_assoc_zval(result, escaped, &new_val); PGSQLfree(escaped); } @@ -6483,14 +6483,14 @@ PHP_FUNCTION(pg_convert) static int do_exec(smart_str *querystr, int expect, PGconn *pg_link, zend_ulong opt) /* {{{ */ { if (opt & PGSQL_DML_ASYNC) { - if (PQsendQuery(pg_link, querystr->s->val)) { + if (PQsendQuery(pg_link, ZSTR_VAL(querystr->s))) { return 0; } } else { PGresult *pg_result; - pg_result = PQexec(pg_link, querystr->s->val); + pg_result = PQexec(pg_link, ZSTR_VAL(querystr->s)); if (PQresultStatus(pg_result) == expect) { PQclear(pg_result); return 0; @@ -6585,15 +6585,15 @@ PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var goto cleanup; } if (opt & PGSQL_DML_ESCAPE) { - tmp = PGSQLescapeIdentifier(pg_link, fld->val, fld->len + 1); + tmp = PGSQLescapeIdentifier(pg_link, ZSTR_VAL(fld), ZSTR_LEN(fld) + 1); smart_str_appends(&querystr, tmp); PGSQLfree(tmp); } else { - smart_str_appendl(&querystr, fld->val, fld->len); + smart_str_appendl(&querystr, ZSTR_VAL(fld), ZSTR_LEN(fld)); } smart_str_appendc(&querystr, ','); } ZEND_HASH_FOREACH_END(); - querystr.s->len--; + ZSTR_LEN(querystr.s)--; smart_str_appends(&querystr, ") VALUES ("); /* make values string */ @@ -6631,7 +6631,7 @@ PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var smart_str_appendc(&querystr, ','); } ZEND_HASH_FOREACH_END(); /* Remove the trailing "," */ - querystr.s->len--; + ZSTR_LEN(querystr.s)--; smart_str_appends(&querystr, ");"); no_values: @@ -6696,11 +6696,11 @@ PHP_FUNCTION(pg_insert) if (php_pgsql_insert(pg_link, table, values, option|PGSQL_DML_STRING, &sql) == FAILURE) { RETURN_FALSE; } - pg_result = PQexec(pg_link, sql->val); + pg_result = PQexec(pg_link, ZSTR_VAL(sql)); if ((PGG(auto_reset_persistent) & 2) && PQstatus(pg_link) != CONNECTION_OK) { PQclear(pg_result); PQreset(pg_link); - pg_result = PQexec(pg_link, sql->val); + pg_result = PQexec(pg_link, ZSTR_VAL(sql)); } efree(sql); @@ -6758,11 +6758,11 @@ static inline int build_assignment_string(PGconn *pg_link, smart_str *querystr, return -1; } if (opt & PGSQL_DML_ESCAPE) { - tmp = PGSQLescapeIdentifier(pg_link, fld->val, fld->len + 1); + tmp = PGSQLescapeIdentifier(pg_link, ZSTR_VAL(fld), ZSTR_LEN(fld) + 1); smart_str_appends(querystr, tmp); PGSQLfree(tmp); } else { - smart_str_appendl(querystr, fld->val, fld->len); + smart_str_appendl(querystr, ZSTR_VAL(fld), ZSTR_LEN(fld)); } if (where_cond && (Z_TYPE_P(val) == IS_TRUE || Z_TYPE_P(val) == IS_FALSE || (Z_TYPE_P(val) == IS_STRING && !strcmp(Z_STRVAL_P(val), "NULL")))) { smart_str_appends(querystr, " IS "); @@ -6800,7 +6800,7 @@ static inline int build_assignment_string(PGconn *pg_link, smart_str *querystr, smart_str_appendl(querystr, pad, pad_len); } ZEND_HASH_FOREACH_END(); if (querystr->s) { - querystr->s->len -= pad_len; + ZSTR_LEN(querystr->s) -= pad_len; } return 0; @@ -7079,11 +7079,11 @@ PHP_PGSQL_API int php_pgsql_select(PGconn *pg_link, const char *table, zval *ids smart_str_appendc(&querystr, ';'); smart_str_0(&querystr); - pg_result = PQexec(pg_link, querystr.s->val); + pg_result = PQexec(pg_link, ZSTR_VAL(querystr.s)); if (PQresultStatus(pg_result) == PGRES_TUPLES_OK) { ret = php_pgsql_result2array(pg_result, ret_array); } else { - php_error_docref(NULL, E_NOTICE, "Failed to execute '%s'", querystr.s->val); + php_error_docref(NULL, E_NOTICE, "Failed to execute '%s'", ZSTR_VAL(querystr.s)); } PQclear(pg_result); diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c index 9a81dbbe3a..6cb78ad692 100644 --- a/ext/phar/dirstream.c +++ b/ext/phar/dirstream.c @@ -102,14 +102,14 @@ static size_t phar_dir_read(php_stream *stream, char *buf, size_t count) /* {{{ } zend_hash_move_forward(data); - to_read = MIN(str_key->len, count); + to_read = MIN(ZSTR_LEN(str_key), count); - if (to_read == 0 || count < str_key->len) { + if (to_read == 0 || count < ZSTR_LEN(str_key)) { return 0; } memset(buf, 0, sizeof(php_stream_dirent)); - memcpy(((php_stream_dirent *) buf)->d_name, str_key->val, to_read); + memcpy(((php_stream_dirent *) buf)->d_name, ZSTR_VAL(str_key), to_read); ((php_stream_dirent *) buf)->d_name[to_read + 1] = '\0'; return sizeof(php_stream_dirent); @@ -160,7 +160,7 @@ static int phar_compare_dir_name(const void *a, const void *b) /* {{{ */ f = (Bucket *) a; s = (Bucket *) b; - result = zend_binary_strcmp(f->key->val, f->key->len, s->key->val, s->key->len); + result = zend_binary_strcmp(ZSTR_VAL(f->key), ZSTR_LEN(f->key), ZSTR_VAL(s->key), ZSTR_LEN(s->key)); if (result < 0) { return -1; @@ -203,9 +203,9 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest) /* {{{ */ break; } - keylen = str_key->len; + keylen = ZSTR_LEN(str_key); if (keylen <= (uint)dirlen) { - if (keylen < (uint)dirlen || !strncmp(str_key->val, dir, dirlen)) { + if (keylen < (uint)dirlen || !strncmp(ZSTR_VAL(str_key), dir, dirlen)) { if (SUCCESS != zend_hash_move_forward(manifest)) { break; } @@ -215,7 +215,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest) /* {{{ */ if (*dir == '/') { /* root directory */ - if (keylen >= sizeof(".phar")-1 && !memcmp(str_key->val, ".phar", sizeof(".phar")-1)) { + if (keylen >= sizeof(".phar")-1 && !memcmp(ZSTR_VAL(str_key), ".phar", sizeof(".phar")-1)) { /* do not add any magic entries to this directory */ if (SUCCESS != zend_hash_move_forward(manifest)) { break; @@ -223,28 +223,28 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest) /* {{{ */ continue; } - if (NULL != (found = (char *) memchr(str_key->val, '/', keylen))) { + if (NULL != (found = (char *) memchr(ZSTR_VAL(str_key), '/', keylen))) { /* the entry has a path separator and is a subdirectory */ - entry = (char *) safe_emalloc(found - str_key->val, 1, 1); - memcpy(entry, str_key->val, found - str_key->val); - keylen = found - str_key->val; + entry = (char *) safe_emalloc(found - ZSTR_VAL(str_key), 1, 1); + memcpy(entry, ZSTR_VAL(str_key), found - ZSTR_VAL(str_key)); + keylen = found - ZSTR_VAL(str_key); entry[keylen] = '\0'; } else { entry = (char *) safe_emalloc(keylen, 1, 1); - memcpy(entry, str_key->val, keylen); + memcpy(entry, ZSTR_VAL(str_key), keylen); entry[keylen] = '\0'; } goto PHAR_ADD_ENTRY; } else { - if (0 != memcmp(str_key->val, dir, dirlen)) { + if (0 != memcmp(ZSTR_VAL(str_key), dir, dirlen)) { /* entry in directory not found */ if (SUCCESS != zend_hash_move_forward(manifest)) { break; } continue; } else { - if (str_key->val[dirlen] != '/') { + if (ZSTR_VAL(str_key)[dirlen] != '/') { if (SUCCESS != zend_hash_move_forward(manifest)) { break; } @@ -253,7 +253,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest) /* {{{ */ } } - save = str_key->val; + save = ZSTR_VAL(str_key); save += dirlen + 1; /* seek to just past the path separator */ if (NULL != (found = (char *) memchr(save, '/', keylen - dirlen - 1))) { @@ -385,7 +385,7 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, while (FAILURE != zend_hash_has_more_elements(&phar->manifest)) { if (HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&phar->manifest, &str_key, &unused)) { - if (str_key->len > (uint)i_len && 0 == memcmp(str_key->val, internal_file, i_len)) { + if (ZSTR_LEN(str_key) > (uint)i_len && 0 == memcmp(ZSTR_VAL(str_key), internal_file, i_len)) { /* directory found */ internal_file = estrndup(internal_file, i_len); @@ -614,9 +614,9 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&phar->manifest, &str_key, &unused); zend_hash_move_forward(&phar->manifest) ) { - if (str_key->len > path_len && - memcmp(str_key->val, resource->path+1, path_len) == 0 && - IS_SLASH(str_key->val[path_len])) { + if (ZSTR_LEN(str_key) > path_len && + memcmp(ZSTR_VAL(str_key), resource->path+1, path_len) == 0 && + IS_SLASH(ZSTR_VAL(str_key)[path_len])) { php_stream_wrapper_log_error(wrapper, options, "phar error: Directory not empty"); if (entry->is_temp_dir) { efree(entry->filename); @@ -631,9 +631,9 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&phar->virtual_dirs, &str_key, &unused); zend_hash_move_forward(&phar->virtual_dirs)) { - if (str_key->len > path_len && - memcmp(str_key->val, resource->path+1, path_len) == 0 && - IS_SLASH(str_key->val[path_len])) { + if (ZSTR_LEN(str_key) > path_len && + memcmp(ZSTR_VAL(str_key), resource->path+1, path_len) == 0 && + IS_SLASH(ZSTR_VAL(str_key)[path_len])) { php_stream_wrapper_log_error(wrapper, options, "phar error: Directory not empty"); if (entry->is_temp_dir) { efree(entry->filename); diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c index c4912649db..dc08bd424f 100644 --- a/ext/phar/func_interceptors.c +++ b/ext/phar/func_interceptors.c @@ -150,7 +150,7 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */ } if (use_include_path) { if ((entry_str = phar_find_in_include_path(entry, entry_len, NULL))) { - name = entry_str->val; + name = ZSTR_VAL(entry_str); goto phar_it; } else { /* this file is not in the phar, use the original path */ @@ -207,7 +207,7 @@ phar_it: /* uses mmap if possible */ contents = php_stream_copy_to_mem(stream, maxlen, 0); - if (contents && contents->len > 0) { + if (contents && ZSTR_LEN(contents) > 0) { RETVAL_STR(contents); } else if (contents) { zend_string_release(contents); @@ -278,7 +278,7 @@ PHAR_FUNC(phar_readfile) /* {{{ */ efree(arch); goto skip_phar; } else { - name = entry_str->val; + name = ZSTR_VAL(entry_str); } } else { entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1); @@ -379,7 +379,7 @@ PHAR_FUNC(phar_fopen) /* {{{ */ efree(arch); goto skip_phar; } else { - name = entry_str->val; + name = ZSTR_VAL(entry_str); } } else { entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1); diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 32f641624a..4f40153ab0 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -50,28 +50,28 @@ ZEND_INI_MH(phar_ini_modify_handler) /* {{{ */ { zend_bool old, ini; - if (entry->name->len == sizeof("phar.readonly")-1) { + if (ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1) { old = PHAR_G(readonly_orig); } else { old = PHAR_G(require_hash_orig); } - if (new_value->len == 2 && !strcasecmp("on", new_value->val)) { + if (ZSTR_LEN(new_value) == 2 && !strcasecmp("on", ZSTR_VAL(new_value))) { ini = (zend_bool) 1; } - else if (new_value->len == 3 && !strcasecmp("yes", new_value->val)) { + else if (ZSTR_LEN(new_value) == 3 && !strcasecmp("yes", ZSTR_VAL(new_value))) { ini = (zend_bool) 1; } - else if (new_value->len == 4 && !strcasecmp("true", new_value->val)) { + else if (ZSTR_LEN(new_value) == 4 && !strcasecmp("true", ZSTR_VAL(new_value))) { ini = (zend_bool) 1; } else { - ini = (zend_bool) atoi(new_value->val); + ini = (zend_bool) atoi(ZSTR_VAL(new_value)); } /* do not allow unsetting in runtime */ if (stage == ZEND_INI_STAGE_STARTUP) { - if (entry->name->len == sizeof("phar.readonly")-1) { + if (ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1) { PHAR_G(readonly_orig) = ini; } else { PHAR_G(require_hash_orig) = ini; @@ -80,7 +80,7 @@ ZEND_INI_MH(phar_ini_modify_handler) /* {{{ */ return FAILURE; } - if (entry->name->len == sizeof("phar.readonly")-1) { + if (ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1) { PHAR_G(readonly) = ini; if (PHAR_G(request_init) && PHAR_G(phar_fname_map.u.flags)) { zend_hash_apply_with_argument(&(PHAR_G(phar_fname_map)), phar_set_writeable_bit, (void *)&ini); @@ -183,7 +183,7 @@ finish_error: ZEND_INI_MH(phar_ini_cache_list) /* {{{ */ { - PHAR_G(cache_list) = new_value->val; + PHAR_G(cache_list) = ZSTR_VAL(new_value); if (stage == ZEND_INI_STAGE_STARTUP) { phar_split_cache_list(); @@ -1339,8 +1339,8 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a fp = php_stream_open_wrapper(fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|0, &actual); if (actual) { - fname = actual->val; - fname_len = actual->len; + fname = ZSTR_VAL(actual); + fname_len = ZSTR_LEN(actual); } if (fp) { @@ -1514,8 +1514,8 @@ int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_l } if (actual) { - fname = actual->val; - fname_len = actual->len; + fname = ZSTR_VAL(actual); + fname_len = ZSTR_LEN(actual); } ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len, options, pphar, is_data, error); @@ -1962,16 +1962,16 @@ woohoo: HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&(PHAR_G(phar_fname_map)), &str_key, &unused); zend_hash_move_forward(&(PHAR_G(phar_fname_map))) ) { - if (str_key->len > (uint) filename_len) { + if (ZSTR_LEN(str_key) > (uint) filename_len) { continue; } - if (!memcmp(filename, str_key->val, str_key->len) && ((uint)filename_len == str_key->len - || filename[str_key->len] == '/' || filename[str_key->len] == '\0')) { + if (!memcmp(filename, ZSTR_VAL(str_key), ZSTR_LEN(str_key)) && ((uint)filename_len == ZSTR_LEN(str_key) + || filename[ZSTR_LEN(str_key)] == '/' || filename[ZSTR_LEN(str_key)] == '\0')) { if (NULL == (pphar = zend_hash_get_current_data_ptr(&(PHAR_G(phar_fname_map))))) { break; } - *ext_str = filename + (str_key->len - pphar->ext_len); + *ext_str = filename + (ZSTR_LEN(str_key) - pphar->ext_len); goto woohoo; } } @@ -1981,16 +1981,16 @@ woohoo: HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&cached_phars, &str_key, &unused); zend_hash_move_forward(&cached_phars) ) { - if (str_key->len > (uint) filename_len) { + if (ZSTR_LEN(str_key) > (uint) filename_len) { continue; } - if (!memcmp(filename, str_key->val, str_key->len) && ((uint)filename_len == str_key->len - || filename[str_key->len] == '/' || filename[str_key->len] == '\0')) { + if (!memcmp(filename, ZSTR_VAL(str_key), ZSTR_LEN(str_key)) && ((uint)filename_len == ZSTR_LEN(str_key) + || filename[ZSTR_LEN(str_key)] == '/' || filename[ZSTR_LEN(str_key)] == '\0')) { if (NULL == (pphar = zend_hash_get_current_data_ptr(&cached_phars))) { break; } - *ext_str = filename + (str_key->len - pphar->ext_len); + *ext_str = filename + (ZSTR_LEN(str_key) - pphar->ext_len); goto woohoo; } } @@ -2303,8 +2303,8 @@ int phar_open_executed_filename(char *alias, int alias_len, char **error) /* {{{ } if (actual) { - fname = actual->val; - fname_len = actual->len; + fname = ZSTR_VAL(actual); + fname_len = ZSTR_LEN(actual); } ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len, REPORT_ERRORS, NULL, 0, error); @@ -2582,8 +2582,8 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv return EOF; } free_user_stub = 1; - user_stub = suser_stub->val; - len = suser_stub->len; + user_stub = ZSTR_VAL(suser_stub); + len = ZSTR_LEN(suser_stub); } else { free_user_stub = 0; } @@ -2723,7 +2723,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv } /* 32 bits for filename length, length of filename, manifest + metadata, and add 1 for trailing / if a directory */ - offset += 4 + entry->filename_len + sizeof(entry_buffer) + (entry->metadata_str.s ? entry->metadata_str.s->len : 0) + (entry->is_dir ? 1 : 0); + offset += 4 + entry->filename_len + sizeof(entry_buffer) + (entry->metadata_str.s ? ZSTR_LEN(entry->metadata_str.s) : 0) + (entry->is_dir ? 1 : 0); /* compress and rehash as necessary */ if ((oldfile && !entry->is_modified) || entry->is_dir) { @@ -2849,7 +2849,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv phar->alias_len = 0; } - manifest_len = offset + phar->alias_len + sizeof(manifest) + (main_metadata_str.s ? main_metadata_str.s->len : 0); + manifest_len = offset + phar->alias_len + sizeof(manifest) + (main_metadata_str.s ? ZSTR_LEN(main_metadata_str.s) : 0); phar_set_32(manifest, manifest_len); /* Hack - see bug #65028, add padding byte to the end of the manifest */ if(manifest[0] == '\r' || manifest[0] == '\n') { @@ -2888,9 +2888,9 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv phar->alias_len = restore_alias_len; - phar_set_32(manifest, main_metadata_str.s ? main_metadata_str.s->len : 0); - if (4 != php_stream_write(newfile, manifest, 4) || ((main_metadata_str.s ? main_metadata_str.s->len : 0) - && main_metadata_str.s->len != php_stream_write(newfile, main_metadata_str.s->val, main_metadata_str.s->len))) { + phar_set_32(manifest, main_metadata_str.s ? ZSTR_LEN(main_metadata_str.s) : 0); + if (4 != php_stream_write(newfile, manifest, 4) || ((main_metadata_str.s ? ZSTR_LEN(main_metadata_str.s) : 0) + && ZSTR_LEN(main_metadata_str.s) != php_stream_write(newfile, ZSTR_VAL(main_metadata_str.s), ZSTR_LEN(main_metadata_str.s)))) { smart_str_free(&main_metadata_str); if (closeoldfile) { @@ -2964,11 +2964,11 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv phar_set_32(entry_buffer+8, entry->compressed_filesize); phar_set_32(entry_buffer+12, entry->crc32); phar_set_32(entry_buffer+16, entry->flags); - phar_set_32(entry_buffer+20, entry->metadata_str.s ? entry->metadata_str.s->len : 0); + phar_set_32(entry_buffer+20, entry->metadata_str.s ? ZSTR_LEN(entry->metadata_str.s) : 0); if (sizeof(entry_buffer) != php_stream_write(newfile, entry_buffer, sizeof(entry_buffer)) || (entry->metadata_str.s && - entry->metadata_str.s->len != php_stream_write(newfile, entry->metadata_str.s->val, entry->metadata_str.s->len))) { + ZSTR_LEN(entry->metadata_str.s) != php_stream_write(newfile, ZSTR_VAL(entry->metadata_str.s), ZSTR_LEN(entry->metadata_str.s)))) { if (closeoldfile) { php_stream_close(oldfile); } diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 11e5d5a7f1..1cfaee416f 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1423,7 +1423,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ if (!value) { /* failure in get_current_data */ - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned no value", ce->name->val); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned no value", ZSTR_VAL(ce->name)); return ZEND_HASH_APPLY_STOP; } @@ -1434,7 +1434,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ php_stream_from_zval_no_verify(fp, value); if (!fp) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Iterator %v returned an invalid stream handle", ce->name->val); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Iterator %v returned an invalid stream handle", ZSTR_VAL(ce->name)); return ZEND_HASH_APPLY_STOP; } @@ -1448,7 +1448,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ if (Z_TYPE(key) != IS_STRING) { zval_dtor(&key); - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned an invalid key (must return a string)", ce->name->val); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned an invalid key (must return a string)", ZSTR_VAL(ce->name)); return ZEND_HASH_APPLY_STOP; } @@ -1458,7 +1458,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ save = str_key; zval_dtor(&key); } else { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned an invalid key (must return a string)", ce->name->val); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned an invalid key (must return a string)", ZSTR_VAL(ce->name)); return ZEND_HASH_APPLY_STOP; } @@ -1472,7 +1472,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ spl_filesystem_object *intern = (spl_filesystem_object*)((char*)Z_OBJ_P(value) - Z_OBJ_P(value)->handlers->offset); if (!base_len) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Iterator %v returns an SplFileInfo object, so base directory must be specified", ce->name->val); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Iterator %v returns an SplFileInfo object, so base directory must be specified", ZSTR_VAL(ce->name)); return ZEND_HASH_APPLY_STOP; } @@ -1516,7 +1516,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ } /* fall-through */ default: - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned an invalid value (must return a string)", ce->name->val); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned an invalid value (must return a string)", ZSTR_VAL(ce->name)); return ZEND_HASH_APPLY_STOP; } @@ -1556,7 +1556,7 @@ phar_spl_fileinfo: } } else { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned a path \"%s\" that is not in the base directory \"%s\"", ce->name->val, fname, base); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned a path \"%s\" that is not in the base directory \"%s\"", ZSTR_VAL(ce->name), fname, base); if (save) { efree(save); @@ -1576,7 +1576,7 @@ phar_spl_fileinfo: if (Z_TYPE(key) != IS_STRING) { zval_dtor(&key); - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned an invalid key (must return a string)", ce->name->val); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned an invalid key (must return a string)", ZSTR_VAL(ce->name)); return ZEND_HASH_APPLY_STOP; } @@ -1586,13 +1586,13 @@ phar_spl_fileinfo: save = str_key; zval_dtor(&key); } else { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned an invalid key (must return a string)", ce->name->val); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned an invalid key (must return a string)", ZSTR_VAL(ce->name)); return ZEND_HASH_APPLY_STOP; } } #if PHP_API_VERSION < 20100412 if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned a path \"%s\" that safe mode prevents opening", ce->name->val, fname); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned a path \"%s\" that safe mode prevents opening", ZSTR_VAL(ce->name), fname); if (save) { efree(save); @@ -1607,7 +1607,7 @@ phar_spl_fileinfo: #endif if (php_check_open_basedir(fname)) { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned a path \"%s\" that open_basedir prevents opening", ce->name->val, fname); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned a path \"%s\" that open_basedir prevents opening", ZSTR_VAL(ce->name), fname); if (save) { efree(save); @@ -1624,7 +1624,7 @@ phar_spl_fileinfo: fp = php_stream_open_wrapper(fname, "rb", STREAM_MUST_SEEK|0, &opened); if (!fp) { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned a file that could not be opened \"%s\"", ce->name->val, fname); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %v returned a file that could not be opened \"%s\"", ZSTR_VAL(ce->name), fname); if (save) { efree(save); @@ -3916,7 +3916,7 @@ PHP_METHOD(Phar, getStub) carry_on: buf = zend_string_alloc(len, 0); - if (len != php_stream_read(fp, buf->val, len)) { + if (len != php_stream_read(fp, ZSTR_VAL(buf), len)) { if (fp != phar_obj->archive->fp) { php_stream_close(fp); } @@ -3935,8 +3935,8 @@ carry_on: php_stream_close(fp); } - buf->val[len] = '\0'; - buf->len = len; + ZSTR_VAL(buf)[len] = '\0'; + ZSTR_LEN(buf) = len; RETVAL_STR(buf); } /* }}}*/ diff --git a/ext/phar/stream.c b/ext/phar/stream.c index 90cb13cf13..fc477f0b9b 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -629,7 +629,7 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int f zend_string *str_key; ZEND_HASH_FOREACH_STR_KEY(&phar->mounted_dirs, str_key) { - if ((int)str_key->len >= internal_file_len || strncmp(str_key->val, internal_file, str_key->len)) { + if ((int)ZSTR_LEN(str_key) >= internal_file_len || strncmp(ZSTR_VAL(str_key), internal_file, ZSTR_LEN(str_key))) { continue; } else { char *test; @@ -642,7 +642,7 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int f if (!entry->tmp || !entry->is_mounted) { goto free_resource; } - test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, internal_file + str_key->len); + test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, internal_file + ZSTR_LEN(str_key)); if (SUCCESS != php_stream_stat_path(test, &ssbi)) { efree(test); continue; @@ -902,21 +902,21 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from str_key = b->key; entry = Z_PTR(b->val); if (!entry->is_deleted && - str_key->len > from_len && - memcmp(str_key->val, resource_from->path+1, from_len) == 0 && - IS_SLASH(str_key->val[from_len])) { + ZSTR_LEN(str_key) > from_len && + memcmp(ZSTR_VAL(str_key), resource_from->path+1, from_len) == 0 && + IS_SLASH(ZSTR_VAL(str_key)[from_len])) { - new_str_key = zend_string_alloc(str_key->len + to_len - from_len, 0); - memcpy(new_str_key->val, resource_to->path + 1, to_len); - memcpy(new_str_key->val + to_len, str_key->val + from_len, str_key->len - from_len); - new_str_key->val[new_str_key->len] = 0; + new_str_key = zend_string_alloc(ZSTR_LEN(str_key) + to_len - from_len, 0); + memcpy(ZSTR_VAL(new_str_key), resource_to->path + 1, to_len); + memcpy(ZSTR_VAL(new_str_key) + to_len, ZSTR_VAL(str_key) + from_len, ZSTR_LEN(str_key) - from_len); + ZSTR_VAL(new_str_key)[ZSTR_LEN(new_str_key)] = 0; is_modified = 1; entry->is_modified = 1; efree(entry->filename); // TODO: avoid reallocation (make entry->filename zend_string*) - entry->filename = estrndup(new_str_key->val, new_str_key->len); - entry->filename_len = new_str_key->len; + entry->filename = estrndup(ZSTR_VAL(new_str_key), ZSTR_LEN(new_str_key)); + entry->filename_len = ZSTR_LEN(new_str_key); zend_string_release(str_key); b->h = zend_string_hash_val(new_str_key); @@ -927,14 +927,14 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from ZEND_HASH_FOREACH_BUCKET(&phar->virtual_dirs, b) { str_key = b->key; - if (str_key->len >= from_len && - memcmp(str_key->val, resource_from->path+1, from_len) == 0 && - (str_key->len == from_len || IS_SLASH(str_key->val[from_len]))) { + if (ZSTR_LEN(str_key) >= from_len && + memcmp(ZSTR_VAL(str_key), resource_from->path+1, from_len) == 0 && + (ZSTR_LEN(str_key) == from_len || IS_SLASH(ZSTR_VAL(str_key)[from_len]))) { - new_str_key = zend_string_alloc(str_key->len + to_len - from_len, 0); - memcpy(new_str_key->val, resource_to->path + 1, to_len); - memcpy(new_str_key->val + to_len, str_key->val + from_len, str_key->len - from_len); - new_str_key->val[new_str_key->len] = 0; + new_str_key = zend_string_alloc(ZSTR_LEN(str_key) + to_len - from_len, 0); + memcpy(ZSTR_VAL(new_str_key), resource_to->path + 1, to_len); + memcpy(ZSTR_VAL(new_str_key) + to_len, ZSTR_VAL(str_key) + from_len, ZSTR_LEN(str_key) - from_len); + ZSTR_VAL(new_str_key)[ZSTR_LEN(new_str_key)] = 0; zend_string_release(str_key); b->h = zend_string_hash_val(new_str_key); @@ -945,14 +945,14 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from ZEND_HASH_FOREACH_BUCKET(&phar->mounted_dirs, b) { str_key = b->key; - if (str_key->len >= from_len && - memcmp(str_key->val, resource_from->path+1, from_len) == 0 && - (str_key->len == from_len || IS_SLASH(str_key->val[from_len]))) { - - new_str_key = zend_string_alloc(str_key->len + to_len - from_len, 0); - memcpy(new_str_key->val, resource_to->path + 1, to_len); - memcpy(new_str_key->val + to_len, str_key->val + from_len, str_key->len - from_len); - new_str_key->val[new_str_key->len] = 0; + if (ZSTR_LEN(str_key) >= from_len && + memcmp(ZSTR_VAL(str_key), resource_from->path+1, from_len) == 0 && + (ZSTR_LEN(str_key) == from_len || IS_SLASH(ZSTR_VAL(str_key)[from_len]))) { + + new_str_key = zend_string_alloc(ZSTR_LEN(str_key) + to_len - from_len, 0); + memcpy(ZSTR_VAL(new_str_key), resource_to->path + 1, to_len); + memcpy(ZSTR_VAL(new_str_key) + to_len, ZSTR_VAL(str_key) + from_len, ZSTR_LEN(str_key) - from_len); + ZSTR_VAL(new_str_key)[ZSTR_LEN(new_str_key)] = 0; zend_string_release(str_key); b->h = zend_string_hash_val(new_str_key); diff --git a/ext/phar/tar.c b/ext/phar/tar.c index 52df81971b..61ae79be8c 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -856,7 +856,7 @@ int phar_tar_setmetadata(zval *metadata, phar_entry_info *entry, char **error) / PHP_VAR_SERIALIZE_INIT(metadata_hash); php_var_serialize(&entry->metadata_str, metadata, &metadata_hash); PHP_VAR_SERIALIZE_DESTROY(metadata_hash); - entry->uncompressed_filesize = entry->compressed_filesize = entry->metadata_str.s ? entry->metadata_str.s->len : 0; + entry->uncompressed_filesize = entry->compressed_filesize = entry->metadata_str.s ? ZSTR_LEN(entry->metadata_str.s) : 0; if (entry->fp && entry->fp_type == PHAR_MOD) { php_stream_close(entry->fp); @@ -870,7 +870,7 @@ int phar_tar_setmetadata(zval *metadata, phar_entry_info *entry, char **error) / spprintf(error, 0, "phar error: unable to create temporary file"); return -1; } - if (entry->metadata_str.s->len != php_stream_write(entry->fp, entry->metadata_str.s->val, entry->metadata_str.s->len)) { + if (ZSTR_LEN(entry->metadata_str.s) != php_stream_write(entry->fp, ZSTR_VAL(entry->metadata_str.s), ZSTR_LEN(entry->metadata_str.s))) { spprintf(error, 0, "phar tar error: unable to write metadata to magic metadata file \"%s\"", entry->filename); zend_hash_str_del(&(entry->phar->manifest), entry->filename, entry->filename_len); return ZEND_HASH_APPLY_STOP; @@ -1017,8 +1017,8 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int { zend_string *str = php_stream_copy_to_mem(stubfile, len, 0); if (str) { - len = str->len; - user_stub = estrndup(str->val, str->len); + len = ZSTR_LEN(str); + user_stub = estrndup(ZSTR_VAL(str), ZSTR_LEN(str)); zend_string_release(str); } else { user_stub = NULL; diff --git a/ext/phar/util.c b/ext/phar/util.c index 1b657de67e..d561342cca 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -321,9 +321,9 @@ splitted: ret = php_resolve_path(filename, filename_len, path); efree(path); - if (ret && ret->len > 8 && !strncmp(ret->val, "phar://", 7)) { + if (ret && ZSTR_LEN(ret) > 8 && !strncmp(ZSTR_VAL(ret), "phar://", 7)) { /* found phar:// */ - if (SUCCESS != phar_split_fname(ret->val, ret->len, &arch, &arch_len, &entry, &entry_len, 1, 0)) { + if (SUCCESS != phar_split_fname(ZSTR_VAL(ret), ZSTR_LEN(ret), &arch, &arch_len, &entry, &entry_len, 1, 0)) { return ret; } @@ -1297,7 +1297,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in zend_string *str_key; ZEND_HASH_FOREACH_STR_KEY(&phar->mounted_dirs, str_key) { - if ((int)str_key->len >= path_len || strncmp(str_key->val, path, str_key->len)) { + if ((int)ZSTR_LEN(str_key) >= path_len || strncmp(ZSTR_VAL(str_key), path, ZSTR_LEN(str_key))) { continue; } else { char *test; @@ -1306,19 +1306,19 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in if (NULL == (entry = zend_hash_find_ptr(&phar->manifest, str_key))) { if (error) { - spprintf(error, 4096, "phar internal error: mounted path \"%s\" could not be retrieved from manifest", str_key->val); + spprintf(error, 4096, "phar internal error: mounted path \"%s\" could not be retrieved from manifest", ZSTR_VAL(str_key)); } return NULL; } if (!entry->tmp || !entry->is_mounted) { if (error) { - spprintf(error, 4096, "phar internal error: mounted path \"%s\" is not properly initialized as a mounted path", str_key->val); + spprintf(error, 4096, "phar internal error: mounted path \"%s\" is not properly initialized as a mounted path", ZSTR_VAL(str_key)); } return NULL; } - test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, path + str_key->len); + test_len = spprintf(&test, MAXPATHLEN, "%s%s", entry->tmp, path + ZSTR_LEN(str_key)); if (SUCCESS != php_stream_stat_path(test, &ssb)) { efree(test); @@ -1509,7 +1509,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ pfp = php_stream_open_wrapper(pfile, "rb", 0, NULL); efree(pfile); - if (!pfp || !(pubkey = php_stream_copy_to_mem(pfp, PHP_STREAM_COPY_ALL, 0)) || !pubkey->len) { + if (!pfp || !(pubkey = php_stream_copy_to_mem(pfp, PHP_STREAM_COPY_ALL, 0)) || !ZSTR_LEN(pubkey)) { if (pfp) { php_stream_close(pfp); } @@ -1523,7 +1523,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ #ifndef PHAR_HAVE_OPENSSL tempsig = sig_len; - if (FAILURE == phar_call_openssl_signverify(0, fp, end_of_phar, pubkey ? pubkey->val : NULL, pubkey ? pubkey->len : 0, &sig, &tempsig)) { + if (FAILURE == phar_call_openssl_signverify(0, fp, end_of_phar, pubkey ? ZSTR_VAL(pubkey) : NULL, pubkey ? ZSTR_LEN(pubkey) : 0, &sig, &tempsig)) { if (pubkey) { zend_string_release(pubkey); } @@ -1541,7 +1541,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ sig_len = tempsig; #else - in = BIO_new_mem_buf(pubkey ? pubkey->val : NULL, pubkey ? pubkey->len : 0); + in = BIO_new_mem_buf(pubkey ? ZSTR_VAL(pubkey) : NULL, pubkey ? ZSTR_LEN(pubkey) : 0); if (NULL == in) { zend_string_release(pubkey); diff --git a/ext/phar/zip.c b/ext/phar/zip.c index f7d6c25c72..7421a89de3 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -584,8 +584,8 @@ foundit: { zend_string *str = php_stream_copy_to_mem(fp, entry.uncompressed_filesize, 0); if (str) { - entry.uncompressed_filesize = str->len; - actual_alias = estrndup(str->val, str->len); + entry.uncompressed_filesize = ZSTR_LEN(str); + actual_alias = estrndup(ZSTR_VAL(str), ZSTR_LEN(str)); zend_string_release(str); } else { actual_alias = NULL; @@ -616,8 +616,8 @@ foundit: { zend_string *str = php_stream_copy_to_mem(fp, entry.uncompressed_filesize, 0); if (str) { - entry.uncompressed_filesize = str->len; - actual_alias = estrndup(str->val, str->len); + entry.uncompressed_filesize = ZSTR_LEN(str); + actual_alias = estrndup(ZSTR_VAL(str), ZSTR_LEN(str)); zend_string_release(str); } else { actual_alias = NULL; @@ -638,8 +638,8 @@ foundit: { zend_string *str = php_stream_copy_to_mem(fp, entry.uncompressed_filesize, 0); if (str) { - entry.uncompressed_filesize = str->len; - actual_alias = estrndup(str->val, str->len); + entry.uncompressed_filesize = ZSTR_LEN(str); + actual_alias = estrndup(ZSTR_VAL(str), ZSTR_LEN(str)); zend_string_release(str); } else { actual_alias = NULL; @@ -969,7 +969,7 @@ continue_dir: PHP_VAR_SERIALIZE_INIT(metadata_hash); php_var_serialize(&entry->metadata_str, &entry->metadata, &metadata_hash); PHP_VAR_SERIALIZE_DESTROY(metadata_hash); - PHAR_SET_16(central.comment_len, entry->metadata_str.s->len); + PHAR_SET_16(central.comment_len, ZSTR_LEN(entry->metadata_str.s)); } entry->header_offset = php_stream_tell(p->filefp); @@ -1080,7 +1080,7 @@ continue_dir: entry->fp_type = PHAR_FP; if (entry->metadata_str.s) { - if (entry->metadata_str.s->len != php_stream_write(p->centralfp, entry->metadata_str.s->val, entry->metadata_str.s->len)) { + if (ZSTR_LEN(entry->metadata_str.s) != php_stream_write(p->centralfp, ZSTR_VAL(entry->metadata_str.s), ZSTR_LEN(entry->metadata_str.s))) { spprintf(p->error, 0, "unable to write metadata as file comment for file \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname); smart_str_free(&entry->metadata_str); return ZEND_HASH_APPLY_STOP; @@ -1123,7 +1123,7 @@ static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pas php_stream_seek(pass->centralfp, 0, SEEK_SET); php_stream_copy_to_stream_ex(pass->centralfp, newfile, tell, NULL); if (metadata->s) { - php_stream_write(newfile, metadata->s->val, metadata->s->len); + php_stream_write(newfile, ZSTR_VAL(metadata->s), ZSTR_LEN(metadata->s)); } if (FAILURE == phar_create_signature(phar, newfile, &signature, &signature_length, pass->error)) { @@ -1272,8 +1272,8 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, zend_long len, int { zend_string *str = php_stream_copy_to_mem(stubfile, len, 0); if (str) { - len = str->len; - user_stub = estrndup(str->val, str->len); + len = ZSTR_LEN(str); + user_stub = estrndup(ZSTR_VAL(str), ZSTR_LEN(str)); zend_string_release(str); } else { user_stub = NULL; @@ -1483,7 +1483,7 @@ nocentralerror: if (Z_TYPE(phar->metadata) != IS_UNDEF) { /* set phar metadata */ - PHAR_SET_16(eocd.comment_len, main_metadata_str.s->len); + PHAR_SET_16(eocd.comment_len, ZSTR_LEN(main_metadata_str.s)); if (sizeof(eocd) != php_stream_write(pass.filefp, (char *)&eocd, sizeof(eocd))) { if (error) { @@ -1492,7 +1492,7 @@ nocentralerror: goto nocentralerror; } - if (main_metadata_str.s->len != php_stream_write(pass.filefp, main_metadata_str.s->val, main_metadata_str.s->len)) { + if (ZSTR_LEN(main_metadata_str.s) != php_stream_write(pass.filefp, ZSTR_VAL(main_metadata_str.s), ZSTR_LEN(main_metadata_str.s))) { if (error) { spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write metadata to zip comment", phar->fname); } diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 3d49f6e96d..47e59d8363 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -520,7 +520,7 @@ PHP_FUNCTION(readline_completion_function) } if (!zend_is_callable(arg, 0, &name)) { - php_error_docref(NULL, E_WARNING, "%s is not callable", name->val); + php_error_docref(NULL, E_WARNING, "%s is not callable", ZSTR_VAL(name)); zend_string_release(name); RETURN_FALSE; } @@ -569,7 +569,7 @@ PHP_FUNCTION(readline_callback_handler_install) } if (!zend_is_callable(callback, 0, &name)) { - php_error_docref(NULL, E_WARNING, "%s is not callable", name->val); + php_error_docref(NULL, E_WARNING, "%s is not callable", ZSTR_VAL(name)); zend_string_release(name); RETURN_FALSE; } diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c index ec006af2d3..125b09e920 100644 --- a/ext/readline/readline_cli.c +++ b/ext/readline/readline_cli.c @@ -409,12 +409,12 @@ static char *cli_completion_generator_ht(const char *text, int textlen, int *sta } while(zend_hash_has_more_elements(ht) == SUCCESS) { zend_hash_get_current_key(ht, &name, &number); - if (!textlen || !strncmp(name->val, text, textlen)) { + if (!textlen || !strncmp(ZSTR_VAL(name), text, textlen)) { if (pData) { *pData = zend_hash_get_current_data_ptr(ht); } zend_hash_move_forward(ht); - return name->val; + return ZSTR_VAL(name); } if (zend_hash_move_forward(ht) == FAILURE) { break; @@ -459,7 +459,7 @@ static char *cli_completion_generator_func(const char *text, int textlen, int *s char *retval = cli_completion_generator_ht(text, textlen, state, ht, (void**)&func); if (retval) { rl_completion_append_character = '('; - retval = strdup(func->common.function_name->val); + retval = strdup(ZSTR_VAL(func->common.function_name)); } return retval; @@ -471,7 +471,7 @@ static char *cli_completion_generator_class(const char *text, int textlen, int * char *retval = cli_completion_generator_ht(text, textlen, state, EG(class_table), (void**)&ce); if (retval) { rl_completion_append_character = '\0'; - retval = strdup(ce->name->val); + retval = strdup(ZSTR_VAL(ce->name)); } return retval; @@ -522,7 +522,7 @@ TODO: if (class_name_end) { class_name_len = class_name_end - text; class_name = zend_string_alloc(class_name_len, 0); - zend_str_tolower_copy(class_name->val, text, class_name_len); + zend_str_tolower_copy(ZSTR_VAL(class_name), text, class_name_len); if ((ce = zend_lookup_class(class_name)) == NULL) { zend_string_release(class_name); return NULL; @@ -561,7 +561,7 @@ TODO: int len = class_name_len + 2 + strlen(retval) + 1; char *tmp = malloc(len); - snprintf(tmp, len, "%s::%s", ce->name->val, retval); + snprintf(tmp, len, "%s::%s", ZSTR_VAL(ce->name), retval); free(retval); retval = tmp; } @@ -604,7 +604,7 @@ static int readline_shell_run(void) /* {{{ */ read_history(history_file); EG(exit_status) = 0; - while ((line = readline(prompt->val)) != NULL) { + while ((line = readline(ZSTR_VAL(prompt))) != NULL) { if (strcmp(line, "exit") == 0 || strcmp(line, "quit") == 0) { free(line); break; diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 5c7f26a9fa..0a65d60d21 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -127,8 +127,8 @@ static void string_init(string *str) { str->buf= zend_string_alloc(1024, 0); str->alloced = 1024; - str->buf->val[0] = '\0'; - str->buf->len = 0; + ZSTR_VAL(str->buf)[0] = '\0'; + ZSTR_LEN(str->buf) = 0; } static string *string_printf(string *str, const char *format, ...) @@ -140,15 +140,15 @@ static string *string_printf(string *str, const char *format, ...) va_start(arg, format); len = zend_vspprintf(&s_tmp, 0, format, arg); if (len) { - register size_t nlen = (str->buf->len + 1 + len + (1024 - 1)) & ~(1024 - 1); + register size_t nlen = (ZSTR_LEN(str->buf) + 1 + len + (1024 - 1)) & ~(1024 - 1); if (str->alloced < nlen) { - size_t old_len = str->buf->len; + size_t old_len = ZSTR_LEN(str->buf); str->alloced = nlen; str->buf = zend_string_extend(str->buf, str->alloced, 0); - str->buf->len = old_len; + ZSTR_LEN(str->buf) = old_len; } - memcpy(str->buf->val + str->buf->len, s_tmp, len + 1); - str->buf->len += len; + memcpy(ZSTR_VAL(str->buf) + ZSTR_LEN(str->buf), s_tmp, len + 1); + ZSTR_LEN(str->buf) += len; } efree(s_tmp); va_end(arg); @@ -157,23 +157,23 @@ static string *string_printf(string *str, const char *format, ...) static string *string_write(string *str, char *buf, size_t len) { - register size_t nlen = (str->buf->len + 1 + len + (1024 - 1)) & ~(1024 - 1); + register size_t nlen = (ZSTR_LEN(str->buf) + 1 + len + (1024 - 1)) & ~(1024 - 1); if (str->alloced < nlen) { - size_t old_len = str->buf->len; + size_t old_len = ZSTR_LEN(str->buf); str->alloced = nlen; str->buf = zend_string_extend(str->buf, str->alloced, 0); - str->buf->len = old_len; + ZSTR_LEN(str->buf) = old_len; } - memcpy(str->buf->val + str->buf->len, buf, len); - str->buf->len += len; - str->buf->val[str->buf->len] = '\0'; + memcpy(ZSTR_VAL(str->buf) + ZSTR_LEN(str->buf), buf, len); + ZSTR_LEN(str->buf) += len; + ZSTR_VAL(str->buf)[ZSTR_LEN(str->buf)] = '\0'; return str; } static string *string_append(string *str, string *append) { - if (append->buf->len > 0) { - string_write(str, append->buf->val, append->buf->len); + if (ZSTR_LEN(append->buf) > 0) { + string_write(str, ZSTR_VAL(append->buf), ZSTR_LEN(append->buf)); } return str; } @@ -419,28 +419,28 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in } string_printf(str, "class "); } - string_printf(str, "%s", ce->name->val); + string_printf(str, "%s", ZSTR_VAL(ce->name)); if (ce->parent) { - string_printf(str, " extends %s", ce->parent->name->val); + string_printf(str, " extends %s", ZSTR_VAL(ce->parent->name)); } if (ce->num_interfaces) { uint32_t i; if (ce->ce_flags & ZEND_ACC_INTERFACE) { - string_printf(str, " extends %s", ce->interfaces[0]->name->val); + string_printf(str, " extends %s", ZSTR_VAL(ce->interfaces[0]->name)); } else { - string_printf(str, " implements %s", ce->interfaces[0]->name->val); + string_printf(str, " implements %s", ZSTR_VAL(ce->interfaces[0]->name)); } for (i = 1; i < ce->num_interfaces; ++i) { - string_printf(str, ", %s", ce->interfaces[i]->name->val); + string_printf(str, ", %s", ZSTR_VAL(ce->interfaces[i]->name)); } } string_printf(str, " ] {\n"); /* The information where a class is declared is only available for user classes */ if (ce->type == ZEND_USER_CLASS) { - string_printf(str, "%s @@ %s %d-%d\n", indent, ce->info.user.filename->val, + string_printf(str, "%s @@ %s %d-%d\n", indent, ZSTR_VAL(ce->info.user.filename), ce->info.user.line_start, ce->info.user.line_end); } @@ -455,7 +455,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in ZEND_HASH_FOREACH_STR_KEY_VAL(&ce->constants_table, key, value) { zval_update_constant_ex(value, 1, NULL); - _const_string(str, key->val, value, indent); + _const_string(str, ZSTR_VAL(key), value, indent); } ZEND_HASH_FOREACH_END(); } string_printf(str, "%s }\n", indent); @@ -484,7 +484,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) { if ((prop->flags & ZEND_ACC_STATIC) && !(prop->flags & ZEND_ACC_SHADOW)) { - _property_string(str, prop, NULL, sub_indent.buf->val); + _property_string(str, prop, NULL, ZSTR_VAL(sub_indent.buf)); } } ZEND_HASH_FOREACH_END(); } @@ -517,7 +517,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) { string_printf(str, "\n"); - _function_string(str, mptr, ce, sub_indent.buf->val); + _function_string(str, mptr, ce, ZSTR_VAL(sub_indent.buf)); } } ZEND_HASH_FOREACH_END(); } else { @@ -535,7 +535,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) { if (!(prop->flags & (ZEND_ACC_STATIC|ZEND_ACC_SHADOW))) { - _property_string(str, prop, NULL, sub_indent.buf->val); + _property_string(str, prop, NULL, ZSTR_VAL(sub_indent.buf)); } } ZEND_HASH_FOREACH_END(); } @@ -552,10 +552,10 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in if (properties && zend_hash_num_elements(properties)) { ZEND_HASH_FOREACH_STR_KEY(properties, prop_name) { - if (prop_name && prop_name->len && prop_name->val[0]) { /* skip all private and protected properties */ + if (prop_name && ZSTR_LEN(prop_name) && ZSTR_VAL(prop_name)[0]) { /* skip all private and protected properties */ if (!zend_hash_exists(&ce->properties_info, prop_name)) { count++; - _property_string(&dyn, NULL, prop_name->val, sub_indent.buf->val); + _property_string(&dyn, NULL, ZSTR_VAL(prop_name), ZSTR_VAL(sub_indent.buf)); } } } ZEND_HASH_FOREACH_END(); @@ -582,18 +582,18 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in if ((mptr->common.fn_flags & ZEND_ACC_STATIC) == 0 && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) { - size_t len = mptr->common.function_name->len; + size_t len = ZSTR_LEN(mptr->common.function_name); /* Do not display old-style inherited constructors */ if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 || mptr->common.scope == ce || !key - || zend_binary_strcasecmp(key->val, key->len, mptr->common.function_name->val, len) == 0) + || zend_binary_strcasecmp(ZSTR_VAL(key), ZSTR_LEN(key), ZSTR_VAL(mptr->common.function_name), len) == 0) { zend_function *closure; /* see if this is a closure */ if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) - && memcmp(mptr->common.function_name->val, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 + && memcmp(ZSTR_VAL(mptr->common.function_name), ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 && (closure = zend_get_closure_invoke_method(Z_OBJ_P(obj))) != NULL) { mptr = closure; @@ -601,7 +601,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in closure = NULL; } string_printf(&dyn, "\n"); - _function_string(&dyn, mptr, ce, sub_indent.buf->val); + _function_string(&dyn, mptr, ce, ZSTR_VAL(sub_indent.buf)); count++; _free_function(closure); } @@ -631,7 +631,7 @@ static void _const_string(string *str, char *name, zval *value, char *indent) zend_string *value_str = zval_get_string(value); string_printf(str, "%s Constant [ %s %s ] { %s }\n", - indent, type, name, value_str->val); + indent, type, name, ZSTR_VAL(value_str)); zend_string_release(value_str); } @@ -670,7 +670,7 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg (fptr->type == ZEND_INTERNAL_FUNCTION && !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ? ((zend_internal_arg_info*)arg_info)->class_name : - arg_info->class_name->val); + ZSTR_VAL(arg_info->class_name)); if (arg_info->allow_null) { string_printf(str, "or NULL "); } @@ -691,7 +691,7 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg (fptr->type == ZEND_INTERNAL_FUNCTION && !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ? ((zend_internal_arg_info*)arg_info)->name : - arg_info->name->val); + ZSTR_VAL(arg_info->name)); } else { string_printf(str, "$param%d", offset); } @@ -724,7 +724,7 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg string_write(str, "Array", sizeof("Array")-1); } else { zend_string *zv_str = zval_get_string(&zv); - string_write(str, zv_str->val, zv_str->len); + string_write(str, ZSTR_VAL(zv_str), ZSTR_LEN(zv_str)); zend_string_release(zv_str); } zval_ptr_dtor(&zv); @@ -782,7 +782,7 @@ static void _function_closure_string(string *str, zend_function *fptr, char* ind string_printf(str, "%s- Bound Variables [%d] {\n", indent, zend_hash_num_elements(static_variables)); i = 0; ZEND_HASH_FOREACH_STR_KEY(static_variables, key) { - string_printf(str, "%s Variable #%d [ $%s ]\n", indent, i++, key->val); + string_printf(str, "%s Variable #%d [ $%s ]\n", indent, i++, ZSTR_VAL(key)); } ZEND_HASH_FOREACH_END(); string_printf(str, "%s}\n", indent); } @@ -801,7 +801,7 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry * swallowed, leading to an unaligned comment. */ if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment) { - string_printf(str, "%s%s\n", indent, fptr->op_array.doc_comment->val); + string_printf(str, "%s%s\n", indent, ZSTR_VAL(fptr->op_array.doc_comment)); } string_write(str, indent, strlen(indent)); @@ -816,21 +816,21 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry if (scope && fptr->common.scope) { if (fptr->common.scope != scope) { - string_printf(str, ", inherits %s", fptr->common.scope->name->val); + string_printf(str, ", inherits %s", ZSTR_VAL(fptr->common.scope->name)); } else if (fptr->common.scope->parent) { - lc_name_len = fptr->common.function_name->len; + lc_name_len = ZSTR_LEN(fptr->common.function_name); lc_name = zend_string_alloc(lc_name_len, 0); - zend_str_tolower_copy(lc_name->val, fptr->common.function_name->val, lc_name_len); + zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(fptr->common.function_name), lc_name_len); if ((overwrites = zend_hash_find_ptr(&fptr->common.scope->parent->function_table, lc_name)) != NULL) { if (fptr->common.scope != overwrites->common.scope) { - string_printf(str, ", overwrites %s", overwrites->common.scope->name->val); + string_printf(str, ", overwrites %s", ZSTR_VAL(overwrites->common.scope->name)); } } efree(lc_name); } } if (fptr->common.prototype && fptr->common.prototype->common.scope) { - string_printf(str, ", prototype %s", fptr->common.prototype->common.scope->name->val); + string_printf(str, ", prototype %s", ZSTR_VAL(fptr->common.prototype->common.scope->name)); } if (fptr->common.fn_flags & ZEND_ACC_CTOR) { string_printf(str, ", ctor"); @@ -874,20 +874,20 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry if (fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) { string_printf(str, "&"); } - string_printf(str, "%s ] {\n", fptr->common.function_name->val); + string_printf(str, "%s ] {\n", ZSTR_VAL(fptr->common.function_name)); /* The information where a function is declared is only available for user classes */ if (fptr->type == ZEND_USER_FUNCTION) { string_printf(str, "%s @@ %s %d - %d\n", indent, - fptr->op_array.filename->val, + ZSTR_VAL(fptr->op_array.filename), fptr->op_array.line_start, fptr->op_array.line_end); } string_init(¶m_indent); string_printf(¶m_indent, "%s ", indent); if (fptr->common.fn_flags & ZEND_ACC_CLOSURE) { - _function_closure_string(str, fptr, param_indent.buf->val); + _function_closure_string(str, fptr, ZSTR_VAL(param_indent.buf)); } - _function_parameter_string(str, fptr, param_indent.buf->val); + _function_parameter_string(str, fptr, ZSTR_VAL(param_indent.buf)); string_free(¶m_indent); if (fptr->op_array.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) { string_printf(str, " %s- Return [ ", indent); @@ -896,7 +896,7 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry (fptr->type == ZEND_INTERNAL_FUNCTION && !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ? ((zend_internal_arg_info*)(fptr->common.arg_info - 1))->class_name : - fptr->common.arg_info[-1].class_name->val); + ZSTR_VAL(fptr->common.arg_info[-1].class_name)); if (fptr->common.arg_info[-1].allow_null) { string_printf(str, "or NULL "); } @@ -962,7 +962,7 @@ static int _extension_ini_string(zval *el, int num_args, va_list args, zend_hash char *comma = ""; if (number == ini_entry->module_number) { - string_printf(str, " %sEntry [ %s <", indent, ini_entry->name->val); + string_printf(str, " %sEntry [ %s <", indent, ZSTR_VAL(ini_entry->name)); if (ini_entry->modifiable == ZEND_INI_ALL) { string_printf(str, "ALL"); } else { @@ -980,9 +980,9 @@ static int _extension_ini_string(zval *el, int num_args, va_list args, zend_hash } string_printf(str, "> ]\n"); - string_printf(str, " %s Current = '%s'\n", indent, ini_entry->value ? ini_entry->value->val : ""); + string_printf(str, " %s Current = '%s'\n", indent, ini_entry->value ? ZSTR_VAL(ini_entry->value) : ""); if (ini_entry->modified) { - string_printf(str, " %s Default = '%s'\n", indent, ini_entry->orig_value ? ini_entry->orig_value->val : ""); + string_printf(str, " %s Default = '%s'\n", indent, ini_entry->orig_value ? ZSTR_VAL(ini_entry->orig_value) : ""); } string_printf(str, " %s}\n", indent); } @@ -1000,7 +1000,7 @@ static int _extension_class_string(zval *el, int num_args, va_list args, zend_ha if ((ce->type == ZEND_INTERNAL_CLASS) && ce->info.internal.module && !strcasecmp(ce->info.internal.module->name, module->name)) { /* dump class if it is not an alias */ - if (!zend_binary_strcasecmp(ce->name->val, ce->name->len, hash_key->key->val, hash_key->key->len)) { + if (!zend_binary_strcasecmp(ZSTR_VAL(ce->name), ZSTR_LEN(ce->name), ZSTR_VAL(hash_key->key), ZSTR_LEN(hash_key->key))) { string_printf(str, "\n"); _class_string(str, ce, NULL, indent); (*num_classes)++; @@ -1019,7 +1019,7 @@ static int _extension_const_string(zval *el, int num_args, va_list args, zend_ha int *num_classes = va_arg(args, int*); if (constant->module_number == module->module_number) { - _const_string(str, constant->name->val, &constant->value, indent); + _const_string(str, ZSTR_VAL(constant->name), &constant->value, indent); (*num_classes)++; } return ZEND_HASH_APPLY_KEEP; @@ -1078,7 +1078,7 @@ static void _extension_string(string *str, zend_module_entry *module, char *inde string str_ini; string_init(&str_ini); zend_hash_apply_with_arguments(EG(ini_directives), (apply_func_args_t) _extension_ini_string, 3, &str_ini, indent, module->module_number); - if (str_ini.buf->len > 0) { + if (ZSTR_LEN(str_ini.buf) > 0) { string_printf(str, "\n - INI {\n"); string_append(str, &str_ini); string_printf(str, "%s }\n", indent); @@ -1127,7 +1127,7 @@ static void _extension_string(string *str, zend_module_entry *module, char *inde string_init(&sub_indent); string_printf(&sub_indent, "%s ", indent); string_init(&str_classes); - zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t) _extension_class_string, 4, &str_classes, sub_indent.buf->val, module, &num_classes); + zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t) _extension_class_string, 4, &str_classes, ZSTR_VAL(sub_indent.buf), module, &num_classes); if (num_classes) { string_printf(str, "\n - Classes [%d] {", num_classes); string_append(str, &str_classes); @@ -1202,7 +1202,7 @@ static void reflection_extension_factory(zval *object, const char *name_str) struct _zend_module_entry *module; lcname = zend_string_alloc(name_len, 0); - zend_str_tolower_copy(lcname->val, name_str, name_len); + zend_str_tolower_copy(ZSTR_VAL(lcname), name_str, name_len); module = zend_hash_find_ptr(&module_registry, lcname); zend_string_free(lcname); if (!module) { @@ -1544,7 +1544,7 @@ ZEND_METHOD(reflection, export) } if (Z_TYPE(retval) == IS_UNDEF) { - php_error_docref(NULL, E_WARNING, "%s::__toString() did not return anything", Z_OBJCE_P(object)->name->val); + php_error_docref(NULL, E_WARNING, "%s::__toString() did not return anything", ZSTR_VAL(Z_OBJCE_P(object)->name)); RETURN_FALSE; } @@ -1952,7 +1952,7 @@ ZEND_METHOD(reflection_function, invoke) if (result == FAILURE) { zend_throw_exception_ex(reflection_exception_ptr, 0, - "Invocation of function %s() failed", fptr->common.function_name->val); + "Invocation of function %s() failed", ZSTR_VAL(fptr->common.function_name)); return; } @@ -2017,7 +2017,7 @@ ZEND_METHOD(reflection_function, invokeArgs) if (result == FAILURE) { zend_throw_exception_ex(reflection_exception_ptr, 0, - "Invocation of function %s() failed", fptr->common.function_name->val); + "Invocation of function %s() failed", ZSTR_VAL(fptr->common.function_name)); return; } @@ -2411,7 +2411,7 @@ ZEND_METHOD(reflection_parameter, __construct) } else if ((fptr = zend_hash_str_find_ptr(&ce->function_table, lcname, lcname_len)) == NULL) { efree(lcname); zend_throw_exception_ex(reflection_exception_ptr, 0, - "Method %s::%s() does not exist", ce->name->val, Z_STRVAL_P(method)); + "Method %s::%s() does not exist", ZSTR_VAL(ce->name), Z_STRVAL_P(method)); return; } efree(lcname); @@ -2427,7 +2427,7 @@ ZEND_METHOD(reflection_parameter, __construct) is_closure = 1; } else if ((fptr = zend_hash_str_find_ptr(&ce->function_table, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME))) == NULL) { zend_throw_exception_ex(reflection_exception_ptr, 0, - "Method %s::%s() does not exist", ce->name->val, ZEND_INVOKE_FUNC_NAME); + "Method %s::%s() does not exist", ZSTR_VAL(ce->name), ZEND_INVOKE_FUNC_NAME); return; } } @@ -2478,7 +2478,7 @@ ZEND_METHOD(reflection_parameter, __construct) } else { for (i = 0; i < num_args; i++) { if (arg_info[i].name) { - if (strcmp(arg_info[i].name->val, Z_STRVAL_P(parameter)) == 0) { + if (strcmp(ZSTR_VAL(arg_info[i].name), Z_STRVAL_P(parameter)) == 0) { position= i; break; } @@ -2629,8 +2629,8 @@ ZEND_METHOD(reflection_parameter, getClass) class_name = ((zend_internal_arg_info*)param->arg_info)->class_name; class_name_len = strlen(class_name); } else { - class_name = param->arg_info->class_name->val; - class_name_len = param->arg_info->class_name->len; + class_name = ZSTR_VAL(param->arg_info->class_name); + class_name_len = ZSTR_LEN(param->arg_info->class_name); } if (0 == zend_binary_strcasecmp(class_name, class_name_len, "self", sizeof("self")- 1)) { ce = param->fptr->common.scope; @@ -3099,7 +3099,7 @@ ZEND_METHOD(reflection_method, __construct) } else if ((mptr = zend_hash_str_find_ptr(&ce->function_table, lcname, name_len)) == NULL) { efree(lcname); zend_throw_exception_ex(reflection_exception_ptr, 0, - "Method %s::%s() does not exist", ce->name->val, name_str); + "Method %s::%s() does not exist", ZSTR_VAL(ce->name), name_str); return; } efree(lcname); @@ -3192,13 +3192,13 @@ ZEND_METHOD(reflection_method, invoke) if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) { zend_throw_exception_ex(reflection_exception_ptr, 0, "Trying to invoke abstract method %s::%s()", - mptr->common.scope->name->val, mptr->common.function_name->val); + ZSTR_VAL(mptr->common.scope->name), ZSTR_VAL(mptr->common.function_name)); } else { zend_throw_exception_ex(reflection_exception_ptr, 0, "Trying to invoke %s method %s::%s() from scope %s", mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private", - mptr->common.scope->name->val, mptr->common.function_name->val, - Z_OBJCE_P(getThis())->name->val); + ZSTR_VAL(mptr->common.scope->name), ZSTR_VAL(mptr->common.function_name), + ZSTR_VAL(Z_OBJCE_P(getThis())->name)); } return; } @@ -3252,7 +3252,7 @@ ZEND_METHOD(reflection_method, invoke) if (result == FAILURE) { zend_throw_exception_ex(reflection_exception_ptr, 0, - "Invocation of method %s::%s() failed", mptr->common.scope->name->val, mptr->common.function_name->val); + "Invocation of method %s::%s() failed", ZSTR_VAL(mptr->common.scope->name), ZSTR_VAL(mptr->common.function_name)); return; } @@ -3292,13 +3292,13 @@ ZEND_METHOD(reflection_method, invokeArgs) if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) { zend_throw_exception_ex(reflection_exception_ptr, 0, "Trying to invoke abstract method %s::%s()", - mptr->common.scope->name->val, mptr->common.function_name->val); + ZSTR_VAL(mptr->common.scope->name), ZSTR_VAL(mptr->common.function_name)); } else { zend_throw_exception_ex(reflection_exception_ptr, 0, "Trying to invoke %s method %s::%s() from scope %s", mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private", - mptr->common.scope->name->val, mptr->common.function_name->val, - Z_OBJCE_P(getThis())->name->val); + ZSTR_VAL(mptr->common.scope->name), ZSTR_VAL(mptr->common.function_name), + ZSTR_VAL(Z_OBJCE_P(getThis())->name)); } return; } @@ -3326,7 +3326,7 @@ ZEND_METHOD(reflection_method, invokeArgs) efree(params); zend_throw_exception_ex(reflection_exception_ptr, 0, "Trying to invoke non static method %s::%s() without an object", - mptr->common.scope->name->val, mptr->common.function_name->val); + ZSTR_VAL(mptr->common.scope->name), ZSTR_VAL(mptr->common.function_name)); return; } @@ -3371,7 +3371,7 @@ ZEND_METHOD(reflection_method, invokeArgs) if (result == FAILURE) { zend_throw_exception_ex(reflection_exception_ptr, 0, - "Invocation of method %s::%s() failed", mptr->common.scope->name->val, mptr->common.function_name->val); + "Invocation of method %s::%s() failed", ZSTR_VAL(mptr->common.scope->name), ZSTR_VAL(mptr->common.function_name)); return; } @@ -3644,7 +3644,7 @@ ZEND_METHOD(reflection_method, getPrototype) if (!mptr->common.prototype) { zend_throw_exception_ex(reflection_exception_ptr, 0, - "Method %s::%s does not have a prototype", intern->ce->name->val, mptr->common.function_name->val); + "Method %s::%s does not have a prototype", ZSTR_VAL(intern->ce->name), ZSTR_VAL(mptr->common.function_name)); return; } @@ -3829,7 +3829,7 @@ ZEND_METHOD(reflection_class, getStaticPropertyValue) ZVAL_COPY(return_value, def_value); } else { zend_throw_exception_ex(reflection_exception_ptr, 0, - "Class %s does not have a property named %s", ce->name->val, name->val); + "Class %s does not have a property named %s", ZSTR_VAL(ce->name), ZSTR_VAL(name)); } return; } else { @@ -3860,7 +3860,7 @@ ZEND_METHOD(reflection_class, setStaticPropertyValue) variable_ptr = zend_std_get_static_property(ce, name, 1); if (!variable_ptr) { zend_throw_exception_ex(reflection_exception_ptr, 0, - "Class %s does not have a property named %s", ce->name->val, name->val); + "Class %s does not have a property named %s", ZSTR_VAL(ce->name), ZSTR_VAL(name)); return; } zval_ptr_dtor(variable_ptr); @@ -4132,11 +4132,11 @@ ZEND_METHOD(reflection_class, getMethod) static void _addmethod(zend_function *mptr, zend_class_entry *ce, zval *retval, zend_long filter, zval *obj) { zval method; - size_t len = mptr->common.function_name->len; + size_t len = ZSTR_LEN(mptr->common.function_name); zend_function *closure; if (mptr->common.fn_flags & filter) { if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) - && memcmp(mptr->common.function_name->val, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 + && memcmp(ZSTR_VAL(mptr->common.function_name), ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 && (closure = zend_get_closure_invoke_method(Z_OBJ_P(obj))) != NULL) { mptr = closure; @@ -4269,20 +4269,20 @@ ZEND_METHOD(reflection_class, getProperty) return; } } - str_name = name->val; - str_name_len = name->len; - if ((tmp = strstr(name->val, "::")) != NULL) { - classname_len = tmp - name->val; + str_name = ZSTR_VAL(name); + str_name_len = ZSTR_LEN(name); + if ((tmp = strstr(ZSTR_VAL(name), "::")) != NULL) { + classname_len = tmp - ZSTR_VAL(name); classname = zend_string_alloc(classname_len, 0); - zend_str_tolower_copy(classname->val, name->val, classname_len); - classname->val[classname_len] = '\0'; - str_name_len = name->len - (classname_len + 2); + zend_str_tolower_copy(ZSTR_VAL(classname), ZSTR_VAL(name), classname_len); + ZSTR_VAL(classname)[classname_len] = '\0'; + str_name_len = ZSTR_LEN(name) - (classname_len + 2); str_name = tmp + 2; ce2 = zend_lookup_class(classname); if (!ce2) { if (!EG(exception)) { - zend_throw_exception_ex(reflection_exception_ptr, -1, "Class %s does not exist", classname->val); + zend_throw_exception_ex(reflection_exception_ptr, -1, "Class %s does not exist", ZSTR_VAL(classname)); } zend_string_release(classname); return; @@ -4290,7 +4290,7 @@ ZEND_METHOD(reflection_class, getProperty) zend_string_release(classname); if (!instanceof_function(ce, ce2)) { - zend_throw_exception_ex(reflection_exception_ptr, -1, "Fully qualified property name %s::%s does not specify a base class of %s", ce2->name->val, str_name, ce->name->val); + zend_throw_exception_ex(reflection_exception_ptr, -1, "Fully qualified property name %s::%s does not specify a base class of %s", ZSTR_VAL(ce2->name), str_name, ZSTR_VAL(ce->name)); return; } ce = ce2; @@ -4340,7 +4340,7 @@ static int _adddynproperty(zval *ptr, int num_args, va_list args, zend_hash_key return 0; } - if (hash_key->key->val[0] == '\0') { + if (ZSTR_VAL(hash_key->key)[0] == '\0') { return 0; /* non public cannot be dynamic */ } @@ -4629,7 +4629,7 @@ ZEND_METHOD(reflection_class, newInstance) zend_fcall_info_cache fcc; if (!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)) { - zend_throw_exception_ex(reflection_exception_ptr, 0, "Access to non-public constructor of class %s", ce->name->val); + zend_throw_exception_ex(reflection_exception_ptr, 0, "Access to non-public constructor of class %s", ZSTR_VAL(ce->name)); zval_dtor(return_value); RETURN_NULL(); } @@ -4665,12 +4665,12 @@ ZEND_METHOD(reflection_class, newInstance) zval_ptr_dtor(¶ms[i]); } if (ret == FAILURE) { - php_error_docref(NULL, E_WARNING, "Invocation of %s's constructor failed", ce->name->val); + php_error_docref(NULL, E_WARNING, "Invocation of %s's constructor failed", ZSTR_VAL(ce->name)); zval_dtor(return_value); RETURN_NULL(); } } else if (ZEND_NUM_ARGS()) { - zend_throw_exception_ex(reflection_exception_ptr, 0, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ce->name->val); + zend_throw_exception_ex(reflection_exception_ptr, 0, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ZSTR_VAL(ce->name)); } } /* }}} */ @@ -4686,7 +4686,7 @@ ZEND_METHOD(reflection_class, newInstanceWithoutConstructor) GET_REFLECTION_OBJECT_PTR(ce); if (ce->create_object != NULL && ce->ce_flags & ZEND_ACC_FINAL) { - zend_throw_exception_ex(reflection_exception_ptr, 0, "Class %s is an internal class marked as final that cannot be instantiated without invoking its constructor", ce->name->val); + zend_throw_exception_ex(reflection_exception_ptr, 0, "Class %s is an internal class marked as final that cannot be instantiated without invoking its constructor", ZSTR_VAL(ce->name)); return; } @@ -4733,7 +4733,7 @@ ZEND_METHOD(reflection_class, newInstanceArgs) zend_fcall_info_cache fcc; if (!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)) { - zend_throw_exception_ex(reflection_exception_ptr, 0, "Access to non-public constructor of class %s", ce->name->val); + zend_throw_exception_ex(reflection_exception_ptr, 0, "Access to non-public constructor of class %s", ZSTR_VAL(ce->name)); zval_dtor(return_value); RETURN_NULL(); } @@ -4773,12 +4773,12 @@ ZEND_METHOD(reflection_class, newInstanceArgs) } if (ret == FAILURE) { zval_ptr_dtor(&retval); - php_error_docref(NULL, E_WARNING, "Invocation of %s's constructor failed", ce->name->val); + php_error_docref(NULL, E_WARNING, "Invocation of %s's constructor failed", ZSTR_VAL(ce->name)); zval_dtor(return_value); RETURN_NULL(); } } else if (argc) { - zend_throw_exception_ex(reflection_exception_ptr, 0, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ce->name->val); + zend_throw_exception_ex(reflection_exception_ptr, 0, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ZSTR_VAL(ce->name)); } } /* }}} */ @@ -4898,9 +4898,9 @@ ZEND_METHOD(reflection_class, getTraitAliases) if (ce->trait_aliases[i]->alias) { - mname = zend_string_alloc(cur_ref->ce->name->len + cur_ref->method_name->len + 2, 0); - snprintf(mname->val, mname->len + 1, "%s::%s", cur_ref->ce->name->val, cur_ref->method_name->val); - add_assoc_str_ex(return_value, ce->trait_aliases[i]->alias->val, ce->trait_aliases[i]->alias->len, mname); + mname = zend_string_alloc(ZSTR_LEN(cur_ref->ce->name) + ZSTR_LEN(cur_ref->method_name) + 2, 0); + snprintf(ZSTR_VAL(mname), ZSTR_LEN(mname) + 1, "%s::%s", ZSTR_VAL(cur_ref->ce->name), ZSTR_VAL(cur_ref->method_name)); + add_assoc_str_ex(return_value, ZSTR_VAL(ce->trait_aliases[i]->alias), ZSTR_LEN(ce->trait_aliases[i]->alias), mname); } i++; } @@ -5014,7 +5014,7 @@ ZEND_METHOD(reflection_class, implementsInterface) if (!(interface_ce->ce_flags & ZEND_ACC_INTERFACE)) { zend_throw_exception_ex(reflection_exception_ptr, 0, - "Interface %s is a Class", interface_ce->name->val); + "Interface %s is a Class", ZSTR_VAL(interface_ce->name)); return; } RETURN_BOOL(instanceof_function(ce, interface_ce)); @@ -5226,7 +5226,7 @@ ZEND_METHOD(reflection_property, __construct) } } if (dynam_prop == 0) { - zend_throw_exception_ex(reflection_exception_ptr, 0, "Property %s::$%s does not exist", ce->name->val, name_str); + zend_throw_exception_ex(reflection_exception_ptr, 0, "Property %s::$%s does not exist", ZSTR_VAL(ce->name), name_str); return; } } @@ -5386,7 +5386,7 @@ ZEND_METHOD(reflection_property, getValue) if (!(ref->prop.flags & (ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC)) && intern->ignore_visibility == 0) { name = _default_load_entry(getThis(), "name", sizeof("name")-1); zend_throw_exception_ex(reflection_exception_ptr, 0, - "Cannot access non-public member %s::%s", intern->ce->name->val, Z_STRVAL_P(name)); + "Cannot access non-public member %s::%s", ZSTR_VAL(intern->ce->name), Z_STRVAL_P(name)); return; } @@ -5395,7 +5395,7 @@ ZEND_METHOD(reflection_property, getValue) return; } if (Z_TYPE(CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) == IS_UNDEF) { - php_error_docref(NULL, E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name->val, ref->prop.name->val); + php_error_docref(NULL, E_ERROR, "Internal error: Could not find the property %s::%s", ZSTR_VAL(intern->ce->name), ZSTR_VAL(ref->prop.name)); /* Bails out */ } ZVAL_DUP(return_value, &CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]); @@ -5432,7 +5432,7 @@ ZEND_METHOD(reflection_property, setValue) if (!(ref->prop.flags & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) { name = _default_load_entry(getThis(), "name", sizeof("name")-1); zend_throw_exception_ex(reflection_exception_ptr, 0, - "Cannot access non-public member %s::%s", intern->ce->name->val, Z_STRVAL_P(name)); + "Cannot access non-public member %s::%s", ZSTR_VAL(intern->ce->name), Z_STRVAL_P(name)); return; } @@ -5447,7 +5447,7 @@ ZEND_METHOD(reflection_property, setValue) } if (Z_TYPE(CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) == IS_UNDEF) { - php_error_docref(NULL, E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name->val, ref->prop.name->val); + php_error_docref(NULL, E_ERROR, "Internal error: Could not find the property %s::%s", ZSTR_VAL(intern->ce->name), ZSTR_VAL(ref->prop.name)); /* Bails out */ } variable_ptr = &CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]; @@ -5772,7 +5772,7 @@ static int add_extension_class(zval *zv, int num_args, va_list args, zend_hash_k if ((ce->type == ZEND_INTERNAL_CLASS) && ce->info.internal.module && !strcasecmp(ce->info.internal.module->name, module->name)) { zend_string *name; - if (zend_binary_strcasecmp(ce->name->val, ce->name->len, hash_key->key->val, hash_key->key->len)) { + if (zend_binary_strcasecmp(ZSTR_VAL(ce->name), ZSTR_LEN(ce->name), ZSTR_VAL(hash_key->key), ZSTR_LEN(hash_key->key))) { /* This is an class alias, use alias name */ name = hash_key->key; } else { @@ -5879,7 +5879,7 @@ ZEND_METHOD(reflection_extension, getDependencies) } relation = zend_string_alloc(len, 0); - snprintf(relation->val, relation->len + 1, "%s%s%s%s%s", + snprintf(ZSTR_VAL(relation), ZSTR_LEN(relation) + 1, "%s%s%s%s%s", rel_type, dep->rel ? " " : "", dep->rel ? dep->rel : "", @@ -6551,7 +6551,7 @@ static void _reflection_write_property(zval *object, zval *member, zval *value, || (Z_STRLEN_P(member) == sizeof("class") - 1 && !memcmp(Z_STRVAL_P(member), "class", sizeof("class"))))) { zend_throw_exception_ex(reflection_exception_ptr, 0, - "Cannot set read-only property %s::$%s", Z_OBJCE_P(object)->name->val, Z_STRVAL_P(member)); + "Cannot set read-only property %s::$%s", ZSTR_VAL(Z_OBJCE_P(object)->name), Z_STRVAL_P(member)); } else { diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index a062f3e93f..f5256206ff 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -227,24 +227,24 @@ static int ps_files_write(ps_files *data, zend_string *key, zend_string *val) /* PS(id) may be changed by calling session_regenerate_id(). Re-initialization should be tried here. ps_files_open() checks data->lastkey and reopen when it is needed. */ - ps_files_open(data, key->val); + ps_files_open(data, ZSTR_VAL(key)); if (data->fd < 0) { return FAILURE; } /* Truncate file if the amount of new data is smaller than the existing data set. */ - if (val->len < data->st_size) { + if (ZSTR_LEN(val) < data->st_size) { php_ignore_value(ftruncate(data->fd, 0)); } #if defined(HAVE_PWRITE) - n = pwrite(data->fd, val->val, val->len, 0); + n = pwrite(data->fd, ZSTR_VAL(val), ZSTR_LEN(val), 0); #else lseek(data->fd, 0, SEEK_SET); #ifdef PHP_WIN32 { - unsigned int to_write = val->len > UINT_MAX ? UINT_MAX : (unsigned int)val->len; - char *buf = val->val; + unsigned int to_write = ZSTR_LEN(val) > UINT_MAX ? UINT_MAX : (unsigned int)ZSTR_LEN(val); + char *buf = ZSTR_VAL(val); int wrote; do { @@ -252,16 +252,16 @@ static int ps_files_write(ps_files *data, zend_string *key, zend_string *val) n += wrote; buf = wrote > -1 ? buf + wrote : 0; - to_write = wrote > -1 ? (val->len - n > UINT_MAX ? UINT_MAX : (unsigned int)(val->len - n)): 0; + to_write = wrote > -1 ? (ZSTR_LEN(val) - n > UINT_MAX ? UINT_MAX : (unsigned int)(ZSTR_LEN(val) - n)): 0; } while(wrote > 0); } #else - n = write(data->fd, val->val, val->len); + n = write(data->fd, ZSTR_VAL(val), ZSTR_LEN(val)); #endif #endif - if (n != val->len) { + if (n != ZSTR_LEN(val)) { if (n == -1) { php_error_docref(NULL, E_WARNING, "write failed: %s (%d)", strerror(errno), errno); } else { @@ -465,7 +465,7 @@ PS_READ_FUNC(files) zend_stat_t sbuf; PS_FILES_DATA; - ps_files_open(data, key->val); + ps_files_open(data, ZSTR_VAL(key)); if (data->fd < 0) { return FAILURE; } @@ -484,13 +484,13 @@ PS_READ_FUNC(files) *val = zend_string_alloc(sbuf.st_size, 0); #if defined(HAVE_PREAD) - n = pread(data->fd, (*val)->val, (*val)->len, 0); + n = pread(data->fd, ZSTR_VAL(*val), ZSTR_LEN(*val), 0); #else lseek(data->fd, 0, SEEK_SET); #ifdef PHP_WIN32 { - unsigned int to_read = (*val)->len > UINT_MAX ? UINT_MAX : (unsigned int)(*val)->len; - char *buf = (*val)->val; + unsigned int to_read = ZSTR_LEN(*val) > UINT_MAX ? UINT_MAX : (unsigned int)ZSTR_LEN(*val); + char *buf = ZSTR_VAL(*val); int read_in; do { @@ -498,13 +498,13 @@ PS_READ_FUNC(files) n += read_in; buf = read_in > -1 ? buf + read_in : 0; - to_read = read_in > -1 ? ((*val)->len - n > UINT_MAX ? UINT_MAX : (unsigned int)((*val)->len - n)): 0; + to_read = read_in > -1 ? (ZSTR_LEN(*val) - n > UINT_MAX ? UINT_MAX : (unsigned int)(ZSTR_LEN(*val) - n)): 0; } while(read_in > 0); } #else - n = read(data->fd, (*val)->val, (*val)->len); + n = read(data->fd, ZSTR_VAL(*val), ZSTR_LEN(*val)); #endif #endif @@ -561,7 +561,7 @@ PS_UPDATE_TIMESTAMP_FUNC(files) int ret; PS_FILES_DATA; - if (!ps_files_path_create(buf, sizeof(buf), data, key->val)) { + if (!ps_files_path_create(buf, sizeof(buf), data, ZSTR_VAL(key))) { return FAILURE; } @@ -596,7 +596,7 @@ PS_DESTROY_FUNC(files) char buf[MAXPATHLEN]; PS_FILES_DATA; - if (!ps_files_path_create(buf, sizeof(buf), data, key->val)) { + if (!ps_files_path_create(buf, sizeof(buf), data, ZSTR_VAL(key))) { return FAILURE; } @@ -673,7 +673,7 @@ PS_CREATE_SID_FUNC(files) } /* Check collision */ /* FIXME: mod_data(data) should not be NULL (User handler could be NULL) */ - if (data && ps_files_key_exists(data, sid->val) == SUCCESS) { + if (data && ps_files_key_exists(data, ZSTR_VAL(sid)) == SUCCESS) { if (sid) { zend_string_release(sid); sid = NULL; @@ -701,7 +701,7 @@ PS_VALIDATE_SID_FUNC(files) { PS_FILES_DATA; - return ps_files_key_exists(data, key->val); + return ps_files_key_exists(data, ZSTR_VAL(key)); } /* diff --git a/ext/session/session.c b/ext/session/session.c index c3d9fbf1d6..ef17b86bad 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -233,7 +233,7 @@ static int php_session_decode(zend_string *data) /* {{{ */ php_error_docref(NULL, E_WARNING, "Unknown session.serialize_handler. Failed to decode session object"); return FAILURE; } - if (PS(serializer)->decode(data->val, data->len) == FAILURE) { + if (PS(serializer)->decode(ZSTR_VAL(data), ZSTR_LEN(data)) == FAILURE) { php_session_destroy(); php_error_docref(NULL, E_WARNING, "Failed to decode session object. Session has been destroyed"); return FAILURE; @@ -434,7 +434,7 @@ PHPAPI zend_string *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */ } outid = zend_string_alloc((digest_len + 2) * ((8.0f / PS(hash_bits_per_character) + 0.5)), 0); - outid->len = (size_t)(bin_to_readable((char *)digest, digest_len, outid->val, (char)PS(hash_bits_per_character)) - (char *)&outid->val); + ZSTR_LEN(outid) = (size_t)(bin_to_readable((char *)digest, digest_len, ZSTR_VAL(outid), (char)PS(hash_bits_per_character)) - (char *)&ZSTR_VAL(outid)); efree(digest); return outid; @@ -556,8 +556,8 @@ static void php_session_save_current_state(int write) /* {{{ */ if (PS(lazy_write) && PS(session_vars) && PS(mod)->s_update_timestamp && PS(mod)->s_update_timestamp != php_session_update_timestamp - && val->len == PS(session_vars)->len - && !memcmp(val->val, PS(session_vars)->val, val->len) + && ZSTR_LEN(val) == ZSTR_LEN(PS(session_vars)) + && !memcmp(ZSTR_VAL(val), ZSTR_VAL(PS(session_vars)), ZSTR_LEN(val)) ) { ret = PS(mod)->s_update_timestamp(&PS(mod_data), PS(id), val, PS(gc_maxlifetime)); } else { @@ -594,7 +594,7 @@ static PHP_INI_MH(OnUpdateSaveHandler) /* {{{ */ ps_module *tmp; SESSION_CHECK_ACTIVE_STATE; - tmp = _php_find_ps_module(new_value->val); + tmp = _php_find_ps_module(ZSTR_VAL(new_value)); if (PG(modules_activated) && !tmp) { int err_type; @@ -607,7 +607,7 @@ static PHP_INI_MH(OnUpdateSaveHandler) /* {{{ */ /* Do not output error when restoring ini options. */ if (stage != ZEND_INI_STAGE_DEACTIVATE) { - php_error_docref(NULL, err_type, "Cannot find save handler '%s'", new_value->val); + php_error_docref(NULL, err_type, "Cannot find save handler '%s'", ZSTR_VAL(new_value)); } return FAILURE; } @@ -624,7 +624,7 @@ static PHP_INI_MH(OnUpdateSerializer) /* {{{ */ const ps_serializer *tmp; SESSION_CHECK_ACTIVE_STATE; - tmp = _php_find_ps_serializer(new_value->val); + tmp = _php_find_ps_serializer(ZSTR_VAL(new_value)); if (PG(modules_activated) && !tmp) { int err_type; @@ -637,7 +637,7 @@ static PHP_INI_MH(OnUpdateSerializer) /* {{{ */ /* Do not output error when restoring ini options. */ if (stage != ZEND_INI_STAGE_DEACTIVATE) { - php_error_docref(NULL, err_type, "Cannot find serialization handler '%s'", new_value->val); + php_error_docref(NULL, err_type, "Cannot find serialization handler '%s'", ZSTR_VAL(new_value)); } return FAILURE; } @@ -651,10 +651,10 @@ static PHP_INI_MH(OnUpdateTransSid) /* {{{ */ { SESSION_CHECK_ACTIVE_STATE; - if (!strncasecmp(new_value->val, "on", sizeof("on"))) { + if (!strncasecmp(ZSTR_VAL(new_value), "on", sizeof("on"))) { PS(use_trans_sid) = (zend_bool) 1; } else { - PS(use_trans_sid) = (zend_bool) atoi(new_value->val); + PS(use_trans_sid) = (zend_bool) atoi(ZSTR_VAL(new_value)); } return SUCCESS; @@ -667,19 +667,19 @@ static PHP_INI_MH(OnUpdateSaveDir) /* {{{ */ if (stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) { char *p; - if (memchr(new_value->val, '\0', new_value->len) != NULL) { + if (memchr(ZSTR_VAL(new_value), '\0', ZSTR_LEN(new_value)) != NULL) { return FAILURE; } /* we do not use zend_memrchr() since path can contain ; itself */ - if ((p = strchr(new_value->val, ';'))) { + if ((p = strchr(ZSTR_VAL(new_value), ';'))) { char *p2; p++; if ((p2 = strchr(p, ';'))) { p = p2 + 1; } } else { - p = new_value->val; + p = ZSTR_VAL(new_value); } if (PG(open_basedir) && *p && php_check_open_basedir(p)) { @@ -695,7 +695,7 @@ static PHP_INI_MH(OnUpdateSaveDir) /* {{{ */ static PHP_INI_MH(OnUpdateName) /* {{{ */ { /* Numeric session.name won't work at all */ - if ((!new_value->len || is_numeric_string(new_value->val, new_value->len, NULL, NULL, 0))) { + if ((!ZSTR_LEN(new_value) || is_numeric_string(ZSTR_VAL(new_value), ZSTR_LEN(new_value), NULL, NULL, 0))) { int err_type; if (stage == ZEND_INI_STAGE_RUNTIME || stage == ZEND_INI_STAGE_ACTIVATE || stage == ZEND_INI_STAGE_STARTUP) { @@ -706,7 +706,7 @@ static PHP_INI_MH(OnUpdateName) /* {{{ */ /* Do not output error when restoring ini options. */ if (stage != ZEND_INI_STAGE_DEACTIVATE) { - php_error_docref(NULL, err_type, "session.name cannot be a numeric or empty '%s'", new_value->val); + php_error_docref(NULL, err_type, "session.name cannot be a numeric or empty '%s'", ZSTR_VAL(new_value)); } return FAILURE; } @@ -725,7 +725,7 @@ static PHP_INI_MH(OnUpdateHashFunc) /* {{{ */ PS(hash_ops) = NULL; #endif - val = ZEND_STRTOL(new_value->val, &endptr, 10); + val = ZEND_STRTOL(ZSTR_VAL(new_value), &endptr, 10); if (endptr && (*endptr == '\0')) { /* Numeric value */ PS(hash_func) = val ? 1 : 0; @@ -733,15 +733,15 @@ static PHP_INI_MH(OnUpdateHashFunc) /* {{{ */ return SUCCESS; } - if (new_value->len == (sizeof("md5") - 1) && - strncasecmp(new_value->val, "md5", sizeof("md5") - 1) == 0) { + if (ZSTR_LEN(new_value) == (sizeof("md5") - 1) && + strncasecmp(ZSTR_VAL(new_value), "md5", sizeof("md5") - 1) == 0) { PS(hash_func) = PS_HASH_FUNC_MD5; return SUCCESS; } - if (new_value->len == (sizeof("sha1") - 1) && - strncasecmp(new_value->val, "sha1", sizeof("sha1") - 1) == 0) { + if (ZSTR_LEN(new_value) == (sizeof("sha1") - 1) && + strncasecmp(ZSTR_VAL(new_value), "sha1", sizeof("sha1") - 1) == 0) { PS(hash_func) = PS_HASH_FUNC_SHA1; return SUCCESS; @@ -749,7 +749,7 @@ static PHP_INI_MH(OnUpdateHashFunc) /* {{{ */ #if defined(HAVE_HASH_EXT) && !defined(COMPILE_DL_HASH) /* {{{ */ { - php_hash_ops *ops = (php_hash_ops*)php_hash_fetch_ops(new_value->val, new_value->len); + php_hash_ops *ops = (php_hash_ops*)php_hash_fetch_ops(ZSTR_VAL(new_value), ZSTR_LEN(new_value)); if (ops) { PS(hash_func) = PS_HASH_FUNC_OTHER; @@ -760,7 +760,7 @@ static PHP_INI_MH(OnUpdateHashFunc) /* {{{ */ } #endif /* HAVE_HASH_EXT }}} */ - php_error_docref(NULL, E_WARNING, "session.configuration 'session.hash_function' must be existing hash function. %s does not exist.", new_value->val); + php_error_docref(NULL, E_WARNING, "session.configuration 'session.hash_function' must be existing hash function. %s does not exist.", ZSTR_VAL(new_value)); return FAILURE; } /* }}} */ @@ -768,12 +768,12 @@ static PHP_INI_MH(OnUpdateHashFunc) /* {{{ */ static PHP_INI_MH(OnUpdateRfc1867Freq) /* {{{ */ { int tmp; - tmp = zend_atoi(new_value->val, (int)new_value->len); + tmp = zend_atoi(ZSTR_VAL(new_value), (int)ZSTR_LEN(new_value)); if(tmp < 0) { php_error_docref(NULL, E_WARNING, "session.upload_progress.freq must be greater than or equal to zero"); return FAILURE; } - if(new_value->len > 0 && new_value->val[new_value->len-1] == '%') { + if(ZSTR_LEN(new_value) > 0 && ZSTR_VAL(new_value)[ZSTR_LEN(new_value)-1] == '%') { if(tmp > 100) { php_error_docref(NULL, E_WARNING, "session.upload_progress.freq cannot be over 100%%"); return FAILURE; @@ -895,14 +895,14 @@ PS_SERIALIZER_ENCODE_FUNC(php_binary) /* {{{ */ PHP_VAR_SERIALIZE_INIT(var_hash); PS_ENCODE_LOOP( - if (key->len > PS_BIN_MAX) continue; - smart_str_appendc(&buf, (unsigned char)key->len); - smart_str_appendl(&buf, key->val, key->len); + if (ZSTR_LEN(key) > PS_BIN_MAX) continue; + smart_str_appendc(&buf, (unsigned char)ZSTR_LEN(key)); + smart_str_appendl(&buf, ZSTR_VAL(key), ZSTR_LEN(key)); php_var_serialize(&buf, struc, &var_hash); } else { - if (key->len > PS_BIN_MAX) continue; - smart_str_appendc(&buf, (unsigned char) (key->len & PS_BIN_UNDEF)); - smart_str_appendl(&buf, key->val, key->len); + if (ZSTR_LEN(key) > PS_BIN_MAX) continue; + smart_str_appendc(&buf, (unsigned char) (ZSTR_LEN(key) & PS_BIN_UNDEF)); + smart_str_appendl(&buf, ZSTR_VAL(key), ZSTR_LEN(key)); ); smart_str_0(&buf); @@ -976,8 +976,8 @@ PS_SERIALIZER_ENCODE_FUNC(php) /* {{{ */ PHP_VAR_SERIALIZE_INIT(var_hash); PS_ENCODE_LOOP( - smart_str_appendl(&buf, key->val, key->len); - if (memchr(key->val, PS_DELIMITER, key->len) || memchr(key->val, PS_UNDEF_MARKER, key->len)) { + smart_str_appendl(&buf, ZSTR_VAL(key), ZSTR_LEN(key)); + if (memchr(ZSTR_VAL(key), PS_DELIMITER, ZSTR_LEN(key)) || memchr(ZSTR_VAL(key), PS_UNDEF_MARKER, ZSTR_LEN(key))) { PHP_VAR_SERIALIZE_DESTROY(var_hash); smart_str_free(&buf); return NULL; @@ -987,7 +987,7 @@ PS_SERIALIZER_ENCODE_FUNC(php) /* {{{ */ php_var_serialize(&buf, struc, &var_hash); } else { smart_str_appendc(&buf, PS_UNDEF_MARKER); - smart_str_appendl(&buf, key->val, key->len); + smart_str_appendl(&buf, ZSTR_VAL(key), ZSTR_LEN(key)); smart_str_appendc(&buf, PS_DELIMITER); ); @@ -1299,7 +1299,7 @@ static void php_session_remove_cookie(void) { size_t len = sizeof("Set-Cookie")-1; e_session_name = php_url_encode(PS(session_name), strlen(PS(session_name))); - spprintf(&session_cookie, 0, "Set-Cookie: %s=", e_session_name->val); + spprintf(&session_cookie, 0, "Set-Cookie: %s=", ZSTR_VAL(e_session_name)); zend_string_free(e_session_name); session_cookie_len = strlen(session_cookie); @@ -1348,12 +1348,12 @@ static void php_session_send_cookie(void) /* {{{ */ /* URL encode session_name and id because they might be user supplied */ e_session_name = php_url_encode(PS(session_name), strlen(PS(session_name))); - e_id = php_url_encode(PS(id)->val, PS(id)->len); + e_id = php_url_encode(ZSTR_VAL(PS(id)), ZSTR_LEN(PS(id))); smart_str_appendl(&ncookie, "Set-Cookie: ", sizeof("Set-Cookie: ")-1); - smart_str_appendl(&ncookie, e_session_name->val, e_session_name->len); + smart_str_appendl(&ncookie, ZSTR_VAL(e_session_name), ZSTR_LEN(e_session_name)); smart_str_appendc(&ncookie, '='); - smart_str_appendl(&ncookie, e_id->val, e_id->len); + smart_str_appendl(&ncookie, ZSTR_VAL(e_id), ZSTR_LEN(e_id)); zend_string_release(e_session_name); zend_string_release(e_id); @@ -1368,7 +1368,7 @@ static void php_session_send_cookie(void) /* {{{ */ if (t > 0) { date_fmt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, t, 0); smart_str_appends(&ncookie, COOKIE_EXPIRES); - smart_str_appendl(&ncookie, date_fmt->val, date_fmt->len); + smart_str_appendl(&ncookie, ZSTR_VAL(date_fmt), ZSTR_LEN(date_fmt)); zend_string_release(date_fmt); smart_str_appends(&ncookie, COOKIE_MAX_AGE); @@ -1399,7 +1399,7 @@ static void php_session_send_cookie(void) /* {{{ */ php_session_remove_cookie(); /* remove already sent session ID cookie */ /* 'replace' must be 0 here, else a previous Set-Cookie header, probably sent with setcookie() will be replaced! */ - sapi_add_header_ex(estrndup(ncookie.s->val, ncookie.s->len), ncookie.s->len, 0, 0); + sapi_add_header_ex(estrndup(ZSTR_VAL(ncookie.s), ZSTR_LEN(ncookie.s)), ZSTR_LEN(ncookie.s), 0, 0); smart_str_free(&ncookie); } /* }}} */ @@ -1471,13 +1471,13 @@ PHPAPI void php_session_reset_id(void) /* {{{ */ smart_str_appends(&var, PS(session_name)); smart_str_appendc(&var, '='); - smart_str_appends(&var, PS(id)->val); + smart_str_appends(&var, ZSTR_VAL(PS(id))); smart_str_0(&var); if (sid) { zend_string_release(Z_STR_P(sid)); ZVAL_NEW_STR(sid, var.s); } else { - REGISTER_STRINGL_CONSTANT("SID", var.s->val, var.s->len, 0); + REGISTER_STRINGL_CONSTANT("SID", ZSTR_VAL(var.s), ZSTR_LEN(var.s), 0); smart_str_free(&var); } } else { @@ -1491,7 +1491,7 @@ PHPAPI void php_session_reset_id(void) /* {{{ */ if (APPLY_TRANS_SID) { /* php_url_scanner_reset_vars(); */ - php_url_scanner_add_var(PS(session_name), strlen(PS(session_name)), PS(id)->val, PS(id)->len, 1); + php_url_scanner_add_var(PS(session_name), strlen(PS(session_name)), ZSTR_VAL(PS(id)), ZSTR_LEN(PS(id)), 1); } } /* }}} */ @@ -1603,7 +1603,7 @@ PHPAPI void php_session_start(void) /* {{{ */ /* Finally check session id for dangerous characters * Security note: session id may be embedded in HTML pages.*/ - if (PS(id) && strpbrk(PS(id)->val, "\r\n\t <>'\"\\")) { + if (PS(id) && strpbrk(ZSTR_VAL(PS(id)), "\r\n\t <>'\"\\")) { zend_string_release(PS(id)); PS(id) = NULL; } @@ -1662,7 +1662,7 @@ static void php_session_reset(void) /* {{{ */ PHPAPI void session_adapt_url(const char *url, size_t urllen, char **new, size_t *newlen) /* {{{ */ { if (APPLY_TRANS_SID && (PS(session_status) == php_session_active)) { - *new = php_url_scanner_adapt_single_url(url, urllen, PS(session_name), PS(id)->val, newlen, 1); + *new = php_url_scanner_adapt_single_url(url, urllen, PS(session_name), ZSTR_VAL(PS(id)), newlen, 1); } } /* }}} */ @@ -1774,8 +1774,8 @@ static PHP_FUNCTION(session_module_name) } if (name) { - if (!_php_find_ps_module(name->val)) { - php_error_docref(NULL, E_WARNING, "Cannot find named PHP session module (%s)", name->val); + if (!_php_find_ps_module(ZSTR_VAL(name))) { + php_error_docref(NULL, E_WARNING, "Cannot find named PHP session module (%s)", ZSTR_VAL(name)); zval_dtor(return_value); RETURN_FALSE; @@ -1961,7 +1961,7 @@ static PHP_FUNCTION(session_save_path) RETVAL_STRING(PS(save_path)); if (name) { - if (memchr(name->val, '\0', name->len) != NULL) { + if (memchr(ZSTR_VAL(name), '\0', ZSTR_LEN(name)) != NULL) { php_error_docref(NULL, E_WARNING, "The save_path cannot contain NULL characters"); zval_dtor(return_value); RETURN_FALSE; @@ -1987,9 +1987,9 @@ static PHP_FUNCTION(session_id) if (PS(id)) { /* keep compatibility for "\0" characters ??? * see: ext/session/tests/session_id_error3.phpt */ - size_t len = strlen(PS(id)->val); - if (UNEXPECTED(len != PS(id)->len)) { - RETVAL_NEW_STR(zend_string_init(PS(id)->val, len, 0)); + size_t len = strlen(ZSTR_VAL(PS(id))); + if (UNEXPECTED(len != ZSTR_LEN(PS(id)))) { + RETVAL_NEW_STR(zend_string_init(ZSTR_VAL(PS(id)), len, 0)); } else { RETVAL_STR_COPY(PS(id)); } @@ -2061,8 +2061,8 @@ static PHP_FUNCTION(session_create_id) return; } - if (prefix && prefix->len) { - if (php_session_valid_key(prefix->val) == FAILURE) { + if (prefix && ZSTR_LEN(prefix)) { + if (php_session_valid_key(ZSTR_VAL(prefix)) == FAILURE) { /* E_ERROR raised for security reason. */ php_error_docref(NULL, E_WARNING, "Prefix cannot contain special characters. Only aphanumeric, ',', '-' are allowed"); RETURN_FALSE; @@ -2202,7 +2202,7 @@ static PHP_FUNCTION(session_start) RETURN_FALSE; } - if (PS(id) && !(PS(id)->len)) { + if (PS(id) && !(ZSTR_LEN(PS(id)))) { php_error_docref(NULL, E_WARNING, "Cannot start session with empty session ID"); RETURN_FALSE; } @@ -2221,13 +2221,13 @@ static PHP_FUNCTION(session_start) } else { zend_string *val = zval_get_string(value); if (php_session_start_set_ini(str_idx, val) == FAILURE) { - php_error_docref(NULL, E_WARNING, "Setting option '%s' failed", str_idx->val); + php_error_docref(NULL, E_WARNING, "Setting option '%s' failed", ZSTR_VAL(str_idx)); } zend_string_release(val); } break; default: - php_error_docref(NULL, E_WARNING, "Option(%s) value must be string, boolean or long", str_idx->val); + php_error_docref(NULL, E_WARNING, "Option(%s) value must be string, boolean or long", ZSTR_VAL(str_idx)); break; } } @@ -2700,7 +2700,7 @@ static PHP_MINFO_FUNCTION(session) /* {{{ */ if (save_handlers.s) { smart_str_0(&save_handlers); - php_info_print_table_row(2, "Registered save handlers", save_handlers.s->val); + php_info_print_table_row(2, "Registered save handlers", ZSTR_VAL(save_handlers.s)); smart_str_free(&save_handlers); } else { php_info_print_table_row(2, "Registered save handlers", "none"); @@ -2708,7 +2708,7 @@ static PHP_MINFO_FUNCTION(session) /* {{{ */ if (ser_handlers.s) { smart_str_0(&ser_handlers); - php_info_print_table_row(2, "Registered serializer handlers", ser_handlers.s->val); + php_info_print_table_row(2, "Registered serializer handlers", ZSTR_VAL(ser_handlers.s)); smart_str_free(&ser_handlers); } else { php_info_print_table_row(2, "Registered serializer handlers", "none"); diff --git a/ext/shmop/shmop.c b/ext/shmop/shmop.c index 1b77c35f26..cf2084a743 100644 --- a/ext/shmop/shmop.c +++ b/ext/shmop/shmop.c @@ -327,8 +327,8 @@ PHP_FUNCTION(shmop_write) RETURN_FALSE; } - writesize = (data->len < shmop->size - offset) ? data->len : shmop->size - offset; - memcpy(shmop->addr + offset, data->val, writesize); + writesize = (ZSTR_LEN(data) < shmop->size - offset) ? ZSTR_LEN(data) : shmop->size - offset; + memcpy(shmop->addr + offset, ZSTR_VAL(data), writesize); RETURN_LONG(writesize); } diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index 7bff2aeab6..21786c6b2e 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -313,13 +313,13 @@ static zend_bool soap_check_zval_ref(zval *data, xmlNodePtr node) { smart_str_appendc(&prefix, '#'); smart_str_appends(&prefix, id); smart_str_0(&prefix); - id = prefix.s->val; + id = ZSTR_VAL(prefix.s); } else { SOAP_GLOBAL(cur_uniq_ref)++; smart_str_appendl(&prefix, "#ref", 4); smart_str_append_long(&prefix, SOAP_GLOBAL(cur_uniq_ref)); smart_str_0(&prefix); - id = prefix.s->val; + id = ZSTR_VAL(prefix.s); xmlSetProp(node_ptr, BAD_CAST("id"), BAD_CAST(id+1)); } xmlSetProp(node, BAD_CAST("href"), BAD_CAST(id)); @@ -330,13 +330,13 @@ static zend_bool soap_check_zval_ref(zval *data, xmlNodePtr node) { smart_str_appendc(&prefix, '#'); smart_str_appends(&prefix, id); smart_str_0(&prefix); - id = prefix.s->val; + id = ZSTR_VAL(prefix.s); } else { SOAP_GLOBAL(cur_uniq_ref)++; smart_str_appendl(&prefix, "#ref", 4); smart_str_append_long(&prefix, SOAP_GLOBAL(cur_uniq_ref)); smart_str_0(&prefix); - id = prefix.s->val; + id = ZSTR_VAL(prefix.s); set_ns_prop(node_ptr, SOAP_1_2_ENC_NAMESPACE, "id", id+1); } set_ns_prop(node, SOAP_1_2_ENC_NAMESPACE, "ref", id); @@ -456,16 +456,16 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml ZEND_HASH_FOREACH_STR_KEY_VAL(SOAP_GLOBAL(class_map), type_name, tmp) { if (Z_TYPE_P(tmp) == IS_STRING && - ce->name->len == Z_STRLEN_P(tmp) && - zend_binary_strncasecmp(ce->name->val, ce->name->len, Z_STRVAL_P(tmp), ce->name->len, ce->name->len) == 0 && + ZSTR_LEN(ce->name) == Z_STRLEN_P(tmp) && + zend_binary_strncasecmp(ZSTR_VAL(ce->name), ZSTR_LEN(ce->name), Z_STRVAL_P(tmp), ZSTR_LEN(ce->name), ZSTR_LEN(ce->name)) == 0 && type_name) { /* TODO: namespace isn't stored */ encodePtr enc = NULL; if (SOAP_GLOBAL(sdl)) { - enc = get_encoder(SOAP_GLOBAL(sdl), SOAP_GLOBAL(sdl)->target_ns, type_name->val); + enc = get_encoder(SOAP_GLOBAL(sdl), SOAP_GLOBAL(sdl)->target_ns, ZSTR_VAL(type_name)); if (!enc) { - enc = find_encoder_by_type_name(SOAP_GLOBAL(sdl), type_name->val); + enc = find_encoder_by_type_name(SOAP_GLOBAL(sdl), ZSTR_VAL(type_name)); } } if (enc) { @@ -797,29 +797,29 @@ static zval *to_zval_hexbin(zval *ret, encodeTypePtr type, xmlNodePtr data) return ret; } str = zend_string_alloc(strlen((char*)data->children->content) / 2, 0); - for (i = j = 0; i < str->len; i++) { + for (i = j = 0; i < ZSTR_LEN(str); i++) { c = data->children->content[j++]; if (c >= '0' && c <= '9') { - str->val[i] = (c - '0') << 4; + ZSTR_VAL(str)[i] = (c - '0') << 4; } else if (c >= 'a' && c <= 'f') { - str->val[i] = (c - 'a' + 10) << 4; + ZSTR_VAL(str)[i] = (c - 'a' + 10) << 4; } else if (c >= 'A' && c <= 'F') { - str->val[i] = (c - 'A' + 10) << 4; + ZSTR_VAL(str)[i] = (c - 'A' + 10) << 4; } else { soap_error0(E_ERROR, "Encoding: Violation of encoding rules"); } c = data->children->content[j++]; if (c >= '0' && c <= '9') { - str->val[i] |= c - '0'; + ZSTR_VAL(str)[i] |= c - '0'; } else if (c >= 'a' && c <= 'f') { - str->val[i] |= c - 'a' + 10; + ZSTR_VAL(str)[i] |= c - 'a' + 10; } else if (c >= 'A' && c <= 'F') { - str->val[i] |= c - 'A' + 10; + ZSTR_VAL(str)[i] |= c - 'A' + 10; } else { soap_error0(E_ERROR, "Encoding: Violation of encoding rules"); } } - str->val[str->len] = '\0'; + ZSTR_VAL(str)[ZSTR_LEN(str)] = '\0'; ZVAL_NEW_STR(ret, str); } else { ZVAL_EMPTY_STRING(ret); @@ -842,8 +842,8 @@ static xmlNodePtr to_xml_string(encodeTypePtr type, zval *data, int style, xmlNo new_len = Z_STRLEN_P(data); } else { zend_string *tmp = zval_get_string(data); - str = estrndup(tmp->val, tmp->len); - new_len = tmp->len; + str = estrndup(ZSTR_VAL(tmp), ZSTR_LEN(tmp)); + new_len = ZSTR_LEN(tmp); zend_string_release(tmp); } @@ -925,11 +925,11 @@ static xmlNodePtr to_xml_base64(encodeTypePtr type, zval *data, int style, xmlNo str = php_base64_encode((unsigned char*)Z_STRVAL_P(data), Z_STRLEN_P(data)); } else { zend_string *tmp = zval_get_string(data); - str = php_base64_encode((unsigned char*) tmp->val, tmp->len); + str = php_base64_encode((unsigned char*) ZSTR_VAL(tmp), ZSTR_LEN(tmp)); zend_string_release(tmp); } - text = xmlNewTextLen(BAD_CAST(str->val), str->len); + text = xmlNewTextLen(BAD_CAST(ZSTR_VAL(str)), ZSTR_LEN(str)); xmlAddChild(ret, text); zend_string_release(str); @@ -1061,7 +1061,7 @@ static xmlNodePtr to_xml_long(encodeTypePtr type, zval *data, int style, xmlNode xmlNodeSetContent(ret, BAD_CAST(s)); } else { zend_string *str = zend_long_to_str(zval_get_long(data)); - xmlNodeSetContentLen(ret, BAD_CAST(str->val), str->len); + xmlNodeSetContentLen(ret, BAD_CAST(ZSTR_VAL(str)), ZSTR_LEN(str)); zend_string_release(str); } @@ -1974,7 +1974,7 @@ static xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style, xmlNo zend_unmangle_property_name(str_key, &class_name, &prop_name); } else { - prop_name = str_key->val; + prop_name = ZSTR_VAL(str_key); } if (prop_name) { xmlNodeSetName(property, BAD_CAST(prop_name)); @@ -2424,7 +2424,7 @@ iterator_done: if (style == SOAP_ENCODED) { if (soap_version == SOAP_1_1) { smart_str_0(&array_type); - if (strcmp(array_type.s->val,"xsd:anyType") == 0) { + if (strcmp(ZSTR_VAL(array_type.s),"xsd:anyType") == 0) { smart_str_free(&array_type); smart_str_appendl(&array_type,"xsd:ur-type",sizeof("xsd:ur-type")-1); } @@ -2432,17 +2432,17 @@ iterator_done: smart_str_append_smart_str(&array_type, &array_size); smart_str_appendc(&array_type, ']'); smart_str_0(&array_type); - set_ns_prop(xmlParam, SOAP_1_1_ENC_NAMESPACE, "arrayType", array_type.s->val); + set_ns_prop(xmlParam, SOAP_1_1_ENC_NAMESPACE, "arrayType", ZSTR_VAL(array_type.s)); } else { int i = 0; - while (i < array_size.s->len) { - if (array_size.s->val[i] == ',') {array_size.s->val[i] = ' ';} + while (i < ZSTR_LEN(array_size.s)) { + if (ZSTR_VAL(array_size.s)[i] == ',') {ZSTR_VAL(array_size.s)[i] = ' ';} ++i; } smart_str_0(&array_type); smart_str_0(&array_size); - set_ns_prop(xmlParam, SOAP_1_2_ENC_NAMESPACE, "itemType", array_type.s->val); - set_ns_prop(xmlParam, SOAP_1_2_ENC_NAMESPACE, "arraySize", array_size.s->val); + set_ns_prop(xmlParam, SOAP_1_2_ENC_NAMESPACE, "itemType", ZSTR_VAL(array_type.s)); + set_ns_prop(xmlParam, SOAP_1_2_ENC_NAMESPACE, "arraySize", ZSTR_VAL(array_size.s)); } } smart_str_free(&array_type); @@ -2694,7 +2694,7 @@ static xmlNodePtr to_xml_map(encodeTypePtr type, zval *data, int style, xmlNodeP if (style == SOAP_ENCODED) { set_xsi_type(key, "xsd:string"); } - xmlNodeSetContent(key, BAD_CAST(key_val->val)); + xmlNodeSetContent(key, BAD_CAST(ZSTR_VAL(key_val))); } else { smart_str tmp = {0}; smart_str_append_long(&tmp, int_val); @@ -2703,7 +2703,7 @@ static xmlNodePtr to_xml_map(encodeTypePtr type, zval *data, int style, xmlNodeP if (style == SOAP_ENCODED) { set_xsi_type(key, "xsd:int"); } - xmlNodeSetContentLen(key, BAD_CAST(tmp.s->val), tmp.s->len); + xmlNodeSetContentLen(key, BAD_CAST(ZSTR_VAL(tmp.s)), ZSTR_LEN(tmp.s)); smart_str_free(&tmp); } @@ -3005,7 +3005,7 @@ static xmlNodePtr to_xml_list(encodeTypePtr enc, zval *data, int style, xmlNodeP ZEND_HASH_FOREACH_VAL(ht, tmp) { xmlNodePtr dummy = master_to_xml(list_enc, tmp, SOAP_LITERAL, ret); if (dummy && dummy->children && dummy->children->content) { - if (list.s && list.s->len != 0) { + if (list.s && ZSTR_LEN(list.s) != 0) { smart_str_appendc(&list, ' '); } smart_str_appends(&list, (char*)dummy->children->content); @@ -3016,7 +3016,7 @@ static xmlNodePtr to_xml_list(encodeTypePtr enc, zval *data, int style, xmlNodeP xmlFreeNode(dummy); } ZEND_HASH_FOREACH_END(); smart_str_0(&list); - xmlNodeSetContentLen(ret, BAD_CAST(list.s->val), list.s->len); + xmlNodeSetContentLen(ret, BAD_CAST(ZSTR_VAL(list.s)), ZSTR_LEN(list.s)); smart_str_free(&list); } else { zval tmp; @@ -3043,7 +3043,7 @@ static xmlNodePtr to_xml_list(encodeTypePtr enc, zval *data, int style, xmlNodeP dummy = master_to_xml(list_enc, &dummy_zval, SOAP_LITERAL, ret); zval_ptr_dtor(&dummy_zval); if (dummy && dummy->children && dummy->children->content) { - if (list.s && list.s->len != 0) { + if (list.s && ZSTR_LEN(list.s) != 0) { smart_str_appendc(&list, ' '); } smart_str_appends(&list, (char*)dummy->children->content); @@ -3056,7 +3056,7 @@ static xmlNodePtr to_xml_list(encodeTypePtr enc, zval *data, int style, xmlNodeP start = next; } smart_str_0(&list); - xmlNodeSetContentLen(ret, BAD_CAST(list.s->val), list.s->len); + xmlNodeSetContentLen(ret, BAD_CAST(ZSTR_VAL(list.s)), ZSTR_LEN(list.s)); smart_str_free(&list); efree(str); if (data == &tmp) {zval_dtor(&tmp);} @@ -3122,7 +3122,7 @@ static xmlNodePtr to_xml_any(encodeTypePtr type, zval *data, int style, xmlNodeP ret = master_to_xml(enc, el, style, parent); if (ret && ret->name != xmlStringTextNoenc) { - xmlNodeSetName(ret, BAD_CAST(name->val)); + xmlNodeSetName(ret, BAD_CAST(ZSTR_VAL(name))); } } ZEND_HASH_FOREACH_END(); return ret; @@ -3131,7 +3131,7 @@ static xmlNodePtr to_xml_any(encodeTypePtr type, zval *data, int style, xmlNodeP ret = xmlNewTextLen(BAD_CAST(Z_STRVAL_P(data)), Z_STRLEN_P(data)); } else { zend_string *tmp = zval_get_string(data); - ret = xmlNewTextLen(BAD_CAST(tmp->val), tmp->len); + ret = xmlNewTextLen(BAD_CAST(ZSTR_VAL(tmp)), ZSTR_LEN(tmp)); zend_string_release(tmp); } @@ -3342,7 +3342,7 @@ static void set_ns_and_type_ex(xmlNodePtr node, char *ns, char *type) { smart_str nstype = {0}; get_type_str(node, ns, type, &nstype); - set_xsi_type(node, nstype.s->val); + set_xsi_type(node, ZSTR_VAL(nstype.s)); smart_str_free(&nstype); } @@ -3408,7 +3408,7 @@ xmlNsPtr encode_add_ns(xmlNodePtr node, const char* ns) smart_str_appendl(&prefix, "ns", 2); smart_str_append_long(&prefix, num); smart_str_0(&prefix); - if (xmlSearchNs(node->doc, node, BAD_CAST(prefix.s->val)) == NULL) { + if (xmlSearchNs(node->doc, node, BAD_CAST(ZSTR_VAL(prefix.s))) == NULL) { break; } smart_str_free(&prefix); @@ -3416,7 +3416,7 @@ xmlNsPtr encode_add_ns(xmlNodePtr node, const char* ns) num = ++SOAP_GLOBAL(cur_uniq_ns); } - xmlns = xmlNewNs(node->doc->children, BAD_CAST(ns), BAD_CAST(prefix.s ? prefix.s->val : "")); + xmlns = xmlNewNs(node->doc->children, BAD_CAST(ns), BAD_CAST(prefix.s ? ZSTR_VAL(prefix.s) : "")); smart_str_free(&prefix); } } @@ -3579,7 +3579,7 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type) smart_str_appends(&array_type, cur_stype); smart_str_0(&array_type); - enc = get_encoder_ex(SOAP_GLOBAL(sdl), array_type.s->val, array_type.s->len); + enc = get_encoder_ex(SOAP_GLOBAL(sdl), ZSTR_VAL(array_type.s), ZSTR_LEN(array_type.s)); smart_str_free(&array_type); return enc; } else { diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index 645d1f24ca..3b42a6bf06 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -48,9 +48,9 @@ int proxy_authentication(zval* this_ptr, smart_str* soap_headers) smart_str_appendl(&auth, Z_STRVAL_P(password), Z_STRLEN_P(password)); } smart_str_0(&auth); - buf = php_base64_encode((unsigned char*)auth.s->val, auth.s->len); + buf = php_base64_encode((unsigned char*)ZSTR_VAL(auth.s), ZSTR_LEN(auth.s)); smart_str_append_const(soap_headers, "Proxy-Authorization: Basic "); - smart_str_appendl(soap_headers, (char*)buf->val, buf->len); + smart_str_appendl(soap_headers, (char*)ZSTR_VAL(buf), ZSTR_LEN(buf)); smart_str_append_const(soap_headers, "\r\n"); zend_string_release(buf); smart_str_free(&auth); @@ -77,9 +77,9 @@ int basic_authentication(zval* this_ptr, smart_str* soap_headers) smart_str_appendl(&auth, Z_STRVAL_P(password), Z_STRLEN_P(password)); } smart_str_0(&auth); - buf = php_base64_encode((unsigned char*)auth.s->val, auth.s->len); + buf = php_base64_encode((unsigned char*)ZSTR_VAL(auth.s), ZSTR_LEN(auth.s)); smart_str_append_const(soap_headers, "Authorization: Basic "); - smart_str_appendl(soap_headers, (char*)buf->val, buf->len); + smart_str_appendl(soap_headers, (char*)ZSTR_VAL(buf), ZSTR_LEN(buf)); smart_str_append_const(soap_headers, "\r\n"); zend_string_release(buf); smart_str_free(&auth); @@ -255,7 +255,7 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, ph smart_str_append_const(&soap_headers, "\r\n"); proxy_authentication(this_ptr, &soap_headers); smart_str_append_const(&soap_headers, "\r\n"); - if (php_stream_write(stream, soap_headers.s->val, soap_headers.s->len) != soap_headers.s->len) { + if (php_stream_write(stream, ZSTR_VAL(soap_headers.s), ZSTR_LEN(soap_headers.s)) != ZSTR_LEN(soap_headers.s)) { php_stream_close(stream); stream = NULL; } @@ -786,9 +786,9 @@ try_again: smart_str_appendl(&auth, Z_STRVAL_P(password), Z_STRLEN_P(password)); } smart_str_0(&auth); - buf = php_base64_encode((unsigned char*)auth.s->val, auth.s->len); + buf = php_base64_encode((unsigned char*)ZSTR_VAL(auth.s), ZSTR_LEN(auth.s)); smart_str_append_const(&soap_headers, "Authorization: Basic "); - smart_str_appendl(&soap_headers, (char*)buf->val, buf->len); + smart_str_appendl(&soap_headers, (char*)ZSTR_VAL(buf), ZSTR_LEN(buf)); smart_str_append_const(&soap_headers, "\r\n"); zend_string_release(buf); smart_str_free(&auth); @@ -846,13 +846,13 @@ try_again: smart_str_0(&soap_headers); if ((trace = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace")-1)) != NULL && (Z_TYPE_P(trace) == IS_TRUE || (Z_TYPE_P(trace) == IS_LONG && Z_LVAL_P(trace) != 0))) { - add_property_stringl(this_ptr, "__last_request_headers", soap_headers.s->val, soap_headers.s->len); + add_property_stringl(this_ptr, "__last_request_headers", ZSTR_VAL(soap_headers.s), ZSTR_LEN(soap_headers.s)); } smart_str_appendl(&soap_headers, request, request_size); smart_str_0(&soap_headers); - err = php_stream_write(stream, soap_headers.s->val, soap_headers.s->len); - if (err != soap_headers.s->len) { + err = php_stream_write(stream, ZSTR_VAL(soap_headers.s), ZSTR_LEN(soap_headers.s)); + if (err != ZSTR_LEN(soap_headers.s)) { if (request != buf) {efree(request);} php_stream_close(stream); zend_hash_str_del(Z_OBJPROP_P(this_ptr), "httpurl", sizeof("httpurl")-1); @@ -897,7 +897,7 @@ try_again: /* Check to see what HTTP status was sent */ http_1_1 = 0; http_status = 0; - http_version = get_http_header_value(http_headers->val, "HTTP/"); + http_version = get_http_header_value(ZSTR_VAL(http_headers), "HTTP/"); if (http_version) { char *tmp; @@ -933,7 +933,7 @@ try_again: we shouldn't be changing urls so path dont matter too much */ - cookie_itt = strstr(http_headers->val, "Set-Cookie: "); + cookie_itt = strstr(ZSTR_VAL(http_headers), "Set-Cookie: "); while (cookie_itt) { char *cookie; char *eqpos, *sempos; @@ -1011,7 +1011,7 @@ try_again: if (http_1_1) { http_close = FALSE; if (use_proxy && !use_ssl) { - connection = get_http_header_value(http_headers->val, "Proxy-Connection: "); + connection = get_http_header_value(ZSTR_VAL(http_headers), "Proxy-Connection: "); if (connection) { if (strncasecmp(connection, "close", sizeof("close")-1) == 0) { http_close = TRUE; @@ -1020,7 +1020,7 @@ try_again: } } if (http_close == FALSE) { - connection = get_http_header_value(http_headers->val, "Connection: "); + connection = get_http_header_value(ZSTR_VAL(http_headers), "Connection: "); if (connection) { if (strncasecmp(connection, "close", sizeof("close")-1) == 0) { http_close = TRUE; @@ -1031,7 +1031,7 @@ try_again: } else { http_close = TRUE; if (use_proxy && !use_ssl) { - connection = get_http_header_value(http_headers->val, "Proxy-Connection: "); + connection = get_http_header_value(ZSTR_VAL(http_headers), "Proxy-Connection: "); if (connection) { if (strncasecmp(connection, "Keep-Alive", sizeof("Keep-Alive")-1) == 0) { http_close = FALSE; @@ -1040,7 +1040,7 @@ try_again: } } if (http_close == TRUE) { - connection = get_http_header_value(http_headers->val, "Connection: "); + connection = get_http_header_value(ZSTR_VAL(http_headers), "Connection: "); if (connection) { if (strncasecmp(connection, "Keep-Alive", sizeof("Keep-Alive")-1) == 0) { http_close = FALSE; @@ -1050,7 +1050,7 @@ try_again: } } - if (!get_http_body(stream, http_close, http_headers->val, &http_body, &http_body_size)) { + if (!get_http_body(stream, http_close, ZSTR_VAL(http_headers), &http_body, &http_body_size)) { if (request != buf) {efree(request);} php_stream_close(stream); zend_string_release(http_headers); @@ -1077,7 +1077,7 @@ try_again: if (http_status >= 300 && http_status < 400) { char *loc; - if ((loc = get_http_header_value(http_headers->val, "Location: ")) != NULL) { + if ((loc = get_http_header_value(ZSTR_VAL(http_headers), "Location: ")) != NULL) { php_url *new_url = php_url_parse(loc); if (new_url != NULL) { @@ -1123,7 +1123,7 @@ try_again: } else if (http_status == 401) { /* Digest authentication */ zval *digest, *login, *password; - char *auth = get_http_header_value(http_headers->val, "WWW-Authenticate: "); + char *auth = get_http_header_value(ZSTR_VAL(http_headers), "WWW-Authenticate: "); if (auth && strstr(auth, "Digest") == auth && @@ -1200,7 +1200,7 @@ try_again: smart_str_free(&soap_headers_z); /* Check and see if the server even sent a xml document */ - content_type = get_http_header_value(http_headers->val, "Content-Type: "); + content_type = get_http_header_value(ZSTR_VAL(http_headers), "Content-Type: "); if (content_type) { char *pos = NULL; int cmplen; @@ -1230,7 +1230,7 @@ try_again: } /* Decompress response */ - content_encoding = get_http_header_value(http_headers->val, "Content-Encoding: "); + content_encoding = get_http_header_value(ZSTR_VAL(http_headers), "Content-Encoding: "); if (content_encoding) { zval func; zval retval; diff --git a/ext/soap/php_packet_soap.c b/ext/soap/php_packet_soap.c index d3b3dc4a06..5fd8cc9ae4 100644 --- a/ext/soap/php_packet_soap.c +++ b/ext/soap/php_packet_soap.c @@ -234,7 +234,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction master_to_zval(&details, NULL, tmp); } } - add_soap_fault(this_ptr, faultcode, faultstring ? faultstring->val : NULL, faultactor ? faultactor->val : NULL, &details); + add_soap_fault(this_ptr, faultcode, faultstring ? ZSTR_VAL(faultstring) : NULL, faultactor ? ZSTR_VAL(faultactor) : NULL, &details); if (faultstring) { zend_string_release(faultstring); } diff --git a/ext/soap/php_schema.c b/ext/soap/php_schema.c index a091803803..4e69ecd198 100644 --- a/ext/soap/php_schema.c +++ b/ext/soap/php_schema.c @@ -463,7 +463,7 @@ static int schema_list(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr listType, sdlTypeP smart_str_append_long(&anonymous, zend_hash_num_elements(sdl->types)); smart_str_0(&anonymous); // TODO: avoid reallocation ??? - newType->name = estrndup(anonymous.s->val, anonymous.s->len); + newType->name = estrndup(ZSTR_VAL(anonymous.s), ZSTR_LEN(anonymous.s)); smart_str_free(&anonymous); } newType->namens = estrdup((char*)tns->children->content); @@ -561,7 +561,7 @@ static int schema_union(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr unionType, sdlTyp smart_str_append_long(&anonymous, zend_hash_num_elements(sdl->types)); smart_str_0(&anonymous); // TODO: avoid reallocation ??? - newType->name = estrndup(anonymous.s->val, anonymous.s->len); + newType->name = estrndup(ZSTR_VAL(anonymous.s), ZSTR_LEN(anonymous.s)); smart_str_free(&anonymous); } newType->namens = estrdup((char*)tns->children->content); @@ -1100,7 +1100,7 @@ static int schema_group(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr groupType, sdlTyp newModel = emalloc(sizeof(sdlContentModel)); newModel->kind = XSD_CONTENT_GROUP_REF; - newModel->u.group_ref = estrndup(key.s->val, key.s->len); + newModel->u.group_ref = estrndup(ZSTR_VAL(key.s), ZSTR_LEN(key.s)); if (type) {efree(type);} if (ns) {efree(ns);} @@ -1127,7 +1127,7 @@ static int schema_group(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr groupType, sdlTyp zend_hash_init(sdl->groups, 0, NULL, delete_type, 0); } if (zend_hash_add_ptr(sdl->groups, key.s, newType) == NULL) { - soap_error1(E_ERROR, "Parsing Schema: group '%s' already defined", key.s->val); + soap_error1(E_ERROR, "Parsing Schema: group '%s' already defined", ZSTR_VAL(key.s)); } cur_type = newType; @@ -1536,7 +1536,7 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr element, sdlTyp smart_str_0(&nscat); if (type) {efree(type);} if (ns) {efree(ns);} - newType->ref = estrndup(nscat.s->val, nscat.s->len); + newType->ref = estrndup(ZSTR_VAL(nscat.s), ZSTR_LEN(nscat.s)); smart_str_free(&nscat); } else { newType->name = estrdup((char*)name->children->content); @@ -1566,7 +1566,7 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr element, sdlTyp smart_str_0(&key); if (zend_hash_add_ptr(addHash, key.s, newType) == NULL) { if (cur_type == NULL) { - soap_error1(E_ERROR, "Parsing Schema: element '%s' already defined", key.s->val); + soap_error1(E_ERROR, "Parsing Schema: element '%s' already defined", ZSTR_VAL(key.s)); } else { zend_hash_next_index_insert_ptr(addHash, newType); } @@ -1767,7 +1767,7 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr attrType, sdl smart_str_appendc(&key, ':'); smart_str_appends(&key, attr_name); smart_str_0(&key); - newAttr->ref = estrndup(key.s->val, key.s->len); + newAttr->ref = estrndup(ZSTR_VAL(key.s), ZSTR_LEN(key.s)); if (attr_name) {efree(attr_name);} if (ns) {efree(ns);} } else { @@ -1797,7 +1797,7 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr attrType, sdl } if (zend_hash_add_ptr(addHash, key.s, newAttr) == NULL) { - soap_error1(E_ERROR, "Parsing Schema: attribute '%s' already defined", key.s->val); + soap_error1(E_ERROR, "Parsing Schema: attribute '%s' already defined", ZSTR_VAL(key.s)); } smart_str_free(&key); } else{ @@ -1934,7 +1934,7 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr attrType, sdl smart_str_append_long(&anonymous, zend_hash_num_elements(sdl->types)); smart_str_0(&anonymous); // TODO: avoid reallocation ??? - dummy_type->name = estrndup(anonymous.s->val, anonymous.s->len); + dummy_type->name = estrndup(ZSTR_VAL(anonymous.s), ZSTR_LEN(anonymous.s)); smart_str_free(&anonymous); } dummy_type->namens = estrdup((char*)tns->children->content); @@ -1982,7 +1982,7 @@ static int schema_attributeGroup(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr attrGrou smart_str_0(&key); if (zend_hash_add_ptr(ctx->attributeGroups, key.s, newType) == NULL) { - soap_error1(E_ERROR, "Parsing Schema: attributeGroup '%s' already defined", key.s->val); + soap_error1(E_ERROR, "Parsing Schema: attributeGroup '%s' already defined", ZSTR_VAL(key.s)); } cur_type = newType; smart_str_free(&key); @@ -2007,7 +2007,7 @@ static int schema_attributeGroup(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr attrGrou smart_str_appendc(&key, ':'); smart_str_appends(&key, group_name); smart_str_0(&key); - newAttr->ref = estrndup(key.s->val, key.s->len); + newAttr->ref = estrndup(ZSTR_VAL(key.s), ZSTR_LEN(key.s)); if (group_name) {efree(group_name);} if (ns) {efree(ns);} smart_str_free(&key); diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c index f316e99eca..32c38a55f6 100644 --- a/ext/soap/php_sdl.c +++ b/ext/soap/php_sdl.c @@ -1793,8 +1793,8 @@ static void sdl_serialize_string(const char *str, smart_str *out) static void sdl_serialize_key(zend_string *key, smart_str *out) { if (key) { - WSDL_CACHE_PUT_INT(key->len, out); - WSDL_CACHE_PUT_N(key->val, key->len, out); + WSDL_CACHE_PUT_INT(ZSTR_LEN(key), out); + WSDL_CACHE_PUT_N(ZSTR_VAL(key), ZSTR_LEN(key), out); } else { WSDL_CACHE_PUT_INT(0, out); } @@ -2362,7 +2362,7 @@ static void add_sdl_to_cache(const char *fn, const char *uri, time_t t, sdlPtr s } ZEND_HASH_FOREACH_END(); } - php_ignore_value(write(f, buf.s->val, buf.s->len)); + php_ignore_value(write(f, ZSTR_VAL(buf.s), ZSTR_LEN(buf.s))); close(f); smart_str_free(&buf); zend_hash_destroy(&tmp_functions); @@ -2472,7 +2472,7 @@ static HashTable* make_persistent_sdl_function_headers(HashTable *headers, HashT if (key) { /* We have to duplicate key emalloc->malloc */ - zend_hash_str_add_ptr(pheaders, key->val, key->len, pheader); + zend_hash_str_add_ptr(pheaders, ZSTR_VAL(key), ZSTR_LEN(key), pheader); } else { zend_hash_next_index_insert_ptr(pheaders, pheader); } @@ -2529,7 +2529,7 @@ static HashTable* make_persistent_sdl_parameters(HashTable *params, HashTable *p if (key) { /* We have to duplicate key emalloc->malloc */ - zend_hash_str_add_ptr(pparams, key->val, key->len, pparam); + zend_hash_str_add_ptr(pparams, ZSTR_VAL(key), ZSTR_LEN(key), pparam); } else { zend_hash_next_index_insert_ptr(pparams, pparam); } @@ -2573,7 +2573,7 @@ static HashTable* make_persistent_sdl_function_faults(sdlFunctionPtr func, HashT if (key) { /* We have to duplicate key emalloc->malloc */ - zend_hash_str_add_ptr(pfaults, key->val, key->len, pfault); + zend_hash_str_add_ptr(pfaults, ZSTR_VAL(key), ZSTR_LEN(key), pfault); } else { zend_hash_next_index_insert_ptr(pfaults, pfault); } @@ -2634,7 +2634,7 @@ static sdlAttributePtr make_persistent_sdl_attribute(sdlAttributePtr attr, HashT } /* We have to duplicate key emalloc->malloc */ - zend_hash_str_add_ptr(pattr->extraAttributes, key->val, key->len, pextra); + zend_hash_str_add_ptr(pattr->extraAttributes, ZSTR_VAL(key), ZSTR_LEN(key), pextra); } } ZEND_HASH_FOREACH_END(); } @@ -2778,7 +2778,7 @@ static sdlTypePtr make_persistent_sdl_type(sdlTypePtr type, HashTable *ptr_map, pelem = make_persistent_sdl_type(tmp, ptr_map, bp_types, bp_encoders); if (key) { /* We have to duplicate key emalloc->malloc */ - zend_hash_str_add_ptr(ptype->elements, key->val, key->len, pelem); + zend_hash_str_add_ptr(ptype->elements, ZSTR_VAL(key), ZSTR_LEN(key), pelem); } else { zend_hash_next_index_insert_ptr(ptype->elements, pelem); } @@ -2796,7 +2796,7 @@ static sdlTypePtr make_persistent_sdl_type(sdlTypePtr type, HashTable *ptr_map, pattr = make_persistent_sdl_attribute(tmp, ptr_map, bp_types, bp_encoders); if (key) { /* We have to duplicate key emalloc->malloc */ - zend_hash_str_add_ptr(ptype->attributes, key->val, key->len, pattr); + zend_hash_str_add_ptr(ptype->attributes, ZSTR_VAL(key), ZSTR_LEN(key), pattr); } else { zend_hash_next_index_insert_ptr(ptype->attributes, pattr); } @@ -2948,7 +2948,7 @@ static sdlPtr make_persistent_sdl(sdlPtr sdl) ptype = make_persistent_sdl_type(tmp, &ptr_map, &bp_types, &bp_encoders); if (key) { /* We have to duplicate key emalloc->malloc */ - zend_hash_str_add_ptr(psdl->groups, key->val, key->len, ptype); + zend_hash_str_add_ptr(psdl->groups, ZSTR_VAL(key), ZSTR_LEN(key), ptype); } else { zend_hash_next_index_insert_ptr(psdl->groups, ptype); } @@ -2967,7 +2967,7 @@ static sdlPtr make_persistent_sdl(sdlPtr sdl) ptype = make_persistent_sdl_type(tmp, &ptr_map, &bp_types, &bp_encoders); if (key) { /* We have to duplicate key emalloc->malloc */ - zend_hash_str_add_ptr(psdl->types, key->val, key->len, ptype); + zend_hash_str_add_ptr(psdl->types, ZSTR_VAL(key), ZSTR_LEN(key), ptype); } else { zend_hash_next_index_insert_ptr(psdl->types, ptype); } @@ -2986,7 +2986,7 @@ static sdlPtr make_persistent_sdl(sdlPtr sdl) ptype = make_persistent_sdl_type(tmp, &ptr_map, &bp_types, &bp_encoders); if (key) { /* We have to duplicate key emalloc->malloc */ - zend_hash_str_add_ptr(psdl->elements, key->val, key->len, ptype); + zend_hash_str_add_ptr(psdl->elements, ZSTR_VAL(key), ZSTR_LEN(key), ptype); } else { zend_hash_next_index_insert_ptr(psdl->elements, ptype); } @@ -3005,7 +3005,7 @@ static sdlPtr make_persistent_sdl(sdlPtr sdl) penc = make_persistent_sdl_encoder(tmp, &ptr_map, &bp_types, &bp_encoders); if (key) { /* We have to duplicate key emalloc->malloc */ - zend_hash_str_add_ptr(psdl->encoders, key->val, key->len, penc); + zend_hash_str_add_ptr(psdl->encoders, ZSTR_VAL(key), ZSTR_LEN(key), penc); } else { zend_hash_next_index_insert_ptr(psdl->encoders, penc); } @@ -3047,7 +3047,7 @@ static sdlPtr make_persistent_sdl(sdlPtr sdl) pbind = make_persistent_sdl_binding(tmp, &ptr_map); if (key) { /* We have to duplicate key emalloc->malloc */ - zend_hash_str_add_ptr(psdl->bindings, key->val, key->len, pbind); + zend_hash_str_add_ptr(psdl->bindings, ZSTR_VAL(key), ZSTR_LEN(key), pbind); } else { zend_hash_next_index_insert_ptr(psdl->bindings, pbind); } @@ -3064,7 +3064,7 @@ static sdlPtr make_persistent_sdl(sdlPtr sdl) pfunc = make_persistent_sdl_function(tmp, &ptr_map); if (key) { /* We have to duplicate key emalloc->malloc */ - zend_hash_str_add_ptr(&psdl->functions, key->val, key->len, pfunc); + zend_hash_str_add_ptr(&psdl->functions, ZSTR_VAL(key), ZSTR_LEN(key), pfunc); } else { zend_hash_next_index_insert_ptr(&psdl->functions, pfunc); } @@ -3089,7 +3089,7 @@ static sdlPtr make_persistent_sdl(sdlPtr sdl) Z_PTR_P(zv) = preq; if (key) { /* We have to duplicate key emalloc->malloc */ - zend_hash_str_add_ptr(psdl->requests, key->val, key->len, preq); + zend_hash_str_add_ptr(psdl->requests, ZSTR_VAL(key), ZSTR_LEN(key), preq); } } ZEND_HASH_FOREACH_END(); } @@ -3277,7 +3277,7 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl) smart_str_appendl(&headers, "Connection: close\r\n", sizeof("Connection: close\r\n")-1); } - if (headers.s && headers.s->len > 0) { + if (headers.s && ZSTR_LEN(headers.s) > 0) { zval str_headers; if (!context) { diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 29e09e81fb..ab9f4ffb12 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -483,7 +483,7 @@ ZEND_INI_MH(OnUpdateCacheMode) p = (char*) (base+(size_t) mh_arg1); - *p = (char)atoi(new_value->val); + *p = (char)atoi(ZSTR_VAL(new_value)); return SUCCESS; } @@ -494,19 +494,19 @@ static PHP_INI_MH(OnUpdateCacheDir) if (stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) { char *p; - if (memchr(new_value->val, '\0', new_value->len) != NULL) { + if (memchr(ZSTR_VAL(new_value), '\0', ZSTR_LEN(new_value)) != NULL) { return FAILURE; } /* we do not use zend_memrchr() since path can contain ; itself */ - if ((p = strchr(new_value->val, ';'))) { + if ((p = strchr(ZSTR_VAL(new_value), ';'))) { char *p2; p++; if ((p2 = strchr(p, ';'))) { p = p2 + 1; } } else { - p = new_value->val; + p = ZSTR_VAL(new_value); } if (PG(open_basedir) && *p && php_check_open_basedir(p)) { @@ -1048,23 +1048,23 @@ static HashTable* soap_create_typemap(sdlPtr sdl, HashTable *ht) ZEND_HASH_FOREACH_STR_KEY_VAL(ht2, name, tmp) { if (name) { - if (name->len == sizeof("type_name")-1 && - strncmp(name->val, "type_name", sizeof("type_name")-1) == 0) { + if (ZSTR_LEN(name) == sizeof("type_name")-1 && + strncmp(ZSTR_VAL(name), "type_name", sizeof("type_name")-1) == 0) { if (Z_TYPE_P(tmp) == IS_STRING) { type_name = Z_STRVAL_P(tmp); } else if (Z_TYPE_P(tmp) != IS_NULL) { } - } else if (name->len == sizeof("type_ns")-1 && - strncmp(name->val, "type_ns", sizeof("type_ns")-1) == 0) { + } else if (ZSTR_LEN(name) == sizeof("type_ns")-1 && + strncmp(ZSTR_VAL(name), "type_ns", sizeof("type_ns")-1) == 0) { if (Z_TYPE_P(tmp) == IS_STRING) { type_ns = Z_STRVAL_P(tmp); } else if (Z_TYPE_P(tmp) != IS_NULL) { } - } else if (name->len == sizeof("to_xml")-1 && - strncmp(name->val, "to_xml", sizeof("to_xml")-1) == 0) { + } else if (ZSTR_LEN(name) == sizeof("to_xml")-1 && + strncmp(ZSTR_VAL(name), "to_xml", sizeof("to_xml")-1) == 0) { to_xml = tmp; - } else if (name->len == sizeof("from_xml")-1 && - strncmp(name->val, "from_xml", sizeof("from_xml")-1) == 0) { + } else if (ZSTR_LEN(name) == sizeof("from_xml")-1 && + strncmp(ZSTR_VAL(name), "from_xml", sizeof("from_xml")-1) == 0) { to_zval = tmp; } } @@ -1324,7 +1324,7 @@ PHP_METHOD(SoapServer, setClass) } } } else { - php_error_docref(NULL, E_WARNING, "Tried to set a non existent class (%s)", classname->val); + php_error_docref(NULL, E_WARNING, "Tried to set a non existent class (%s)", ZSTR_VAL(classname)); return; } @@ -1438,7 +1438,7 @@ PHP_METHOD(SoapServer, addFunction) } key = zend_string_alloc(Z_STRLEN_P(tmp_function), 0); - zend_str_tolower_copy(key->val, Z_STRVAL_P(tmp_function), Z_STRLEN_P(tmp_function)); + zend_str_tolower_copy(ZSTR_VAL(key), Z_STRVAL_P(tmp_function), Z_STRLEN_P(tmp_function)); if ((f = zend_hash_find_ptr(EG(function_table), key)) == NULL) { php_error_docref(NULL, E_WARNING, "Tried to add a non existent function '%s'", Z_STRVAL_P(tmp_function)); @@ -1456,7 +1456,7 @@ PHP_METHOD(SoapServer, addFunction) zend_function *f; key = zend_string_alloc(Z_STRLEN_P(function_name), 0); - zend_str_tolower_copy(key->val, Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)); + zend_str_tolower_copy(ZSTR_VAL(key), Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)); if ((f = zend_hash_find_ptr(EG(function_table), key)) == NULL) { php_error_docref(NULL, E_WARNING, "Tried to add a non existent function '%s'", Z_STRVAL_P(function_name)); @@ -1500,7 +1500,7 @@ static void _soap_server_exception(soapServicePtr service, sdlFunctionPtr functi if (service->send_errors) { zval rv; zend_string *msg = zval_get_string(zend_read_property(zend_get_error(), &exception_object, "message", sizeof("message")-1, 0, &rv)); - add_soap_fault_ex(&exception_object, this_ptr, "Server", msg->val, NULL, NULL); + add_soap_fault_ex(&exception_object, this_ptr, "Server", ZSTR_VAL(msg), NULL, NULL); zend_string_release(msg); } else { add_soap_fault_ex(&exception_object, this_ptr, "Server", "Internal Error", NULL, NULL); @@ -1732,10 +1732,10 @@ PHP_METHOD(SoapServer, handle) zval_dtor(&constructor); zval_dtor(&c_ret); } else { - int class_name_len = service->soap_class.ce->name->len; + int class_name_len = ZSTR_LEN(service->soap_class.ce->name); char *class_name = emalloc(class_name_len+1); - memcpy(class_name, service->soap_class.ce->name->val, class_name_len+1); + memcpy(class_name, ZSTR_VAL(service->soap_class.ce->name), class_name_len+1); if (zend_hash_str_exists(&Z_OBJCE(tmp_soap)->function_table, php_strtolower(class_name, class_name_len), class_name_len)) { zval c_ret, constructor; @@ -2605,7 +2605,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act msg = zval_get_string(zend_read_property(zend_get_error(), &exception_object, "message", sizeof("message")-1, 0, &rv)); /* change class */ EG(exception)->ce = soap_fault_class_entry; - set_soap_fault(&exception_object, NULL, "Client", msg->val, NULL, NULL, NULL); + set_soap_fault(&exception_object, NULL, "Client", ZSTR_VAL(msg), NULL, NULL, NULL); zend_string_release(msg); } else if ((fault = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "__soap_fault", sizeof("__soap_fault")-1)) == NULL) { add_soap_fault(this_ptr, "Client", "SoapClient::__doRequest() returned non string value", NULL, NULL); @@ -2762,7 +2762,7 @@ static void do_soap_call(zend_execute_data *execute_data, smart_str_appends(&error,function); smart_str_appends(&error,"\") is not a valid method for this service"); smart_str_0(&error); - add_soap_fault(this_ptr, "Client", error.s->val, NULL, NULL); + add_soap_fault(this_ptr, "Client", ZSTR_VAL(error.s), NULL, NULL); smart_str_free(&error); } } else { @@ -2787,7 +2787,7 @@ static void do_soap_call(zend_execute_data *execute_data, } smart_str_0(&action); - ret = do_request(this_ptr, request, location, action.s->val, soap_version, 0, &response); + ret = do_request(this_ptr, request, location, ZSTR_VAL(action.s), soap_version, 0, &response); smart_str_free(&action); xmlFreeDoc(request); @@ -2987,7 +2987,7 @@ PHP_METHOD(SoapClient, __getFunctions) array_init(return_value); ZEND_HASH_FOREACH_PTR(&sdl->functions, function) { function_to_string(function, &buf); - add_next_index_stringl(return_value, buf.s->val, buf.s->len); + add_next_index_stringl(return_value, ZSTR_VAL(buf.s), ZSTR_LEN(buf.s)); smart_str_free(&buf); } ZEND_HASH_FOREACH_END(); } @@ -3015,7 +3015,7 @@ PHP_METHOD(SoapClient, __getTypes) if (sdl->types) { ZEND_HASH_FOREACH_PTR(sdl->types, type) { type_to_string(type, &buf, 0); - add_next_index_stringl(return_value, buf.s->val, buf.s->len); + add_next_index_stringl(return_value, ZSTR_VAL(buf.s), ZSTR_LEN(buf.s)); smart_str_free(&buf); } ZEND_HASH_FOREACH_END(); } @@ -3829,11 +3829,11 @@ static int serialize_response_call2(xmlNodePtr body, sdlFunctionPtr function, ch zend_ulong param_index = i; ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(ret), param_index, param_name, data) { - parameter = get_param(function, param_name->val, param_index, TRUE); + parameter = get_param(function, ZSTR_VAL(param_name), param_index, TRUE); if (style == SOAP_RPC) { - param = serialize_parameter(parameter, data, i, param_name->val, use, method); + param = serialize_parameter(parameter, data, i, ZSTR_VAL(param_name), use, method); } else { - param = serialize_parameter(parameter, data, i, param_name->val, use, body); + param = serialize_parameter(parameter, data, i, ZSTR_VAL(param_name), use, body); if (function && function->binding->bindingType == BINDING_SOAP) { if (parameter && parameter->element) { ns = encode_add_ns(param, parameter->element->namens); @@ -4008,11 +4008,11 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function xmlAddChild(param, node); if (fault_ns) { xmlNsPtr nsptr = encode_add_ns(node, fault_ns); - xmlChar *code = xmlBuildQName(BAD_CAST(str->val), nsptr->prefix, NULL, 0); + xmlChar *code = xmlBuildQName(BAD_CAST(ZSTR_VAL(str)), nsptr->prefix, NULL, 0); xmlNodeSetContent(node, code); xmlFree(code); } else { - xmlNodeSetContentLen(node, BAD_CAST(str->val), (int)str->len); + xmlNodeSetContentLen(node, BAD_CAST(ZSTR_VAL(str)), (int)ZSTR_LEN(str)); } zend_string_release(str); } @@ -4033,11 +4033,11 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function node = xmlNewChild(node, ns, BAD_CAST("Value"), NULL); if (fault_ns) { xmlNsPtr nsptr = encode_add_ns(node, fault_ns); - xmlChar *code = xmlBuildQName(BAD_CAST(str->val), nsptr->prefix, NULL, 0); + xmlChar *code = xmlBuildQName(BAD_CAST(ZSTR_VAL(str)), nsptr->prefix, NULL, 0); xmlNodeSetContent(node, code); xmlFree(code); } else { - xmlNodeSetContentLen(node, BAD_CAST(str->val), (int)str->len); + xmlNodeSetContentLen(node, BAD_CAST(ZSTR_VAL(str)), (int)ZSTR_LEN(str)); } zend_string_release(str); } @@ -4682,7 +4682,7 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) smart_str_appendc(&spaces, ' '); } if (spaces.s) { - smart_str_appendl(buf, spaces.s->val, spaces.s->len); + smart_str_appendl(buf, ZSTR_VAL(spaces.s), ZSTR_LEN(spaces.s)); } switch (type->kind) { case XSD_TYPEKIND_SIMPLE: @@ -4744,7 +4744,7 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) if (end == NULL) { len = strlen(ext->val); } else { - len = end-ext->val; + len = end - ext->val; } if (len == 0) { smart_str_appendl(buf, "anyType", sizeof("anyType")-1); @@ -4804,7 +4804,7 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) enc = enc->details.sdl_type->encode; } if (enc) { - smart_str_appendl(buf, spaces.s->val, spaces.s->len); + smart_str_appendl(buf, ZSTR_VAL(spaces.s), ZSTR_LEN(spaces.s)); smart_str_appendc(buf, ' '); smart_str_appendl(buf, type->encode->details.type_str, strlen(type->encode->details.type_str)); smart_str_appendl(buf, " _;\n", 4); @@ -4817,7 +4817,7 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) sdlAttributePtr attr; ZEND_HASH_FOREACH_PTR(type->attributes, attr) { - smart_str_appendl(buf, spaces.s->val, spaces.s->len); + smart_str_appendl(buf, ZSTR_VAL(spaces.s), ZSTR_LEN(spaces.s)); smart_str_appendc(buf, ' '); if (attr->encode && attr->encode->details.type_str) { smart_str_appends(buf, attr->encode->details.type_str); @@ -4830,7 +4830,7 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) } ZEND_HASH_FOREACH_END(); } if (spaces.s) { - smart_str_appendl(buf, spaces.s->val, spaces.s->len); + smart_str_appendl(buf, ZSTR_VAL(spaces.s), ZSTR_LEN(spaces.s)); } smart_str_appendc(buf, '}'); } diff --git a/ext/sockets/conversions.c b/ext/sockets/conversions.c index 1f7d3e8766..c8acaf6995 100644 --- a/ext/sockets/conversions.c +++ b/ext/sockets/conversions.c @@ -159,8 +159,8 @@ static void do_from_to_zval_err(struct err_s *err, smart_str_appends(&path, " > "); } - if (path.s && path.s->len > 3) { - path.s->len -= 3; + if (path.s && ZSTR_LEN(path.s) > 3) { + ZSTR_LEN(path.s) -= 3; } smart_str_0(&path); @@ -170,7 +170,7 @@ static void do_from_to_zval_err(struct err_s *err, err->level = E_WARNING; spprintf(&err->msg, 0, "error converting %s data (path: %s): %.*s", what_conv, - path.s && *path.s->val != '\0' ? path.s->val : "unavailable", + path.s && *ZSTR_VAL(path.s) != '\0' ? ZSTR_VAL(path.s) : "unavailable", user_msg_size, user_msg); err->should_free = 1; @@ -544,13 +544,13 @@ static void from_zval_write_sin_addr(const zval *zaddr_str, char *inaddr, ser_co zend_string *addr_str; addr_str = zval_get_string((zval *) zaddr_str); - res = php_set_inet_addr(&saddr, addr_str->val, ctx->sock); + res = php_set_inet_addr(&saddr, ZSTR_VAL(addr_str), ctx->sock); if (res) { memcpy(inaddr, &saddr.sin_addr, sizeof saddr.sin_addr); } else { /* error already emitted, but let's emit another more relevant */ do_from_zval_err(ctx, "could not resolve address '%s' to get an AF_INET " - "address", addr_str->val); + "address", ZSTR_VAL(addr_str)); } zend_string_release(addr_str); @@ -560,7 +560,7 @@ static void to_zval_read_sin_addr(const char *data, zval *zv, res_context *ctx) const struct in_addr *addr = (const struct in_addr *)data; socklen_t size = INET_ADDRSTRLEN; zend_string *str = zend_string_alloc(size - 1, 0); - memset(str->val, '\0', size); + memset(ZSTR_VAL(str), '\0', size); ZVAL_NEW_STR(zv, str); @@ -594,7 +594,7 @@ static void from_zval_write_sin6_addr(const zval *zaddr_str, char *addr6, ser_co zend_string *addr_str; addr_str = zval_get_string((zval *) zaddr_str); - res = php_set_inet6_addr(&saddr6, addr_str->val, ctx->sock); + res = php_set_inet6_addr(&saddr6, ZSTR_VAL(addr_str), ctx->sock); if (res) { memcpy(addr6, &saddr6.sin6_addr, sizeof saddr6.sin6_addr); } else { @@ -611,7 +611,7 @@ static void to_zval_read_sin6_addr(const char *data, zval *zv, res_context *ctx) socklen_t size = INET6_ADDRSTRLEN; zend_string *str = zend_string_alloc(size - 1, 0); - memset(str->val, '\0', size); + memset(ZSTR_VAL(str), '\0', size); ZVAL_NEW_STR(zv, str); @@ -650,18 +650,18 @@ static void from_zval_write_sun_path(const zval *path, char *sockaddr_un_c, ser_ /* code in this file relies on the path being nul terminated, even though * this is not required, at least on linux for abstract paths. It also * assumes that the path is not empty */ - if (path_str->len == 0) { + if (ZSTR_LEN(path_str) == 0) { do_from_zval_err(ctx, "%s", "the path is cannot be empty"); return; } - if (path_str->len >= sizeof(saddr->sun_path)) { + if (ZSTR_LEN(path_str) >= sizeof(saddr->sun_path)) { do_from_zval_err(ctx, "the path is too long, the maximum permitted " "length is %ld", sizeof(saddr->sun_path) - 1); return; } - memcpy(&saddr->sun_path, path_str->val, path_str->len); - saddr->sun_path[path_str->len] = '\0'; + memcpy(&saddr->sun_path, ZSTR_VAL(path_str), ZSTR_LEN(path_str)); + saddr->sun_path[ZSTR_LEN(path_str)] = '\0'; zend_string_release(path_str); } @@ -1207,8 +1207,8 @@ static void to_zval_read_iov(const char *msghdr_c, zval *zv, res_context *ctx) size_t len = MIN(msghdr->msg_iov[i].iov_len, (size_t)bytes_left); zend_string *buf = zend_string_alloc(len, 0); - memcpy(buf->val, msghdr->msg_iov[i].iov_base, buf->len); - buf->val[buf->len] = '\0'; + memcpy(ZSTR_VAL(buf), msghdr->msg_iov[i].iov_base, ZSTR_LEN(buf)); + ZSTR_VAL(buf)[ZSTR_LEN(buf)] = '\0'; ZVAL_NEW_STR(&elem, buf); add_next_index_zval(zv, &elem); @@ -1248,24 +1248,24 @@ static void from_zval_write_ifindex(const zval *zv, char *uinteger, ser_context str = zval_get_string((zval *) zv); #if HAVE_IF_NAMETOINDEX - ret = if_nametoindex(str->val); + ret = if_nametoindex(ZSTR_VAL(str)); if (ret == 0) { - do_from_zval_err(ctx, "no interface with name \"%s\" could be found", str->val); + do_from_zval_err(ctx, "no interface with name \"%s\" could be found", ZSTR_VAL(str)); } #elif defined(SIOCGIFINDEX) { struct ifreq ifr; - if (strlcpy(ifr.ifr_name, str->val, sizeof(ifr.ifr_name)) + if (strlcpy(ifr.ifr_name, ZSTR_VAL(str), sizeof(ifr.ifr_name)) >= sizeof(ifr.ifr_name)) { - do_from_zval_err(ctx, "the interface name \"%s\" is too large ", str->val); + do_from_zval_err(ctx, "the interface name \"%s\" is too large ", ZSTR_VAL(str)); } else if (ioctl(ctx->sock->bsd_socket, SIOCGIFINDEX, &ifr) < 0) { if (errno == ENODEV) { do_from_zval_err(ctx, "no interface with name \"%s\" could be " - "found", str->val); + "found", ZSTR_VAL(str)); } else { do_from_zval_err(ctx, "error fetching interface index for " "interface with name \"%s\" (errno %d)", - str->val, errno); + ZSTR_VAL(str), errno); } } else { ret = (unsigned)ifr.ifr_ifindex; diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 19e1c76d38..e1caa19fc5 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -1152,9 +1152,9 @@ PHP_FUNCTION(socket_read) } if (type == PHP_NORMAL_READ) { - retval = php_read(php_sock, tmpbuf->val, length, 0); + retval = php_read(php_sock, ZSTR_VAL(tmpbuf), length, 0); } else { - retval = recv(php_sock->bsd_socket, tmpbuf->val, length, 0); + retval = recv(php_sock->bsd_socket, ZSTR_VAL(tmpbuf), length, 0); } if (retval == -1) { @@ -1179,8 +1179,8 @@ PHP_FUNCTION(socket_read) } tmpbuf = zend_string_truncate(tmpbuf, retval, 0); - tmpbuf->len = retval; - tmpbuf->val[tmpbuf->len] = '\0' ; + ZSTR_LEN(tmpbuf) = retval; + ZSTR_VAL(tmpbuf)[ZSTR_LEN(tmpbuf)] = '\0' ; RETURN_NEW_STR(tmpbuf); } @@ -1608,14 +1608,14 @@ PHP_FUNCTION(socket_recv) recv_buf = zend_string_alloc(len, 0); - if ((retval = recv(php_sock->bsd_socket, recv_buf->val, len, flags)) < 1) { + if ((retval = recv(php_sock->bsd_socket, ZSTR_VAL(recv_buf), len, flags)) < 1) { efree(recv_buf); zval_dtor(buf); ZVAL_NULL(buf); } else { - recv_buf->len = retval; - recv_buf->val[recv_buf->len] = '\0'; + ZSTR_LEN(recv_buf) = retval; + ZSTR_VAL(recv_buf)[ZSTR_LEN(recv_buf)] = '\0'; /* Rebuild buffer zval */ zval_dtor(buf); @@ -1697,15 +1697,15 @@ PHP_FUNCTION(socket_recvfrom) case AF_UNIX: slen = sizeof(s_un); s_un.sun_family = AF_UNIX; - retval = recvfrom(php_sock->bsd_socket, recv_buf->val, arg3, arg4, (struct sockaddr *)&s_un, (socklen_t *)&slen); + retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&s_un, (socklen_t *)&slen); if (retval < 0) { PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno); zend_string_free(recv_buf); RETURN_FALSE; } - recv_buf->len = retval; - recv_buf->val[recv_buf->len] = '\0'; + ZSTR_LEN(recv_buf) = retval; + ZSTR_VAL(recv_buf)[ZSTR_LEN(recv_buf)] = '\0'; zval_dtor(arg2); zval_dtor(arg5); @@ -1724,15 +1724,15 @@ PHP_FUNCTION(socket_recvfrom) WRONG_PARAM_COUNT; } - retval = recvfrom(php_sock->bsd_socket, recv_buf->val, arg3, arg4, (struct sockaddr *)&sin, (socklen_t *)&slen); + retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin, (socklen_t *)&slen); if (retval < 0) { PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno); zend_string_free(recv_buf); RETURN_FALSE; } - recv_buf->len = retval; - recv_buf->val[recv_buf->len] = '\0'; + ZSTR_LEN(recv_buf) = retval; + ZSTR_VAL(recv_buf)[ZSTR_LEN(recv_buf)] = '\0'; zval_dtor(arg2); zval_dtor(arg5); @@ -1755,15 +1755,15 @@ PHP_FUNCTION(socket_recvfrom) WRONG_PARAM_COUNT; } - retval = recvfrom(php_sock->bsd_socket, recv_buf->val, arg3, arg4, (struct sockaddr *)&sin6, (socklen_t *)&slen); + retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin6, (socklen_t *)&slen); if (retval < 0) { PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno); zend_string_free(recv_buf); RETURN_FALSE; } - recv_buf->len = retval; - recv_buf->val[recv_buf->len] = '\0'; + ZSTR_LEN(recv_buf) = retval; + ZSTR_VAL(recv_buf)[ZSTR_LEN(recv_buf)] = '\0'; zval_dtor(arg2); zval_dtor(arg5); diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 40e3126355..e89caa2059 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -66,8 +66,8 @@ static zend_class_entry * spl_find_ce_by_name(zend_string *name, zend_bool autol zend_class_entry *ce; if (!autoload) { - zend_string *lc_name = zend_string_alloc(name->len, 0); - zend_str_tolower_copy(lc_name->val, name->val, name->len); + zend_string *lc_name = zend_string_alloc(ZSTR_LEN(name), 0); + zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(name), ZSTR_LEN(name)); ce = zend_hash_find_ptr(EG(class_table), lc_name); zend_string_free(lc_name); @@ -75,7 +75,7 @@ static zend_class_entry * spl_find_ce_by_name(zend_string *name, zend_bool autol ce = zend_lookup_class(name); } if (ce == NULL) { - php_error_docref(NULL, E_WARNING, "Class %s does not exist%s", name->val, autoload ? " and could not be loaded" : ""); + php_error_docref(NULL, E_WARNING, "Class %s does not exist%s", ZSTR_VAL(name), autoload ? " and could not be loaded" : ""); return NULL; } @@ -255,7 +255,7 @@ static int spl_autoload(zend_string *class_name, zend_string *lc_name, const cha zval result; int ret; - class_file_len = (int)spprintf(&class_file, 0, "%s%.*s", lc_name->val, ext_len, ext); + class_file_len = (int)spprintf(&class_file, 0, "%s%.*s", ZSTR_VAL(lc_name), ext_len, ext); #if DEFAULT_SLASH != '\\' { @@ -319,12 +319,12 @@ PHP_FUNCTION(spl_autoload) pos = SPL_DEFAULT_FILE_EXTENSIONS; pos_len = sizeof(SPL_DEFAULT_FILE_EXTENSIONS) - 1; } else { - pos = file_exts->val; - pos_len = (int)file_exts->len; + pos = ZSTR_VAL(file_exts); + pos_len = (int)ZSTR_LEN(file_exts); } - lc_name = zend_string_alloc(class_name->len, 0); - zend_str_tolower_copy(lc_name->val, class_name->val, class_name->len); + lc_name = zend_string_alloc(ZSTR_LEN(class_name), 0); + zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(class_name), ZSTR_LEN(class_name)); while (pos && *pos && !EG(exception)) { pos1 = strchr(pos, ','); if (pos1) { @@ -354,9 +354,9 @@ PHP_FUNCTION(spl_autoload) if (ex && ex->opline->opcode != ZEND_FETCH_CLASS && ex->opline->opcode != ZEND_NEW) { - zend_throw_exception_ex(spl_ce_LogicException, 0, "Class %s could not be loaded", class_name->val); + zend_throw_exception_ex(spl_ce_LogicException, 0, "Class %s could not be loaded", ZSTR_VAL(class_name)); } else { - php_error_docref(NULL, E_ERROR, "Class %s could not be loaded", class_name->val); + php_error_docref(NULL, E_ERROR, "Class %s could not be loaded", ZSTR_VAL(class_name)); } } } /* }}} */ @@ -420,9 +420,9 @@ PHP_FUNCTION(spl_autoload_call) int l_autoload_running = SPL_G(autoload_running); SPL_G(autoload_running) = 1; lc_name = zend_string_alloc(Z_STRLEN_P(class_name), 0); - zend_str_tolower_copy(lc_name->val, Z_STRVAL_P(class_name), Z_STRLEN_P(class_name)); + zend_str_tolower_copy(ZSTR_VAL(lc_name), Z_STRVAL_P(class_name), Z_STRLEN_P(class_name)); ZEND_HASH_FOREACH_STR_KEY_PTR(SPL_G(autoload_functions), func_name, alfi) { - zend_call_method(Z_ISUNDEF(alfi->obj)? NULL : &alfi->obj, alfi->ce, &alfi->func_ptr, func_name->val, func_name->len, retval, 1, class_name, NULL); + zend_call_method(Z_ISUNDEF(alfi->obj)? NULL : &alfi->obj, alfi->ce, &alfi->func_ptr, ZSTR_VAL(func_name), ZSTR_LEN(func_name), retval, 1, class_name, NULL); zend_exception_save(); if (retval) { zval_ptr_dtor(retval); @@ -494,7 +494,7 @@ PHP_FUNCTION(spl_autoload_register) RETURN_FALSE; } else if (Z_TYPE_P(zcallable) == IS_STRING) { if (do_throw) { - zend_throw_exception_ex(spl_ce_LogicException, 0, "Function '%s' not %s (%s)", func_name->val, alfi.func_ptr ? "callable" : "found", error); + zend_throw_exception_ex(spl_ce_LogicException, 0, "Function '%s' not %s (%s)", ZSTR_VAL(func_name), alfi.func_ptr ? "callable" : "found", error); } if (error) { efree(error); @@ -532,14 +532,14 @@ PHP_FUNCTION(spl_autoload_register) if (Z_TYPE_P(zcallable) == IS_OBJECT) { ZVAL_COPY(&alfi.closure, zcallable); - lc_name = zend_string_alloc(func_name->len + sizeof(uint32_t), 0); - zend_str_tolower_copy(lc_name->val, func_name->val, func_name->len); - memcpy(lc_name->val + func_name->len, &Z_OBJ_HANDLE_P(zcallable), sizeof(uint32_t)); - lc_name->val[lc_name->len] = '\0'; + lc_name = zend_string_alloc(ZSTR_LEN(func_name) + sizeof(uint32_t), 0); + zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(func_name), ZSTR_LEN(func_name)); + memcpy(ZSTR_VAL(lc_name) + ZSTR_LEN(func_name), &Z_OBJ_HANDLE_P(zcallable), sizeof(uint32_t)); + ZSTR_VAL(lc_name)[ZSTR_LEN(lc_name)] = '\0'; } else { ZVAL_UNDEF(&alfi.closure); - lc_name = zend_string_alloc(func_name->len, 0); - zend_str_tolower_copy(lc_name->val, func_name->val, func_name->len); + lc_name = zend_string_alloc(ZSTR_LEN(func_name), 0); + zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(func_name), ZSTR_LEN(func_name)); } zend_string_release(func_name); @@ -552,9 +552,9 @@ PHP_FUNCTION(spl_autoload_register) if (obj_ptr && !(alfi.func_ptr->common.fn_flags & ZEND_ACC_STATIC)) { /* add object id to the hash to ensure uniqueness, for more reference look at bug #40091 */ - lc_name = zend_string_extend(lc_name, lc_name->len + sizeof(uint32_t), 0); - memcpy(lc_name->val + lc_name->len - sizeof(uint32_t), &obj_ptr->handle, sizeof(uint32_t)); - lc_name->val[lc_name->len] = '\0'; + lc_name = zend_string_extend(lc_name, ZSTR_LEN(lc_name) + sizeof(uint32_t), 0); + memcpy(ZSTR_VAL(lc_name) + ZSTR_LEN(lc_name) - sizeof(uint32_t), &obj_ptr->handle, sizeof(uint32_t)); + ZSTR_VAL(lc_name)[ZSTR_LEN(lc_name)] = '\0'; ZVAL_OBJ(&alfi.obj, obj_ptr); Z_ADDREF(alfi.obj); } else { @@ -641,18 +641,18 @@ PHP_FUNCTION(spl_autoload_unregister) } if (Z_TYPE_P(zcallable) == IS_OBJECT) { - lc_name = zend_string_alloc(func_name->len + sizeof(uint32_t), 0); - zend_str_tolower_copy(lc_name->val, func_name->val, func_name->len); - memcpy(lc_name->val + func_name->len, &Z_OBJ_HANDLE_P(zcallable), sizeof(uint32_t)); - lc_name->val[lc_name->len] = '\0'; + lc_name = zend_string_alloc(ZSTR_LEN(func_name) + sizeof(uint32_t), 0); + zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(func_name), ZSTR_LEN(func_name)); + memcpy(ZSTR_VAL(lc_name) + ZSTR_LEN(func_name), &Z_OBJ_HANDLE_P(zcallable), sizeof(uint32_t)); + ZSTR_VAL(lc_name)[ZSTR_LEN(lc_name)] = '\0'; } else { - lc_name = zend_string_alloc(func_name->len, 0); - zend_str_tolower_copy(lc_name->val, func_name->val, func_name->len); + lc_name = zend_string_alloc(ZSTR_LEN(func_name), 0); + zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(func_name), ZSTR_LEN(func_name)); } zend_string_release(func_name); if (SPL_G(autoload_functions)) { - if (lc_name->len == sizeof("spl_autoload_call") - 1 && !strcmp(lc_name->val, "spl_autoload_call")) { + if (ZSTR_LEN(lc_name) == sizeof("spl_autoload_call") - 1 && !strcmp(ZSTR_VAL(lc_name), "spl_autoload_call")) { /* remove all */ zend_hash_destroy(SPL_G(autoload_functions)); FREE_HASHTABLE(SPL_G(autoload_functions)); @@ -663,13 +663,13 @@ PHP_FUNCTION(spl_autoload_unregister) /* remove specific */ success = zend_hash_del(SPL_G(autoload_functions), lc_name); if (success != SUCCESS && obj_ptr) { - lc_name = zend_string_extend(lc_name, lc_name->len + sizeof(uint32_t), 0); - memcpy(lc_name->val + lc_name->len - sizeof(uint32_t), &obj_ptr->handle, sizeof(uint32_t)); - lc_name->val[lc_name->len] = '\0'; + lc_name = zend_string_extend(lc_name, ZSTR_LEN(lc_name) + sizeof(uint32_t), 0); + memcpy(ZSTR_VAL(lc_name) + ZSTR_LEN(lc_name) - sizeof(uint32_t), &obj_ptr->handle, sizeof(uint32_t)); + ZSTR_VAL(lc_name)[ZSTR_LEN(lc_name)] = '\0'; success = zend_hash_del(SPL_G(autoload_functions), lc_name); } } - } else if (lc_name->len == sizeof("spl_autoload")-1 && !strcmp(lc_name->val, "spl_autoload")) { + } else if (ZSTR_LEN(lc_name) == sizeof("spl_autoload")-1 && !strcmp(ZSTR_VAL(lc_name), "spl_autoload")) { /* register single spl_autoload() */ spl_func_ptr = zend_hash_str_find_ptr(EG(function_table), "spl_autoload", sizeof("spl_autoload") - 1); @@ -725,7 +725,7 @@ PHP_FUNCTION(spl_autoload_functions) add_next_index_str(&tmp, zend_string_copy(alfi->func_ptr->common.function_name)); add_next_index_zval(return_value, &tmp); } else { - if (strncmp(alfi->func_ptr->common.function_name->val, "__lambda_func", sizeof("__lambda_func") - 1)) { + if (strncmp(ZSTR_VAL(alfi->func_ptr->common.function_name), "__lambda_func", sizeof("__lambda_func") - 1)) { add_next_index_str(return_value, zend_string_copy(alfi->func_ptr->common.function_name)); } else { add_next_index_str(return_value, zend_string_copy(key)); diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 58147f3d39..ce8a37bf36 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -290,13 +290,13 @@ fetch_dim_string: if (Z_TYPE_P(retval) == IS_UNDEF) { switch (type) { case BP_VAR_R: - zend_error(E_NOTICE, "Undefined index: %s", offset_key->val); + zend_error(E_NOTICE, "Undefined index: %s", ZSTR_VAL(offset_key)); case BP_VAR_UNSET: case BP_VAR_IS: retval = &EG(uninitialized_zval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined index: %s", offset_key->val); + zend_error(E_NOTICE,"Undefined index: %s", ZSTR_VAL(offset_key)); case BP_VAR_W: { ZVAL_NULL(retval); } @@ -306,13 +306,13 @@ fetch_dim_string: } else { switch (type) { case BP_VAR_R: - zend_error(E_NOTICE, "Undefined index: %s", offset_key->val); + zend_error(E_NOTICE, "Undefined index: %s", ZSTR_VAL(offset_key)); case BP_VAR_UNSET: case BP_VAR_IS: retval = &EG(uninitialized_zval); break; case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined index: %s", offset_key->val); + zend_error(E_NOTICE,"Undefined index: %s", ZSTR_VAL(offset_key)); case BP_VAR_W: { zval value; ZVAL_NULL(&value); @@ -737,7 +737,7 @@ void spl_array_iterator_append(zval *object, zval *append_value) /* {{{ */ } if (spl_array_is_object(intern)) { - php_error_docref(NULL, E_RECOVERABLE_ERROR, "Cannot append properties to objects, use %s::offsetSet() instead", Z_OBJCE_P(object)->name->val); + php_error_docref(NULL, E_RECOVERABLE_ERROR, "Cannot append properties to objects, use %s::offsetSet() instead", ZSTR_VAL(Z_OBJCE_P(object)->name)); return; } @@ -936,7 +936,7 @@ static int spl_array_skip_protected(spl_array_object *intern, HashTable *aht) /* if (data && Z_TYPE_P(data) == IS_INDIRECT && Z_TYPE_P(data = Z_INDIRECT_P(data)) == IS_UNDEF) { /* skip */ - } else if (!string_key->len || string_key->val[0]) { + } else if (!ZSTR_LEN(string_key) || ZSTR_VAL(string_key)[0]) { return SUCCESS; } } else { diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index b159601ad6..34baf63334 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -359,7 +359,7 @@ static zend_object *spl_filesystem_object_clone(zval *zobject) intern->u.dir.index = index; break; case SPL_FS_FILE: - php_error_docref(NULL, E_ERROR, "An object of class %s cannot be cloned", old_object->ce->name->val); + php_error_docref(NULL, E_ERROR, "An object of class %s cannot be cloned", ZSTR_VAL(old_object->ce->name)); break; } @@ -937,11 +937,11 @@ SPL_METHOD(SplFileInfo, getExtension) ret = php_basename(fname, flen, NULL, 0); - p = zend_memrchr(ret->val, '.', ret->len); + p = zend_memrchr(ZSTR_VAL(ret), '.', ZSTR_LEN(ret)); if (p) { - assert(p > ret->val); - idx = (int)(p - ret->val); - RETVAL_STRINGL(ret->val + idx + 1, ret->len - idx - 1); + assert(p > ZSTR_VAL(ret)); + idx = (int)(p - ZSTR_VAL(ret)); + RETVAL_STRINGL(ZSTR_VAL(ret) + idx + 1, ZSTR_LEN(ret) - idx - 1); zend_string_release(ret); return; } else { @@ -966,10 +966,10 @@ SPL_METHOD(DirectoryIterator, getExtension) fname = php_basename(intern->u.dir.entry.d_name, strlen(intern->u.dir.entry.d_name), NULL, 0); - p = zend_memrchr(fname->val, '.', fname->len); + p = zend_memrchr(ZSTR_VAL(fname), '.', ZSTR_LEN(fname)); if (p) { - idx = (int)(p - fname->val); - RETVAL_STRINGL(fname->val + idx + 1, fname->len - idx - 1); + idx = (int)(p - ZSTR_VAL(fname)); + RETVAL_STRINGL(ZSTR_VAL(fname) + idx + 1, ZSTR_LEN(fname) - idx - 1); zend_string_release(fname); } else { zend_string_release(fname); diff --git a/ext/spl/spl_engine.h b/ext/spl/spl_engine.h index 8cbbd48150..6d7900be27 100644 --- a/ext/spl/spl_engine.h +++ b/ext/spl/spl_engine.h @@ -35,7 +35,7 @@ static inline int spl_instantiate_arg_ex1(zend_class_entry *pce, zval *retval, z zend_function *func = pce->constructor; spl_instantiate(pce, retval); - zend_call_method(retval, pce, &func, func->common.function_name->val, func->common.function_name->len, NULL, 1, arg1, NULL); + zend_call_method(retval, pce, &func, ZSTR_VAL(func->common.function_name), ZSTR_LEN(func->common.function_name), NULL, 1, arg1, NULL); return 0; } /* }}} */ @@ -46,7 +46,7 @@ static inline int spl_instantiate_arg_ex2(zend_class_entry *pce, zval *retval, z zend_function *func = pce->constructor; spl_instantiate(pce, retval); - zend_call_method(retval, pce, &func, func->common.function_name->val, func->common.function_name->len, NULL, 2, arg1, arg2); + zend_call_method(retval, pce, &func, ZSTR_VAL(func->common.function_name), ZSTR_LEN(func->common.function_name), NULL, 2, arg1, arg2); return 0; } /* }}} */ diff --git a/ext/spl/spl_functions.c b/ext/spl/spl_functions.c index c33fee34a8..5f0d5f4e85 100644 --- a/ext/spl/spl_functions.c +++ b/ext/spl/spl_functions.c @@ -134,7 +134,7 @@ int spl_add_classes(zend_class_entry *pce, zval *list, int sub, int allow, int c zend_string * spl_gen_private_prop_name(zend_class_entry *ce, char *prop_name, int prop_len) /* {{{ */ { - return zend_mangle_property_name(ce->name->val, ce->name->len, prop_name, prop_len, 0); + return zend_mangle_property_name(ZSTR_VAL(ce->name), ZSTR_LEN(ce->name), prop_name, prop_len, 0); } /* }}} */ diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index eca51fbca3..c27d737b51 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -881,7 +881,7 @@ static union _zend_function *spl_recursive_it_get_method(zend_object **zobject, zval *zobj; if (!object->iterators) { - php_error_docref(NULL, E_ERROR, "The %s instance wasn't initialized properly", (*zobject)->ce->name->val); + php_error_docref(NULL, E_ERROR, "The %s instance wasn't initialized properly", ZSTR_VAL((*zobject)->ce->name)); } zobj = &object->iterators[level].zobject; @@ -1024,15 +1024,15 @@ static void spl_recursive_tree_iterator_get_prefix(spl_recursive_it_object *obje zval has_next; int level; - smart_str_appendl(&str, object->prefix[0].s->val, object->prefix[0].s->len); + smart_str_appendl(&str, ZSTR_VAL(object->prefix[0].s), ZSTR_LEN(object->prefix[0].s)); for (level = 0; level < object->level; ++level) { zend_call_method_with_0_params(&object->iterators[level].zobject, object->iterators[level].ce, NULL, "hasnext", &has_next); if (Z_TYPE(has_next) != IS_UNDEF) { if (Z_TYPE(has_next) == IS_TRUE) { - smart_str_appendl(&str, object->prefix[1].s->val, object->prefix[1].s->len); + smart_str_appendl(&str, ZSTR_VAL(object->prefix[1].s), ZSTR_LEN(object->prefix[1].s)); } else { - smart_str_appendl(&str, object->prefix[2].s->val, object->prefix[2].s->len); + smart_str_appendl(&str, ZSTR_VAL(object->prefix[2].s), ZSTR_LEN(object->prefix[2].s)); } zval_ptr_dtor(&has_next); } @@ -1040,14 +1040,14 @@ static void spl_recursive_tree_iterator_get_prefix(spl_recursive_it_object *obje zend_call_method_with_0_params(&object->iterators[level].zobject, object->iterators[level].ce, NULL, "hasnext", &has_next); if (Z_TYPE(has_next) != IS_UNDEF) { if (Z_TYPE(has_next) == IS_TRUE) { - smart_str_appendl(&str, object->prefix[3].s->val, object->prefix[3].s->len); + smart_str_appendl(&str, ZSTR_VAL(object->prefix[3].s), ZSTR_LEN(object->prefix[3].s)); } else { - smart_str_appendl(&str, object->prefix[4].s->val, object->prefix[4].s->len); + smart_str_appendl(&str, ZSTR_VAL(object->prefix[4].s), ZSTR_LEN(object->prefix[4].s)); } zval_ptr_dtor(&has_next); } - smart_str_appendl(&str, object->prefix[5].s->val, object->prefix[5].s->len); + smart_str_appendl(&str, ZSTR_VAL(object->prefix[5].s), ZSTR_LEN(object->prefix[5].s)); smart_str_0(&str); RETURN_NEW_STR(str.s); @@ -1228,7 +1228,7 @@ SPL_METHOD(RecursiveTreeIterator, current) spl_recursive_tree_iterator_get_postfix(object, &postfix); str = zend_string_alloc(Z_STRLEN(prefix) + Z_STRLEN(entry) + Z_STRLEN(postfix), 0); - ptr = str->val; + ptr = ZSTR_VAL(str); memcpy(ptr, Z_STRVAL(prefix), Z_STRLEN(prefix)); ptr += Z_STRLEN(prefix); @@ -1282,7 +1282,7 @@ SPL_METHOD(RecursiveTreeIterator, key) spl_recursive_tree_iterator_get_postfix(object, &postfix); str = zend_string_alloc(Z_STRLEN(prefix) + Z_STRLEN(key) + Z_STRLEN(postfix), 0); - ptr = str->val; + ptr = ZSTR_VAL(str); memcpy(ptr, Z_STRVAL(prefix), Z_STRLEN(prefix)); ptr += Z_STRLEN(prefix); @@ -1418,7 +1418,7 @@ int spl_dual_it_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS) #define SPL_CHECK_CTOR(intern, classname) \ if (intern->dit_type == DIT_Unknown) { \ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Classes derived from %s must call %s::__construct()", \ - (spl_ce_##classname)->name->val, (spl_ce_##classname)->name->val); \ + ZSTR_VAL((spl_ce_##classname)->name), ZSTR_VAL((spl_ce_##classname)->name)); \ return; \ } @@ -1449,7 +1449,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z intern = Z_SPLDUAL_IT_P(getThis()); if (intern->dit_type != DIT_Unknown) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s::getIterator() must be called exactly once per instance", ce_base->name->val); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s::getIterator() must be called exactly once per instance", ZSTR_VAL(ce_base->name)); return NULL; } @@ -1511,7 +1511,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z return NULL; } if (Z_TYPE(retval) != IS_OBJECT || !instanceof_function(Z_OBJCE(retval), zend_ce_traversable)) { - zend_throw_exception_ex(spl_ce_LogicException, 0, "%s::getIterator() must return an object that implements Traversable", ce->name->val); + zend_throw_exception_ex(spl_ce_LogicException, 0, "%s::getIterator() must return an object that implements Traversable", ZSTR_VAL(ce->name)); return NULL; } zobject = &retval; @@ -2040,7 +2040,7 @@ SPL_METHOD(RegexIterator, accept) { case REGIT_MODE_MAX: /* won't happen but makes compiler happy */ case REGIT_MODE_MATCH: - count = pcre_exec(intern->u.regex.pce->re, intern->u.regex.pce->extra, subject->val, subject->len, 0, 0, NULL, 0); + count = pcre_exec(intern->u.regex.pce->re, intern->u.regex.pce->extra, ZSTR_VAL(subject), ZSTR_LEN(subject), 0, 0, NULL, 0); RETVAL_BOOL(count >= 0); break; @@ -2052,7 +2052,7 @@ SPL_METHOD(RegexIterator, accept) //??? } zval_ptr_dtor(&intern->current.data); ZVAL_UNDEF(&intern->current.data); - php_pcre_match_impl(intern->u.regex.pce, subject->val, subject->len, &zcount, + php_pcre_match_impl(intern->u.regex.pce, ZSTR_VAL(subject), ZSTR_LEN(subject), &zcount, &intern->current.data, intern->u.regex.mode == REGIT_MODE_ALL_MATCHES, intern->u.regex.use_flags, intern->u.regex.preg_flags, 0); RETVAL_BOOL(Z_LVAL(zcount) > 0); break; @@ -2064,7 +2064,7 @@ SPL_METHOD(RegexIterator, accept) //??? } zval_ptr_dtor(&intern->current.data); ZVAL_UNDEF(&intern->current.data); - php_pcre_split_impl(intern->u.regex.pce, subject->val, subject->len, &intern->current.data, -1, intern->u.regex.preg_flags); + php_pcre_split_impl(intern->u.regex.pce, ZSTR_VAL(subject), ZSTR_LEN(subject), &intern->current.data, -1, intern->u.regex.preg_flags); count = zend_hash_num_elements(Z_ARRVAL(intern->current.data)); RETVAL_BOOL(count > 1); break; @@ -2076,7 +2076,7 @@ SPL_METHOD(RegexIterator, accept) convert_to_string(&tmp_replacement); replacement = &tmp_replacement; } - result = php_pcre_replace_impl(intern->u.regex.pce, subject, subject->val, subject->len, replacement, 0, -1, &count); + result = php_pcre_replace_impl(intern->u.regex.pce, subject, ZSTR_VAL(subject), ZSTR_LEN(subject), replacement, 0, -1, &count); if (intern->u.regex.flags & REGIT_USE_KEY) { zval_ptr_dtor(&intern->current.key); @@ -2780,7 +2780,7 @@ SPL_METHOD(CachingIterator, __toString) SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis()); if (!(intern->u.caching.flags & (CIT_CALL_TOSTRING|CIT_TOSTRING_USE_KEY|CIT_TOSTRING_USE_CURRENT|CIT_TOSTRING_USE_INNER))) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not fetch string value (see CachingIterator::__construct)", Z_OBJCE_P(getThis())->name->val); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not fetch string value (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(getThis())->name)); return; } if (intern->u.caching.flags & CIT_TOSTRING_USE_KEY) { @@ -2810,7 +2810,7 @@ SPL_METHOD(CachingIterator, offsetSet) SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis()); if (!(intern->u.caching.flags & CIT_FULL_CACHE)) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", Z_OBJCE_P(getThis())->name->val); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(getThis())->name)); return; } @@ -2836,7 +2836,7 @@ SPL_METHOD(CachingIterator, offsetGet) SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis()); if (!(intern->u.caching.flags & CIT_FULL_CACHE)) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", Z_OBJCE_P(getThis())->name->val); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(getThis())->name)); return; } @@ -2845,7 +2845,7 @@ SPL_METHOD(CachingIterator, offsetGet) } if ((value = zend_symtable_find(HASH_OF(&intern->u.caching.zcache), key)) == NULL) { - zend_error(E_NOTICE, "Undefined index: %s", key->val); + zend_error(E_NOTICE, "Undefined index: %s", ZSTR_VAL(key)); return; } @@ -2863,7 +2863,7 @@ SPL_METHOD(CachingIterator, offsetUnset) SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis()); if (!(intern->u.caching.flags & CIT_FULL_CACHE)) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", Z_OBJCE_P(getThis())->name->val); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(getThis())->name)); return; } @@ -2885,7 +2885,7 @@ SPL_METHOD(CachingIterator, offsetExists) SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis()); if (!(intern->u.caching.flags & CIT_FULL_CACHE)) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", Z_OBJCE_P(getThis())->name->val); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(getThis())->name)); return; } @@ -2910,7 +2910,7 @@ SPL_METHOD(CachingIterator, getCache) SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis()); if (!(intern->u.caching.flags & CIT_FULL_CACHE)) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%v does not use a full cache (see CachingIterator::__construct)", Z_OBJCE_P(getThis())->name->val); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%v does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(getThis())->name)); return; } @@ -2980,7 +2980,7 @@ SPL_METHOD(CachingIterator, count) SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis()); if (!(intern->u.caching.flags & CIT_FULL_CACHE)) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%v does not use a full cache (see CachingIterator::__construct)", Z_OBJCE_P(getThis())->name->val); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%v does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(getThis())->name)); return; } diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index 23cc73f6eb..2f53946ffb 100644 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -135,8 +135,8 @@ static zend_string *spl_object_storage_get_hash(spl_SplObjectStorage *intern, zv } } else { zend_string *hash = zend_string_alloc(sizeof(zend_object*), 0); - memcpy(hash->val, (void*)&Z_OBJ_P(obj), sizeof(zend_object*)); - hash->val[hash->len] = '\0'; + memcpy(ZSTR_VAL(hash), (void*)&Z_OBJ_P(obj), sizeof(zend_object*)); + ZSTR_VAL(hash)[ZSTR_LEN(hash)] = '\0'; return hash; /* !!! FIXME int hash_len = sizeof(zend_object_value); diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 00560450fe..8161690ead 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -222,7 +222,7 @@ PHP_METHOD(sqlite3, exec) return; } - if (sqlite3_exec(db_obj->db, sql->val, NULL, NULL, &errtext) != SQLITE_OK) { + if (sqlite3_exec(db_obj->db, ZSTR_VAL(sql), NULL, NULL, &errtext) != SQLITE_OK) { php_sqlite3_error(db_obj, "%s", errtext); sqlite3_free(errtext); RETURN_FALSE; @@ -433,8 +433,8 @@ PHP_METHOD(sqlite3, escapeString) return; } - if (sql->len) { - ret = sqlite3_mprintf("%q", sql->val); + if (ZSTR_LEN(sql)) { + ret = sqlite3_mprintf("%q", ZSTR_VAL(sql)); if (ret) { RETVAL_STRING(ret); sqlite3_free(ret); @@ -464,7 +464,7 @@ PHP_METHOD(sqlite3, prepare) return; } - if (!sql->len) { + if (!ZSTR_LEN(sql)) { RETURN_FALSE; } @@ -473,7 +473,7 @@ PHP_METHOD(sqlite3, prepare) stmt_obj->db_obj = db_obj; ZVAL_COPY(&stmt_obj->db_obj_zval, object); - errcode = sqlite3_prepare_v2(db_obj->db, sql->val, sql->len, &(stmt_obj->stmt), NULL); + errcode = sqlite3_prepare_v2(db_obj->db, ZSTR_VAL(sql), ZSTR_LEN(sql), &(stmt_obj->stmt), NULL); if (errcode != SQLITE_OK) { php_sqlite3_error(db_obj, "Unable to prepare statement: %d, %s", errcode, sqlite3_errmsg(db_obj->db)); zval_dtor(return_value); @@ -510,13 +510,13 @@ PHP_METHOD(sqlite3, query) return; } - if (!sql->len) { + if (!ZSTR_LEN(sql)) { RETURN_FALSE; } /* If there was no return value then just execute the query */ if (!USED_RET()) { - if (sqlite3_exec(db_obj->db, sql->val, NULL, NULL, &errtext) != SQLITE_OK) { + if (sqlite3_exec(db_obj->db, ZSTR_VAL(sql), NULL, NULL, &errtext) != SQLITE_OK) { php_sqlite3_error(db_obj, "%s", errtext); sqlite3_free(errtext); } @@ -528,7 +528,7 @@ PHP_METHOD(sqlite3, query) stmt_obj->db_obj = db_obj; ZVAL_COPY(&stmt_obj->db_obj_zval, object); - return_code = sqlite3_prepare_v2(db_obj->db, sql->val, sql->len, &(stmt_obj->stmt), NULL); + return_code = sqlite3_prepare_v2(db_obj->db, ZSTR_VAL(sql), ZSTR_LEN(sql), &(stmt_obj->stmt), NULL); if (return_code != SQLITE_OK) { php_sqlite3_error(db_obj, "Unable to prepare statement: %d, %s", return_code, sqlite3_errmsg(db_obj->db)); zval_ptr_dtor(&stmt); @@ -616,20 +616,20 @@ PHP_METHOD(sqlite3, querySingle) return; } - if (!sql->len) { + if (!ZSTR_LEN(sql)) { RETURN_FALSE; } /* If there was no return value then just execute the query */ if (!USED_RET()) { - if (sqlite3_exec(db_obj->db, sql->val, NULL, NULL, &errtext) != SQLITE_OK) { + if (sqlite3_exec(db_obj->db, ZSTR_VAL(sql), NULL, NULL, &errtext) != SQLITE_OK) { php_sqlite3_error(db_obj, "%s", errtext); sqlite3_free(errtext); } return; } - return_code = sqlite3_prepare_v2(db_obj->db, sql->val, sql->len, &stmt, NULL); + return_code = sqlite3_prepare_v2(db_obj->db, ZSTR_VAL(sql), ZSTR_LEN(sql), &stmt, NULL); if (return_code != SQLITE_OK) { php_sqlite3_error(db_obj, "Unable to prepare statement: %d, %s", return_code, sqlite3_errmsg(db_obj->db)); RETURN_FALSE; @@ -908,7 +908,7 @@ PHP_METHOD(sqlite3, createFunction) } if (!zend_is_callable(callback_func, 0, &callback_name)) { - php_sqlite3_error(db_obj, "Not a valid callback function %s", callback_name->val); + php_sqlite3_error(db_obj, "Not a valid callback function %s", ZSTR_VAL(callback_name)); zend_string_release(callback_name); RETURN_FALSE; } @@ -958,14 +958,14 @@ PHP_METHOD(sqlite3, createAggregate) } if (!zend_is_callable(step_callback, 0, &callback_name)) { - php_sqlite3_error(db_obj, "Not a valid callback function %s", callback_name->val); + php_sqlite3_error(db_obj, "Not a valid callback function %s", ZSTR_VAL(callback_name)); zend_string_release(callback_name); RETURN_FALSE; } zend_string_release(callback_name); if (!zend_is_callable(fini_callback, 0, &callback_name)) { - php_sqlite3_error(db_obj, "Not a valid callback function %s", callback_name->val); + php_sqlite3_error(db_obj, "Not a valid callback function %s", ZSTR_VAL(callback_name)); zend_string_release(callback_name); RETURN_FALSE; } @@ -1015,7 +1015,7 @@ PHP_METHOD(sqlite3, createCollation) } if (!zend_is_callable(callback_func, 0, &callback_name)) { - php_sqlite3_error(db_obj, "Not a valid callback function %s", callback_name->val); + php_sqlite3_error(db_obj, "Not a valid callback function %s", ZSTR_VAL(callback_name)); zend_string_release(callback_name); RETURN_FALSE; } @@ -1360,17 +1360,17 @@ static int register_bound_parameter_to_sqlite(struct php_sqlite3_bound_param *pa /* We need a : prefix to resolve a name to a parameter number */ if (param->name) { - if (param->name->val[0] != ':') { + if (ZSTR_VAL(param->name)[0] != ':') { /* pre-increment for character + 1 for null */ - zend_string *temp = zend_string_alloc(param->name->len + 1, 0); - temp->val[0] = ':'; - memmove(temp->val + 1, param->name->val, param->name->len + 1); + zend_string *temp = zend_string_alloc(ZSTR_LEN(param->name) + 1, 0); + ZSTR_VAL(temp)[0] = ':'; + memmove(ZSTR_VAL(temp) + 1, ZSTR_VAL(param->name), ZSTR_LEN(param->name) + 1); param->name = temp; } else { - param->name = zend_string_init(param->name->val, param->name->len, 0); + param->name = zend_string_init(ZSTR_VAL(param->name), ZSTR_LEN(param->name), 0); } /* do lookup*/ - param->param_number = sqlite3_bind_parameter_index(stmt->stmt, param->name->val); + param->param_number = sqlite3_bind_parameter_index(stmt->stmt, ZSTR_VAL(param->name)); } if (param->param_number < 1) { @@ -1527,7 +1527,7 @@ PHP_METHOD(sqlite3stmt, execute) buffer = Z_STR_P(parameter); } - sqlite3_bind_blob(stmt_obj->stmt, param->param_number, buffer->val, buffer->len, SQLITE_TRANSIENT); + sqlite3_bind_blob(stmt_obj->stmt, param->param_number, ZSTR_VAL(buffer), ZSTR_LEN(buffer), SQLITE_TRANSIENT); if (stream) { zend_string_release(buffer); @@ -1606,14 +1606,14 @@ PHP_METHOD(sqlite3stmt, __construct) SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3) zend_restore_error_handling(&error_handling); - if (!sql->len) { + if (!ZSTR_LEN(sql)) { RETURN_FALSE; } stmt_obj->db_obj = db_obj; ZVAL_COPY(&stmt_obj->db_obj_zval, db_zval); - errcode = sqlite3_prepare_v2(db_obj->db, sql->val, sql->len, &(stmt_obj->stmt), NULL); + errcode = sqlite3_prepare_v2(db_obj->db, ZSTR_VAL(sql), ZSTR_LEN(sql), &(stmt_obj->stmt), NULL); if (errcode != SQLITE_OK) { php_sqlite3_error(db_obj, "Unable to prepare statement: %d, %s", errcode, sqlite3_errmsg(db_obj->db)); zval_dtor(return_value); diff --git a/ext/standard/array.c b/ext/standard/array.c index e923968840..696ad05ff6 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -417,7 +417,7 @@ static int php_array_natural_general_compare(const void *a, const void *b, int f zend_string *str1 = zval_get_string(&f->val); zend_string *str2 = zval_get_string(&s->val); - int result = strnatcmp_ex(str1->val, str1->len, str2->val, str2->len, fold_case); + int result = strnatcmp_ex(ZSTR_VAL(str1), ZSTR_LEN(str1), ZSTR_VAL(str2), ZSTR_LEN(str2), fold_case); zend_string_release(str1); zend_string_release(str2); @@ -1497,7 +1497,7 @@ PHP_FUNCTION(extract) var_exists = zend_hash_exists_ind(symbol_table, var_name); } else if (extract_type == EXTR_PREFIX_ALL || extract_type == EXTR_PREFIX_INVALID) { zend_string *str = zend_long_to_str(num_key); - php_prefix_varname(&final_name, prefix, str->val, str->len, 1); + php_prefix_varname(&final_name, prefix, ZSTR_VAL(str), ZSTR_LEN(str), 1); zend_string_release(str); } else { continue; @@ -1510,10 +1510,10 @@ PHP_FUNCTION(extract) case EXTR_OVERWRITE: /* GLOBALS protection */ - if (var_exists && var_name->len == sizeof("GLOBALS")-1 && !strcmp(var_name->val, "GLOBALS")) { + if (var_exists && ZSTR_LEN(var_name) == sizeof("GLOBALS")-1 && !strcmp(ZSTR_VAL(var_name), "GLOBALS")) { break; } - if (var_exists && var_name->len == sizeof("this")-1 && !strcmp(var_name->val, "this") && EG(scope) && EG(scope)->name->len != 0) { + if (var_exists && ZSTR_LEN(var_name) == sizeof("this")-1 && !strcmp(ZSTR_VAL(var_name), "this") && EG(scope) && ZSTR_LEN(EG(scope)->name) != 0) { break; } ZVAL_STR_COPY(&final_name, var_name); @@ -1521,26 +1521,26 @@ PHP_FUNCTION(extract) case EXTR_PREFIX_IF_EXISTS: if (var_exists) { - php_prefix_varname(&final_name, prefix, var_name->val, var_name->len, 1); + php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1); } break; case EXTR_PREFIX_SAME: - if (!var_exists && var_name->len != 0) { + if (!var_exists && ZSTR_LEN(var_name) != 0) { ZVAL_STR_COPY(&final_name, var_name); } /* break omitted intentionally */ case EXTR_PREFIX_ALL: - if (Z_TYPE(final_name) == IS_NULL && var_name->len != 0) { - php_prefix_varname(&final_name, prefix, var_name->val, var_name->len, 1); + if (Z_TYPE(final_name) == IS_NULL && ZSTR_LEN(var_name) != 0) { + php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1); } break; case EXTR_PREFIX_INVALID: if (Z_TYPE(final_name) == IS_NULL) { - if (!php_valid_var_name(var_name->val, var_name->len)) { - php_prefix_varname(&final_name, prefix, var_name->val, var_name->len, 1); + if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) { + php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1); } else { ZVAL_STR_COPY(&final_name, var_name); } @@ -3076,7 +3076,7 @@ static inline zval *array_column_fetch_prop(zval *data, zval *name, zval *rv) zend_string *key = zval_get_string(name); if (!Z_OBJ_HANDLER_P(data, has_property) || Z_OBJ_HANDLER_P(data, has_property)(data, name, 1, NULL)) { - prop = zend_read_property(Z_OBJCE_P(data), data, key->val, key->len, 1, rv); + prop = zend_read_property(Z_OBJCE_P(data), data, ZSTR_VAL(key), ZSTR_LEN(key), 1, rv); } zend_string_release(key); } else if (Z_TYPE_P(data) == IS_ARRAY) { diff --git a/ext/standard/assert.c b/ext/standard/assert.c index 7054278d70..6a4d7f27aa 100644 --- a/ext/standard/assert.c +++ b/ext/standard/assert.c @@ -63,17 +63,17 @@ static PHP_INI_MH(OnChangeCallback) /* {{{ */ zval_ptr_dtor(&ASSERTG(callback)); ZVAL_UNDEF(&ASSERTG(callback)); } - if (new_value && (Z_TYPE(ASSERTG(callback)) != IS_UNDEF || new_value->len)) { + if (new_value && (Z_TYPE(ASSERTG(callback)) != IS_UNDEF || ZSTR_LEN(new_value))) { ZVAL_STR_COPY(&ASSERTG(callback), new_value); } } else { if (ASSERTG(cb)) { pefree(ASSERTG(cb), 1); } - if (new_value && new_value->len) { - ASSERTG(cb) = pemalloc(new_value->len + 1, 1); - memcpy(ASSERTG(cb), new_value->val, new_value->len); - ASSERTG(cb)[new_value->len] = '\0'; + if (new_value && ZSTR_LEN(new_value)) { + ASSERTG(cb) = pemalloc(ZSTR_LEN(new_value) + 1, 1); + memcpy(ASSERTG(cb), ZSTR_VAL(new_value), ZSTR_LEN(new_value)); + ASSERTG(cb)[ZSTR_LEN(new_value)] = '\0'; } else { ASSERTG(cb) = NULL; } @@ -183,7 +183,7 @@ PHP_FUNCTION(assert) php_error_docref(NULL, E_RECOVERABLE_ERROR, "Failure evaluating code: %s%s", PHP_EOL, myeval); } else { zend_string *str = zval_get_string(description); - php_error_docref(NULL, E_RECOVERABLE_ERROR, "Failure evaluating code: %s%s:\"%s\"", PHP_EOL, str->val, myeval); + php_error_docref(NULL, E_RECOVERABLE_ERROR, "Failure evaluating code: %s%s:\"%s\"", PHP_EOL, ZSTR_VAL(str), myeval); zend_string_release(str); } if (ASSERTG(bail)) { @@ -251,7 +251,7 @@ PHP_FUNCTION(assert) zend_throw_exception_object(description); } else { zend_string *str = zval_get_string(description); - zend_throw_exception(assertion_error_ce, str->val, E_ERROR); + zend_throw_exception(assertion_error_ce, ZSTR_VAL(str), E_ERROR); zend_string_release(str); } } else if (ASSERTG(warning)) { @@ -264,9 +264,9 @@ PHP_FUNCTION(assert) } else { zend_string *str = zval_get_string(description); if (myeval) { - php_error_docref(NULL, E_WARNING, "%s: \"%s\" failed", str->val, myeval); + php_error_docref(NULL, E_WARNING, "%s: \"%s\" failed", ZSTR_VAL(str), myeval); } else { - php_error_docref(NULL, E_WARNING, "%s failed", str->val); + php_error_docref(NULL, E_WARNING, "%s failed", ZSTR_VAL(str)); } zend_string_release(str); } diff --git a/ext/standard/base64.c b/ext/standard/base64.c index b5de548046..c4f66e638a 100644 --- a/ext/standard/base64.c +++ b/ext/standard/base64.c @@ -60,7 +60,7 @@ PHPAPI zend_string *php_base64_encode(const unsigned char *str, size_t length) / zend_string *result; result = zend_string_alloc(((length + 2) / 3) * 4 * sizeof(char), 0); - p = (unsigned char *)result->val; + p = (unsigned char *)ZSTR_VAL(result); while (length > 2) { /* keep going until we have less than 24 bits */ *p++ = base64_table[current[0] >> 2]; @@ -87,7 +87,7 @@ PHPAPI zend_string *php_base64_encode(const unsigned char *str, size_t length) / } *p = '\0'; - result->len = (p - (unsigned char *)result->val); + ZSTR_LEN(result) = (p - (unsigned char *)ZSTR_VAL(result)); return result; } @@ -170,18 +170,18 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t length switch(i % 4) { case 0: - result->val[j] = ch << 2; + ZSTR_VAL(result)[j] = ch << 2; break; case 1: - result->val[j++] |= ch >> 4; - result->val[j] = (ch & 0x0f) << 4; + ZSTR_VAL(result)[j++] |= ch >> 4; + ZSTR_VAL(result)[j] = (ch & 0x0f) << 4; break; case 2: - result->val[j++] |= ch >>2; - result->val[j] = (ch & 0x03) << 6; + ZSTR_VAL(result)[j++] |= ch >>2; + ZSTR_VAL(result)[j] = (ch & 0x03) << 6; break; case 3: - result->val[j++] |= ch; + ZSTR_VAL(result)[j++] |= ch; break; } i++; @@ -197,11 +197,11 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t length case 2: k++; case 3: - result->val[k] = 0; + ZSTR_VAL(result)[k] = 0; } } - result->len = j; - result->val[result->len] = '\0'; + ZSTR_LEN(result) = j; + ZSTR_VAL(result)[ZSTR_LEN(result)] = '\0'; return result; } diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index d4e9ade162..da42e42e04 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -3852,7 +3852,7 @@ PHP_FUNCTION(constant) } zval_copy_ctor(return_value); } else { - php_error_docref(NULL, E_WARNING, "Couldn't find constant %s", const_name->val); + php_error_docref(NULL, E_WARNING, "Couldn't find constant %s", ZSTR_VAL(const_name)); RETURN_NULL(); } } @@ -4281,7 +4281,7 @@ PHP_FUNCTION(getopt) ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(args), entry) { zend_string *arg_str = zval_get_string(entry); - argv[pos++] = estrdup(arg_str->val); + argv[pos++] = estrdup(ZSTR_VAL(arg_str)); zend_string_release(arg_str); } ZEND_HASH_FOREACH_END(); @@ -4315,7 +4315,7 @@ PHP_FUNCTION(getopt) zend_string *arg_str = zval_get_string(entry); opts->need_param = 0; - opts->opt_name = estrdup(arg_str->val); + opts->opt_name = estrdup(ZSTR_VAL(arg_str)); len = (int)strlen(opts->opt_name); if ((len > 0) && (opts->opt_name[len - 1] == ':')) { opts->need_param++; @@ -4560,7 +4560,7 @@ static int add_config_entry_cb(zval *entry, int num_args, va_list args, zend_has if (Z_TYPE_P(entry) == IS_STRING) { if (hash_key->key) { - add_assoc_str_ex(retval, hash_key->key->val, hash_key->key->len, zend_string_copy(Z_STR_P(entry))); + add_assoc_str_ex(retval, ZSTR_VAL(hash_key->key), ZSTR_LEN(hash_key->key), zend_string_copy(Z_STR_P(entry))); } else { add_index_str(retval, hash_key->h, zend_string_copy(Z_STR_P(entry))); } @@ -4904,7 +4904,7 @@ static int user_shutdown_function_call(zval *zv) /* {{{ */ if (!zend_is_callable(&shutdown_function_entry->arguments[0], 0, &function_name)) { if (function_name) { - php_error(E_WARNING, "(Registered shutdown functions) Unable to call %s() - function does not exist", function_name->val); + php_error(E_WARNING, "(Registered shutdown functions) Unable to call %s() - function does not exist", ZSTR_VAL(function_name)); zend_string_release(function_name); } else { php_error(E_WARNING, "(Registered shutdown functions) Unable to call - function does not exist"); @@ -4954,7 +4954,7 @@ static void user_tick_function_call(user_tick_function_entry *tick_fe) /* {{{ */ && (method = zend_hash_index_find(Z_ARRVAL_P(function), 1)) != NULL && Z_TYPE_P(obj) == IS_OBJECT && Z_TYPE_P(method) == IS_STRING) { - php_error_docref(NULL, E_WARNING, "Unable to call %s::%s() - function does not exist", Z_OBJCE_P(obj)->name->val, Z_STRVAL_P(method)); + php_error_docref(NULL, E_WARNING, "Unable to call %s::%s() - function does not exist", ZSTR_VAL(Z_OBJCE_P(obj)->name), Z_STRVAL_P(method)); } else { php_error_docref(NULL, E_WARNING, "Unable to call tick function"); } @@ -5047,7 +5047,7 @@ PHP_FUNCTION(register_shutdown_function) /* Prevent entering of anything but valid callback (syntax check only!) */ if (!zend_is_callable(&shutdown_function_entry.arguments[0], 0, &callback_name)) { if (callback_name) { - php_error_docref(NULL, E_WARNING, "Invalid shutdown callback '%s' passed", callback_name->val); + php_error_docref(NULL, E_WARNING, "Invalid shutdown callback '%s' passed", ZSTR_VAL(callback_name)); } else { php_error_docref(NULL, E_WARNING, "Invalid shutdown callback passed"); } @@ -5269,7 +5269,7 @@ static int php_ini_get_option(zval *zv, int num_args, va_list args, zend_hash_ke } if (hash_key->key == NULL || - hash_key->key->val[0] != 0 + ZSTR_VAL(hash_key->key)[0] != 0 ) { if (details) { array_init(&option); @@ -5356,7 +5356,7 @@ PHP_FUNCTION(ini_set) return; } - old_value = zend_ini_string(varname->val, (int)varname->len, 0); + old_value = zend_ini_string(ZSTR_VAL(varname), (int)ZSTR_LEN(varname), 0); /* copy to return here, because alter might free it! */ if (old_value) { @@ -5368,13 +5368,13 @@ PHP_FUNCTION(ini_set) #define _CHECK_PATH(var, var_len, ini) php_ini_check_path(var, (int)var_len, ini, sizeof(ini)) /* open basedir check */ if (PG(open_basedir)) { - if (_CHECK_PATH(varname->val, varname->len, "error_log") || - _CHECK_PATH(varname->val, varname->len, "java.class.path") || - _CHECK_PATH(varname->val, varname->len, "java.home") || - _CHECK_PATH(varname->val, varname->len, "mail.log") || - _CHECK_PATH(varname->val, varname->len, "java.library.path") || - _CHECK_PATH(varname->val, varname->len, "vpopmail.directory")) { - if (php_check_open_basedir(new_value->val)) { + if (_CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "error_log") || + _CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "java.class.path") || + _CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "java.home") || + _CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "mail.log") || + _CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "java.library.path") || + _CHECK_PATH(ZSTR_VAL(varname), ZSTR_LEN(varname), "vpopmail.directory")) { + if (php_check_open_basedir(ZSTR_VAL(new_value))) { zval_dtor(return_value); RETURN_FALSE; } @@ -5661,7 +5661,7 @@ PHP_FUNCTION(register_tick_function) if (!zend_is_callable(&tick_fe.arguments[0], 0, &function_name)) { efree(tick_fe.arguments); - php_error_docref(NULL, E_WARNING, "Invalid tick callback '%s' passed", function_name->val); + php_error_docref(NULL, E_WARNING, "Invalid tick callback '%s' passed", ZSTR_VAL(function_name)); zend_string_release(function_name); RETURN_FALSE; } else if (function_name) { diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c index 110da9210c..193ee74436 100644 --- a/ext/standard/browscap.c +++ b/ext/standard/browscap.c @@ -84,7 +84,7 @@ static void convert_browscap_pattern(zval *pattern, int persistent) /* {{{ */ char *lc_pattern; res = zend_string_safe_alloc(Z_STRLEN_P(pattern), 2, 4, persistent); - t = res->val; + t = ZSTR_VAL(res); lc_pattern = zend_str_tolower_dup(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern)); @@ -130,7 +130,7 @@ static void convert_browscap_pattern(zval *pattern, int persistent) /* {{{ */ t[j++] = '~'; t[j]=0; - res->len = j; + ZSTR_LEN(res) = j; Z_STR_P(pattern) = res; efree(lc_pattern); } @@ -180,7 +180,7 @@ static void php_browscap_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callb ZVAL_STR(&new_property, zend_string_dup(Z_STR_P(arg2), persistent)); } new_key = zend_string_dup(Z_STR_P(arg1), persistent); - zend_str_tolower(new_key->val, new_key->len); + zend_str_tolower(ZSTR_VAL(new_key), ZSTR_LEN(new_key)); zend_hash_update(Z_ARRVAL(bdata->current_section), new_key, &new_property); zend_string_release(new_key); } @@ -296,7 +296,7 @@ PHP_INI_MH(OnChangeBrowscap) if (bdata->filename[0] != '\0') { browscap_bdata_dtor(bdata, 0); } - if (VCWD_REALPATH(new_value->val, bdata->filename) == NULL) { + if (VCWD_REALPATH(ZSTR_VAL(new_value), bdata->filename) == NULL) { return FAILURE; } return SUCCESS; diff --git a/ext/standard/cyr_convert.c b/ext/standard/cyr_convert.c index 65b0781059..209be271b5 100644 --- a/ext/standard/cyr_convert.c +++ b/ext/standard/cyr_convert.c @@ -280,7 +280,7 @@ PHP_FUNCTION(convert_cyr_string) str = zend_string_init(input, input_len, 0); - php_convert_cyr_string((unsigned char *) str->val, str->len, fr_cs[0], to_cs[0]); + php_convert_cyr_string((unsigned char *) ZSTR_VAL(str), ZSTR_LEN(str), fr_cs[0], to_cs[0]); RETVAL_NEW_STR(str); } /* }}} */ diff --git a/ext/standard/dns.c b/ext/standard/dns.c index 0f32fde49e..52773abfb7 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -547,14 +547,14 @@ static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_t n = dlen - (l1 + 1); } if (n) { - memcpy(tp->val + l2 , cp + l1 + 1, n); + memcpy(ZSTR_VAL(tp) + l2 , cp + l1 + 1, n); add_next_index_stringl(&entries, (char *) cp + l1 + 1, n); } l1 = l1 + n + 1; l2 = l2 + n; } - tp->val[l2] = '\0'; - tp->len = l2; + ZSTR_VAL(tp)[l2] = '\0'; + ZSTR_LEN(tp) = l2; cp += dlen; add_assoc_str(subarray, "txt", tp); diff --git a/ext/standard/exec.c b/ext/standard/exec.c index d13ac454ad..55d777cb92 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -262,7 +262,7 @@ PHPAPI zend_string *php_escape_shell_cmd(char *str) if (mb_len < 0) { continue; } else if (mb_len > 1) { - memcpy(cmd->val + y, str + x, mb_len); + memcpy(ZSTR_VAL(cmd) + y, str + x, mb_len); y += mb_len; x += mb_len - 1; continue; @@ -277,9 +277,9 @@ PHPAPI zend_string *php_escape_shell_cmd(char *str) } else if (p && *p == str[x]) { p = NULL; } else { - cmd->val[y++] = '\\'; + ZSTR_VAL(cmd)[y++] = '\\'; } - cmd->val[y++] = str[x]; + ZSTR_VAL(cmd)[y++] = str[x]; break; #else /* % is Windows specific for environmental variables, ^%PATH% will @@ -312,17 +312,17 @@ PHPAPI zend_string *php_escape_shell_cmd(char *str) case '\x0A': /* excluding these two */ case '\xFF': #ifdef PHP_WIN32 - cmd->val[y++] = '^'; + ZSTR_VAL(cmd)[y++] = '^'; #else - cmd->val[y++] = '\\'; + ZSTR_VAL(cmd)[y++] = '\\'; #endif /* fall-through */ default: - cmd->val[y++] = str[x]; + ZSTR_VAL(cmd)[y++] = str[x]; } } - cmd->val[y] = '\0'; + ZSTR_VAL(cmd)[y] = '\0'; if ((estimate - y) > 4096) { /* realloc if the estimate was way overill @@ -330,7 +330,7 @@ PHPAPI zend_string *php_escape_shell_cmd(char *str) cmd = zend_string_truncate(cmd, y, 0); } - cmd->len = y; + ZSTR_LEN(cmd) = y; return cmd; } @@ -348,9 +348,9 @@ PHPAPI zend_string *php_escape_shell_arg(char *str) cmd = zend_string_alloc(4 * l + 2, 0); /* worst case */ #ifdef PHP_WIN32 - cmd->val[y++] = '"'; + ZSTR_VAL(cmd)[y++] = '"'; #else - cmd->val[y++] = '\''; + ZSTR_VAL(cmd)[y++] = '\''; #endif for (x = 0; x < l; x++) { @@ -360,7 +360,7 @@ PHPAPI zend_string *php_escape_shell_arg(char *str) if (mb_len < 0) { continue; } else if (mb_len > 1) { - memcpy(cmd->val + y, str + x, mb_len); + memcpy(ZSTR_VAL(cmd) + y, str + x, mb_len); y += mb_len; x += mb_len - 1; continue; @@ -371,40 +371,40 @@ PHPAPI zend_string *php_escape_shell_arg(char *str) case '"': case '%': case '!': - cmd->val[y++] = ' '; + ZSTR_VAL(cmd)[y++] = ' '; break; #else case '\'': - cmd->val[y++] = '\''; - cmd->val[y++] = '\\'; - cmd->val[y++] = '\''; + ZSTR_VAL(cmd)[y++] = '\''; + ZSTR_VAL(cmd)[y++] = '\\'; + ZSTR_VAL(cmd)[y++] = '\''; #endif /* fall-through */ default: - cmd->val[y++] = str[x]; + ZSTR_VAL(cmd)[y++] = str[x]; } } #ifdef PHP_WIN32 - if (y > 0 && '\\' == cmd->val[y - 1]) { + if (y > 0 && '\\' == ZSTR_VAL(cmd)[y - 1]) { int k = 0, n = y - 1; - for (; n >= 0 && '\\' == cmd->val[n]; n--, k++); + for (; n >= 0 && '\\' == ZSTR_VAL(cmd)[n]; n--, k++); if (k % 2) { - cmd->val[y++] = '\\'; + ZSTR_VAL(cmd)[y++] = '\\'; } } - cmd->val[y++] = '"'; + ZSTR_VAL(cmd)[y++] = '"'; #else - cmd->val[y++] = '\''; + ZSTR_VAL(cmd)[y++] = '\''; #endif - cmd->val[y] = '\0'; + ZSTR_VAL(cmd)[y] = '\0'; if ((estimate - y) > 4096) { /* realloc if the estimate was way overill * Arbitrary cutoff point of 4096 */ cmd = zend_string_truncate(cmd, y, 0); } - cmd->len = y; + ZSTR_LEN(cmd) = y; return cmd; } /* }}} */ @@ -472,7 +472,7 @@ PHP_FUNCTION(shell_exec) ret = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0); php_stream_close(stream); - if (ret && ret->len > 0) { + if (ret && ZSTR_LEN(ret) > 0) { RETVAL_STR(ret); } } diff --git a/ext/standard/file.c b/ext/standard/file.c index 53e22d533e..fc6bf5ae95 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -656,11 +656,11 @@ PHP_FUNCTION(file_put_contents) ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(data), tmp) { zend_string *str = zval_get_string(tmp); - if (str->len) { - numbytes += str->len; - bytes_written = php_stream_write(stream, str->val, str->len); - if (bytes_written != str->len) { - php_error_docref(NULL, E_WARNING, "Failed to write %zd bytes to %s", str->len, filename); + if (ZSTR_LEN(str)) { + numbytes += ZSTR_LEN(str); + bytes_written = php_stream_write(stream, ZSTR_VAL(str), ZSTR_LEN(str)); + if (bytes_written != ZSTR_LEN(str)) { + php_error_docref(NULL, E_WARNING, "Failed to write %zd bytes to %s", ZSTR_LEN(str), filename); ret_ok = 0; zend_string_release(str); break; @@ -743,8 +743,8 @@ PHP_FUNCTION(file) array_init(return_value); if ((target_buf = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0)) != NULL) { - s = target_buf->val; - e = target_buf->val + target_buf->len; + s = ZSTR_VAL(target_buf); + e = ZSTR_VAL(target_buf) + ZSTR_LEN(target_buf); if (!(p = (char*)php_stream_locate_eol(stream, target_buf))) { p = e; @@ -767,7 +767,7 @@ parse_eol: } else { do { int windows_eol = 0; - if (p != target_buf->val && eol_marker == '\n' && *(p - 1) == '\r') { + if (p != ZSTR_VAL(target_buf) && eol_marker == '\n' && *(p - 1) == '\r') { windows_eol++; } if (skip_blank_lines && !(p-s-windows_eol)) { @@ -812,13 +812,13 @@ PHP_FUNCTION(tempnam) } p = php_basename(prefix, prefix_len, NULL, 0); - if (p->len > 64) { - p->val[63] = '\0'; + if (ZSTR_LEN(p) > 64) { + ZSTR_VAL(p)[63] = '\0'; } RETVAL_FALSE; - if ((fd = php_open_temporary_fd_ex(dir, p->val, &opened_path, 1)) >= 0) { + if ((fd = php_open_temporary_fd_ex(dir, ZSTR_VAL(p), &opened_path, 1)) >= 0) { close(fd); RETVAL_STR(opened_path); } @@ -1116,11 +1116,11 @@ PHPAPI PHP_FUNCTION(fgetss) if (allowed != NULL) { // TODO: reimplement to avoid reallocation ??? if (ZSTR_IS_INTERNED(allowed)) { - allowed_tags = estrndup(allowed->val, allowed->len); - allowed_tags_len = allowed->len; + allowed_tags = estrndup(ZSTR_VAL(allowed), ZSTR_LEN(allowed)); + allowed_tags_len = ZSTR_LEN(allowed); } else { - allowed_tags = allowed->val; - allowed_tags_len = allowed->len; + allowed_tags = ZSTR_VAL(allowed); + allowed_tags_len = ZSTR_LEN(allowed); } } @@ -1823,7 +1823,7 @@ quit_loop: } /* }}} */ -#define FPUTCSV_FLD_CHK(c) memchr(field_str->val, c, field_str->len) +#define FPUTCSV_FLD_CHK(c) memchr(ZSTR_VAL(field_str), c, ZSTR_LEN(field_str)) /* {{{ proto int fputcsv(resource fp, array fields [, string delimiter [, string enclosure [, string escape_char]]]) Format line as CSV and write to file pointer */ @@ -1908,8 +1908,8 @@ PHPAPI size_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char FPUTCSV_FLD_CHK('\t') || FPUTCSV_FLD_CHK(' ') ) { - char *ch = field_str->val; - char *end = ch + field_str->len; + char *ch = ZSTR_VAL(field_str); + char *end = ch + ZSTR_LEN(field_str); int escaped = 0; smart_str_appendc(&csvline, enclosure); @@ -1938,7 +1938,7 @@ PHPAPI size_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char smart_str_appendc(&csvline, '\n'); smart_str_0(&csvline); - ret = php_stream_write(stream, csvline.s->val, csvline.s->len); + ret = php_stream_write(stream, ZSTR_VAL(csvline.s), ZSTR_LEN(csvline.s)); smart_str_free(&csvline); diff --git a/ext/standard/filters.c b/ext/standard/filters.c index de3a3b2026..105e156c9e 100644 --- a/ext/standard/filters.c +++ b/ext/standard/filters.c @@ -274,7 +274,7 @@ static php_stream_filter *strfilter_strip_tags_create(const char *filtername, zv } } - if (php_strip_tags_filter_ctor(inst, tags_ss.s->val, tags_ss.s->len, persistent) != SUCCESS) { + if (php_strip_tags_filter_ctor(inst, ZSTR_VAL(tags_ss.s), ZSTR_LEN(tags_ss.s), persistent) != SUCCESS) { smart_str_free(&tags_ss); pefree(inst, persistent); return NULL; @@ -1219,12 +1219,12 @@ static php_conv_err_t php_conv_get_string_prop_ex(const HashTable *ht, char **pr if ((tmpval = zend_hash_str_find((HashTable *)ht, field_name, field_name_len-1)) != NULL) { zend_string *str = zval_get_string(tmpval); - if (NULL == (*pretval = pemalloc(str->len + 1, persistent))) { + if (NULL == (*pretval = pemalloc(ZSTR_LEN(str) + 1, persistent))) { return PHP_CONV_ERR_ALLOC; } - *pretval_len = str->len; - memcpy(*pretval, str->val, str->len + 1); + *pretval_len = ZSTR_LEN(str); + memcpy(*pretval, ZSTR_VAL(str), ZSTR_LEN(str) + 1); zend_string_release(str); } else { return PHP_CONV_ERR_NOT_FOUND; diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index 1c381cdb00..e8bce6fa3f 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -59,12 +59,12 @@ static char HEXCHARS[] = "0123456789ABCDEF"; inline static void php_sprintf_appendchar(zend_string **buffer, size_t *pos, char add) { - if (!*buffer || (*pos + 1) >= (*buffer)->len) { - PRINTF_DEBUG(("%s(): ereallocing buffer to %d bytes\n", get_active_function_name(), (*buffer)->len)); - *buffer = zend_string_extend(*buffer, (*buffer)->len << 1, 0); + if (!*buffer || (*pos + 1) >= ZSTR_LEN(*buffer)) { + PRINTF_DEBUG(("%s(): ereallocing buffer to %d bytes\n", get_active_function_name(), ZSTR_LEN(*buffer))); + *buffer = zend_string_extend(*buffer, ZSTR_LEN(*buffer) << 1, 0); } PRINTF_DEBUG(("sprintf: appending '%c', pos=\n", add, *pos)); - (*buffer)->val[(*pos)++] = add; + ZSTR_VAL(*buffer)[(*pos)++] = add; } /* }}} */ @@ -83,7 +83,7 @@ php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add, npad = (min_width < copy_len) ? 0 : min_width - copy_len; PRINTF_DEBUG(("sprintf: appendstring(%x, %d, %d, \"%s\", %d, '%c', %d)\n", - *buffer, *pos, (*buffer)->len, add, min_width, padding, alignment)); + *buffer, *pos, ZSTR_LEN(*buffer), add, min_width, padding, alignment)); m_width = MAX(min_width, copy_len); if(m_width > INT_MAX - *pos - 1) { @@ -92,8 +92,8 @@ php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add, req_size = *pos + m_width + 1; - if (!*buffer || req_size > (*buffer)->len) { - size_t size = (*buffer)->len; + if (!*buffer || req_size > ZSTR_LEN(*buffer)) { + size_t size = ZSTR_LEN(*buffer); while (req_size > size) { if (size > ZEND_SIZE_MAX/2) { zend_error_noreturn(E_ERROR, "Field width %zd is too long", req_size); @@ -105,21 +105,21 @@ php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add, } if (alignment == ALIGN_RIGHT) { if ((neg || always_sign) && padding=='0') { - (*buffer)->val[(*pos)++] = (neg) ? '-' : '+'; + ZSTR_VAL(*buffer)[(*pos)++] = (neg) ? '-' : '+'; add++; len--; copy_len--; } while (npad-- > 0) { - (*buffer)->val[(*pos)++] = padding; + ZSTR_VAL(*buffer)[(*pos)++] = padding; } } PRINTF_DEBUG(("sprintf: appending \"%s\"\n", add)); - memcpy(&(*buffer)->val[*pos], add, copy_len + 1); + memcpy(&ZSTR_VAL(*buffer)[*pos], add, copy_len + 1); *pos += copy_len; if (alignment == ALIGN_LEFT) { while (npad--) { - (*buffer)->val[(*pos)++] = padding; + ZSTR_VAL(*buffer)[(*pos)++] = padding; } } } @@ -136,7 +136,7 @@ php_sprintf_appendint(zend_string **buffer, size_t *pos, zend_long number, register unsigned int i = NUM_BUF_SIZE - 1, neg = 0; PRINTF_DEBUG(("sprintf: appendint(%x, %x, %x, %d, %d, '%c', %d)\n", - *buffer, pos, &(*buffer)->len, number, width, padding, alignment)); + *buffer, pos, &ZSTR_LEN(*buffer), number, width, padding, alignment)); if (number < 0) { neg = 1; magn = ((zend_ulong) -(number + 1)) + 1; @@ -180,7 +180,7 @@ php_sprintf_appenduint(zend_string **buffer, size_t *pos, register unsigned int i = NUM_BUF_SIZE - 1; PRINTF_DEBUG(("sprintf: appenduint(%x, %x, %x, %d, %d, '%c', %d)\n", - *buffer, pos, &(*buffer)->len, number, width, padding, alignment)); + *buffer, pos, &ZSTR_LEN(*buffer), number, width, padding, alignment)); magn = (zend_ulong) number; /* Can't right-pad 0's on integers */ @@ -224,7 +224,7 @@ php_sprintf_appenddouble(zend_string **buffer, size_t *pos, #endif PRINTF_DEBUG(("sprintf: appenddouble(%x, %x, %x, %f, %d, '%c', %d, %c)\n", - *buffer, pos, &(*buffer)->len, number, width, padding, alignment, fmt)); + *buffer, pos, &ZSTR_LEN(*buffer), number, width, padding, alignment, fmt)); if ((adjust & ADJ_PRECISION) == 0) { precision = FLOAT_PRECISION; } else if (precision > MAX_FLOAT_PRECISION) { @@ -317,7 +317,7 @@ php_sprintf_append2n(zend_string **buffer, size_t *pos, zend_long number, register int andbits = (1 << n) - 1; PRINTF_DEBUG(("sprintf: append2n(%x, %x, %x, %d, %d, '%c', %d, %d, %x)\n", - *buffer, pos, &(*buffer)->len, number, width, padding, alignment, n, + *buffer, pos, &ZSTR_LEN(*buffer), number, width, padding, alignment, n, chartable)); PRINTF_DEBUG(("sprintf: append2n 2^%d andbits=%x\n", n, andbits)); @@ -579,10 +579,10 @@ php_formatted_print(zend_execute_data *execute_data, int use_array, int format_o case 's': { zend_string *str = zval_get_string(tmp); php_sprintf_appendstring(&result, &outpos, - str->val, + ZSTR_VAL(str), width, precision, padding, alignment, - str->len, + ZSTR_LEN(str), 0, expprec, 0); zend_string_release(str); break; @@ -664,8 +664,8 @@ php_formatted_print(zend_execute_data *execute_data, int use_array, int format_o } /* possibly, we have to make sure we have room for the terminating null? */ - result->val[outpos]=0; - result->len = outpos; + ZSTR_VAL(result)[outpos]=0; + ZSTR_LEN(result) = outpos; return result; } /* }}} */ @@ -706,7 +706,7 @@ PHP_FUNCTION(user_printf) if ((result=php_formatted_print(execute_data, 0, 0))==NULL) { RETURN_FALSE; } - rlen = PHPWRITE(result->val, result->len); + rlen = PHPWRITE(ZSTR_VAL(result), ZSTR_LEN(result)); zend_string_free(result); RETURN_LONG(rlen); } @@ -722,7 +722,7 @@ PHP_FUNCTION(vprintf) if ((result=php_formatted_print(execute_data, 1, 0))==NULL) { RETURN_FALSE; } - rlen = PHPWRITE(result->val, result->len); + rlen = PHPWRITE(ZSTR_VAL(result), ZSTR_LEN(result)); zend_string_free(result); RETURN_LONG(rlen); } @@ -750,9 +750,9 @@ PHP_FUNCTION(fprintf) RETURN_FALSE; } - php_stream_write(stream, result->val, result->len); + php_stream_write(stream, ZSTR_VAL(result), ZSTR_LEN(result)); - RETVAL_LONG(result->len); + RETVAL_LONG(ZSTR_LEN(result)); zend_string_free(result); } /* }}} */ @@ -779,9 +779,9 @@ PHP_FUNCTION(vfprintf) RETURN_FALSE; } - php_stream_write(stream, result->val, result->len); + php_stream_write(stream, ZSTR_VAL(result), ZSTR_LEN(result)); - RETVAL_LONG(result->len); + RETVAL_LONG(ZSTR_LEN(result)); zend_string_free(result); } /* }}} */ diff --git a/ext/standard/fsock.c b/ext/standard/fsock.c index 05a98502cb..b6f3483280 100644 --- a/ext/standard/fsock.c +++ b/ext/standard/fsock.c @@ -92,7 +92,7 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent) efree(hostname); } if (stream == NULL) { - php_error_docref(NULL, E_WARNING, "unable to connect to %s:" ZEND_LONG_FMT " (%s)", host, port, errstr == NULL ? "Unknown error" : errstr->val); + php_error_docref(NULL, E_WARNING, "unable to connect to %s:" ZEND_LONG_FMT " (%s)", host, port, errstr == NULL ? "Unknown error" : ZSTR_VAL(errstr)); } if (hashkey) { diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index b003ffda0f..3dbafa5907 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -629,8 +629,8 @@ static size_t php_ftp_dirstream_read(php_stream *stream, char *buf, size_t count basename = php_basename(ent->d_name, tmp_len, NULL, 0); - tmp_len = MIN(sizeof(ent->d_name), basename->len - 1); - memcpy(ent->d_name, basename->val, tmp_len); + tmp_len = MIN(sizeof(ent->d_name), ZSTR_LEN(basename) - 1); + memcpy(ent->d_name, ZSTR_VAL(basename), tmp_len); ent->d_name[tmp_len - 1] = '\0'; zend_string_release(basename); diff --git a/ext/standard/head.c b/ext/standard/head.c index 22a2af1abe..84dd3f5e54 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -102,10 +102,10 @@ PHPAPI int php_setcookie(char *name, size_t name_len, char *value, size_t value_ len += name_len; if (value && url_encode) { encoded_value = php_url_encode(value, value_len); - len += encoded_value->len; + len += ZSTR_LEN(encoded_value); } else if (value) { encoded_value = zend_string_init(value, value_len, 0); - len += encoded_value->len; + len += ZSTR_LEN(encoded_value); } if (path) { @@ -124,17 +124,17 @@ PHPAPI int php_setcookie(char *name, size_t name_len, char *value, size_t value_ * pick an expiry date in the past */ dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, 1, 0); - snprintf(cookie, len + 100, "Set-Cookie: %s=deleted; expires=%s; Max-Age=0", name, dt->val); + snprintf(cookie, len + 100, "Set-Cookie: %s=deleted; expires=%s; Max-Age=0", name, ZSTR_VAL(dt)); zend_string_free(dt); } else { - snprintf(cookie, len + 100, "Set-Cookie: %s=%s", name, value ? encoded_value->val : ""); + snprintf(cookie, len + 100, "Set-Cookie: %s=%s", name, value ? ZSTR_VAL(encoded_value) : ""); if (expires > 0) { const char *p; char tsdelta[13]; strlcat(cookie, COOKIE_EXPIRES, len + 100); dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, expires, 0); /* check to make sure that the year does not exceed 4 digits in length */ - p = zend_memrchr(dt->val, '-', dt->len); + p = zend_memrchr(ZSTR_VAL(dt), '-', ZSTR_LEN(dt)); if (!p || *(p + 5) != ' ') { zend_string_free(dt); efree(cookie); @@ -142,7 +142,7 @@ PHPAPI int php_setcookie(char *name, size_t name_len, char *value, size_t value_ zend_error(E_WARNING, "Expiry date cannot have a year greater than 9999"); return FAILURE; } - strlcat(cookie, dt->val, len + 100); + strlcat(cookie, ZSTR_VAL(dt), len + 100); zend_string_free(dt); snprintf(tsdelta, sizeof(tsdelta), ZEND_LONG_FMT, (zend_long) difftime(expires, time(NULL))); diff --git a/ext/standard/html.c b/ext/standard/html.c index b6a799d4a4..42f26bf820 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -951,7 +951,7 @@ static void traverse_for_entities( lim = old + oldlen; /* terminator address */ assert(*lim == '\0'); - for (p = old, q = ret->val; p < lim;) { + for (p = old, q = ZSTR_VAL(ret); p < lim;) { unsigned code, code2 = 0; const char *next = NULL; /* when set, next > p, otherwise possible inf loop */ @@ -1040,7 +1040,7 @@ invalid_code: } *q = '\0'; - ret->len = (size_t)(q - ret->val); + ZSTR_LEN(ret) = (size_t)(q - ZSTR_VAL(ret)); } /* }}} */ @@ -1118,8 +1118,8 @@ PHPAPI zend_string *php_unescape_html_entities(unsigned char *old, size_t oldlen goto empty_source; } ret = zend_string_alloc(new_size, 0); - ret->val[0] = '\0'; - ret->len = oldlen; + ZSTR_VAL(ret)[0] = '\0'; + ZSTR_LEN(ret) = oldlen; retlen = oldlen; if (retlen == 0) { goto empty_source; @@ -1298,7 +1298,7 @@ PHPAPI zend_string *php_escape_html_entities_ex(unsigned char *old, size_t oldle if (flags & ENT_HTML_IGNORE_ERRORS) { continue; } else if (flags & ENT_HTML_SUBSTITUTE_ERRORS) { - memcpy(&replaced->val[len], replacement, replacement_len); + memcpy(&ZSTR_VAL(replaced)[len], replacement, replacement_len); len += replacement_len; continue; } else { @@ -1335,10 +1335,10 @@ PHPAPI zend_string *php_escape_html_entities_ex(unsigned char *old, size_t oldle } if (rep != NULL) { - replaced->val[len++] = '&'; - memcpy(&replaced->val[len], rep, rep_len); + ZSTR_VAL(replaced)[len++] = '&'; + memcpy(&ZSTR_VAL(replaced)[len], rep, rep_len); len += rep_len; - replaced->val[len++] = ';'; + ZSTR_VAL(replaced)[len++] = ';'; } else { /* we did not find an entity for this char. * check for its validity, if its valid pass it unchanged */ @@ -1372,16 +1372,16 @@ PHPAPI zend_string *php_escape_html_entities_ex(unsigned char *old, size_t oldle } pass_char_through: if (mbseqlen > 1) { - memcpy(replaced->val + len, mbsequence, mbseqlen); + memcpy(ZSTR_VAL(replaced) + len, mbsequence, mbseqlen); len += mbseqlen; } else { - replaced->val[len++] = mbsequence[0]; + ZSTR_VAL(replaced)[len++] = mbsequence[0]; } } } else { /* this_char == '&' */ if (double_encode) { encode_amp: - memcpy(&replaced->val[len], "&", sizeof("&") - 1); + memcpy(&ZSTR_VAL(replaced)[len], "&", sizeof("&") - 1); len += sizeof("&") - 1; } else { /* no double encode */ /* check if entity is valid */ @@ -1424,16 +1424,16 @@ encode_amp: replaced = zend_string_safe_realloc(replaced, maxlen, 1, ent_len + 128, 0); maxlen += ent_len + 128; } - replaced->val[len++] = '&'; - memcpy(&replaced->val[len], &old[cursor], ent_len); + ZSTR_VAL(replaced)[len++] = '&'; + memcpy(&ZSTR_VAL(replaced)[len], &old[cursor], ent_len); len += ent_len; - replaced->val[len++] = ';'; + ZSTR_VAL(replaced)[len++] = ';'; cursor += ent_len + 1; } } } - replaced->val[len] = '\0'; - replaced->len = len; + ZSTR_VAL(replaced)[len] = '\0'; + ZSTR_LEN(replaced) = len; return replaced; } @@ -1466,7 +1466,7 @@ static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all) if (!hint_charset) { default_charset = get_default_charset(); } - replaced = php_escape_html_entities_ex((unsigned char*)str->val, str->len, all, (int) flags, (hint_charset ? hint_charset->val : default_charset), double_encode); + replaced = php_escape_html_entities_ex((unsigned char*)ZSTR_VAL(str), ZSTR_LEN(str), all, (int) flags, (hint_charset ? ZSTR_VAL(hint_charset) : default_charset), double_encode); RETVAL_STR(replaced); } /* }}} */ @@ -1548,7 +1548,7 @@ PHP_FUNCTION(html_entity_decode) if (!hint_charset) { default_charset = get_default_charset(); } - replaced = php_unescape_html_entities((unsigned char*)str->val, str->len, 1 /*all*/, (int)quote_style, (hint_charset ? hint_charset->val : default_charset)); + replaced = php_unescape_html_entities((unsigned char*)ZSTR_VAL(str), ZSTR_LEN(str), 1 /*all*/, (int)quote_style, (hint_charset ? ZSTR_VAL(hint_charset) : default_charset)); if (replaced) { RETURN_STR(replaced); diff --git a/ext/standard/http.c b/ext/standard/http.c index 7fe094009e..7fd49a843c 100644 --- a/ext/standard/http.c +++ b/ext/standard/http.c @@ -58,7 +58,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, ZEND_HASH_FOREACH_KEY_VAL_IND(ht, idx, key, zdata) { /* handling for private & protected object properties */ if (key) { - if (key->val[0] == '\0' && type != NULL) { + if (ZSTR_VAL(key)[0] == '\0' && type != NULL) { const char *tmp; zend_object *zobj = Z_OBJ_P(type); @@ -68,8 +68,8 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, } zend_unmangle_property_name_ex(key, &tmp, &prop_name, &prop_len); } else { - prop_name = key->val; - prop_len = key->len; + prop_name = ZSTR_VAL(key); + prop_len = ZSTR_LEN(key); } } else { prop_name = NULL; @@ -85,7 +85,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, } else { ekey = php_url_encode(prop_name, prop_len); } - newprefix_len = key_suffix_len + ekey->len + key_prefix_len + 3 /* %5B */; + newprefix_len = key_suffix_len + ZSTR_LEN(ekey) + key_prefix_len + 3 /* %5B */; newprefix = emalloc(newprefix_len + 1); p = newprefix; @@ -94,8 +94,8 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, p += key_prefix_len; } - memcpy(p, ekey->val, ekey->len); - p += ekey->len; + memcpy(p, ZSTR_VAL(ekey), ZSTR_LEN(ekey)); + p += ZSTR_LEN(ekey); zend_string_free(ekey); if (key_suffix) { @@ -206,9 +206,9 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, zend_string *ekey; zend_string *tmp = zval_get_string(zdata); if (enc_type == PHP_QUERY_RFC3986) { - ekey = php_raw_url_encode(tmp->val, tmp->len); + ekey = php_raw_url_encode(ZSTR_VAL(tmp), ZSTR_LEN(tmp)); } else { - ekey = php_url_encode(tmp->val, tmp->len); + ekey = php_url_encode(ZSTR_VAL(tmp), ZSTR_LEN(tmp)); } smart_str_append(formstr, ekey); zend_string_release(tmp); diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 6662384be5..90f2e9493d 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -229,7 +229,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, } if (errstr) { - php_stream_wrapper_log_error(wrapper, options, "%s", errstr->val); + php_stream_wrapper_log_error(wrapper, options, "%s", ZSTR_VAL(errstr)); zend_string_release(errstr); errstr = NULL; } @@ -310,7 +310,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, finish: smart_str_appendl(&header, "\r\n", sizeof("\r\n")-1); - if (php_stream_write(stream, header.s->val, header.s->len) != header.s->len) { + if (php_stream_write(stream, ZSTR_VAL(header.s), ZSTR_LEN(header.s)) != ZSTR_LEN(header.s)) { php_stream_wrapper_log_error(wrapper, options, "Cannot connect to HTTPS server through proxy"); php_stream_close(stream); stream = NULL; @@ -448,22 +448,22 @@ finish: /* Remove newlines and spaces from start and end php_trim will estrndup() */ tmp = php_trim(Z_STR_P(tmpzval), NULL, 0, 3); } - if (tmp && tmp->len) { + if (tmp && ZSTR_LEN(tmp)) { char *s; char *t; - user_headers = estrndup(tmp->val, tmp->len); + user_headers = estrndup(ZSTR_VAL(tmp), ZSTR_LEN(tmp)); if (ZSTR_IS_INTERNED(tmp)) { - tmp = zend_string_init(tmp->val, tmp->len, 0); + tmp = zend_string_init(ZSTR_VAL(tmp), ZSTR_LEN(tmp), 0); } else if (GC_REFCOUNT(tmp) > 1) { GC_REFCOUNT(tmp)--; - tmp = zend_string_init(tmp->val, tmp->len, 0); + tmp = zend_string_init(ZSTR_VAL(tmp), ZSTR_LEN(tmp), 0); } /* Make lowercase for easy comparison against 'standard' headers */ - php_strtolower(tmp->val, tmp->len); - t = tmp->val; + php_strtolower(ZSTR_VAL(tmp), ZSTR_LEN(tmp)); + t = ZSTR_VAL(tmp); if (!header_init) { /* strip POST headers on redirect */ @@ -552,7 +552,7 @@ finish: stmp = php_base64_encode((unsigned char*)scratch, strlen(scratch)); - if (snprintf(scratch, scratch_len, "Authorization: Basic %s\r\n", stmp->val) > 0) { + if (snprintf(scratch, scratch_len, "Authorization: Basic %s\r\n", ZSTR_VAL(stmp)) > 0) { php_stream_write(stream, scratch, strlen(scratch)); php_stream_notify_info(context, PHP_STREAM_NOTIFY_AUTH_REQUIRED, NULL, 0); } diff --git a/ext/standard/image.c b/ext/standard/image.c index e1fa27e41b..0ea3abace2 100644 --- a/ext/standard/image.c +++ b/ext/standard/image.c @@ -231,9 +231,9 @@ static struct gfxinfo *php_handle_swc(php_stream * stream) */ do { - szlength = bufz->len * (1<<factor++); + szlength = ZSTR_LEN(bufz) * (1<<factor++); buf = (char *) erealloc(buf, szlength); - status = uncompress(buf, &szlength, bufz->val, bufz->len); + status = uncompress(buf, &szlength, ZSTR_VAL(bufz), ZSTR_LEN(bufz)); } while ((status==Z_BUF_ERROR)&&(factor<maxfactor)); if (bufz) { diff --git a/ext/standard/incomplete_class.c b/ext/standard/incomplete_class.c index 149b4ad337..bc2d232ce1 100644 --- a/ext/standard/incomplete_class.c +++ b/ext/standard/incomplete_class.c @@ -41,7 +41,7 @@ static void incomplete_class_message(zval *object, int error_type) class_name = php_lookup_class_name(object); if (class_name) { - php_error_docref(NULL, error_type, INCOMPLETE_CLASS_MSG, class_name->val); + php_error_docref(NULL, error_type, INCOMPLETE_CLASS_MSG, ZSTR_VAL(class_name)); zend_string_release(class_name); } else { php_error_docref(NULL, error_type, INCOMPLETE_CLASS_MSG, "unknown"); diff --git a/ext/standard/info.c b/ext/standard/info.c index 7d1d9ff3b1..f2f7cf6d07 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -65,7 +65,7 @@ static int php_info_print_html_esc(const char *str, size_t len) /* {{{ */ zend_string *new_str; new_str = php_escape_html_entities((unsigned char *) str, len, 0, ENT_QUOTES, "utf-8"); - written = php_output_write(new_str->val, new_str->len); + written = php_output_write(ZSTR_VAL(new_str), ZSTR_LEN(new_str)); zend_string_free(new_str); return written; } @@ -115,9 +115,9 @@ static void php_info_print_stream_hash(const char *name, HashTable *ht) /* {{{ * php_info_print(", "); } if (!sapi_module.phpinfo_as_text) { - php_info_print_html_esc(key->val, key->len); + php_info_print_html_esc(ZSTR_VAL(key), ZSTR_LEN(key)); } else { - php_info_print(key->val); + php_info_print(ZSTR_VAL(key)); } } } ZEND_HASH_FOREACH_END(); @@ -142,8 +142,8 @@ PHPAPI void php_info_print_module(zend_module_entry *zend_module) /* {{{ */ if (!sapi_module.phpinfo_as_text) { zend_string *url_name = php_url_encode(zend_module->name, strlen(zend_module->name)); - php_strtolower(url_name->val, url_name->len); - php_info_printf("<h2><a name=\"module_%s\">%s</a></h2>\n", url_name->val, zend_module->name); + php_strtolower(ZSTR_VAL(url_name), ZSTR_LEN(url_name)); + php_info_printf("<h2><a name=\"module_%s\">%s</a></h2>\n", ZSTR_VAL(url_name), zend_module->name); efree(url_name); } else { @@ -214,9 +214,9 @@ static void php_print_gpcse_array(char *name, uint name_length) if (string_key != NULL) { if (!sapi_module.phpinfo_as_text) { - php_info_print_html_esc(string_key->val, string_key->len); + php_info_print_html_esc(ZSTR_VAL(string_key), ZSTR_LEN(string_key)); } else { - php_info_print(string_key->val); + php_info_print(ZSTR_VAL(string_key)); } } else { php_info_printf(ZEND_ULONG_FMT, num_key); @@ -862,7 +862,7 @@ PHPAPI void php_print_info(int flag) } php_info_print_box_end(); php_info_print_table_start(); - php_info_print_table_row(2, "System", php_uname->val); + php_info_print_table_row(2, "System", ZSTR_VAL(php_uname)); php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__); #ifdef COMPILER php_info_print_table_row(2, "Compiler", COMPILER); diff --git a/ext/standard/mail.c b/ext/standard/mail.c index 22ba52d425..6e83b95fc3 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -118,11 +118,11 @@ PHP_FUNCTION(mail) MAIL_ASCIIZ_CHECK(subject, subject_len); MAIL_ASCIIZ_CHECK(message, message_len); if (headers) { - MAIL_ASCIIZ_CHECK(headers->val, headers->len); + MAIL_ASCIIZ_CHECK(ZSTR_VAL(headers), ZSTR_LEN(headers)); headers_trimmed = php_trim(headers, NULL, 0, 2); } if (extra_cmd) { - MAIL_ASCIIZ_CHECK(extra_cmd->val, extra_cmd->len); + MAIL_ASCIIZ_CHECK(ZSTR_VAL(extra_cmd), ZSTR_LEN(extra_cmd)); } if (to_len > 0) { @@ -168,10 +168,10 @@ PHP_FUNCTION(mail) if (force_extra_parameters) { extra_cmd = php_escape_shell_cmd(force_extra_parameters); } else if (extra_cmd) { - extra_cmd = php_escape_shell_cmd(extra_cmd->val); + extra_cmd = php_escape_shell_cmd(ZSTR_VAL(extra_cmd)); } - if (php_mail(to_r, subject_r, message, headers_trimmed ? headers_trimmed->val : NULL, extra_cmd ? extra_cmd->val : NULL)) { + if (php_mail(to_r, subject_r, message, headers_trimmed ? ZSTR_VAL(headers_trimmed) : NULL, extra_cmd ? ZSTR_VAL(extra_cmd) : NULL)) { RETVAL_TRUE; } else { RETVAL_FALSE; @@ -294,7 +294,7 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char time(&curtime); date_str = php_format_date("d-M-Y H:i:s e", 13, curtime, 1); - l = spprintf(&tmp, 0, "[%s] mail() on [%s:%d]: To: %s -- Headers: %s\n", date_str->val, zend_get_executed_filename(), zend_get_executed_lineno(), to, hdr ? hdr : ""); + l = spprintf(&tmp, 0, "[%s] mail() on [%s:%d]: To: %s -- Headers: %s\n", ZSTR_VAL(date_str), zend_get_executed_filename(), zend_get_executed_lineno(), to, hdr ? hdr : ""); zend_string_free(date_str); @@ -323,9 +323,9 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char f = php_basename(tmp, strlen(tmp), NULL, 0); if (headers != NULL && *headers) { - spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s\n%s", php_getuid(), f->val, headers); + spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s\n%s", php_getuid(), ZSTR_VAL(f), headers); } else { - spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s", php_getuid(), f->val); + spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s", php_getuid(), ZSTR_VAL(f)); } zend_string_release(f); } diff --git a/ext/standard/math.c b/ext/standard/math.c index 8d041d55df..33c83626a1 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -1292,23 +1292,23 @@ PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, char *dec_poin tmpbuf = strpprintf(0, "%.*F", dec, d); if (tmpbuf == NULL) { return NULL; - } else if (!isdigit((int)tmpbuf->val[0])) { + } else if (!isdigit((int)ZSTR_VAL(tmpbuf)[0])) { return tmpbuf; } /* find decimal point, if expected */ if (dec) { - dp = strpbrk(tmpbuf->val, ".,"); + dp = strpbrk(ZSTR_VAL(tmpbuf), ".,"); } else { dp = NULL; } /* calculate the length of the return buffer */ if (dp) { - integral = (int)(dp - tmpbuf->val); + integral = (int)(dp - ZSTR_VAL(tmpbuf)); } else { /* no decimal point was found */ - integral = (int)tmpbuf->len; + integral = (int)ZSTR_LEN(tmpbuf); } /* allow for thousand separators */ @@ -1332,8 +1332,8 @@ PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, char *dec_poin } res = zend_string_alloc(reslen, 0); - s = tmpbuf->val + tmpbuf->len - 1; - t = res->val + reslen; + s = ZSTR_VAL(tmpbuf) + ZSTR_LEN(tmpbuf) - 1; + t = ZSTR_VAL(res) + reslen; *t-- = '\0'; /* copy the decimal places. @@ -1365,9 +1365,9 @@ PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, char *dec_poin /* copy the numbers before the decimal point, adding thousand * separator every three digits */ - while (s >= tmpbuf->val) { + while (s >= ZSTR_VAL(tmpbuf)) { *t-- = *s--; - if (thousand_sep && (++count%3)==0 && s>=tmpbuf->val) { + if (thousand_sep && (++count%3)==0 && s >= ZSTR_VAL(tmpbuf)) { t -= thousand_sep_len; memcpy(t + 1, thousand_sep, thousand_sep_len); } @@ -1378,7 +1378,7 @@ PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, char *dec_poin *t-- = '-'; } - res->len = reslen; + ZSTR_LEN(res) = reslen; zend_string_release(tmpbuf); return res; } diff --git a/ext/standard/md5.c b/ext/standard/md5.c index 2df92a4927..1d7d2fba01 100644 --- a/ext/standard/md5.c +++ b/ext/standard/md5.c @@ -58,7 +58,7 @@ PHP_NAMED_FUNCTION(php_if_md5) md5str[0] = '\0'; PHP_MD5Init(&context); - PHP_MD5Update(&context, arg->val, arg->len); + PHP_MD5Update(&context, ZSTR_VAL(arg), ZSTR_LEN(arg)); PHP_MD5Final(digest, &context); if (raw_output) { RETURN_STRINGL((char *) digest, 16); diff --git a/ext/standard/metaphone.c b/ext/standard/metaphone.c index de29415cdf..2aa5bc87a8 100644 --- a/ext/standard/metaphone.c +++ b/ext/standard/metaphone.c @@ -39,7 +39,7 @@ PHP_FUNCTION(metaphone) return; } - if (metaphone((unsigned char *)str->val, str->len, phones, &result, 1) == 0) { + if (metaphone((unsigned char *)ZSTR_VAL(str), ZSTR_LEN(str), phones, &result, 1) == 0) { RETVAL_STR(result); } else { if (result) { @@ -145,8 +145,8 @@ static char Lookahead(char *word, int how_far) *phoned_word = zend_string_extend(*phoned_word, 2 * sizeof(char) + max_buffer_len, 0); \ max_buffer_len += 2; \ } \ - (*phoned_word)->val[p_idx++] = c; \ - (*phoned_word)->len = p_idx; \ + ZSTR_VAL(*phoned_word)[p_idx++] = c; \ + ZSTR_LEN(*phoned_word) = p_idx; \ } /* Slap a null character on the end of the phoned word */ #define End_Phoned_Word { \ @@ -154,8 +154,8 @@ static char Lookahead(char *word, int how_far) *phoned_word = zend_string_extend(*phoned_word, 1 * sizeof(char) + max_buffer_len, 0); \ max_buffer_len += 1; \ } \ - (*phoned_word)->val[p_idx] = '\0'; \ - (*phoned_word)->len = p_idx; \ + ZSTR_VAL(*phoned_word)[p_idx] = '\0'; \ + ZSTR_LEN(*phoned_word) = p_idx; \ } /* How long is the phoned word? */ #define Phone_Len (p_idx) diff --git a/ext/standard/pack.c b/ext/standard/pack.c index 4327c7db10..0701bcc874 100644 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@ -350,8 +350,8 @@ PHP_FUNCTION(pack) zend_string *str = zval_get_string(&argv[currentarg++]); memset(&output[outputpos], (code == 'a' || code == 'Z') ? '\0' : ' ', arg); - memcpy(&output[outputpos], str->val, - (str->len < arg_cp) ? str->len : arg_cp); + memcpy(&output[outputpos], ZSTR_VAL(str), + (ZSTR_LEN(str) < arg_cp) ? ZSTR_LEN(str) : arg_cp); outputpos += arg; zend_string_release(str); @@ -364,12 +364,12 @@ PHP_FUNCTION(pack) int first = 1; zend_string *str = zval_get_string(&argv[currentarg++]); - char *v = str->val; + char *v = ZSTR_VAL(str); outputpos--; - if(arg > str->len) { + if(arg > ZSTR_LEN(str)) { php_error_docref(NULL, E_WARNING, "Type %c: not enough characters in string", code); - arg = str->len; + arg = ZSTR_LEN(str); } while (arg-- > 0) { @@ -568,10 +568,10 @@ PHP_FUNCTION(unpack) return; } - format = formatarg->val; - formatlen = formatarg->len; - input = inputarg->val; - inputlen = inputarg->len; + format = ZSTR_VAL(formatarg); + formatlen = ZSTR_LEN(formatarg); + input = ZSTR_VAL(inputarg); + inputlen = ZSTR_LEN(inputarg); inputpos = 0; array_init(return_value); diff --git a/ext/standard/password.c b/ext/standard/password.c index 592f41838d..859dbe9d5f 100644 --- a/ext/standard/password.c +++ b/ext/standard/password.c @@ -87,19 +87,19 @@ static int php_password_salt_to64(const char *str, const size_t str_len, const s return FAILURE; } buffer = php_base64_encode((unsigned char*) str, str_len); - if (buffer->len < out_len) { + if (ZSTR_LEN(buffer) < out_len) { /* Too short of an encoded string generated */ zend_string_release(buffer); return FAILURE; } for (pos = 0; pos < out_len; pos++) { - if (buffer->val[pos] == '+') { + if (ZSTR_VAL(buffer)[pos] == '+') { ret[pos] = '.'; - } else if (buffer->val[pos] == '=') { + } else if (ZSTR_VAL(buffer)[pos] == '=') { zend_string_free(buffer); return FAILURE; } else { - ret[pos] = buffer->val[pos]; + ret[pos] = ZSTR_VAL(buffer)[pos]; } } zend_string_free(buffer); @@ -264,7 +264,7 @@ PHP_FUNCTION(password_verify) RETURN_FALSE; } - if (ret->len != hash_len || hash_len < 13) { + if (ZSTR_LEN(ret) != hash_len || hash_len < 13) { zend_string_free(ret); RETURN_FALSE; } @@ -274,7 +274,7 @@ PHP_FUNCTION(password_verify) * equality check that will always check every byte of both * values. */ for (i = 0; i < hash_len; i++) { - status |= (ret->val[i] ^ hash[i]); + status |= (ZSTR_VAL(ret)[i] ^ hash[i]); } zend_string_free(ret); @@ -343,8 +343,8 @@ PHP_FUNCTION(password_hash) case IS_OBJECT: { zend_string *tmp = zval_get_string(option_buffer); - buffer = estrndup(tmp->val, tmp->len); - buffer_len = tmp->len; + buffer = estrndup(ZSTR_VAL(tmp), ZSTR_LEN(tmp)); + buffer_len = ZSTR_LEN(tmp); zend_string_release(tmp); break; } @@ -417,7 +417,7 @@ PHP_FUNCTION(password_hash) efree(hash); - if (result->len < 13) { + if (ZSTR_LEN(result) < 13) { zend_string_free(result); RETURN_FALSE; } diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index bbcdd1073a..27584ea1f2 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -109,7 +109,7 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent /* first, we have to get the size of all the elements in the hash */ ZEND_HASH_FOREACH_STR_KEY_VAL(target_hash, string_key, element) { zend_string *str = zval_get_string(element); - size_t el_len = str->len; + size_t el_len = ZSTR_LEN(str); zend_string_release(str); if (el_len == 0) { @@ -119,10 +119,10 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent sizeenv += el_len + 1; if (string_key) { - if (string_key->len == 0) { + if (ZSTR_LEN(string_key) == 0) { continue; } - sizeenv += string_key->len + 1; + sizeenv += ZSTR_LEN(string_key) + 1; } } ZEND_HASH_FOREACH_END(); @@ -134,19 +134,19 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent ZEND_HASH_FOREACH_STR_KEY_VAL(target_hash, string_key, element) { zend_string *str = zval_get_string(element); - if (str->len == 0) { + if (ZSTR_LEN(str) == 0) { goto next_element; } if (string_key) { - if (string_key->len == 0) { + if (ZSTR_LEN(string_key) == 0) { goto next_element; } - l = string_key->len + str->len + 2; - memcpy(p, string_key->val, string_key->len); + l = ZSTR_LEN(string_key) + ZSTR_LEN(str) + 2; + memcpy(p, ZSTR_VAL(string_key), ZSTR_LEN(string_key)); strncat(p, "=", 1); - strncat(p, str->val, str->len); + strncat(p, ZSTR_VAL(str), ZSTR_LEN(str)); #ifndef PHP_WIN32 *ep = p; @@ -154,12 +154,12 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent #endif p += l; } else { - memcpy(p, str->val, str->len); + memcpy(p, ZSTR_VAL(str), ZSTR_LEN(str)); #ifndef PHP_WIN32 *ep = p; ++ep; #endif - p += str->len + 1; + p += ZSTR_LEN(str) + 1; } next_element: zend_string_release(str); diff --git a/ext/standard/quot_print.c b/ext/standard/quot_print.c index 26d1d2b6fc..df0b5584f8 100644 --- a/ext/standard/quot_print.c +++ b/ext/standard/quot_print.c @@ -97,7 +97,7 @@ PHPAPI zend_string *php_quot_print_decode(const unsigned char *str, size_t lengt } retval = zend_string_alloc(buf_size, 0); - i = length; p1 = str; p2 = (unsigned char*)retval->val; + i = length; p1 = str; p2 = (unsigned char*)ZSTR_VAL(retval); decoded_len = 0; while (i > 0 && *p1 != '\0') { @@ -138,7 +138,7 @@ PHPAPI zend_string *php_quot_print_decode(const unsigned char *str, size_t lengt } *p2 = '\0'; - retval->len = decoded_len; + ZSTR_LEN(retval) = decoded_len; return retval; } /* }}} */ @@ -153,7 +153,7 @@ PHPAPI zend_string *php_quot_print_encode(const unsigned char *str, size_t lengt zend_string *ret; ret = zend_string_safe_alloc(3, (length + (((3 * length)/(PHP_QPRINT_MAXL-9)) + 1)), 0, 0); - d = (unsigned char*)ret->val; + d = (unsigned char*)ZSTR_VAL(ret); while (length--) { if (((c = *str++) == '\015') && (*str == '\012') && length > 0) { @@ -187,7 +187,7 @@ PHPAPI zend_string *php_quot_print_encode(const unsigned char *str, size_t lengt } } *d = '\0'; - ret = zend_string_truncate(ret, d - (unsigned char*)ret->val, 0); + ret = zend_string_truncate(ret, d - (unsigned char*)ZSTR_VAL(ret), 0); return ret; } /* }}} */ @@ -210,13 +210,13 @@ PHP_FUNCTION(quoted_printable_decode) return; } - if (arg1->len == 0) { + if (ZSTR_LEN(arg1) == 0) { /* shortcut */ RETURN_EMPTY_STRING(); } - str_in = arg1->val; - str_out = zend_string_alloc(arg1->len, 0); + str_in = ZSTR_VAL(arg1); + str_out = zend_string_alloc(ZSTR_LEN(arg1), 0); while (str_in[i]) { switch (str_in[i]) { case '=': @@ -224,7 +224,7 @@ PHP_FUNCTION(quoted_printable_decode) isxdigit((int) str_in[i + 1]) && isxdigit((int) str_in[i + 2])) { - str_out->val[j++] = (php_hex2int((int) str_in[i + 1]) << 4) + ZSTR_VAL(str_out)[j++] = (php_hex2int((int) str_in[i + 1]) << 4) + php_hex2int((int) str_in[i + 2]); i += 3; } else /* check for soft line break according to RFC 2045*/ { @@ -246,16 +246,16 @@ PHP_FUNCTION(quoted_printable_decode) i += k + 1; } else { - str_out->val[j++] = str_in[i++]; + ZSTR_VAL(str_out)[j++] = str_in[i++]; } } break; default: - str_out->val[j++] = str_in[i++]; + ZSTR_VAL(str_out)[j++] = str_in[i++]; } } - str_out->val[j] = '\0'; - str_out->len = j; + ZSTR_VAL(str_out)[j] = '\0'; + ZSTR_LEN(str_out) = j; RETVAL_NEW_STR(str_out); } @@ -271,11 +271,11 @@ PHP_FUNCTION(quoted_printable_encode) return; } - if (!str->len) { + if (!ZSTR_LEN(str)) { RETURN_EMPTY_STRING(); } - new_str = php_quot_print_encode((unsigned char *)str->val, (size_t)str->len); + new_str = php_quot_print_encode((unsigned char *)ZSTR_VAL(str), (size_t)ZSTR_LEN(str)); RETURN_STR(new_str); } /* }}} */ diff --git a/ext/standard/random.c b/ext/standard/random.c index 4a1adbfb02..cc15012c20 100644 --- a/ext/standard/random.c +++ b/ext/standard/random.c @@ -138,12 +138,12 @@ PHP_FUNCTION(random_bytes) bytes = zend_string_alloc(size, 0); - if (php_random_bytes(bytes->val, size) == FAILURE) { + if (php_random_bytes(ZSTR_VAL(bytes), size) == FAILURE) { zend_string_release(bytes); RETURN_FALSE; } - bytes->val[size] = '\0'; + ZSTR_VAL(bytes)[size] = '\0'; RETURN_STR(bytes); } diff --git a/ext/standard/sha1.c b/ext/standard/sha1.c index ceef21e289..db64d5dbc5 100644 --- a/ext/standard/sha1.c +++ b/ext/standard/sha1.c @@ -46,7 +46,7 @@ PHP_FUNCTION(sha1) sha1str[0] = '\0'; PHP_SHA1Init(&context); - PHP_SHA1Update(&context, (unsigned char *) arg->val, arg->len); + PHP_SHA1Update(&context, (unsigned char *) ZSTR_VAL(arg), ZSTR_LEN(arg)); PHP_SHA1Final(digest, &context); if (raw_output) { RETURN_STRINGL((char *) digest, 20); diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index be0cbefac1..d5c3f53dc3 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -108,7 +108,7 @@ PHP_FUNCTION(stream_socket_client) context = php_stream_context_from_zval(zcontext, flags & PHP_FILE_NO_DEFAULT_CONTEXT); if (flags & PHP_STREAM_CLIENT_PERSISTENT) { - spprintf(&hashkey, 0, "stream_socket_client__%s", host->val); + spprintf(&hashkey, 0, "stream_socket_client__%s", ZSTR_VAL(host)); } /* prepare the timeout value for use */ @@ -129,7 +129,7 @@ PHP_FUNCTION(stream_socket_client) ZVAL_EMPTY_STRING(zerrstr); } - stream = php_stream_xport_create(host->val, host->len, REPORT_ERRORS, + stream = php_stream_xport_create(ZSTR_VAL(host), ZSTR_LEN(host), REPORT_ERRORS, STREAM_XPORT_CLIENT | (flags & PHP_STREAM_CLIENT_CONNECT ? STREAM_XPORT_CONNECT : 0) | (flags & PHP_STREAM_CLIENT_ASYNC_CONNECT ? STREAM_XPORT_CONNECT_ASYNC : 0), hashkey, &tv, context, &errstr, &err); @@ -139,7 +139,7 @@ PHP_FUNCTION(stream_socket_client) /* host might contain binary characters */ zend_string *quoted_host = php_addslashes(host, 0); - php_error_docref(NULL, E_WARNING, "unable to connect to %s (%s)", quoted_host->val, errstr == NULL ? "Unknown error" : errstr->val); + php_error_docref(NULL, E_WARNING, "unable to connect to %s (%s)", ZSTR_VAL(quoted_host), errstr == NULL ? "Unknown error" : ZSTR_VAL(errstr)); zend_string_release(quoted_host); } @@ -209,7 +209,7 @@ PHP_FUNCTION(stream_socket_server) NULL, NULL, context, &errstr, &err); if (stream == NULL) { - php_error_docref(NULL, E_WARNING, "unable to connect to %s (%s)", host, errstr == NULL ? "Unknown error" : errstr->val); + php_error_docref(NULL, E_WARNING, "unable to connect to %s (%s)", host, errstr == NULL ? "Unknown error" : ZSTR_VAL(errstr)); } if (stream == NULL) { @@ -278,7 +278,7 @@ PHP_FUNCTION(stream_socket_accept) } php_stream_to_zval(clistream, return_value); } else { - php_error_docref(NULL, E_WARNING, "accept failed: %s", errstr ? errstr->val : "Unknown error"); + php_error_docref(NULL, E_WARNING, "accept failed: %s", errstr ? ZSTR_VAL(errstr) : "Unknown error"); RETVAL_FALSE; } @@ -373,7 +373,7 @@ PHP_FUNCTION(stream_socket_recvfrom) read_buf = zend_string_alloc(to_read, 0); - recvd = php_stream_xport_recvfrom(stream, read_buf->val, to_read, (int)flags, NULL, NULL, + recvd = php_stream_xport_recvfrom(stream, ZSTR_VAL(read_buf), to_read, (int)flags, NULL, NULL, zremote ? &remote_addr : NULL ); @@ -381,8 +381,8 @@ PHP_FUNCTION(stream_socket_recvfrom) if (zremote) { ZVAL_STR(zremote, remote_addr); } - read_buf->val[recvd] = '\0'; - read_buf->len = recvd; + ZSTR_VAL(read_buf)[recvd] = '\0'; + ZSTR_LEN(read_buf) = recvd; RETURN_NEW_STR(read_buf); } @@ -869,7 +869,7 @@ static int parse_context_options(php_stream_context *context, zval *options) ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(wval), okey, oval) { if (okey) { - php_stream_context_set_option(context, wkey->val, okey->val, oval); + php_stream_context_set_option(context, ZSTR_VAL(wkey), ZSTR_VAL(okey), oval); } } ZEND_HASH_FOREACH_END(); diff --git a/ext/standard/string.c b/ext/standard/string.c index 8d9c94df16..3a828ed675 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -135,10 +135,10 @@ static zend_string *php_bin2hex(const unsigned char *old, const size_t oldlen) result = zend_string_safe_alloc(oldlen, 2 * sizeof(char), 0, 0); for (i = j = 0; i < oldlen; i++) { - result->val[j++] = hexconvtab[old[i] >> 4]; - result->val[j++] = hexconvtab[old[i] & 15]; + ZSTR_VAL(result)[j++] = hexconvtab[old[i] >> 4]; + ZSTR_VAL(result)[j++] = hexconvtab[old[i] & 15]; } - result->val[j] = '\0'; + ZSTR_VAL(result)[j] = '\0'; return result; } @@ -150,7 +150,7 @@ static zend_string *php_hex2bin(const unsigned char *old, const size_t oldlen) { size_t target_length = oldlen >> 1; zend_string *str = zend_string_alloc(target_length, 0); - unsigned char *ret = (unsigned char *)str->val; + unsigned char *ret = (unsigned char *)ZSTR_VAL(str); size_t i, j; for (i = j = 0; i < target_length; i++) { @@ -256,7 +256,7 @@ PHP_FUNCTION(bin2hex) return; } - result = php_bin2hex((unsigned char *)data->val, data->len); + result = php_bin2hex((unsigned char *)ZSTR_VAL(data), ZSTR_LEN(data)); if (!result) { RETURN_FALSE; @@ -276,12 +276,12 @@ PHP_FUNCTION(hex2bin) return; } - if (data->len % 2 != 0) { + if (ZSTR_LEN(data) % 2 != 0) { php_error_docref(NULL, E_WARNING, "Hexadecimal input string must have an even length"); RETURN_FALSE; } - result = php_hex2bin((unsigned char *)data->val, data->len); + result = php_hex2bin((unsigned char *)ZSTR_VAL(data), ZSTR_LEN(data)); if (!result) { php_error_docref(NULL, E_WARNING, "Input string must be hexadecimal string"); @@ -303,29 +303,29 @@ static void php_spn_common_handler(INTERNAL_FUNCTION_PARAMETERS, int behavior) / } if (ZEND_NUM_ARGS() < 4) { - len = s11->len; + len = ZSTR_LEN(s11); } /* look at substr() function for more information */ if (start < 0) { - start += (zend_long)s11->len; + start += (zend_long)ZSTR_LEN(s11); if (start < 0) { start = 0; } - } else if ((size_t)start > s11->len) { + } else if ((size_t)start > ZSTR_LEN(s11)) { RETURN_FALSE; } if (len < 0) { - len += (s11->len - start); + len += (ZSTR_LEN(s11) - start); if (len < 0) { len = 0; } } - if (len > (zend_long)s11->len - start) { - len = s11->len - start; + if (len > (zend_long)ZSTR_LEN(s11) - start) { + len = ZSTR_LEN(s11) - start; } if(len == 0) { @@ -333,15 +333,15 @@ static void php_spn_common_handler(INTERNAL_FUNCTION_PARAMETERS, int behavior) / } if (behavior == STR_STRSPN) { - RETURN_LONG(php_strspn(s11->val + start /*str1_start*/, - s22->val /*str2_start*/, - s11->val + start + len /*str1_end*/, - s22->val + s22->len /*str2_end*/)); + RETURN_LONG(php_strspn(ZSTR_VAL(s11) + start /*str1_start*/, + ZSTR_VAL(s22) /*str2_start*/, + ZSTR_VAL(s11) + start + len /*str1_end*/, + ZSTR_VAL(s22) + ZSTR_LEN(s22) /*str2_end*/)); } else if (behavior == STR_STRCSPN) { - RETURN_LONG(php_strcspn(s11->val + start /*str1_start*/, - s22->val /*str2_start*/, - s11->val + start + len /*str1_end*/, - s22->val + s22->len /*str2_end*/)); + RETURN_LONG(php_strcspn(ZSTR_VAL(s11) + start /*str1_start*/, + ZSTR_VAL(s22) /*str2_start*/, + ZSTR_VAL(s11) + start + len /*str1_end*/, + ZSTR_VAL(s22) + ZSTR_LEN(s22) /*str2_end*/)); } } @@ -731,8 +731,8 @@ PHP_FUNCTION(strcoll) return; } - RETURN_LONG(strcoll((const char *) s1->val, - (const char *) s2->val)); + RETURN_LONG(strcoll((const char *) ZSTR_VAL(s1), + (const char *) ZSTR_VAL(s2))); } /* }}} */ #endif @@ -793,8 +793,8 @@ static inline int php_charmask(unsigned char *input, size_t len, char *mask) */ PHPAPI zend_string *php_trim(zend_string *str, char *what, size_t what_len, int mode) { - const char *c = str->val; - size_t len = str->len; + const char *c = ZSTR_VAL(str); + size_t len = ZSTR_LEN(str); register size_t i; size_t trimmed = 0; char mask[256]; @@ -880,7 +880,7 @@ PHPAPI zend_string *php_trim(zend_string *str, char *what, size_t what_len, int } } - if (str->len == len) { + if (ZSTR_LEN(str) == len) { return zend_string_copy(str); } else { return zend_string_init(c, len, 0); @@ -908,7 +908,7 @@ static void php_do_trim(INTERNAL_FUNCTION_PARAMETERS, int mode) ZEND_PARSE_PARAMETERS_END(); #endif - ZVAL_STR(return_value, php_trim(str, (what ? what->val : NULL), (what ? what->len : 0), mode)); + ZVAL_STR(return_value, php_trim(str, (what ? ZSTR_VAL(what) : NULL), (what ? ZSTR_LEN(what) : 0), mode)); } /* }}} */ @@ -953,7 +953,7 @@ PHP_FUNCTION(wordwrap) return; } - if (text->len == 0) { + if (ZSTR_LEN(text) == 0) { RETURN_EMPTY_STRING(); } @@ -970,20 +970,20 @@ PHP_FUNCTION(wordwrap) /* Special case for a single-character break as it needs no additional storage space */ if (breakchar_len == 1 && !docut) { - newtext = zend_string_init(text->val, text->len, 0); + newtext = zend_string_init(ZSTR_VAL(text), ZSTR_LEN(text), 0); laststart = lastspace = 0; - for (current = 0; current < text->len; current++) { - if (text->val[current] == breakchar[0]) { + for (current = 0; current < ZSTR_LEN(text); current++) { + if (ZSTR_VAL(text)[current] == breakchar[0]) { laststart = lastspace = current + 1; - } else if (text->val[current] == ' ') { + } else if (ZSTR_VAL(text)[current] == ' ') { if (current - laststart >= linelength) { - newtext->val[current] = breakchar[0]; + ZSTR_VAL(newtext)[current] = breakchar[0]; laststart = current + 1; } lastspace = current; } else if (current - laststart >= linelength && laststart != lastspace) { - newtext->val[lastspace] = breakchar[0]; + ZSTR_VAL(newtext)[lastspace] = breakchar[0]; laststart = lastspace + 1; } } @@ -992,31 +992,31 @@ PHP_FUNCTION(wordwrap) } else { /* Multiple character line break or forced cut */ if (linelength > 0) { - chk = (size_t)(text->len/linelength + 1); - newtext = zend_string_alloc(chk * breakchar_len + text->len, 0); - alloced = text->len + chk * breakchar_len + 1; + chk = (size_t)(ZSTR_LEN(text)/linelength + 1); + newtext = zend_string_alloc(chk * breakchar_len + ZSTR_LEN(text), 0); + alloced = ZSTR_LEN(text) + chk * breakchar_len + 1; } else { - chk = text->len; - alloced = text->len * (breakchar_len + 1) + 1; - newtext = zend_string_alloc(text->len * (breakchar_len + 1), 0); + chk = ZSTR_LEN(text); + alloced = ZSTR_LEN(text) * (breakchar_len + 1) + 1; + newtext = zend_string_alloc(ZSTR_LEN(text) * (breakchar_len + 1), 0); } /* now keep track of the actual new text length */ newtextlen = 0; laststart = lastspace = 0; - for (current = 0; current < text->len; current++) { + for (current = 0; current < ZSTR_LEN(text); current++) { if (chk <= 0) { - alloced += (size_t) (((text->len - current + 1)/linelength + 1) * breakchar_len) + 1; + alloced += (size_t) (((ZSTR_LEN(text) - current + 1)/linelength + 1) * breakchar_len) + 1; newtext = zend_string_extend(newtext, alloced, 0); - chk = (size_t) ((text->len - current)/linelength) + 1; + chk = (size_t) ((ZSTR_LEN(text) - current)/linelength) + 1; } /* when we hit an existing break, copy to new buffer, and * fix up laststart and lastspace */ - if (text->val[current] == breakchar[0] - && current + breakchar_len < text->len - && !strncmp(text->val+current, breakchar, breakchar_len)) { - memcpy(newtext->val + newtextlen, text->val + laststart, current - laststart + breakchar_len); + if (ZSTR_VAL(text)[current] == breakchar[0] + && current + breakchar_len < ZSTR_LEN(text) + && !strncmp(ZSTR_VAL(text) + current, breakchar, breakchar_len)) { + memcpy(ZSTR_VAL(newtext) + newtextlen, ZSTR_VAL(text) + laststart, current - laststart + breakchar_len); newtextlen += current - laststart + breakchar_len; current += breakchar_len - 1; laststart = lastspace = current + 1; @@ -1024,11 +1024,11 @@ PHP_FUNCTION(wordwrap) } /* if it is a space, check if it is at the line boundary, * copy and insert a break, or just keep track of it */ - else if (text->val[current] == ' ') { + else if (ZSTR_VAL(text)[current] == ' ') { if (current - laststart >= linelength) { - memcpy(newtext->val + newtextlen, text->val + laststart, current - laststart); + memcpy(ZSTR_VAL(newtext) + newtextlen, ZSTR_VAL(text) + laststart, current - laststart); newtextlen += current - laststart; - memcpy(newtext->val + newtextlen, breakchar, breakchar_len); + memcpy(ZSTR_VAL(newtext) + newtextlen, breakchar, breakchar_len); newtextlen += breakchar_len; laststart = current + 1; chk--; @@ -1040,9 +1040,9 @@ PHP_FUNCTION(wordwrap) * copy and insert a break. */ else if (current - laststart >= linelength && docut && laststart >= lastspace) { - memcpy(newtext->val + newtextlen, text->val + laststart, current - laststart); + memcpy(ZSTR_VAL(newtext) + newtextlen, ZSTR_VAL(text) + laststart, current - laststart); newtextlen += current - laststart; - memcpy(newtext->val + newtextlen, breakchar, breakchar_len); + memcpy(ZSTR_VAL(newtext) + newtextlen, breakchar, breakchar_len); newtextlen += breakchar_len; laststart = lastspace = current; chk--; @@ -1052,9 +1052,9 @@ PHP_FUNCTION(wordwrap) * up the laststart */ else if (current - laststart >= linelength && laststart < lastspace) { - memcpy(newtext->val + newtextlen, text->val + laststart, lastspace - laststart); + memcpy(ZSTR_VAL(newtext) + newtextlen, ZSTR_VAL(text) + laststart, lastspace - laststart); newtextlen += lastspace - laststart; - memcpy(newtext->val + newtextlen, breakchar, breakchar_len); + memcpy(ZSTR_VAL(newtext) + newtextlen, breakchar, breakchar_len); newtextlen += breakchar_len; laststart = lastspace = lastspace + 1; chk--; @@ -1063,11 +1063,11 @@ PHP_FUNCTION(wordwrap) /* copy over any stragglers */ if (laststart != current) { - memcpy(newtext->val + newtextlen, text->val + laststart, current - laststart); + memcpy(ZSTR_VAL(newtext) + newtextlen, ZSTR_VAL(text) + laststart, current - laststart); newtextlen += current - laststart; } - newtext->val[newtextlen] = '\0'; + ZSTR_VAL(newtext)[newtextlen] = '\0'; /* free unused memory */ newtext = zend_string_truncate(newtext, newtextlen, 0); @@ -1080,9 +1080,9 @@ PHP_FUNCTION(wordwrap) */ PHPAPI void php_explode(const zend_string *delim, zend_string *str, zval *return_value, zend_long limit) { - char *p1 = str->val; - char *endp = str->val + str->len; - char *p2 = (char *) php_memnstr(str->val, delim->val, delim->len, endp); + char *p1 = ZSTR_VAL(str); + char *endp = ZSTR_VAL(str) + ZSTR_LEN(str); + char *p2 = (char *) php_memnstr(ZSTR_VAL(str), ZSTR_VAL(delim), ZSTR_LEN(delim), endp); zval tmp; if (p2 == NULL) { @@ -1092,8 +1092,8 @@ PHPAPI void php_explode(const zend_string *delim, zend_string *str, zval *return do { 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); + p1 = p2 + ZSTR_LEN(delim); + p2 = (char *) php_memnstr(p1, ZSTR_VAL(delim), ZSTR_LEN(delim), endp); } while (p2 != NULL && --limit > 1); if (p1 <= endp) { @@ -1109,9 +1109,9 @@ PHPAPI void php_explode(const zend_string *delim, zend_string *str, zval *return PHPAPI void php_explode_negative_limit(const zend_string *delim, zend_string *str, zval *return_value, zend_long limit) { #define EXPLODE_ALLOC_STEP 64 - char *p1 = str->val; - char *endp = str->val + str->len; - char *p2 = (char *) php_memnstr(str->val, delim->val, delim->len, endp); + char *p1 = ZSTR_VAL(str); + char *endp = ZSTR_VAL(str) + ZSTR_LEN(str); + char *p2 = (char *) php_memnstr(ZSTR_VAL(str), ZSTR_VAL(delim), ZSTR_LEN(delim), endp); zval tmp; if (p2 == NULL) { @@ -1130,14 +1130,14 @@ PHPAPI void php_explode_negative_limit(const zend_string *delim, zend_string *st allocated = found + EXPLODE_ALLOC_STEP;/* make sure we have enough memory */ positions = erealloc(positions, allocated*sizeof(char *)); } - positions[found++] = p1 = p2 + delim->len; - p2 = (char *) php_memnstr(p1, delim->val, delim->len, endp); + positions[found++] = p1 = p2 + ZSTR_LEN(delim); + p2 = (char *) php_memnstr(p1, ZSTR_VAL(delim), ZSTR_LEN(delim), endp); } while (p2 != NULL); 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 */ - ZVAL_STRINGL(&tmp, positions[i], (positions[i+1] - delim->len) - positions[i]); + ZVAL_STRINGL(&tmp, positions[i], (positions[i+1] - ZSTR_LEN(delim)) - positions[i]); zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp); } efree(positions); @@ -1167,14 +1167,14 @@ PHP_FUNCTION(explode) ZEND_PARSE_PARAMETERS_END(); #endif - if (delim->len == 0) { + if (ZSTR_LEN(delim) == 0) { php_error_docref(NULL, E_WARNING, "Empty delimiter"); RETURN_FALSE; } array_init(return_value); - if (str->len == 0) { + if (ZSTR_LEN(str) == 0) { if (limit >= 0) { ZVAL_EMPTY_STRING(&tmp); zend_hash_index_add_new(Z_ARRVAL_P(return_value), 0, &tmp); @@ -1237,18 +1237,18 @@ PHPAPI void php_implode(const zend_string *delim, zval *arr, zval *return_value) } } else { *++strptr = zval_get_string(tmp); - len += (*strptr)->len; + len += ZSTR_LEN(*strptr); } } ZEND_HASH_FOREACH_END(); - str = zend_string_alloc(len + (numelems - 1) * delim->len, 0); - cptr = str->val + str->len; + str = zend_string_alloc(len + (numelems - 1) * ZSTR_LEN(delim), 0); + cptr = ZSTR_VAL(str) + ZSTR_LEN(str); *cptr = 0; do { if (*strptr) { - cptr -= (*strptr)->len; - memcpy(cptr, (*strptr)->val, (*strptr)->len); + cptr -= ZSTR_LEN(*strptr); + memcpy(cptr, ZSTR_VAL(*strptr), ZSTR_LEN(*strptr)); zend_string_release(*strptr); } else { char *oldPtr = cptr; @@ -1258,12 +1258,12 @@ PHPAPI void php_implode(const zend_string *delim, zval *arr, zval *return_value) *oldPtr = oldVal; } - cptr -= delim->len; - memcpy(cptr, delim->val, delim->len); + cptr -= ZSTR_LEN(delim); + memcpy(cptr, ZSTR_VAL(delim), ZSTR_LEN(delim)); } while (--strptr > strings); if (*strptr) { - memcpy(str->val, (*strptr)->val, (*strptr)->len); + memcpy(ZSTR_VAL(str), ZSTR_VAL(*strptr), ZSTR_LEN(*strptr)); zend_string_release(*strptr); } else { char *oldPtr = cptr; @@ -1351,9 +1351,9 @@ PHP_FUNCTION(strtok) tok = str; } else { zval_ptr_dtor(&BG(strtok_zval)); - ZVAL_STRINGL(&BG(strtok_zval), str->val, str->len); + ZVAL_STRINGL(&BG(strtok_zval), ZSTR_VAL(str), ZSTR_LEN(str)); BG(strtok_last) = BG(strtok_string) = Z_STRVAL(BG(strtok_zval)); - BG(strtok_len) = str->len; + BG(strtok_len) = ZSTR_LEN(str); } p = BG(strtok_last); /* Where we start to search */ @@ -1363,8 +1363,8 @@ PHP_FUNCTION(strtok) RETURN_FALSE; } - token = tok->val; - token_end = token + tok->len; + token = ZSTR_VAL(tok); + token_end = token + ZSTR_LEN(tok); while (token < token_end) { STRTOK_TABLE(token++) = 1; @@ -1399,7 +1399,7 @@ return_token: /* Restore table -- usually faster then memset'ing the table on every invocation */ restore: - token = tok->val; + token = ZSTR_VAL(tok); while (token < token_end) { STRTOK_TABLE(token++) = 0; @@ -1430,18 +1430,18 @@ PHPAPI zend_string *php_string_toupper(zend_string *s) { unsigned char *c, *e; - c = (unsigned char *)s->val; - e = c + s->len; + c = (unsigned char *)ZSTR_VAL(s); + e = c + ZSTR_LEN(s); while (c < e) { if (!isupper(*c)) { register unsigned char *r; - zend_string *res = zend_string_alloc(s->len, 0); + zend_string *res = zend_string_alloc(ZSTR_LEN(s), 0); - if (c != (unsigned char*)s->val) { - memcpy(res->val, s->val, c - (unsigned char*)s->val); + if (c != (unsigned char*)ZSTR_VAL(s)) { + memcpy(ZSTR_VAL(res), ZSTR_VAL(s), c - (unsigned char*)ZSTR_VAL(s)); } - r = c + (res->val - s->val); + r = c + (ZSTR_VAL(res) - ZSTR_VAL(s)); while (c < e) { *r = toupper(*c); r++; @@ -1499,18 +1499,18 @@ PHPAPI zend_string *php_string_tolower(zend_string *s) { unsigned char *c, *e; - c = (unsigned char *)s->val; - e = c + s->len; + c = (unsigned char *)ZSTR_VAL(s); + e = c + ZSTR_LEN(s); while (c < e) { if (!islower(*c)) { register unsigned char *r; - zend_string *res = zend_string_alloc(s->len, 0); + zend_string *res = zend_string_alloc(ZSTR_LEN(s), 0); - if (c != (unsigned char*)s->val) { - memcpy(res->val, s->val, c - (unsigned char*)s->val); + if (c != (unsigned char*)ZSTR_VAL(s)) { + memcpy(ZSTR_VAL(res), ZSTR_VAL(s), c - (unsigned char*)ZSTR_VAL(s)); } - r = c + (res->val - s->val); + r = c + (ZSTR_VAL(res) - ZSTR_VAL(s)); while (c < e) { *r = tolower(*c); r++; @@ -1661,7 +1661,7 @@ PHP_FUNCTION(dirname) } ret = zend_string_init(str, str_len, 0); - ret->len = zend_dirname(ret->val, str_len); + ZSTR_LEN(ret) = zend_dirname(ZSTR_VAL(ret), str_len); RETURN_NEW_STR(ret); } @@ -1708,11 +1708,11 @@ PHP_FUNCTION(pathinfo) ret = php_basename(path, path_len, NULL, 0); } - p = zend_memrchr(ret->val, '.', ret->len); + p = zend_memrchr(ZSTR_VAL(ret), '.', ZSTR_LEN(ret)); if (p) { - idx = p - ret->val; - add_assoc_stringl(&tmp, "extension", ret->val + idx + 1, ret->len - idx - 1); + idx = p - ZSTR_VAL(ret); + add_assoc_stringl(&tmp, "extension", ZSTR_VAL(ret) + idx + 1, ZSTR_LEN(ret) - idx - 1); } } @@ -1725,10 +1725,10 @@ PHP_FUNCTION(pathinfo) ret = php_basename(path, path_len, NULL, 0); } - p = zend_memrchr(ret->val, '.', ret->len); + p = zend_memrchr(ZSTR_VAL(ret), '.', ZSTR_LEN(ret)); - idx = p ? (p - ret->val) : ret->len; - add_assoc_stringl(&tmp, "filename", ret->val, idx); + idx = p ? (p - ZSTR_VAL(ret)) : ZSTR_LEN(ret); + add_assoc_stringl(&tmp, "filename", ZSTR_VAL(ret), idx); } if (ret) { @@ -1842,7 +1842,7 @@ PHP_FUNCTION(stristr) return; } - haystack_dup = estrndup(haystack->val, haystack->len); + haystack_dup = estrndup(ZSTR_VAL(haystack), ZSTR_LEN(haystack)); if (Z_TYPE_P(needle) == IS_STRING) { char *orig_needle; @@ -1852,7 +1852,7 @@ PHP_FUNCTION(stristr) RETURN_FALSE; } orig_needle = estrndup(Z_STRVAL_P(needle), Z_STRLEN_P(needle)); - found = php_stristr(haystack_dup, orig_needle, haystack->len, Z_STRLEN_P(needle)); + found = php_stristr(haystack_dup, orig_needle, ZSTR_LEN(haystack), Z_STRLEN_P(needle)); efree(orig_needle); } else { if (php_needle_char(needle, needle_char) != SUCCESS) { @@ -1861,15 +1861,15 @@ PHP_FUNCTION(stristr) } needle_char[1] = 0; - found = php_stristr(haystack_dup, needle_char, haystack->len, 1); + found = php_stristr(haystack_dup, needle_char, ZSTR_LEN(haystack), 1); } if (found) { found_offset = found - haystack_dup; if (part) { - RETVAL_STRINGL(haystack->val, found_offset); + RETVAL_STRINGL(ZSTR_VAL(haystack), found_offset); } else { - RETVAL_STRINGL(haystack->val + found_offset, haystack->len - found_offset); + RETVAL_STRINGL(ZSTR_VAL(haystack) + found_offset, ZSTR_LEN(haystack) - found_offset); } } else { RETVAL_FALSE; @@ -1900,22 +1900,22 @@ PHP_FUNCTION(strstr) RETURN_FALSE; } - found = (char*)php_memnstr(haystack->val, Z_STRVAL_P(needle), Z_STRLEN_P(needle), haystack->val + haystack->len); + found = (char*)php_memnstr(ZSTR_VAL(haystack), Z_STRVAL_P(needle), Z_STRLEN_P(needle), ZSTR_VAL(haystack) + ZSTR_LEN(haystack)); } else { if (php_needle_char(needle, needle_char) != SUCCESS) { RETURN_FALSE; } needle_char[1] = 0; - found = (char*)php_memnstr(haystack->val, needle_char, 1, haystack->val + haystack->len); + found = (char*)php_memnstr(ZSTR_VAL(haystack), needle_char, 1, ZSTR_VAL(haystack) + ZSTR_LEN(haystack)); } if (found) { - found_offset = found - haystack->val; + found_offset = found - ZSTR_VAL(haystack); if (part) { - RETURN_STRINGL(haystack->val, found_offset); + RETURN_STRINGL(ZSTR_VAL(haystack), found_offset); } else { - RETURN_STRINGL(found, haystack->len - found_offset); + RETURN_STRINGL(found, ZSTR_LEN(haystack) - found_offset); } } RETURN_FALSE; @@ -1949,7 +1949,7 @@ PHP_FUNCTION(strpos) ZEND_PARSE_PARAMETERS_END(); #endif - if (offset < 0 || (size_t)offset > haystack->len) { + if (offset < 0 || (size_t)offset > ZSTR_LEN(haystack)) { php_error_docref(NULL, E_WARNING, "Offset not contained in string"); RETURN_FALSE; } @@ -1960,24 +1960,24 @@ PHP_FUNCTION(strpos) RETURN_FALSE; } - found = (char*)php_memnstr(haystack->val + offset, + found = (char*)php_memnstr(ZSTR_VAL(haystack) + offset, Z_STRVAL_P(needle), Z_STRLEN_P(needle), - haystack->val + haystack->len); + ZSTR_VAL(haystack) + ZSTR_LEN(haystack)); } else { if (php_needle_char(needle, needle_char) != SUCCESS) { RETURN_FALSE; } needle_char[1] = 0; - found = (char*)php_memnstr(haystack->val + offset, + found = (char*)php_memnstr(ZSTR_VAL(haystack) + offset, needle_char, 1, - haystack->val + haystack->len); + ZSTR_VAL(haystack) + ZSTR_LEN(haystack)); } if (found) { - RETURN_LONG(found - haystack->val); + RETURN_LONG(found - ZSTR_VAL(haystack)); } else { RETURN_FALSE; } @@ -1999,24 +1999,24 @@ PHP_FUNCTION(stripos) return; } - if (offset < 0 || (size_t)offset > haystack->len) { + if (offset < 0 || (size_t)offset > ZSTR_LEN(haystack)) { php_error_docref(NULL, E_WARNING, "Offset not contained in string"); RETURN_FALSE; } - if (haystack->len == 0) { + if (ZSTR_LEN(haystack) == 0) { RETURN_FALSE; } if (Z_TYPE_P(needle) == IS_STRING) { - if (Z_STRLEN_P(needle) == 0 || Z_STRLEN_P(needle) > haystack->len) { + if (Z_STRLEN_P(needle) == 0 || Z_STRLEN_P(needle) > ZSTR_LEN(haystack)) { RETURN_FALSE; } haystack_dup = php_string_tolower(haystack); needle_dup = php_string_tolower(Z_STR_P(needle)); - found = (char*)php_memnstr(haystack_dup->val + offset, - needle_dup->val, needle_dup->len, haystack_dup->val + haystack->len); + found = (char*)php_memnstr(ZSTR_VAL(haystack_dup) + offset, + ZSTR_VAL(needle_dup), ZSTR_LEN(needle_dup), ZSTR_VAL(haystack_dup) + ZSTR_LEN(haystack)); } else { if (php_needle_char(needle, needle_char) != SUCCESS) { RETURN_FALSE; @@ -2024,15 +2024,15 @@ PHP_FUNCTION(stripos) haystack_dup = php_string_tolower(haystack); needle_char[0] = tolower(needle_char[0]); needle_char[1] = '\0'; - found = (char*)php_memnstr(haystack_dup->val + offset, + found = (char*)php_memnstr(ZSTR_VAL(haystack_dup) + offset, needle_char, sizeof(needle_char) - 1, - haystack_dup->val + haystack->len); + ZSTR_VAL(haystack_dup) + ZSTR_LEN(haystack)); } if (found) { - RETVAL_LONG(found - haystack_dup->val); + RETVAL_LONG(found - ZSTR_VAL(haystack_dup)); } else { RETVAL_FALSE; } @@ -2081,32 +2081,32 @@ PHP_FUNCTION(strrpos) needle_len = 1; } - if ((haystack->len == 0) || (needle_len == 0)) { + if ((ZSTR_LEN(haystack) == 0) || (needle_len == 0)) { RETURN_FALSE; } if (offset >= 0) { - if ((size_t)offset > haystack->len) { + if ((size_t)offset > ZSTR_LEN(haystack)) { php_error_docref(NULL, E_WARNING, "Offset is greater than the length of haystack string"); RETURN_FALSE; } - p = haystack->val + (size_t)offset; - e = haystack->val + haystack->len; + p = ZSTR_VAL(haystack) + (size_t)offset; + e = ZSTR_VAL(haystack) + ZSTR_LEN(haystack); } else { - if (offset < -INT_MAX || (size_t)(-offset) > haystack->len) { + if (offset < -INT_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) { php_error_docref(NULL, E_WARNING, "Offset is greater than the length of haystack string"); RETURN_FALSE; } - p = haystack->val; + p = ZSTR_VAL(haystack); if (-offset < needle_len) { - e = haystack->val + haystack->len; + e = ZSTR_VAL(haystack) + ZSTR_LEN(haystack); } else { - e = haystack->val + haystack->len + offset + needle_len; + e = ZSTR_VAL(haystack) + ZSTR_LEN(haystack) + offset + needle_len; } } if ((found = (char *)zend_memnrstr(p, needle, needle_len, e))) { - RETURN_LONG(found - haystack->val); + RETURN_LONG(found - ZSTR_VAL(haystack)); } RETURN_FALSE; @@ -2135,43 +2135,43 @@ PHP_FUNCTION(strripos) if (Z_TYPE_P(zneedle) == IS_STRING) { needle = Z_STR_P(zneedle); } else { - if (php_needle_char(zneedle, ord_needle->val) != SUCCESS) { + if (php_needle_char(zneedle, ZSTR_VAL(ord_needle)) != SUCCESS) { ZSTR_ALLOCA_FREE(ord_needle, use_heap); RETURN_FALSE; } - ord_needle->val[1] = '\0'; + ZSTR_VAL(ord_needle)[1] = '\0'; needle = ord_needle; } - if ((haystack->len == 0) || (needle->len == 0)) { + if ((ZSTR_LEN(haystack) == 0) || (ZSTR_LEN(needle) == 0)) { ZSTR_ALLOCA_FREE(ord_needle, use_heap); RETURN_FALSE; } - if (needle->len == 1) { + if (ZSTR_LEN(needle) == 1) { /* Single character search can shortcut memcmps Can also avoid tolower emallocs */ if (offset >= 0) { - if ((size_t)offset > haystack->len) { + if ((size_t)offset > ZSTR_LEN(haystack)) { ZSTR_ALLOCA_FREE(ord_needle, use_heap); php_error_docref(NULL, E_WARNING, "Offset is greater than the length of haystack string"); RETURN_FALSE; } - p = haystack->val + (size_t)offset; - e = haystack->val + haystack->len - 1; + p = ZSTR_VAL(haystack) + (size_t)offset; + e = ZSTR_VAL(haystack) + ZSTR_LEN(haystack) - 1; } else { - p = haystack->val; - if (offset < -INT_MAX || (size_t)(-offset) > haystack->len) { + p = ZSTR_VAL(haystack); + if (offset < -INT_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) { ZSTR_ALLOCA_FREE(ord_needle, use_heap); php_error_docref(NULL, E_WARNING, "Offset is greater than the length of haystack string"); RETURN_FALSE; } - e = haystack->val + haystack->len + (size_t)offset; + e = ZSTR_VAL(haystack) + ZSTR_LEN(haystack) + (size_t)offset; } /* Borrow that ord_needle buffer to avoid repeatedly tolower()ing needle */ - *ord_needle->val = tolower(*needle->val); + *ZSTR_VAL(ord_needle) = tolower(*ZSTR_VAL(needle)); while (e >= p) { - if (tolower(*e) == *ord_needle->val) { + if (tolower(*e) == *ZSTR_VAL(ord_needle)) { ZSTR_ALLOCA_FREE(ord_needle, use_heap); RETURN_LONG(e - p + (offset > 0 ? offset : 0)); } @@ -2183,32 +2183,32 @@ PHP_FUNCTION(strripos) haystack_dup = php_string_tolower(haystack); if (offset >= 0) { - if ((size_t)offset > haystack->len) { + if ((size_t)offset > ZSTR_LEN(haystack)) { zend_string_release(haystack_dup); ZSTR_ALLOCA_FREE(ord_needle, use_heap); php_error_docref(NULL, E_WARNING, "Offset is greater than the length of haystack string"); RETURN_FALSE; } - p = haystack_dup->val + offset; - e = haystack_dup->val + haystack->len; + p = ZSTR_VAL(haystack_dup) + offset; + e = ZSTR_VAL(haystack_dup) + ZSTR_LEN(haystack); } else { - if (offset < -INT_MAX || (size_t)(-offset) > haystack->len) { + if (offset < -INT_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) { zend_string_release(haystack_dup); ZSTR_ALLOCA_FREE(ord_needle, use_heap); php_error_docref(NULL, E_WARNING, "Offset is greater than the length of haystack string"); RETURN_FALSE; } - p = haystack_dup->val; - if (-offset < needle->len) { - e = haystack_dup->val + haystack->len; + p = ZSTR_VAL(haystack_dup); + if (-offset < ZSTR_LEN(needle)) { + e = ZSTR_VAL(haystack_dup) + ZSTR_LEN(haystack); } else { - e = haystack_dup->val + haystack->len + offset + needle->len; + e = ZSTR_VAL(haystack_dup) + ZSTR_LEN(haystack) + offset + ZSTR_LEN(needle); } } needle_dup = php_string_tolower(needle); - if ((found = (char *)zend_memnrstr(p, needle_dup->val, needle_dup->len, e))) { - RETVAL_LONG(found - haystack_dup->val); + if ((found = (char *)zend_memnrstr(p, ZSTR_VAL(needle_dup), ZSTR_LEN(needle_dup), e))) { + RETVAL_LONG(found - ZSTR_VAL(haystack_dup)); zend_string_release(needle_dup); zend_string_release(haystack_dup); ZSTR_ALLOCA_FREE(ord_needle, use_heap); @@ -2235,19 +2235,19 @@ PHP_FUNCTION(strrchr) } if (Z_TYPE_P(needle) == IS_STRING) { - found = zend_memrchr(haystack->val, *Z_STRVAL_P(needle), haystack->len); + found = zend_memrchr(ZSTR_VAL(haystack), *Z_STRVAL_P(needle), ZSTR_LEN(haystack)); } else { char needle_chr; if (php_needle_char(needle, &needle_chr) != SUCCESS) { RETURN_FALSE; } - found = zend_memrchr(haystack->val, needle_chr, haystack->len); + found = zend_memrchr(ZSTR_VAL(haystack), needle_chr, ZSTR_LEN(haystack)); } if (found) { - found_offset = found - haystack->val; - RETURN_STRINGL(found, haystack->len - found_offset); + found_offset = found - ZSTR_VAL(haystack); + RETURN_STRINGL(found, ZSTR_LEN(haystack) - found_offset); } else { RETURN_FALSE; } @@ -2282,7 +2282,7 @@ static zend_string *php_chunk_split(char *src, size_t srclen, char *end, size_t dest = zend_string_alloc(out_len * sizeof(char), 0); - for (p = src, q = dest->val; p < (src + srclen - chunklen + 1); ) { + for (p = src, q = ZSTR_VAL(dest); p < (src + srclen - chunklen + 1); ) { memcpy(q, p, chunklen); q += chunklen; memcpy(q, end, endlen); @@ -2298,7 +2298,7 @@ static zend_string *php_chunk_split(char *src, size_t srclen, char *end, size_t } *q = '\0'; - dest->len = q - dest->val; + ZSTR_LEN(dest) = q - ZSTR_VAL(dest); return dest; } @@ -2323,20 +2323,20 @@ PHP_FUNCTION(chunk_split) RETURN_FALSE; } - if ((size_t)chunklen > str->len) { + if ((size_t)chunklen > ZSTR_LEN(str)) { /* to maintain BC, we must return original string + ending */ - result = zend_string_alloc(endlen + str->len, 0); - memcpy(result->val, str->val, str->len); - memcpy(result->val + str->len, end, endlen); - result->val[result->len] = '\0'; + result = zend_string_alloc(endlen + ZSTR_LEN(str), 0); + memcpy(ZSTR_VAL(result), ZSTR_VAL(str), ZSTR_LEN(str)); + memcpy(ZSTR_VAL(result) + ZSTR_LEN(str), end, endlen); + ZSTR_VAL(result)[ZSTR_LEN(result)] = '\0'; RETURN_NEW_STR(result); } - if (!str->len) { + if (!ZSTR_LEN(str)) { RETURN_EMPTY_STRING(); } - result = php_chunk_split(str->val, str->len, end, endlen, (size_t)chunklen); + result = php_chunk_split(ZSTR_VAL(str), ZSTR_LEN(str), end, endlen, (size_t)chunklen); if (result) { RETURN_STR(result); @@ -2368,22 +2368,22 @@ PHP_FUNCTION(substr) #endif if (argc > 2) { - if ((l < 0 && (size_t)(-l) > str->len)) { + if ((l < 0 && (size_t)(-l) > ZSTR_LEN(str))) { RETURN_FALSE; - } else if (l > (zend_long)str->len) { - l = str->len; + } else if (l > (zend_long)ZSTR_LEN(str)) { + l = ZSTR_LEN(str); } } else { - l = str->len; + l = ZSTR_LEN(str); } - if (f > (zend_long)str->len) { + if (f > (zend_long)ZSTR_LEN(str)) { RETURN_FALSE; - } else if (f < 0 && -f > str->len) { + } else if (f < 0 && -f > ZSTR_LEN(str)) { f = 0; } - if (l < 0 && (l + (zend_long)str->len - f) < 0) { + if (l < 0 && (l + (zend_long)ZSTR_LEN(str) - f) < 0) { RETURN_FALSE; } @@ -2391,7 +2391,7 @@ PHP_FUNCTION(substr) * of the string */ if (f < 0) { - f = (zend_long)str->len + f; + f = (zend_long)ZSTR_LEN(str) + f; if (f < 0) { f = 0; } @@ -2401,21 +2401,21 @@ PHP_FUNCTION(substr) * needed to stop that many chars from the end of the string */ if (l < 0) { - l = ((zend_long)str->len - f) + l; + l = ((zend_long)ZSTR_LEN(str) - f) + l; if (l < 0) { l = 0; } } - if (f > (zend_long)str->len) { + if (f > (zend_long)ZSTR_LEN(str)) { RETURN_FALSE; } - if ((f + l) > (zend_long)str->len) { - l = str->len - f; + if ((f + l) > (zend_long)ZSTR_LEN(str)) { + l = ZSTR_LEN(str) - f; } - RETURN_STRINGL(str->val + f, l); + RETURN_STRINGL(ZSTR_VAL(str) + f, l); } /* }}} */ @@ -2527,12 +2527,12 @@ PHP_FUNCTION(substr_replace) result = zend_string_alloc(Z_STRLEN_P(str) - l + repl_len, 0); - memcpy(result->val, Z_STRVAL_P(str), f); + memcpy(ZSTR_VAL(result), Z_STRVAL_P(str), f); if (repl_len) { - memcpy((result->val + f), (Z_TYPE_P(repl) == IS_ARRAY ? Z_STRVAL_P(tmp_repl) : Z_STRVAL_P(repl)), repl_len); + memcpy((ZSTR_VAL(result) + f), (Z_TYPE_P(repl) == IS_ARRAY ? Z_STRVAL_P(tmp_repl) : Z_STRVAL_P(repl)), repl_len); } - memcpy((result->val + f + repl_len), Z_STRVAL_P(str) + f + l, Z_STRLEN_P(str) - f - l); - result->val[result->len] = '\0'; + memcpy((ZSTR_VAL(result) + f + repl_len), Z_STRVAL_P(str) + f + l, Z_STRLEN_P(str) - f - l); + ZSTR_VAL(result)[ZSTR_LEN(result)] = '\0'; RETURN_NEW_STR(result); } else { php_error_docref(NULL, E_WARNING, "Functionality of 'from' and 'len' as arrays is not implemented"); @@ -2562,12 +2562,12 @@ PHP_FUNCTION(substr_replace) f = zval_get_long(tmp_from); if (f < 0) { - f = (zend_long)orig_str->len + f; + f = (zend_long)ZSTR_LEN(orig_str) + f; if (f < 0) { f = 0; } - } else if (f > (zend_long)orig_str->len) { - f = orig_str->len; + } else if (f > (zend_long)ZSTR_LEN(orig_str)) { + f = ZSTR_LEN(orig_str); } from_idx++; } else { @@ -2576,12 +2576,12 @@ PHP_FUNCTION(substr_replace) } else { f = Z_LVAL_P(from); if (f < 0) { - f = (zend_long)orig_str->len + f; + f = (zend_long)ZSTR_LEN(orig_str) + f; if (f < 0) { f = 0; } - } else if (f > (zend_long)orig_str->len) { - f = orig_str->len; + } else if (f > (zend_long)ZSTR_LEN(orig_str)) { + f = ZSTR_LEN(orig_str); } } @@ -2597,26 +2597,26 @@ PHP_FUNCTION(substr_replace) l = zval_get_long(tmp_len); len_idx++; } else { - l = orig_str->len; + l = ZSTR_LEN(orig_str); } } else if (argc > 3) { l = Z_LVAL_P(len); } else { - l = orig_str->len; + l = ZSTR_LEN(orig_str); } if (l < 0) { - l = (orig_str->len - f) + l; + l = (ZSTR_LEN(orig_str) - f) + l; if (l < 0) { l = 0; } } - if ((f + l) > (zend_long)orig_str->len) { - l = orig_str->len - f; + if ((f + l) > (zend_long)ZSTR_LEN(orig_str)) { + l = ZSTR_LEN(orig_str) - f; } - result_len = orig_str->len - l; + result_len = ZSTR_LEN(orig_str) - l; if (Z_TYPE_P(repl) == IS_ARRAY) { while (repl_idx < Z_ARRVAL_P(repl)->nNumUsed) { @@ -2629,31 +2629,31 @@ PHP_FUNCTION(substr_replace) if (repl_idx < Z_ARRVAL_P(repl)->nNumUsed) { zend_string *repl_str = zval_get_string(tmp_repl); - result_len += repl_str->len; + result_len += ZSTR_LEN(repl_str); repl_idx++; result = zend_string_alloc(result_len, 0); - memcpy(result->val, orig_str->val, f); - memcpy((result->val + f), repl_str->val, repl_str->len); - memcpy((result->val + f + repl_str->len), orig_str->val + f + l, orig_str->len - f - l); + memcpy(ZSTR_VAL(result), ZSTR_VAL(orig_str), f); + memcpy((ZSTR_VAL(result) + f), ZSTR_VAL(repl_str), ZSTR_LEN(repl_str)); + memcpy((ZSTR_VAL(result) + f + ZSTR_LEN(repl_str)), ZSTR_VAL(orig_str) + f + l, ZSTR_LEN(orig_str) - f - l); zend_string_release(repl_str); } else { result = zend_string_alloc(result_len, 0); - memcpy(result->val, orig_str->val, f); - memcpy((result->val + f), orig_str->val + f + l, orig_str->len - f - l); + memcpy(ZSTR_VAL(result), ZSTR_VAL(orig_str), f); + memcpy((ZSTR_VAL(result) + f), ZSTR_VAL(orig_str) + f + l, ZSTR_LEN(orig_str) - f - l); } } else { result_len += Z_STRLEN_P(repl); result = zend_string_alloc(result_len, 0); - memcpy(result->val, orig_str->val, f); - memcpy((result->val + f), Z_STRVAL_P(repl), Z_STRLEN_P(repl)); - memcpy((result->val + f + Z_STRLEN_P(repl)), orig_str->val + f + l, orig_str->len - f - l); + memcpy(ZSTR_VAL(result), ZSTR_VAL(orig_str), f); + memcpy((ZSTR_VAL(result) + f), Z_STRVAL_P(repl), Z_STRLEN_P(repl)); + memcpy((ZSTR_VAL(result) + f + Z_STRLEN_P(repl)), ZSTR_VAL(orig_str) + f + l, ZSTR_LEN(orig_str) - f - l); } - result->val[result->len] = '\0'; + ZSTR_VAL(result)[ZSTR_LEN(result)] = '\0'; if (str_index) { zval tmp; @@ -2684,15 +2684,15 @@ PHP_FUNCTION(quotemeta) return; } - old_end = old->val + old->len; + old_end = ZSTR_VAL(old) + ZSTR_LEN(old); - if (old->val == old_end) { + if (ZSTR_VAL(old) == old_end) { RETURN_FALSE; } - str = zend_string_alloc(2 * old->len, 0); + str = zend_string_alloc(2 * ZSTR_LEN(old), 0); - for (p = old->val, q = str->val; p != old_end; p++) { + for (p = ZSTR_VAL(old), q = ZSTR_VAL(str); p != old_end; p++) { c = *p; switch (c) { case '.': @@ -2715,7 +2715,7 @@ PHP_FUNCTION(quotemeta) *q = '\0'; - RETURN_NEW_STR(zend_string_truncate(str, q - str->val, 0)); + RETURN_NEW_STR(zend_string_truncate(str, q - ZSTR_VAL(str), 0)); } /* }}} */ @@ -2797,11 +2797,11 @@ PHP_FUNCTION(ucfirst) ZEND_PARSE_PARAMETERS_END(); #endif - if (!str->len) { + if (!ZSTR_LEN(str)) { RETURN_EMPTY_STRING(); } - ZVAL_STRINGL(return_value, str->val, str->len); + ZVAL_STRINGL(return_value, ZSTR_VAL(str), ZSTR_LEN(str)); php_ucfirst(Z_STRVAL_P(return_value)); } /* }}} */ @@ -2826,11 +2826,11 @@ PHP_FUNCTION(lcfirst) return; } - if (!str->len) { + if (!ZSTR_LEN(str)) { RETURN_EMPTY_STRING(); } - ZVAL_STRINGL(return_value, str->val, str->len); + ZVAL_STRINGL(return_value, ZSTR_VAL(str), ZSTR_LEN(str)); php_lcfirst(Z_STRVAL_P(return_value)); } /* }}} */ @@ -2857,13 +2857,13 @@ PHP_FUNCTION(ucwords) ZEND_PARSE_PARAMETERS_END(); #endif - if (!str->len) { + if (!ZSTR_LEN(str)) { RETURN_EMPTY_STRING(); } php_charmask((unsigned char *)delims, delims_len, mask); - ZVAL_STRINGL(return_value, str->val, str->len); + ZVAL_STRINGL(return_value, ZSTR_VAL(str), ZSTR_LEN(str)); r = Z_STRVAL_P(return_value); *r = toupper((unsigned char) *r); @@ -2923,16 +2923,16 @@ static zend_string *php_strtr_ex(zend_string *str, char *str_from, char *str_to, char ch_from = *str_from; char ch_to = *str_to; - for (i = 0; i < str->len; i++) { - if (str->val[i] == ch_from) { - new_str = zend_string_alloc(str->len, 0); - memcpy(new_str->val, str->val, i); - new_str->val[i] = ch_to; + for (i = 0; i < ZSTR_LEN(str); i++) { + if (ZSTR_VAL(str)[i] == ch_from) { + new_str = zend_string_alloc(ZSTR_LEN(str), 0); + memcpy(ZSTR_VAL(new_str), ZSTR_VAL(str), i); + ZSTR_VAL(new_str)[i] = ch_to; break; } } - for (; i < str->len; i++) { - new_str->val[i] = (str->val[i] != ch_from) ? str->val[i] : ch_to; + for (; i < ZSTR_LEN(str); i++) { + ZSTR_VAL(new_str)[i] = (ZSTR_VAL(str)[i] != ch_from) ? ZSTR_VAL(str)[i] : ch_to; } } else { unsigned char xlat[256], j = 0; @@ -2943,17 +2943,17 @@ static zend_string *php_strtr_ex(zend_string *str, char *str_from, char *str_to, xlat[(size_t)(unsigned char) str_from[i]] = str_to[i]; } - for (i = 0; i < str->len; i++) { - if (str->val[i] != xlat[(size_t)(unsigned char) str->val[i]]) { - new_str = zend_string_alloc(str->len, 0); - memcpy(new_str->val, str->val, i); - new_str->val[i] = xlat[(size_t)(unsigned char) str->val[i]]; + for (i = 0; i < ZSTR_LEN(str); i++) { + if (ZSTR_VAL(str)[i] != xlat[(size_t)(unsigned char) ZSTR_VAL(str)[i]]) { + new_str = zend_string_alloc(ZSTR_LEN(str), 0); + memcpy(ZSTR_VAL(new_str), ZSTR_VAL(str), i); + ZSTR_VAL(new_str)[i] = xlat[(size_t)(unsigned char) ZSTR_VAL(str)[i]]; break; } } - for (;i < str->len; i++) { - new_str->val[i] = xlat[(size_t)(unsigned char) str->val[i]]; + for (;i < ZSTR_LEN(str); i++) { + ZSTR_VAL(new_str)[i] = xlat[(size_t)(unsigned char) ZSTR_VAL(str)[i]]; } } @@ -2961,7 +2961,7 @@ static zend_string *php_strtr_ex(zend_string *str, char *str_from, char *str_to, return zend_string_copy(str); } - new_str->val[new_str->len] = 0; + ZSTR_VAL(new_str)[ZSTR_LEN(new_str)] = 0; return new_str; } /* }}} */ @@ -2978,8 +2978,8 @@ static int php_strtr_key_compare(const void *a, const void *b) /* {{{ */ /* {{{ php_strtr_array */ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *pats) { - char *str = input->val; - size_t slen = input->len; + char *str = ZSTR_VAL(input); + size_t slen = ZSTR_LEN(input); zend_ulong num_key; zend_string *str_key; size_t len, pos, old_pos; @@ -3002,7 +3002,7 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p if (UNEXPECTED(!str_key)) { num_keys = 1; } else { - len = str_key->len; + len = ZSTR_LEN(str_key); if (UNEXPECTED(len < 1)) { RETURN_FALSE; } else if (UNEXPECTED(len > slen)) { @@ -3017,7 +3017,7 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p } /* remember possible key length */ num_bitset[len / sizeof(zend_ulong)] |= Z_UL(1) << (len % sizeof(zend_ulong)); - bitset[((unsigned char)str_key->val[0]) / sizeof(zend_ulong)] |= Z_UL(1) << (((unsigned char)str_key->val[0]) % sizeof(zend_ulong)); + bitset[((unsigned char)ZSTR_VAL(str_key)[0]) / sizeof(zend_ulong)] |= Z_UL(1) << (((unsigned char)ZSTR_VAL(str_key)[0]) % sizeof(zend_ulong)); } } ZEND_HASH_FOREACH_END(); @@ -3028,7 +3028,7 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p ZEND_HASH_FOREACH_KEY_VAL(pats, num_key, str_key, entry) { if (UNEXPECTED(!str_key)) { key_used = zend_long_to_str(num_key); - len = key_used->len; + len = ZSTR_LEN(key_used); if (UNEXPECTED(len > slen)) { /* skip long patterns */ continue; @@ -3041,10 +3041,10 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p } /* remember possible key length */ num_bitset[len / sizeof(zend_ulong)] |= Z_UL(1) << (len % sizeof(zend_ulong)); - bitset[((unsigned char)key_used->val[0]) / sizeof(zend_ulong)] |= Z_UL(1) << (((unsigned char)key_used->val[0]) % sizeof(zend_ulong)); + bitset[((unsigned char)ZSTR_VAL(key_used)[0]) / sizeof(zend_ulong)] |= Z_UL(1) << (((unsigned char)ZSTR_VAL(key_used)[0]) % sizeof(zend_ulong)); } else { key_used = str_key; - len = key_used->len; + len = ZSTR_LEN(key_used); if (UNEXPECTED(len > slen)) { /* skip long patterns */ continue; @@ -3117,17 +3117,17 @@ static zend_string* php_char_to_str_ex(zend_string *str, char from, char *to, si zend_string *result; size_t char_count = 0; char lc_from = 0; - char *source, *target, *source_end= str->val + str->len; + char *source, *target, *source_end= ZSTR_VAL(str) + ZSTR_LEN(str); if (case_sensitivity) { - char *p = str->val, *e = p + str->len; + char *p = ZSTR_VAL(str), *e = p + ZSTR_LEN(str); while ((p = memchr(p, from, (e - p)))) { char_count++; p++; } } else { lc_from = tolower(from); - for (source = str->val; source < source_end; source++) { + for (source = ZSTR_VAL(str); source < source_end; source++) { if (tolower(*source) == lc_from) { char_count++; } @@ -3139,14 +3139,14 @@ static zend_string* php_char_to_str_ex(zend_string *str, char from, char *to, si } if (to_len > 0) { - result = zend_string_safe_alloc(char_count, to_len - 1, str->len, 0); + result = zend_string_safe_alloc(char_count, to_len - 1, ZSTR_LEN(str), 0); } else { - result = zend_string_alloc(str->len - char_count, 0); + result = zend_string_alloc(ZSTR_LEN(str) - char_count, 0); } - target = result->val; + target = ZSTR_VAL(result); if (case_sensitivity) { - char *p = str->val, *e = p + str->len, *s = str->val; + char *p = ZSTR_VAL(str), *e = p + ZSTR_LEN(str), *s = ZSTR_VAL(str); while ((p = memchr(p, from, (e - p)))) { memcpy(target, s, (p - s)); target += p - s; @@ -3163,7 +3163,7 @@ static zend_string* php_char_to_str_ex(zend_string *str, char from, char *to, si target += e - s; } } else { - for (source = str->val; source < source_end; source++) { + for (source = ZSTR_VAL(str); source < source_end; source++) { if (tolower(*source) == lc_from) { if (replace_count) { *replace_count += 1; @@ -3188,18 +3188,18 @@ static zend_string *php_str_to_str_ex(zend_string *haystack, { zend_string *new_str; - if (needle_len < haystack->len) { + if (needle_len < ZSTR_LEN(haystack)) { char *end; char *e, *s, *p, *r; if (needle_len == str_len) { new_str = NULL; - end = haystack->val + haystack->len; - for (p = haystack->val; (r = (char*)php_memnstr(p, needle, needle_len, end)); p = r + needle_len) { + end = ZSTR_VAL(haystack) + ZSTR_LEN(haystack); + for (p = ZSTR_VAL(haystack); (r = (char*)php_memnstr(p, needle, needle_len, end)); p = r + needle_len) { if (!new_str) { - new_str = zend_string_init(haystack->val, haystack->len, 0); + new_str = zend_string_init(ZSTR_VAL(haystack), ZSTR_LEN(haystack), 0); } - memcpy(new_str->val + (r - haystack->val), str, str_len); + memcpy(ZSTR_VAL(new_str) + (r - ZSTR_VAL(haystack)), str, str_len); (*replace_count)++; } if (!new_str) { @@ -3208,9 +3208,9 @@ static zend_string *php_str_to_str_ex(zend_string *haystack, return new_str; } else { size_t count = 0; - char *o = haystack->val; + char *o = ZSTR_VAL(haystack); char *n = needle; - char *endp = o + haystack->len; + char *endp = o + ZSTR_LEN(haystack); while ((o = (char*)php_memnstr(o, n, needle_len, endp))) { o += needle_len; @@ -3220,11 +3220,11 @@ static zend_string *php_str_to_str_ex(zend_string *haystack, /* Needle doesn't occur, shortcircuit the actual replacement. */ goto nothing_todo; } - new_str = zend_string_alloc(count * (str_len - needle_len) + haystack->len, 0); + new_str = zend_string_alloc(count * (str_len - needle_len) + ZSTR_LEN(haystack), 0); - e = s = new_str->val; - end = haystack->val + haystack->len; - for (p = haystack->val; (r = (char*)php_memnstr(p, needle, needle_len, end)); p = r + needle_len) { + e = s = ZSTR_VAL(new_str); + end = ZSTR_VAL(haystack) + ZSTR_LEN(haystack); + for (p = ZSTR_VAL(haystack); (r = (char*)php_memnstr(p, needle, needle_len, end)); p = r + needle_len) { memcpy(e, p, r - p); e += r - p; memcpy(e, str, str_len); @@ -3240,7 +3240,7 @@ static zend_string *php_str_to_str_ex(zend_string *haystack, *e = '\0'; return new_str; } - } else if (needle_len > haystack->len || memcmp(haystack->val, needle, haystack->len)) { + } else if (needle_len > ZSTR_LEN(haystack) || memcmp(ZSTR_VAL(haystack), needle, ZSTR_LEN(haystack))) { nothing_todo: return zend_string_copy(haystack); } else { @@ -3259,18 +3259,18 @@ static zend_string *php_str_to_str_i_ex(zend_string *haystack, char *lc_haystack zend_string *new_str = NULL; zend_string *lc_needle; - if (needle->len < haystack->len) { + if (ZSTR_LEN(needle) < ZSTR_LEN(haystack)) { char *end; char *e, *s, *p, *r; - if (needle->len == str_len) { + if (ZSTR_LEN(needle) == str_len) { lc_needle = php_string_tolower(needle); - end = lc_haystack + haystack->len; - for (p = lc_haystack; (r = (char*)php_memnstr(p, lc_needle->val, lc_needle->len, end)); p = r + lc_needle->len) { + end = lc_haystack + ZSTR_LEN(haystack); + for (p = lc_haystack; (r = (char*)php_memnstr(p, ZSTR_VAL(lc_needle), ZSTR_LEN(lc_needle), end)); p = r + ZSTR_LEN(lc_needle)) { if (!new_str) { - new_str = zend_string_init(haystack->val, haystack->len, 0); + new_str = zend_string_init(ZSTR_VAL(haystack), ZSTR_LEN(haystack), 0); } - memcpy(new_str->val + (r - lc_haystack), str, str_len); + memcpy(ZSTR_VAL(new_str) + (r - lc_haystack), str, str_len); (*replace_count)++; } zend_string_release(lc_needle); @@ -3283,13 +3283,13 @@ static zend_string *php_str_to_str_i_ex(zend_string *haystack, char *lc_haystack size_t count = 0; char *o = lc_haystack; char *n; - char *endp = o + haystack->len; + char *endp = o + ZSTR_LEN(haystack); lc_needle = php_string_tolower(needle); - n = lc_needle->val; + n = ZSTR_VAL(lc_needle); - while ((o = (char*)php_memnstr(o, n, lc_needle->len, endp))) { - o += lc_needle->len; + while ((o = (char*)php_memnstr(o, n, ZSTR_LEN(lc_needle), endp))) { + o += ZSTR_LEN(lc_needle); count++; } if (count == 0) { @@ -3298,13 +3298,13 @@ static zend_string *php_str_to_str_i_ex(zend_string *haystack, char *lc_haystack goto nothing_todo; } - new_str = zend_string_alloc(count * (str_len - lc_needle->len) + haystack->len, 0); + new_str = zend_string_alloc(count * (str_len - ZSTR_LEN(lc_needle)) + ZSTR_LEN(haystack), 0); - e = s = new_str->val; - end = lc_haystack + haystack->len; + e = s = ZSTR_VAL(new_str); + end = lc_haystack + ZSTR_LEN(haystack); - for (p = lc_haystack; (r = (char*)php_memnstr(p, lc_needle->val, lc_needle->len, end)); p = r + lc_needle->len) { - memcpy(e, haystack->val + (p - lc_haystack), r - p); + for (p = lc_haystack; (r = (char*)php_memnstr(p, ZSTR_VAL(lc_needle), ZSTR_LEN(lc_needle), end)); p = r + ZSTR_LEN(lc_needle)) { + memcpy(e, ZSTR_VAL(haystack) + (p - lc_haystack), r - p); e += r - p; memcpy(e, str, str_len); e += str_len; @@ -3312,7 +3312,7 @@ static zend_string *php_str_to_str_i_ex(zend_string *haystack, char *lc_haystack } if (p < end) { - memcpy(e, haystack->val + (p - lc_haystack), end - p); + memcpy(e, ZSTR_VAL(haystack) + (p - lc_haystack), end - p); e += end - p; } *e = '\0'; @@ -3321,13 +3321,13 @@ static zend_string *php_str_to_str_i_ex(zend_string *haystack, char *lc_haystack return new_str; } - } else if (needle->len > haystack->len) { + } else if (ZSTR_LEN(needle) > ZSTR_LEN(haystack)) { nothing_todo: return zend_string_copy(haystack); } else { lc_needle = php_string_tolower(needle); - if (memcmp(lc_haystack, lc_needle->val, lc_needle->len)) { + if (memcmp(lc_haystack, ZSTR_VAL(lc_needle), ZSTR_LEN(lc_needle))) { zend_string_release(lc_needle); goto nothing_todo; } @@ -3353,8 +3353,8 @@ PHPAPI zend_string *php_str_to_str(char *haystack, size_t length, char *needle, if (needle_len == str_len) { new_str = zend_string_init(haystack, length, 0); - end = new_str->val + length; - for (p = new_str->val; (r = (char*)php_memnstr(p, needle, needle_len, end)); p = r + needle_len) { + end = ZSTR_VAL(new_str) + length; + for (p = ZSTR_VAL(new_str); (r = (char*)php_memnstr(p, needle, needle_len, end)); p = r + needle_len) { memcpy(r, str, str_len); } return new_str; @@ -3380,7 +3380,7 @@ PHPAPI zend_string *php_str_to_str(char *haystack, size_t length, char *needle, } } - e = s = new_str->val; + e = s = ZSTR_VAL(new_str); end = haystack + length; for (p = haystack; (r = (char*)php_memnstr(p, needle, needle_len, end)); p = r + needle_len) { memcpy(e, p, r - p); @@ -3438,7 +3438,7 @@ PHP_FUNCTION(strtr) } /* shortcut for empty string */ - if (str->len == 0) { + if (ZSTR_LEN(str) == 0) { RETURN_EMPTY_STRING(); } @@ -3460,20 +3460,20 @@ PHP_FUNCTION(strtr) str_key = Z_STR(tmp); } replace = zval_get_string(entry); - if (str_key->len < 1) { + if (ZSTR_LEN(str_key) < 1) { RETVAL_STR_COPY(str); - } else if (str_key->len == 1) { + } else if (ZSTR_LEN(str_key) == 1) { RETVAL_STR(php_char_to_str_ex(str, - str_key->val[0], - replace->val, - replace->len, + ZSTR_VAL(str_key)[0], + ZSTR_VAL(replace), + ZSTR_LEN(replace), 1, NULL)); } else { zend_long dummy; RETVAL_STR(php_str_to_str_ex(str, - str_key->val, str_key->len, - replace->val, replace->len, &dummy)); + ZSTR_VAL(str_key), ZSTR_LEN(str_key), + ZSTR_VAL(replace), ZSTR_LEN(replace), &dummy)); } zend_string_release(replace); zval_dtor(&tmp); @@ -3505,12 +3505,12 @@ PHP_FUNCTION(strrev) return; } - n = zend_string_alloc(str->len, 0); - p = n->val; + n = zend_string_alloc(ZSTR_LEN(str), 0); + p = ZSTR_VAL(n); - e = str->val + str->len; + e = ZSTR_VAL(str) + ZSTR_LEN(str); - while (--e>=str->val) { + while (--e >= ZSTR_VAL(str)) { *p++ = *e; } @@ -3583,7 +3583,7 @@ PHP_FUNCTION(similar_text) convert_to_double_ex(percent); } - if (t1->len + t2->len == 0) { + if (ZSTR_LEN(t1) + ZSTR_LEN(t2) == 0) { if (ac > 2) { Z_DVAL_P(percent) = 0; } @@ -3591,10 +3591,10 @@ PHP_FUNCTION(similar_text) RETURN_LONG(0); } - sim = php_similar_char(t1->val, t1->len, t2->val, t2->len); + sim = php_similar_char(ZSTR_VAL(t1), ZSTR_LEN(t1), ZSTR_VAL(t2), ZSTR_LEN(t2)); if (ac > 2) { - Z_DVAL_P(percent) = sim * 200.0 / (t1->len + t2->len); + Z_DVAL_P(percent) = sim * 200.0 / (ZSTR_LEN(t1) + ZSTR_LEN(t2)); } RETURN_LONG(sim); @@ -3609,14 +3609,14 @@ PHPAPI void php_stripslashes(zend_string *str) char *s, *t; size_t l; - s = (char *)str->val; - t = (char *)str->val; - l = str->len; + s = ZSTR_VAL(str); + t = ZSTR_VAL(str); + l = ZSTR_LEN(str); while (l > 0) { if (*t == '\\') { t++; /* skip the slash */ - str->len--; + ZSTR_LEN(str)--; l--; if (l > 0) { if (*t == '0') { @@ -3648,15 +3648,15 @@ PHP_FUNCTION(addcslashes) return; } - if (str->len == 0) { + if (ZSTR_LEN(str) == 0) { RETURN_EMPTY_STRING(); } - if (what->len == 0) { - RETURN_STRINGL(str->val, str->len); + if (ZSTR_LEN(what) == 0) { + RETURN_STRINGL(ZSTR_VAL(str), ZSTR_LEN(str)); } - RETURN_STR(php_addcslashes(str, 0, what->val, what->len)); + RETURN_STR(php_addcslashes(str, 0, ZSTR_VAL(what), ZSTR_LEN(what))); } /* }}} */ @@ -3676,7 +3676,7 @@ PHP_FUNCTION(addslashes) ZEND_PARSE_PARAMETERS_END(); #endif - if (str->len == 0) { + if (ZSTR_LEN(str) == 0) { RETURN_EMPTY_STRING(); } @@ -3694,7 +3694,7 @@ PHP_FUNCTION(stripcslashes) return; } - ZVAL_STRINGL(return_value, str->val, str->len); + ZVAL_STRINGL(return_value, ZSTR_VAL(str), ZSTR_LEN(str)); php_stripcslashes(Z_STR_P(return_value)); } /* }}} */ @@ -3709,7 +3709,7 @@ PHP_FUNCTION(stripslashes) return; } - ZVAL_STRINGL(return_value, str->val, str->len); + ZVAL_STRINGL(return_value, ZSTR_VAL(str), ZSTR_LEN(str)); php_stripslashes(Z_STR_P(return_value)); } /* }}} */ @@ -3737,10 +3737,10 @@ char *php_strerror(int errnum) PHPAPI void php_stripcslashes(zend_string *str) { char *source, *target, *end; - size_t nlen = str->len, i; + size_t nlen = ZSTR_LEN(str), i; char numtmp[4]; - for (source = (char*)str->val, end = source + str->len, target = str->val; source < end; source++) { + for (source = (char*)ZSTR_VAL(str), end = source + ZSTR_LEN(str), target = ZSTR_VAL(str); source < end; source++) { if (*source == '\\' && source + 1 < end) { source++; switch (*source) { @@ -3791,7 +3791,7 @@ PHPAPI void php_stripcslashes(zend_string *str) *target='\0'; } - str->len = nlen; + ZSTR_LEN(str) = nlen; } /* }}} */ @@ -3804,11 +3804,11 @@ PHPAPI zend_string *php_addcslashes(zend_string *str, int should_free, char *wha char *end; char c; size_t newlen; - zend_string *new_str = zend_string_alloc(4 * str->len, 0); + zend_string *new_str = zend_string_alloc(4 * ZSTR_LEN(str), 0); php_charmask((unsigned char *)what, wlength, flags); - for (source = (char*)str->val, end = source + str->len, target = new_str->val; source < end; source++) { + for (source = (char*)ZSTR_VAL(str), end = source + ZSTR_LEN(str), target = ZSTR_VAL(new_str); source < end; source++) { c = *source; if (flags[(unsigned char)c]) { if ((unsigned char) c < 32 || (unsigned char) c > 126) { @@ -3830,8 +3830,8 @@ PHPAPI zend_string *php_addcslashes(zend_string *str, int should_free, char *wha *target++ = c; } *target = 0; - newlen = target - new_str->val; - if (newlen < str->len * 4) { + newlen = target - ZSTR_VAL(new_str); + if (newlen < ZSTR_LEN(str) * 4) { new_str = zend_string_truncate(new_str, newlen, 0); } if (should_free) { @@ -3855,8 +3855,8 @@ PHPAPI zend_string *php_addslashes(zend_string *str, int should_free) return ZSTR_EMPTY_ALLOC(); } - source = str->val; - end = source + str->len; + source = ZSTR_VAL(str); + end = source + ZSTR_LEN(str); while (source < end) { switch (*source) { @@ -3878,10 +3878,10 @@ PHPAPI zend_string *php_addslashes(zend_string *str, int should_free) return str; do_escape: - offset = source - (char *)str->val; - new_str = zend_string_alloc(offset + (2 * (str->len - offset)), 0); - memcpy(new_str->val, str->val, offset); - target = new_str->val + offset; + offset = source - (char *)ZSTR_VAL(str); + new_str = zend_string_alloc(offset + (2 * (ZSTR_LEN(str) - offset)), 0); + memcpy(ZSTR_VAL(new_str), ZSTR_VAL(str), offset); + target = ZSTR_VAL(new_str) + offset; while (source < end) { switch (*source) { @@ -3907,10 +3907,10 @@ do_escape: zend_string_release(str); } - if (new_str->len - (target - new_str->val) > 16) { - new_str = zend_string_truncate(new_str, target - new_str->val, 0); + if (ZSTR_LEN(new_str) - (target - ZSTR_VAL(new_str)) > 16) { + new_str = zend_string_truncate(new_str, target - ZSTR_VAL(new_str), 0); } else { - new_str->len = target - new_str->val; + ZSTR_LEN(new_str) = target - ZSTR_VAL(new_str); } return new_str; @@ -3940,7 +3940,7 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s /* Make sure we're dealing with strings. */ subject_str = zval_get_string(subject); - if (subject_str->len == 0) { + if (ZSTR_LEN(subject_str) == 0) { zend_string_release(subject_str); ZVAL_EMPTY_STRING(result); return 0; @@ -3987,8 +3987,8 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s replace_entry_str = zval_get_string(replace_entry); /* Set replacement value to the one we got from array */ - replace_value = replace_entry_str->val; - replace_len = replace_entry_str->len; + replace_value = ZSTR_VAL(replace_entry_str); + replace_len = ZSTR_LEN(replace_entry_str); replace_idx++; } else { @@ -4022,7 +4022,7 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s if (!lc_subject_str) { lc_subject_str = php_string_tolower(Z_STR_P(result)); } - tmp_result = php_str_to_str_i_ex(Z_STR_P(result), lc_subject_str->val, + tmp_result = php_str_to_str_i_ex(Z_STR_P(result), ZSTR_VAL(lc_subject_str), Z_STR_P(search_entry), replace_value, replace_len, &replace_count); if (replace_count != old_replace_count) { zend_string_release(lc_subject_str); @@ -4065,7 +4065,7 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s Z_STRVAL_P(replace), Z_STRLEN_P(replace), &replace_count)); } else { lc_subject_str = php_string_tolower(Z_STR_P(subject)); - ZVAL_STR(result, php_str_to_str_i_ex(subject_str, lc_subject_str->val, + ZVAL_STR(result, php_str_to_str_i_ex(subject_str, ZSTR_VAL(lc_subject_str), Z_STR_P(search), Z_STRVAL_P(replace), Z_STRLEN_P(replace), &replace_count)); zend_string_release(lc_subject_str); @@ -4266,7 +4266,7 @@ static void php_hebrev(INTERNAL_FUNCTION_PARAMETERS, int convert_newlines) broken_str = zend_string_alloc(str_len, 0); begin = end = str_len-1; - target = broken_str->val; + target = ZSTR_VAL(broken_str); while (1) { char_count=0; @@ -4371,8 +4371,8 @@ PHP_FUNCTION(nl2br) ZEND_PARSE_PARAMETERS_END(); #endif - tmp = str->val; - end = str->val + str->len; + tmp = ZSTR_VAL(str); + end = ZSTR_VAL(str) + ZSTR_LEN(str); /* it is really faster to scan twice and allocate mem once instead of scanning once and constantly reallocing */ @@ -4393,17 +4393,17 @@ PHP_FUNCTION(nl2br) } if (repl_cnt == 0) { - RETURN_STRINGL(str->val, str->len); + RETURN_STRINGL(ZSTR_VAL(str), ZSTR_LEN(str)); } { size_t repl_len = is_xhtml ? (sizeof("<br />") - 1) : (sizeof("<br>") - 1); - result = zend_string_alloc(repl_cnt * repl_len + str->len, 0); - target = result->val; + result = zend_string_alloc(repl_cnt * repl_len + ZSTR_LEN(str), 0); + target = ZSTR_VAL(result); } - tmp = str->val; + tmp = ZSTR_VAL(str); while (tmp < end) { switch (*tmp) { case '\r': @@ -4463,8 +4463,8 @@ PHP_FUNCTION(strip_tags) } } - buf = zend_string_init(str->val, str->len, 0); - buf->len = php_strip_tags_ex(buf->val, str->len, NULL, allowed_tags, allowed_tags_len, 0); + buf = zend_string_init(ZSTR_VAL(str), ZSTR_LEN(str), 0); + ZSTR_LEN(buf) = php_strip_tags_ex(ZSTR_VAL(buf), ZSTR_LEN(str), NULL, allowed_tags, allowed_tags_len, 0); // TODO: reimplement to avoid reallocation ??? if (allow && !Z_REFCOUNTED_P(allow)) { @@ -4510,18 +4510,18 @@ PHP_FUNCTION(setlocale) loc = zval_get_string(plocale); - if (!strcmp("0", loc->val)) { + if (!strcmp("0", ZSTR_VAL(loc))) { zend_string_release(loc); loc = NULL; } else { - if (loc->len >= 255) { + if (ZSTR_LEN(loc) >= 255) { php_error_docref(NULL, E_WARNING, "Specified locale name is too long"); zend_string_release(loc); break; } } - retval = php_my_setlocale(cat, loc ? loc->val : NULL); + retval = php_my_setlocale(cat, loc ? ZSTR_VAL(loc) : NULL); zend_update_current_locale(); if (retval) { if (loc) { @@ -4533,7 +4533,7 @@ PHP_FUNCTION(setlocale) if (BG(locale_string)) { zend_string_release(BG(locale_string)); } - if (len == loc->len && !memcmp(loc->val, retval, len)) { + if (len == ZSTR_LEN(loc) && !memcmp(ZSTR_VAL(loc), retval, len)) { BG(locale_string) = zend_string_copy(loc); RETURN_STR(BG(locale_string)); } else { @@ -4541,7 +4541,7 @@ PHP_FUNCTION(setlocale) zend_string_release(loc); RETURN_STR_COPY(BG(locale_string)); } - } else if (len == loc->len && !memcmp(loc->val, retval, len)) { + } else if (len == ZSTR_LEN(loc) && !memcmp(ZSTR_VAL(loc), retval, len)) { RETURN_STR(loc); } zend_string_release(loc); @@ -4982,7 +4982,7 @@ PHP_FUNCTION(str_getcsv) enc = enc_len ? enc_str[0] : enc; esc = esc_len ? esc_str[0] : esc; - php_fgetcsv(NULL, delim, enc, esc, str->len, str->val, return_value); + php_fgetcsv(NULL, delim, enc, esc, ZSTR_LEN(str), ZSTR_VAL(str), return_value); } /* }}} */ @@ -5006,23 +5006,23 @@ PHP_FUNCTION(str_repeat) /* Don't waste our time if it's empty */ /* ... or if the multiplier is zero */ - if (input_str->len == 0 || mult == 0) + if (ZSTR_LEN(input_str) == 0 || mult == 0) RETURN_EMPTY_STRING(); /* Initialize the result string */ - result = zend_string_safe_alloc(input_str->len, mult, 0, 0); - result_len = input_str->len * mult; + result = zend_string_safe_alloc(ZSTR_LEN(input_str), mult, 0, 0); + result_len = ZSTR_LEN(input_str) * mult; /* Heavy optimization for situations where input string is 1 byte long */ - if (input_str->len == 1) { - memset(result->val, *(input_str->val), mult); + if (ZSTR_LEN(input_str) == 1) { + memset(ZSTR_VAL(result), *ZSTR_VAL(input_str), mult); } else { char *s, *e, *ee; ptrdiff_t l=0; - memcpy(result->val, input_str->val, input_str->len); - s = result->val; - e = result->val + input_str->len; - ee = result->val + result_len; + memcpy(ZSTR_VAL(result), ZSTR_VAL(input_str), ZSTR_LEN(input_str)); + s = ZSTR_VAL(result); + e = ZSTR_VAL(result) + ZSTR_LEN(input_str); + ee = ZSTR_VAL(result) + result_len; while (e<ee) { l = (e-s) < (ee-e) ? (e-s) : (ee-e); @@ -5031,7 +5031,7 @@ PHP_FUNCTION(str_repeat) } } - result->val[result_len] = '\0'; + ZSTR_VAL(result)[result_len] = '\0'; RETURN_NEW_STR(result); } @@ -5059,10 +5059,10 @@ PHP_FUNCTION(count_chars) RETURN_FALSE; } - buf = (unsigned char *) input->val; + buf = (unsigned char *) ZSTR_VAL(input); memset((void*) chars, 0, sizeof(chars)); - while (tmp < input->len) { + while (tmp < ZSTR_LEN(input)) { chars[*buf]++; buf++; tmp++; @@ -5116,8 +5116,8 @@ static void php_strnatcmp(INTERNAL_FUNCTION_PARAMETERS, int fold_case) return; } - RETURN_LONG(strnatcmp_ex(s1->val, s1->len, - s2->val, s2->len, + RETURN_LONG(strnatcmp_ex(ZSTR_VAL(s1), ZSTR_LEN(s1), + ZSTR_VAL(s2), ZSTR_LEN(s2), fold_case)); } /* }}} */ @@ -5127,7 +5127,7 @@ PHPAPI int string_natural_compare_function_ex(zval *result, zval *op1, zval *op2 zend_string *str1 = zval_get_string(op1); zend_string *str2 = zval_get_string(op2); - ZVAL_LONG(result, strnatcmp_ex(str1->val, str1->len, str2->val, str2->len, case_insensitive)); + ZVAL_LONG(result, strnatcmp_ex(ZSTR_VAL(str1), ZSTR_LEN(str1), ZSTR_VAL(str2), ZSTR_LEN(str2), case_insensitive)); zend_string_release(str1); zend_string_release(str2); @@ -5333,8 +5333,8 @@ PHP_FUNCTION(str_pad) /* If resulting string turns out to be shorter than input string, we simply copy the input and return. */ - if (pad_length < 0 || (size_t)pad_length <= input->len) { - RETURN_STRINGL(input->val, input->len); + if (pad_length < 0 || (size_t)pad_length <= ZSTR_LEN(input)) { + RETURN_STRINGL(ZSTR_VAL(input), ZSTR_LEN(input)); } if (pad_str_len == 0) { @@ -5347,14 +5347,14 @@ PHP_FUNCTION(str_pad) return; } - num_pad_chars = pad_length - input->len; + num_pad_chars = pad_length - ZSTR_LEN(input); if (num_pad_chars >= INT_MAX) { php_error_docref(NULL, E_WARNING, "Padding length is too long"); return; } - result = zend_string_alloc(input->len + num_pad_chars, 0); - result->len = 0; + result = zend_string_alloc(ZSTR_LEN(input) + num_pad_chars, 0); + ZSTR_LEN(result) = 0; /* We need to figure out the left/right padding lengths. */ switch (pad_type_val) { @@ -5376,17 +5376,17 @@ PHP_FUNCTION(str_pad) /* First we pad on the left. */ for (i = 0; i < left_pad; i++) - result->val[result->len++] = pad_str[i % pad_str_len]; + ZSTR_VAL(result)[ZSTR_LEN(result)++] = pad_str[i % pad_str_len]; /* Then we copy the input string. */ - memcpy(result->val + result->len, input->val, input->len); - result->len += input->len; + memcpy(ZSTR_VAL(result) + ZSTR_LEN(result), ZSTR_VAL(input), ZSTR_LEN(input)); + ZSTR_LEN(result) += ZSTR_LEN(input); /* Finally, we pad on the right. */ for (i = 0; i < right_pad; i++) - result->val[result->len++] = pad_str[i % pad_str_len]; + ZSTR_VAL(result)[ZSTR_LEN(result)++] = pad_str[i % pad_str_len]; - result->val[result->len] = '\0'; + ZSTR_VAL(result)[ZSTR_LEN(result)] = '\0'; RETURN_NEW_STR(result); } @@ -5427,7 +5427,7 @@ PHP_FUNCTION(str_rot13) return; } - if (arg->len == 0) { + if (ZSTR_LEN(arg) == 0) { RETURN_EMPTY_STRING(); } else { RETURN_STR(php_strtr_ex(arg, rot13_from, rot13_to, 52)); @@ -5471,7 +5471,7 @@ PHP_FUNCTION(str_shuffle) return; } - RETVAL_STRINGL(arg->val, arg->len); + RETVAL_STRINGL(ZSTR_VAL(arg), ZSTR_LEN(arg)); if (Z_STRLEN_P(return_value) > 1) { php_string_shuffle(Z_STRVAL_P(return_value), (zend_long) Z_STRLEN_P(return_value)); } @@ -5504,12 +5504,12 @@ PHP_FUNCTION(str_word_count) case 1: case 2: array_init(return_value); - if (!str->len) { + if (!ZSTR_LEN(str)) { return; } break; case 0: - if (!str->len) { + if (!ZSTR_LEN(str)) { RETURN_LONG(0); } /* nothing to be done */ @@ -5523,8 +5523,8 @@ PHP_FUNCTION(str_word_count) php_charmask((unsigned char *)char_list, char_list_len, ch); } - p = str->val; - e = str->val + str->len; + p = ZSTR_VAL(str); + e = ZSTR_VAL(str) + ZSTR_LEN(str); /* first character cannot be ' or -, unless explicitly allowed by the user */ if ((*p == '\'' && (!char_list || !ch['\''])) || (*p == '-' && (!char_list || !ch['-']))) { @@ -5547,7 +5547,7 @@ PHP_FUNCTION(str_word_count) add_next_index_stringl(return_value, s, p - s); break; case 2: - add_index_stringl(return_value, (s - str->val), s, p - s); + add_index_stringl(return_value, (s - ZSTR_VAL(str)), s, p - s); break; default: word_count++; @@ -5595,14 +5595,14 @@ PHP_FUNCTION(money_format) } str = zend_string_alloc(format_len + 1024, 0); - if ((res_len = strfmon(str->val, str->len, format, value)) < 0) { + if ((res_len = strfmon(ZSTR_VAL(str), ZSTR_LEN(str), format, value)) < 0) { zend_string_free(str); RETURN_FALSE; } - str->len = (size_t)res_len; - str->val[str->len] = '\0'; + ZSTR_LEN(str) = (size_t)res_len; + ZSTR_VAL(str)[ZSTR_LEN(str)] = '\0'; - RETURN_NEW_STR(zend_string_truncate(str, str->len, 0)); + RETURN_NEW_STR(zend_string_truncate(str, ZSTR_LEN(str), 0)); } /* }}} */ #endif @@ -5626,24 +5626,24 @@ PHP_FUNCTION(str_split) } - if (0 == str->len || (size_t)split_length >= str->len) { + if (0 == ZSTR_LEN(str) || (size_t)split_length >= ZSTR_LEN(str)) { array_init_size(return_value, 1); - add_next_index_stringl(return_value, str->val, str->len); + add_next_index_stringl(return_value, ZSTR_VAL(str), ZSTR_LEN(str)); return; } - array_init_size(return_value, (uint32_t)(((str->len - 1) / split_length) + 1)); + array_init_size(return_value, (uint32_t)(((ZSTR_LEN(str) - 1) / split_length) + 1)); - n_reg_segments = str->len / split_length; - p = str->val; + n_reg_segments = ZSTR_LEN(str) / split_length; + p = ZSTR_VAL(str); while (n_reg_segments-- > 0) { add_next_index_stringl(return_value, p, split_length); p += split_length; } - if (p != (str->val + str->len)) { - add_next_index_stringl(return_value, p, (str->val + str->len - p)); + if (p != (ZSTR_VAL(str) + ZSTR_LEN(str))) { + add_next_index_stringl(return_value, p, (ZSTR_VAL(str) + ZSTR_LEN(str) - p)); } } /* }}} */ @@ -5659,15 +5659,15 @@ PHP_FUNCTION(strpbrk) RETURN_FALSE; } - if (!char_list->len) { + if (!ZSTR_LEN(char_list)) { php_error_docref(NULL, E_WARNING, "The character list cannot be empty"); RETURN_FALSE; } - for (haystack_ptr = haystack->val; haystack_ptr < (haystack->val + haystack->len); ++haystack_ptr) { - for (cl_ptr = char_list->val; cl_ptr < (char_list->val + char_list->len); ++cl_ptr) { + for (haystack_ptr = ZSTR_VAL(haystack); haystack_ptr < (ZSTR_VAL(haystack) + ZSTR_LEN(haystack)); ++haystack_ptr) { + for (cl_ptr = ZSTR_VAL(char_list); cl_ptr < (ZSTR_VAL(char_list) + ZSTR_LEN(char_list)); ++cl_ptr) { if (*cl_ptr == *haystack_ptr) { - RETURN_STRINGL(haystack_ptr, (haystack->val + haystack->len - haystack_ptr)); + RETURN_STRINGL(haystack_ptr, (ZSTR_VAL(haystack) + ZSTR_LEN(haystack) - haystack_ptr)); } } } @@ -5699,21 +5699,21 @@ PHP_FUNCTION(substr_compare) } if (offset < 0) { - offset = s1->len + offset; + offset = ZSTR_LEN(s1) + offset; offset = (offset < 0) ? 0 : offset; } - if ((size_t)offset >= s1->len) { + if ((size_t)offset >= ZSTR_LEN(s1)) { php_error_docref(NULL, E_WARNING, "The start position cannot exceed initial string length"); RETURN_FALSE; } - cmp_len = (size_t) (len ? len : MAX(s2->len, (s1->len - offset))); + cmp_len = (size_t) (len ? len : MAX(ZSTR_LEN(s2), (ZSTR_LEN(s1) - offset))); if (!cs) { - RETURN_LONG(zend_binary_strncmp(s1->val + offset, (s1->len - offset), s2->val, s2->len, cmp_len)); + RETURN_LONG(zend_binary_strncmp(ZSTR_VAL(s1) + offset, (ZSTR_LEN(s1) - offset), ZSTR_VAL(s2), ZSTR_LEN(s2), cmp_len)); } else { - RETURN_LONG(zend_binary_strncasecmp_l(s1->val + offset, (s1->len - offset), s2->val, s2->len, cmp_len)); + RETURN_LONG(zend_binary_strncasecmp_l(ZSTR_VAL(s1) + offset, (ZSTR_LEN(s1) - offset), ZSTR_VAL(s2), ZSTR_LEN(s2), cmp_len)); } } /* }}} */ diff --git a/ext/standard/type.c b/ext/standard/type.c index 8251a3f155..b4d8586dcc 100644 --- a/ext/standard/type.c +++ b/ext/standard/type.c @@ -225,8 +225,8 @@ static inline void php_is_type(INTERNAL_FUNCTION_PARAMETERS, int type) if (Z_TYPE_P(arg) == type) { if (type == IS_OBJECT) { zend_class_entry *ce = Z_OBJCE_P(arg); - if (ce->name->len == sizeof(INCOMPLETE_CLASS) - 1 - && !memcmp(ce->name->val, INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS) - 1)) { + if (ZSTR_LEN(ce->name) == sizeof(INCOMPLETE_CLASS) - 1 + && !memcmp(ZSTR_VAL(ce->name), INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS) - 1)) { RETURN_FALSE; } } else if (type == IS_RESOURCE) { @@ -413,8 +413,8 @@ PHP_FUNCTION(is_callable) retval = zend_is_callable_ex(var, NULL, check_flags, &name, NULL, &error); zval_dtor(callable_name); //??? is it necessary to be consistent with old PHP ("\0" support) - if (UNEXPECTED(name->len) != strlen(name->val)) { - ZVAL_STRINGL(callable_name, name->val, strlen(name->val)); + if (UNEXPECTED(ZSTR_LEN(name)) != strlen(ZSTR_VAL(name))) { + ZVAL_STRINGL(callable_name, ZSTR_VAL(name), strlen(ZSTR_VAL(name))); zend_string_release(name); } else { ZVAL_STR(callable_name, name); diff --git a/ext/standard/url.c b/ext/standard/url.c index f7bca053a7..fe38c2d993 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -494,7 +494,7 @@ PHPAPI zend_string *php_url_encode(char const *s, size_t len) from = (unsigned char *)s; end = (unsigned char *)s + len; start = zend_string_alloc(3 * len, 0); - to = (unsigned char*)start->val; + to = (unsigned char*)ZSTR_VAL(start); while (from < end) { c = *from++; @@ -524,7 +524,7 @@ PHPAPI zend_string *php_url_encode(char const *s, size_t len) } *to = '\0'; - start = zend_string_truncate(start, to - (unsigned char*)start->val, 0); + start = zend_string_truncate(start, to - (unsigned char*)ZSTR_VAL(start), 0); return start; } @@ -546,7 +546,7 @@ PHP_FUNCTION(urlencode) ZEND_PARSE_PARAMETERS_END(); #endif - RETURN_STR(php_url_encode(in_str->val, in_str->len)); + RETURN_STR(php_url_encode(ZSTR_VAL(in_str), ZSTR_LEN(in_str))); } /* }}} */ @@ -566,8 +566,8 @@ PHP_FUNCTION(urldecode) ZEND_PARSE_PARAMETERS_END(); #endif - out_str = zend_string_init(in_str->val, in_str->len, 0); - out_str->len = php_url_decode(out_str->val, out_str->len); + out_str = zend_string_init(ZSTR_VAL(in_str), ZSTR_LEN(in_str), 0); + ZSTR_LEN(out_str) = php_url_decode(ZSTR_VAL(out_str), ZSTR_LEN(out_str)); RETURN_NEW_STR(out_str); } @@ -613,24 +613,24 @@ PHPAPI zend_string *php_raw_url_encode(char const *s, size_t len) str = zend_string_alloc(3 * len, 0); for (x = 0, y = 0; len--; x++, y++) { - str->val[y] = (unsigned char) s[x]; + ZSTR_VAL(str)[y] = (unsigned char) s[x]; #ifndef CHARSET_EBCDIC - if ((str->val[y] < '0' && str->val[y] != '-' && str->val[y] != '.') || - (str->val[y] < 'A' && str->val[y] > '9') || - (str->val[y] > 'Z' && str->val[y] < 'a' && str->val[y] != '_') || - (str->val[y] > 'z' && str->val[y] != '~')) { - str->val[y++] = '%'; - str->val[y++] = hexchars[(unsigned char) s[x] >> 4]; - str->val[y] = hexchars[(unsigned char) s[x] & 15]; + if ((ZSTR_VAL(str)[y] < '0' && ZSTR_VAL(str)[y] != '-' && ZSTR_VAL(str)[y] != '.') || + (ZSTR_VAL(str)[y] < 'A' && ZSTR_VAL(str)[y] > '9') || + (ZSTR_VAL(str)[y] > 'Z' && ZSTR_VAL(str)[y] < 'a' && ZSTR_VAL(str)[y] != '_') || + (ZSTR_VAL(str)[y] > 'z' && ZSTR_VAL(str)[y] != '~')) { + ZSTR_VAL(str)[y++] = '%'; + ZSTR_VAL(str)[y++] = hexchars[(unsigned char) s[x] >> 4]; + ZSTR_VAL(str)[y] = hexchars[(unsigned char) s[x] & 15]; #else /*CHARSET_EBCDIC*/ - if (!isalnum(str->val[y]) && str->valchr("_-.~", str->val[y]) != NULL) { - str->val[y++] = '%'; - str->val[y++] = hexchars[os_toascii[(unsigned char) s[x]] >> 4]; - str->val[y] = hexchars[os_toascii[(unsigned char) s[x]] & 15]; + if (!isalnum(ZSTR_VAL(str)[y]) && strchr("_-.~", ZSTR_VAL(str)[y]) != NULL) { + ZSTR_VAL(str)[y++] = '%'; + ZSTR_VAL(str)[y++] = hexchars[os_toascii[(unsigned char) s[x]] >> 4]; + ZSTR_VAL(str)[y] = hexchars[os_toascii[(unsigned char) s[x]] & 15]; #endif /*CHARSET_EBCDIC*/ } } - str->val[y] = '\0'; + ZSTR_VAL(str)[y] = '\0'; str = zend_string_truncate(str, y, 0); return str; @@ -653,7 +653,7 @@ PHP_FUNCTION(rawurlencode) ZEND_PARSE_PARAMETERS_END(); #endif - RETURN_STR(php_raw_url_encode(in_str->val, in_str->len)); + RETURN_STR(php_raw_url_encode(ZSTR_VAL(in_str), ZSTR_LEN(in_str))); } /* }}} */ @@ -673,8 +673,8 @@ PHP_FUNCTION(rawurldecode) ZEND_PARSE_PARAMETERS_END(); #endif - out_str = zend_string_init(in_str->val, in_str->len, 0); - out_str->len = php_raw_url_decode(out_str->val, out_str->len); + out_str = zend_string_init(ZSTR_VAL(in_str), ZSTR_LEN(in_str), 0); + ZSTR_LEN(out_str) = php_raw_url_decode(ZSTR_VAL(out_str), ZSTR_LEN(out_str)); RETURN_NEW_STR(out_str); } diff --git a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c index 0014027872..2ffe1451c2 100644 --- a/ext/standard/url_scanner_ex.c +++ b/ext/standard/url_scanner_ex.c @@ -58,7 +58,7 @@ static PHP_INI_MH(OnUpdateTags) ctx = &BG(url_adapt_state_ex); - tmp = estrndup(new_value->val, new_value->len); + tmp = estrndup(ZSTR_VAL(new_value), ZSTR_LEN(new_value)); if (ctx->tags) zend_hash_destroy(ctx->tags); @@ -115,7 +115,7 @@ static inline void append_modified_url(smart_str *url, smart_str *dest, smart_st const char *bash = NULL; const char *sep = "?"; - q = (p = url->s->val) + url->s->len; + q = (p = ZSTR_VAL(url->s)) + ZSTR_LEN(url->s); scan: @@ -194,13 +194,13 @@ yy8: done: /* Don't modify URLs of the format "#mark" */ - if (bash && bash - url->s->val == 0) { + if (bash && bash - ZSTR_VAL(url->s) == 0) { smart_str_append_smart_str(dest, url); return; } if (bash) - smart_str_appendl(dest, url->s->val, bash - url->s->val); + smart_str_appendl(dest, ZSTR_VAL(url->s), bash - ZSTR_VAL(url->s)); else smart_str_append_smart_str(dest, url); @@ -222,7 +222,7 @@ static inline void tag_arg(url_adapt_state_ex_t *ctx, char quotes, char type) { char f = 0; - if (strncasecmp(ctx->arg.s->val, ctx->lookup_data, ctx->arg.s->len) == 0) + if (strncasecmp(ZSTR_VAL(ctx->arg.s), ctx->lookup_data, ZSTR_LEN(ctx->arg.s)) == 0) f = 1; if (quotes) @@ -276,18 +276,18 @@ static void handle_form(STD_PARA) { int doit = 0; - if (ctx->form_app.s->len > 0) { - switch (ctx->tag.s->len) { + if (ZSTR_LEN(ctx->form_app.s) > 0) { + switch (ZSTR_LEN(ctx->tag.s)) { case sizeof("form") - 1: - if (!strncasecmp(ctx->tag.s->val, "form", sizeof("form") - 1)) { + if (!strncasecmp(ZSTR_VAL(ctx->tag.s), "form", sizeof("form") - 1)) { doit = 1; } if (doit && ctx->val.s && ctx->lookup_data && *ctx->lookup_data) { - char *e, *p = (char *)zend_memnstr(ctx->val.s->val, "://", sizeof("://") - 1, ctx->val.s->val + ctx->val.s->len); + char *e, *p = (char *)zend_memnstr(ZSTR_VAL(ctx->val.s), "://", sizeof("://") - 1, ZSTR_VAL(ctx->val.s) + ZSTR_LEN(ctx->val.s)); if (p) { - e = memchr(p, '/', (ctx->val.s->val + ctx->val.s->len) - p); + e = memchr(p, '/', (ZSTR_VAL(ctx->val.s) + ZSTR_LEN(ctx->val.s)) - p); if (!e) { - e = ctx->val.s->val + ctx->val.s->len; + e = ZSTR_VAL(ctx->val.s) + ZSTR_LEN(ctx->val.s); } if ((e - p) && strncasecmp(p, ctx->lookup_data, (e - p))) { doit = 0; @@ -297,7 +297,7 @@ static void handle_form(STD_PARA) break; case sizeof("fieldset") - 1: - if (!strncasecmp(ctx->tag.s->val, "fieldset", sizeof("fieldset") - 1)) { + if (!strncasecmp(ZSTR_VAL(ctx->tag.s), "fieldset", sizeof("fieldset") - 1)) { doit = 1; } break; @@ -321,13 +321,13 @@ static inline void handle_tag(STD_PARA) unsigned int i; if (ctx->tag.s) { - ctx->tag.s->len = 0; + ZSTR_LEN(ctx->tag.s) = 0; } smart_str_appendl(&ctx->tag, start, YYCURSOR - start); - for (i = 0; i < ctx->tag.s->len; i++) - ctx->tag.s->val[i] = tolower((int)(unsigned char)ctx->tag.s->val[i]); + for (i = 0; i < ZSTR_LEN(ctx->tag.s); i++) + ZSTR_VAL(ctx->tag.s)[i] = tolower((int)(unsigned char)ZSTR_VAL(ctx->tag.s)[i]); /* intentionally using str_find here, in case the hash value is set, but the string val is changed later */ - if ((ctx->lookup_data = zend_hash_str_find_ptr(ctx->tags, ctx->tag.s->val, ctx->tag.s->len)) != NULL) + if ((ctx->lookup_data = zend_hash_str_find_ptr(ctx->tags, ZSTR_VAL(ctx->tag.s), ZSTR_LEN(ctx->tag.s))) != NULL) ok = 1; STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN; } @@ -335,7 +335,7 @@ static inline void handle_tag(STD_PARA) static inline void handle_arg(STD_PARA) { if (ctx->arg.s) { - ctx->arg.s->len = 0; + ZSTR_LEN(ctx->arg.s) = 0; } smart_str_appendl(&ctx->arg, start, YYCURSOR - start); } @@ -355,8 +355,8 @@ static inline void xx_mainloop(url_adapt_state_ex_t *ctx, const char *newdata, s smart_str_appendl(&ctx->buf, newdata, newlen); - YYCURSOR = ctx->buf.s->val; - YYLIMIT = ctx->buf.s->val + ctx->buf.s->len; + YYCURSOR = ZSTR_VAL(ctx->buf.s); + YYLIMIT = ZSTR_VAL(ctx->buf.s) + ZSTR_LEN(ctx->buf.s); switch (STATE) { case STATE_PLAIN: goto state_plain; @@ -914,8 +914,8 @@ stop: scdebug(("stopped in state %d at pos %d (%d:%c) %d\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *YYCURSOR, rest)); } - if (rest) memmove(ctx->buf.s->val, start, rest); - ctx->buf.s->len = rest; + if (rest) memmove(ZSTR_VAL(ctx->buf.s), start, rest); + ZSTR_LEN(ctx->buf.s) = rest; } @@ -931,7 +931,7 @@ PHPAPI char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, co if (urlencode) { encoded = php_raw_url_encode(name, strlen(name)); - smart_str_appendl(&url_app, encoded->val, encoded->len); + smart_str_appendl(&url_app, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded); } else { smart_str_appends(&url_app, name); @@ -939,7 +939,7 @@ PHPAPI char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, co smart_str_appendc(&url_app, '='); if (urlencode) { encoded = php_raw_url_encode(value, strlen(value)); - smart_str_appendl(&url_app, encoded->val, encoded->len); + smart_str_appendl(&url_app, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded); } else { smart_str_appends(&url_app, value); @@ -948,8 +948,8 @@ PHPAPI char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, co append_modified_url(&surl, &buf, &url_app, PG(arg_separator).output); smart_str_0(&buf); - if (newlen) *newlen = buf.s->len; - result = estrndup(buf.s->val, buf.s->len); + if (newlen) *newlen = ZSTR_LEN(buf.s); + result = estrndup(ZSTR_VAL(buf.s), ZSTR_LEN(buf.s)); smart_str_free(&url_app); smart_str_free(&buf); @@ -971,16 +971,16 @@ static char *url_adapt_ext(const char *src, size_t srclen, size_t *newlen, zend_ smart_str_appendl(&ctx->result, "", 0); *newlen = 0; } else { - *newlen = ctx->result.s->len; + *newlen = ZSTR_LEN(ctx->result.s); } smart_str_0(&ctx->result); if (do_flush) { smart_str_append(&ctx->result, ctx->buf.s); - *newlen += ctx->buf.s->len; + *newlen += ZSTR_LEN(ctx->buf.s); smart_str_free(&ctx->buf); smart_str_free(&ctx->val); } - retval = estrndup(ctx->result.s->val, ctx->result.s->len); + retval = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s)); smart_str_free(&ctx->result); return retval; } @@ -1014,21 +1014,21 @@ static void php_url_scanner_output_handler(char *output, size_t output_len, char { size_t len; - if (BG(url_adapt_state_ex).url_app.s->len != 0) { + if (ZSTR_LEN(BG(url_adapt_state_ex).url_app.s) != 0) { *handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END | PHP_OUTPUT_HANDLER_CONT | PHP_OUTPUT_HANDLER_FLUSH | PHP_OUTPUT_HANDLER_FINAL) ? 1 : 0)); if (sizeof(uint) < sizeof(size_t)) { if (len > UINT_MAX) len = UINT_MAX; } *handled_output_len = len; - } else if (BG(url_adapt_state_ex).url_app.s->len == 0) { + } else if (ZSTR_LEN(BG(url_adapt_state_ex).url_app.s) == 0) { url_adapt_state_ex_t *ctx = &BG(url_adapt_state_ex); - if (ctx->buf.s && ctx->buf.s->len) { + if (ctx->buf.s && ZSTR_LEN(ctx->buf.s)) { smart_str_append(&ctx->result, ctx->buf.s); smart_str_appendl(&ctx->result, output, output_len); - *handled_output = estrndup(ctx->result.s->val, ctx->result.s->len); - *handled_output_len = ctx->buf.s->len + output_len; + *handled_output = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s)); + *handled_output_len = ZSTR_LEN(ctx->buf.s) + output_len; smart_str_free(&ctx->buf); smart_str_free(&ctx->result); @@ -1052,16 +1052,16 @@ PHPAPI int php_url_scanner_add_var(char *name, size_t name_len, char *value, siz BG(url_adapt_state_ex).active = 1; } - if (BG(url_adapt_state_ex).url_app.s && BG(url_adapt_state_ex).url_app.s->len != 0) { + if (BG(url_adapt_state_ex).url_app.s && ZSTR_LEN(BG(url_adapt_state_ex).url_app.s) != 0) { smart_str_appends(&BG(url_adapt_state_ex).url_app, PG(arg_separator).output); } if (urlencode) { encoded = php_raw_url_encode(name, name_len); - smart_str_appendl(&sname, encoded->val, encoded->len); + smart_str_appendl(&sname, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded); encoded = php_raw_url_encode(value, value_len); - smart_str_appendl(&svalue, encoded->val, encoded->len); + smart_str_appendl(&svalue, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded); } else { smart_str_appendl(&sname, name, name_len); @@ -1087,10 +1087,10 @@ PHPAPI int php_url_scanner_add_var(char *name, size_t name_len, char *value, siz PHPAPI int php_url_scanner_reset_vars(void) { if (BG(url_adapt_state_ex).form_app.s) { - BG(url_adapt_state_ex).form_app.s->len = 0; + ZSTR_LEN(BG(url_adapt_state_ex).form_app.s) = 0; } if (BG(url_adapt_state_ex).url_app.s) { - BG(url_adapt_state_ex).url_app.s->len = 0; + ZSTR_LEN(BG(url_adapt_state_ex).url_app.s) = 0; } return SUCCESS; diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re index 48a6d8db62..ef05e8098f 100644 --- a/ext/standard/url_scanner_ex.re +++ b/ext/standard/url_scanner_ex.re @@ -56,7 +56,7 @@ static PHP_INI_MH(OnUpdateTags) ctx = &BG(url_adapt_state_ex); - tmp = estrndup(new_value->val, new_value->len); + tmp = estrndup(ZSTR_VAL(new_value), ZSTR_LEN(new_value)); if (ctx->tags) zend_hash_destroy(ctx->tags); @@ -118,7 +118,7 @@ static inline void append_modified_url(smart_str *url, smart_str *dest, smart_st const char *bash = NULL; const char *sep = "?"; - q = (p = url->s->val) + url->s->len; + q = (p = ZSTR_VAL(url->s)) + ZSTR_LEN(url->s); scan: /*!re2c @@ -130,13 +130,13 @@ scan: done: /* Don't modify URLs of the format "#mark" */ - if (bash && bash - url->s->val == 0) { + if (bash && bash - ZSTR_VAL(url->s) == 0) { smart_str_append_smart_str(dest, url); return; } if (bash) - smart_str_appendl(dest, url->s->val, bash - url->s->val); + smart_str_appendl(dest, ZSTR_VAL(url->s), bash - ZSTR_VAL(url->s)); else smart_str_append_smart_str(dest, url); @@ -158,7 +158,7 @@ static inline void tag_arg(url_adapt_state_ex_t *ctx, char quotes, char type) { char f = 0; - if (strncasecmp(ctx->arg.s->val, ctx->lookup_data, ctx->arg.s->len) == 0) + if (strncasecmp(ZSTR_VAL(ctx->arg.s), ctx->lookup_data, ZSTR_LEN(ctx->arg.s)) == 0) f = 1; if (quotes) @@ -212,18 +212,18 @@ static void handle_form(STD_PARA) { int doit = 0; - if (ctx->form_app.s->len > 0) { - switch (ctx->tag.s->len) { + if (ZSTR_LEN(ctx->form_app.s) > 0) { + switch (ZSTR_LEN(ctx->tag.s)) { case sizeof("form") - 1: - if (!strncasecmp(ctx->tag.s->val, "form", sizeof("form") - 1)) { + if (!strncasecmp(ZSTR_VAL(ctx->tag.s), "form", sizeof("form") - 1)) { doit = 1; } if (doit && ctx->val.s && ctx->lookup_data && *ctx->lookup_data) { - char *e, *p = (char *)zend_memnstr(ctx->val.s->val, "://", sizeof("://") - 1, ctx->val.s->val + ctx->val.s->len); + char *e, *p = (char *)zend_memnstr(ZSTR_VAL(ctx->val.s), "://", sizeof("://") - 1, ZSTR_VAL(ctx->val.s) + ZSTR_LEN(ctx->val.s)); if (p) { - e = memchr(p, '/', (ctx->val.s->val + ctx->val.s->len) - p); + e = memchr(p, '/', (ZSTR_VAL(ctx->val.s) + ZSTR_LEN(ctx->val.s)) - p); if (!e) { - e = ctx->val.s->val + ctx->val.s->len; + e = ZSTR_VAL(ctx->val.s) + ZSTR_LEN(ctx->val.s); } if ((e - p) && strncasecmp(p, ctx->lookup_data, (e - p))) { doit = 0; @@ -233,7 +233,7 @@ static void handle_form(STD_PARA) break; case sizeof("fieldset") - 1: - if (!strncasecmp(ctx->tag.s->val, "fieldset", sizeof("fieldset") - 1)) { + if (!strncasecmp(ZSTR_VAL(ctx->tag.s), "fieldset", sizeof("fieldset") - 1)) { doit = 1; } break; @@ -257,13 +257,13 @@ static inline void handle_tag(STD_PARA) unsigned int i; if (ctx->tag.s) { - ctx->tag.s->len = 0; + ZSTR_LEN(ctx->tag.s) = 0; } smart_str_appendl(&ctx->tag, start, YYCURSOR - start); - for (i = 0; i < ctx->tag.s->len; i++) - ctx->tag.s->val[i] = tolower((int)(unsigned char)ctx->tag.s->val[i]); + for (i = 0; i < ZSTR_LEN(ctx->tag.s); i++) + ZSTR_VAL(ctx->tag.s)[i] = tolower((int)(unsigned char)ZSTR_VAL(ctx->tag.s)[i]); /* intentionally using str_find here, in case the hash value is set, but the string val is changed later */ - if ((ctx->lookup_data = zend_hash_str_find_ptr(ctx->tags, ctx->tag.s->val, ctx->tag.s->len)) != NULL) + if ((ctx->lookup_data = zend_hash_str_find_ptr(ctx->tags, ZSTR_VAL(ctx->tag.s), ZSTR_LEN(ctx->tag.s))) != NULL) ok = 1; STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN; } @@ -271,7 +271,7 @@ static inline void handle_tag(STD_PARA) static inline void handle_arg(STD_PARA) { if (ctx->arg.s) { - ctx->arg.s->len = 0; + ZSTR_LEN(ctx->arg.s) = 0; } smart_str_appendl(&ctx->arg, start, YYCURSOR - start); } @@ -291,8 +291,8 @@ static inline void xx_mainloop(url_adapt_state_ex_t *ctx, const char *newdata, s smart_str_appendl(&ctx->buf, newdata, newlen); - YYCURSOR = ctx->buf.s->val; - YYLIMIT = ctx->buf.s->val + ctx->buf.s->len; + YYCURSOR = ZSTR_VAL(ctx->buf.s); + YYLIMIT = ZSTR_VAL(ctx->buf.s) + ZSTR_LEN(ctx->buf.s); switch (STATE) { case STATE_PLAIN: goto state_plain; @@ -366,8 +366,8 @@ stop: scdebug(("stopped in state %d at pos %d (%d:%c) %d\n", STATE, YYCURSOR - ctx->buf.c, *YYCURSOR, *YYCURSOR, rest)); } - if (rest) memmove(ctx->buf.s->val, start, rest); - ctx->buf.s->len = rest; + if (rest) memmove(ZSTR_VAL(ctx->buf.s), start, rest); + ZSTR_LEN(ctx->buf.s) = rest; } @@ -383,7 +383,7 @@ PHPAPI char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, co if (urlencode) { encoded = php_raw_url_encode(name, strlen(name)); - smart_str_appendl(&url_app, encoded->val, encoded->len); + smart_str_appendl(&url_app, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded); } else { smart_str_appends(&url_app, name); @@ -391,7 +391,7 @@ PHPAPI char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, co smart_str_appendc(&url_app, '='); if (urlencode) { encoded = php_raw_url_encode(value, strlen(value)); - smart_str_appendl(&url_app, encoded->val, encoded->len); + smart_str_appendl(&url_app, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded); } else { smart_str_appends(&url_app, value); @@ -400,8 +400,8 @@ PHPAPI char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, co append_modified_url(&surl, &buf, &url_app, PG(arg_separator).output); smart_str_0(&buf); - if (newlen) *newlen = buf.s->len; - result = estrndup(buf.s->val, buf.s->len); + if (newlen) *newlen = ZSTR_LEN(buf.s); + result = estrndup(ZSTR_VAL(buf.s), ZSTR_LEN(buf.s)); smart_str_free(&url_app); smart_str_free(&buf); @@ -423,16 +423,16 @@ static char *url_adapt_ext(const char *src, size_t srclen, size_t *newlen, zend_ smart_str_appendl(&ctx->result, "", 0); *newlen = 0; } else { - *newlen = ctx->result.s->len; + *newlen = ZSTR_LEN(ctx->result.s); } smart_str_0(&ctx->result); if (do_flush) { smart_str_append(&ctx->result, ctx->buf.s); - *newlen += ctx->buf.s->len; + *newlen += ZSTR_LEN(ctx->buf.s); smart_str_free(&ctx->buf); smart_str_free(&ctx->val); } - retval = estrndup(ctx->result.s->val, ctx->result.s->len); + retval = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s)); smart_str_free(&ctx->result); return retval; } @@ -466,21 +466,21 @@ static void php_url_scanner_output_handler(char *output, size_t output_len, char { size_t len; - if (BG(url_adapt_state_ex).url_app.s->len != 0) { + if (ZSTR_LEN(BG(url_adapt_state_ex).url_app.s) != 0) { *handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END | PHP_OUTPUT_HANDLER_CONT | PHP_OUTPUT_HANDLER_FLUSH | PHP_OUTPUT_HANDLER_FINAL) ? 1 : 0)); if (sizeof(uint) < sizeof(size_t)) { if (len > UINT_MAX) len = UINT_MAX; } *handled_output_len = len; - } else if (BG(url_adapt_state_ex).url_app.s->len == 0) { + } else if (ZSTR_LEN(BG(url_adapt_state_ex).url_app.s) == 0) { url_adapt_state_ex_t *ctx = &BG(url_adapt_state_ex); - if (ctx->buf.s && ctx->buf.s->len) { + if (ctx->buf.s && ZSTR_LEN(ctx->buf.s)) { smart_str_append(&ctx->result, ctx->buf.s); smart_str_appendl(&ctx->result, output, output_len); - *handled_output = estrndup(ctx->result.s->val, ctx->result.s->len); - *handled_output_len = ctx->buf.s->len + output_len; + *handled_output = estrndup(ZSTR_VAL(ctx->result.s), ZSTR_LEN(ctx->result.s)); + *handled_output_len = ZSTR_LEN(ctx->buf.s) + output_len; smart_str_free(&ctx->buf); smart_str_free(&ctx->result); @@ -504,16 +504,16 @@ PHPAPI int php_url_scanner_add_var(char *name, size_t name_len, char *value, siz BG(url_adapt_state_ex).active = 1; } - if (BG(url_adapt_state_ex).url_app.s && BG(url_adapt_state_ex).url_app.s->len != 0) { + if (BG(url_adapt_state_ex).url_app.s && ZSTR_LEN(BG(url_adapt_state_ex).url_app.s) != 0) { smart_str_appends(&BG(url_adapt_state_ex).url_app, PG(arg_separator).output); } if (urlencode) { encoded = php_raw_url_encode(name, name_len); - smart_str_appendl(&sname, encoded->val, encoded->len); + smart_str_appendl(&sname, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded); encoded = php_raw_url_encode(value, value_len); - smart_str_appendl(&svalue, encoded->val, encoded->len); + smart_str_appendl(&svalue, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded); } else { smart_str_appendl(&sname, name, name_len); @@ -539,10 +539,10 @@ PHPAPI int php_url_scanner_add_var(char *name, size_t name_len, char *value, siz PHPAPI int php_url_scanner_reset_vars(void) { if (BG(url_adapt_state_ex).form_app.s) { - BG(url_adapt_state_ex).form_app.s->len = 0; + ZSTR_LEN(BG(url_adapt_state_ex).form_app.s) = 0; } if (BG(url_adapt_state_ex).url_app.s) { - BG(url_adapt_state_ex).url_app.s->len = 0; + ZSTR_LEN(BG(url_adapt_state_ex).url_app.s) = 0; } return SUCCESS; diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c index 3e66449db5..fc2141f73b 100644 --- a/ext/standard/user_filters.c +++ b/ext/standard/user_filters.c @@ -318,7 +318,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, if (NULL == (fdat->ce = zend_lookup_class(fdat->classname))) { php_error_docref(NULL, E_WARNING, "user-filter \"%s\" requires class \"%s\", but that class is not defined", - filtername, fdat->classname->val); + filtername, ZSTR_VAL(fdat->classname)); return NULL; } } @@ -567,12 +567,12 @@ PHP_FUNCTION(stream_filter_register) RETVAL_FALSE; - if (!filtername->len) { + if (!ZSTR_LEN(filtername)) { php_error_docref(NULL, E_WARNING, "Filter name cannot be empty"); return; } - if (!classname->len) { + if (!ZSTR_LEN(classname)) { php_error_docref(NULL, E_WARNING, "Class name cannot be empty"); return; } @@ -586,7 +586,7 @@ PHP_FUNCTION(stream_filter_register) fdat->classname = zend_string_copy(classname); if (zend_hash_add_ptr(BG(user_filter_map), filtername, fdat) != NULL && - php_stream_filter_register_factory_volatile(filtername->val, &user_filter_factory) == SUCCESS) { + php_stream_filter_register_factory_volatile(ZSTR_VAL(filtername), &user_filter_factory) == SUCCESS) { RETVAL_TRUE; } else { zend_string_release(classname); diff --git a/ext/standard/uuencode.c b/ext/standard/uuencode.c index 91de87a194..6520dda376 100644 --- a/ext/standard/uuencode.c +++ b/ext/standard/uuencode.c @@ -73,7 +73,7 @@ PHPAPI zend_string *php_uuencode(char *src, size_t src_len) /* {{{ */ /* encoded length is ~ 38% greater than the original */ dest = zend_string_alloc((size_t)ceil(src_len * 1.38) + 46, 0); - p = dest->val; + p = ZSTR_VAL(dest); s = src; e = src + src_len; @@ -122,7 +122,7 @@ PHPAPI zend_string *php_uuencode(char *src, size_t src_len) /* {{{ */ *p++ = '\n'; *p = '\0'; - dest = zend_string_truncate(dest, p - dest->val, 0); + dest = zend_string_truncate(dest, p - ZSTR_VAL(dest), 0); return dest; } /* }}} */ @@ -134,7 +134,7 @@ PHPAPI zend_string *php_uudecode(char *src, size_t src_len) /* {{{ */ zend_string *dest; dest = zend_string_alloc((size_t) ceil(src_len * 0.75), 0); - p = dest->val; + p = ZSTR_VAL(dest); s = src; e = src + src_len; @@ -173,8 +173,8 @@ PHPAPI zend_string *php_uudecode(char *src, size_t src_len) /* {{{ */ s++; } - assert(p >= dest->val); - if ((len = total_len > (size_t)(p - dest->val))) { + assert(p >= ZSTR_VAL(dest)); + if ((len = total_len > (size_t)(p - ZSTR_VAL(dest)))) { *p++ = PHP_UU_DEC(*s) << 2 | PHP_UU_DEC(*(s + 1)) >> 4; if (len > 1) { *p++ = PHP_UU_DEC(*(s + 1)) << 4 | PHP_UU_DEC(*(s + 2)) >> 2; @@ -184,8 +184,8 @@ PHPAPI zend_string *php_uudecode(char *src, size_t src_len) /* {{{ */ } } - dest->len = total_len; - dest->val[dest->len] = '\0'; + ZSTR_LEN(dest) = total_len; + ZSTR_VAL(dest)[ZSTR_LEN(dest)] = '\0'; return dest; @@ -202,11 +202,11 @@ PHP_FUNCTION(convert_uuencode) { zend_string *src; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &src) == FAILURE || src->len < 1) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &src) == FAILURE || ZSTR_LEN(src) < 1) { RETURN_FALSE; } - RETURN_STR(php_uuencode(src->val, src->len)); + RETURN_STR(php_uuencode(ZSTR_VAL(src), ZSTR_LEN(src))); } /* }}} */ @@ -217,11 +217,11 @@ PHP_FUNCTION(convert_uudecode) zend_string *src; zend_string *dest; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &src) == FAILURE || src->len < 1) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &src) == FAILURE || ZSTR_LEN(src) < 1) { RETURN_FALSE; } - if ((dest = php_uudecode(src->val, src->len)) == NULL) { + if ((dest = php_uudecode(ZSTR_VAL(src), ZSTR_LEN(src))) == NULL) { php_error_docref(NULL, E_WARNING, "The given parameter is not a valid uuencoded string"); RETURN_FALSE; } diff --git a/ext/standard/var.c b/ext/standard/var.c index 2870821fad..055110382b 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -60,7 +60,7 @@ static void php_array_element_dump(zval *zv, zend_ulong index, zend_string *key, php_printf("%*c[" ZEND_LONG_FMT "]=>\n", level + 1, ' ', index); } else { /* string key */ php_printf("%*c[\"", level + 1, ' '); - PHPWRITE(key->val, key->len); + PHPWRITE(ZSTR_VAL(key), ZSTR_LEN(key)); php_printf("\"]=>\n"); } php_var_dump(zv, level + 2); @@ -85,7 +85,7 @@ static void php_object_property_dump(zval *zv, zend_ulong index, zend_string *ke } } else { php_printf("\""); - PHPWRITE(key->val, key->len); + PHPWRITE(ZSTR_VAL(key), ZSTR_LEN(key)); php_printf("\""); } ZEND_PUTS("]=>\n"); @@ -164,7 +164,7 @@ again: myht = Z_OBJDEBUG_P(struc, is_temp); class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc)); - php_printf("%sobject(%s)#%d (%d) {\n", COMMON, class_name->val, Z_OBJ_HANDLE_P(struc), myht ? zend_obj_num_elements(myht) : 0); + php_printf("%sobject(%s)#%d (%d) {\n", COMMON, ZSTR_VAL(class_name), Z_OBJ_HANDLE_P(struc), myht ? zend_obj_num_elements(myht) : 0); zend_string_release(class_name); if (myht) { @@ -230,7 +230,7 @@ static void zval_array_element_dump(zval *zv, zend_ulong index, zend_string *key php_printf("%*c[" ZEND_LONG_FMT "]=>\n", level + 1, ' ', index); } else { /* string key */ php_printf("%*c[\"", level + 1, ' '); - PHPWRITE(key->val, key->len); + PHPWRITE(ZSTR_VAL(key), ZSTR_LEN(key)); php_printf("\"]=>\n"); } php_debug_zval_dump(zv, level + 2); @@ -332,7 +332,7 @@ again: } } class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc)); - php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", COMMON, class_name->val, Z_OBJ_HANDLE_P(struc), myht ? zend_obj_num_elements(myht) : 0, Z_REFCOUNT_P(struc)); + php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", COMMON, ZSTR_VAL(class_name), Z_OBJ_HANDLE_P(struc), myht ? zend_obj_num_elements(myht) : 0, Z_REFCOUNT_P(struc)); zend_string_release(class_name); if (myht) { ZEND_HASH_FOREACH_KEY_VAL_IND(myht, index, key, val) { @@ -405,7 +405,7 @@ static void php_array_element_export(zval *zv, zend_ulong index, zend_string *ke } else { /* string key */ zend_string *tmp_str; zend_string *ckey = php_addcslashes(key, 0, "'\\", 2); - tmp_str = php_str_to_str(ckey->val, ckey->len, "\0", 1, "' . \"\\0\" . '", 12); + tmp_str = php_str_to_str(ZSTR_VAL(ckey), ZSTR_LEN(ckey), "\0", 1, "' . \"\\0\" . '", 12); buffer_append_spaces(buf, level + 1); @@ -479,7 +479,7 @@ again: break; case IS_STRING: ztmp = php_addcslashes(Z_STR_P(struc), 0, "'\\", 2); - ztmp2 = php_str_to_str(ztmp->val, ztmp->len, "\0", 1, "' . \"\\0\" . '", 12); + ztmp2 = php_str_to_str(ZSTR_VAL(ztmp), ZSTR_LEN(ztmp), "\0", 1, "' . \"\\0\" . '", 12); smart_str_appendc(buf, '\''); smart_str_append(buf, ztmp2); @@ -562,7 +562,7 @@ PHPAPI void php_var_export(zval *struc, int level) /* {{{ */ smart_str buf = {0}; php_var_export_ex(struc, level, &buf); smart_str_0(&buf); - PHPWRITE(buf.s->val, buf.s->len); + PHPWRITE(ZSTR_VAL(buf.s), ZSTR_LEN(buf.s)); smart_str_free(&buf); } /* }}} */ @@ -586,7 +586,7 @@ PHP_FUNCTION(var_export) if (return_output) { RETURN_NEW_STR(buf.s); } else { - PHPWRITE(buf.s->val, buf.s->len); + PHPWRITE(ZSTR_VAL(buf.s), ZSTR_LEN(buf.s)); smart_str_free(&buf); } } @@ -664,7 +664,7 @@ static inline zend_bool php_var_serialize_class_name(smart_str *buf, zval *struc PHP_SET_CLASS_ATTRIBUTES(struc); smart_str_appendl(buf, "O:", 2); - smart_str_append_unsigned(buf, class_name->len); + smart_str_append_unsigned(buf, ZSTR_LEN(class_name)); smart_str_appendl(buf, ":\"", 2); smart_str_append(buf, class_name); smart_str_appendl(buf, "\":", 2); @@ -700,7 +700,7 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt ht = HASH_OF(retval_ptr); ZEND_HASH_FOREACH_STR_KEY_VAL(ht, key, val) { - if (incomplete_class && strcmp(key->val, MAGIC_MEMBER) == 0) { + if (incomplete_class && strcmp(ZSTR_VAL(key), MAGIC_MEMBER) == 0) { continue; } @@ -718,7 +718,7 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt continue; } } - php_var_serialize_string(buf, name->val, name->len); + php_var_serialize_string(buf, ZSTR_VAL(name), ZSTR_LEN(name)); php_var_serialize_intern(buf, d, var_hash); } else { zend_class_entry *ce = Z_OBJ_P(struc)->ce; @@ -727,7 +727,7 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt do { priv_name = zend_mangle_property_name( - ce->name->val, ce->name->len, name->val, name->len, ce->type & ZEND_INTERNAL_CLASS); + ZSTR_VAL(ce->name), ZSTR_LEN(ce->name), ZSTR_VAL(name), ZSTR_LEN(name), ce->type & ZEND_INTERNAL_CLASS); if ((d = zend_hash_find(propers, priv_name)) != NULL) { if (Z_TYPE_P(d) == IS_INDIRECT) { d = Z_INDIRECT_P(d); @@ -735,14 +735,14 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt break; } } - php_var_serialize_string(buf, priv_name->val, priv_name->len); + php_var_serialize_string(buf, ZSTR_VAL(priv_name), ZSTR_LEN(priv_name)); zend_string_free(priv_name); php_var_serialize_intern(buf, d, var_hash); break; } zend_string_free(priv_name); prot_name = zend_mangle_property_name( - "*", 1, name->val, name->len, ce->type & ZEND_INTERNAL_CLASS); + "*", 1, ZSTR_VAL(name), ZSTR_LEN(name), ce->type & ZEND_INTERNAL_CLASS); if ((d = zend_hash_find(propers, prot_name)) != NULL) { if (Z_TYPE_P(d) == IS_INDIRECT) { d = Z_INDIRECT_P(d); @@ -751,19 +751,19 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt break; } } - php_var_serialize_string(buf, prot_name->val, prot_name->len); + php_var_serialize_string(buf, ZSTR_VAL(prot_name), ZSTR_LEN(prot_name)); zend_string_free(prot_name); php_var_serialize_intern(buf, d, var_hash); break; } zend_string_free(prot_name); - php_var_serialize_string(buf, name->val, name->len); + php_var_serialize_string(buf, ZSTR_VAL(name), ZSTR_LEN(name)); php_var_serialize_intern(buf, nvalp, var_hash); php_error_docref(NULL, E_NOTICE, - "\"%s\" returned as member variable from __sleep() but does not exist", name->val); + "\"%s\" returned as member variable from __sleep() but does not exist", ZSTR_VAL(name)); } while (0); } else { - php_var_serialize_string(buf, name->val, name->len); + php_var_serialize_string(buf, ZSTR_VAL(name), ZSTR_LEN(name)); php_var_serialize_intern(buf, nvalp, var_hash); } } @@ -844,7 +844,7 @@ again: if (ce->serialize(struc, &serialized_data, &serialized_length, (zend_serialize_data *)var_hash) == SUCCESS) { smart_str_appendl(buf, "C:", 2); - smart_str_append_unsigned(buf, Z_OBJCE_P(struc)->name->len); + smart_str_append_unsigned(buf, ZSTR_LEN(Z_OBJCE_P(struc)->name)); smart_str_appendl(buf, ":\"", 2); smart_str_append(buf, Z_OBJCE_P(struc)->name); smart_str_appendl(buf, "\":", 2); @@ -918,14 +918,14 @@ again: ZEND_HASH_FOREACH_KEY_VAL_IND(myht, index, key, data) { - if (incomplete_class && strcmp(key->val, MAGIC_MEMBER) == 0) { + if (incomplete_class && strcmp(ZSTR_VAL(key), MAGIC_MEMBER) == 0) { continue; } if (!key) { php_var_serialize_long(buf, index); } else { - php_var_serialize_string(buf, key->val, key->len); + php_var_serialize_string(buf, ZSTR_VAL(key), ZSTR_LEN(key)); } /* we should still add element even if it's not OK, diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c index f3b22c1e27..b3aa1c567b 100644 --- a/ext/standard/var_unserializer.c +++ b/ext/standard/var_unserializer.c @@ -206,7 +206,7 @@ static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t return NULL; } if (**p != '\\') { - str->val[i] = (char)**p; + ZSTR_VAL(str)[i] = (char)**p; } else { unsigned char ch = 0; @@ -223,12 +223,12 @@ static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t return NULL; } } - str->val[i] = (char)ch; + ZSTR_VAL(str)[i] = (char)ch; } (*p)++; } - str->val[i] = 0; - str->len = i; + ZSTR_VAL(str)[i] = 0; + ZSTR_LEN(str) = i; return str; } @@ -245,8 +245,8 @@ static inline int unserialize_allowed_class(zend_string *class_name, HashTable * return 0; } - ZSTR_ALLOCA_ALLOC(lcname, class_name->len, use_heap); - zend_str_tolower_copy(lcname->val, class_name->val, class_name->len); + ZSTR_ALLOCA_ALLOC(lcname, ZSTR_LEN(class_name), use_heap); + zend_str_tolower_copy(ZSTR_VAL(lcname), ZSTR_VAL(class_name), ZSTR_LEN(class_name)); res = zend_hash_exists(classes, lcname); ZSTR_ALLOCA_FREE(lcname, use_heap); return res; @@ -428,7 +428,7 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) } if (ce->unserialize == NULL) { - zend_error(E_WARNING, "Class %s has no unserializer", ce->name->val); + zend_error(E_WARNING, "Class %s has no unserializer", ZSTR_VAL(ce->name)); object_init_ex(rval, ce); } else if (ce->unserialize(rval, ce, (const unsigned char*)*p, datalen, (zend_unserialize_data *)var_hash) != SUCCESS) { return 0; @@ -452,7 +452,7 @@ static inline zend_long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry * } else { /* If this class implements Serializable, it should not land here but in object_custom(). The passed string obviously doesn't descend from the regular serializer. */ - zend_error(E_WARNING, "Erroneous data format for unserializing '%s'", ce->name->val); + zend_error(E_WARNING, "Erroneous data format for unserializing '%s'", ZSTR_VAL(ce->name)); return 0; } @@ -795,7 +795,7 @@ yy20: ret = object_custom(UNSERIALIZE_PASSTHRU, ce); if (ret && incomplete_class) { - php_store_class_name(rval, class_name->val, len2); + php_store_class_name(rval, ZSTR_VAL(class_name), len2); } zend_string_release(class_name); return ret; @@ -804,7 +804,7 @@ yy20: elements = object_common1(UNSERIALIZE_PASSTHRU, ce); if (incomplete_class) { - php_store_class_name(rval, class_name->val, len2); + php_store_class_name(rval, ZSTR_VAL(class_name), len2); } zend_string_release(class_name); diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index fbe9cf9cf3..0b0917a60a 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -204,7 +204,7 @@ static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t return NULL; } if (**p != '\\') { - str->val[i] = (char)**p; + ZSTR_VAL(str)[i] = (char)**p; } else { unsigned char ch = 0; @@ -221,12 +221,12 @@ static zend_string *unserialize_str(const unsigned char **p, size_t len, size_t return NULL; } } - str->val[i] = (char)ch; + ZSTR_VAL(str)[i] = (char)ch; } (*p)++; } - str->val[i] = 0; - str->len = i; + ZSTR_VAL(str)[i] = 0; + ZSTR_LEN(str) = i; return str; } @@ -243,8 +243,8 @@ static inline int unserialize_allowed_class(zend_string *class_name, HashTable * return 0; } - ZSTR_ALLOCA_ALLOC(lcname, class_name->len, use_heap); - zend_str_tolower_copy(lcname->val, class_name->val, class_name->len); + ZSTR_ALLOCA_ALLOC(lcname, ZSTR_LEN(class_name), use_heap); + zend_str_tolower_copy(ZSTR_VAL(lcname), ZSTR_VAL(class_name), ZSTR_LEN(class_name)); res = zend_hash_exists(classes, lcname); ZSTR_ALLOCA_FREE(lcname, use_heap); return res; @@ -432,7 +432,7 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) } if (ce->unserialize == NULL) { - zend_error(E_WARNING, "Class %s has no unserializer", ce->name->val); + zend_error(E_WARNING, "Class %s has no unserializer", ZSTR_VAL(ce->name)); object_init_ex(rval, ce); } else if (ce->unserialize(rval, ce, (const unsigned char*)*p, datalen, (zend_unserialize_data *)var_hash) != SUCCESS) { return 0; @@ -456,7 +456,7 @@ static inline zend_long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry * } else { /* If this class implements Serializable, it should not land here but in object_custom(). The passed string obviously doesn't descend from the regular serializer. */ - zend_error(E_WARNING, "Erroneous data format for unserializing '%s'", ce->name->val); + zend_error(E_WARNING, "Erroneous data format for unserializing '%s'", ZSTR_VAL(ce->name)); return 0; } @@ -850,7 +850,7 @@ object ":" uiv ":" ["] { ret = object_custom(UNSERIALIZE_PASSTHRU, ce); if (ret && incomplete_class) { - php_store_class_name(rval, class_name->val, len2); + php_store_class_name(rval, ZSTR_VAL(class_name), len2); } zend_string_release(class_name); return ret; @@ -859,7 +859,7 @@ object ":" uiv ":" ["] { elements = object_common1(UNSERIALIZE_PASSTHRU, ce); if (incomplete_class) { - php_store_class_name(rval, class_name->val, len2); + php_store_class_name(rval, ZSTR_VAL(class_name), len2); } zend_string_release(class_name); diff --git a/ext/sysvmsg/sysvmsg.c b/ext/sysvmsg/sysvmsg.c index d0a079c280..09cf0a561f 100644 --- a/ext/sysvmsg/sysvmsg.c +++ b/ext/sysvmsg/sysvmsg.c @@ -422,9 +422,9 @@ PHP_FUNCTION(msg_send) /* NB: php_msgbuf is 1 char bigger than a long, so there is no need to * allocate the extra byte. */ - messagebuffer = safe_emalloc(msg_var.s->len, 1, sizeof(struct php_msgbuf)); - memcpy(messagebuffer->mtext, msg_var.s->val, msg_var.s->len + 1); - message_len = msg_var.s->len; + messagebuffer = safe_emalloc(ZSTR_LEN(msg_var.s), 1, sizeof(struct php_msgbuf)); + memcpy(messagebuffer->mtext, ZSTR_VAL(msg_var.s), ZSTR_LEN(msg_var.s) + 1); + message_len = ZSTR_LEN(msg_var.s); smart_str_free(&msg_var); } else { char *p; diff --git a/ext/sysvshm/sysvshm.c b/ext/sysvshm/sysvshm.c index ac90b47496..f5d8ca8c93 100644 --- a/ext/sysvshm/sysvshm.c +++ b/ext/sysvshm/sysvshm.c @@ -268,7 +268,7 @@ PHP_FUNCTION(shm_put_var) } /* insert serialized variable into shared memory */ - ret = php_put_shm_data(shm_list_ptr->ptr, shm_key, shm_var.s? shm_var.s->val : NULL, shm_var.s? shm_var.s->len : 0); + ret = php_put_shm_data(shm_list_ptr->ptr, shm_key, shm_var.s? ZSTR_VAL(shm_var.s) : NULL, shm_var.s? ZSTR_LEN(shm_var.s) : 0); /* free string */ smart_str_free(&shm_var); diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index e1c13e6515..edd0bcf85e 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -567,7 +567,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|zsb", &arg1, &config, &enc, &enc_len, &use_include_path) == FAILURE) { RETURN_FALSE; } - if (!(data = php_tidy_file_to_mem(arg1->val, use_include_path))) { + if (!(data = php_tidy_file_to_mem(ZSTR_VAL(arg1), use_include_path))) { RETURN_FALSE; } } else { @@ -608,7 +608,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil TidyBuffer buf; tidyBufInit(&buf); - tidyBufAttach(&buf, (byte *) data->val, data->len); + tidyBufAttach(&buf, (byte *) ZSTR_VAL(data), ZSTR_LEN(data)); if (tidyParseBuffer(doc, &buf) < 0) { php_error_docref(NULL, E_WARNING, "%s", errbuf->bp); @@ -998,7 +998,7 @@ static int _php_tidy_apply_config_array(TidyDoc doc, HashTable *ht_options) if (opt_name == NULL) { continue; } - _php_tidy_set_tidy_opt(doc, opt_name->val, opt_val); + _php_tidy_set_tidy_opt(doc, ZSTR_VAL(opt_name), opt_val); } ZEND_HASH_FOREACH_END(); return SUCCESS; @@ -1086,14 +1086,14 @@ static PHP_INI_MH(php_tidy_set_clean_output) int status; zend_bool value; - if (new_value->len==2 && strcasecmp("on", new_value->val)==0) { + if (ZSTR_LEN(new_value)==2 && strcasecmp("on", ZSTR_VAL(new_value))==0) { value = (zend_bool) 1; - } else if (new_value->len==3 && strcasecmp("yes", new_value->val)==0) { + } else if (ZSTR_LEN(new_value)==3 && strcasecmp("yes", ZSTR_VAL(new_value))==0) { value = (zend_bool) 1; - } else if (new_value->len==4 && strcasecmp("true", new_value->val)==0) { + } else if (ZSTR_LEN(new_value)==4 && strcasecmp("true", ZSTR_VAL(new_value))==0) { value = (zend_bool) 1; } else { - value = (zend_bool) atoi(new_value->val); + value = (zend_bool) atoi(ZSTR_VAL(new_value)); } if (stage == PHP_INI_STAGE_RUNTIME) { @@ -1202,7 +1202,7 @@ static PHP_FUNCTION(tidy_parse_string) TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options); - if (php_tidy_parse_string(obj, input->val, input->len, enc) == FAILURE) { + if (php_tidy_parse_string(obj, ZSTR_VAL(input), ZSTR_LEN(input), enc) == FAILURE) { zval_ptr_dtor(return_value); RETURN_FALSE; } @@ -1258,14 +1258,14 @@ static PHP_FUNCTION(tidy_parse_file) tidy_instanciate(tidy_ce_doc, return_value); obj = Z_TIDY_P(return_value); - if (!(contents = php_tidy_file_to_mem(inputfile->val, use_include_path))) { - php_error_docref(NULL, E_WARNING, "Cannot Load '%s' into memory%s", inputfile->val, (use_include_path) ? " (Using include path)" : ""); + if (!(contents = php_tidy_file_to_mem(ZSTR_VAL(inputfile), use_include_path))) { + php_error_docref(NULL, E_WARNING, "Cannot Load '%s' into memory%s", ZSTR_VAL(inputfile), (use_include_path) ? " (Using include path)" : ""); RETURN_FALSE; } TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options); - if (php_tidy_parse_string(obj, contents->val, contents->len, enc) == FAILURE) { + if (php_tidy_parse_string(obj, ZSTR_VAL(contents), ZSTR_LEN(contents), enc) == FAILURE) { zval_ptr_dtor(return_value); RETVAL_FALSE; } @@ -1571,14 +1571,14 @@ static TIDY_DOC_METHOD(__construct) obj = Z_TIDY_P(object); if (inputfile) { - if (!(contents = php_tidy_file_to_mem(inputfile->val, use_include_path))) { - php_error_docref(NULL, E_WARNING, "Cannot Load '%s' into memory%s", inputfile->val, (use_include_path) ? " (Using include path)" : ""); + if (!(contents = php_tidy_file_to_mem(ZSTR_VAL(inputfile), use_include_path))) { + php_error_docref(NULL, E_WARNING, "Cannot Load '%s' into memory%s", ZSTR_VAL(inputfile), (use_include_path) ? " (Using include path)" : ""); return; } TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options); - php_tidy_parse_string(obj, contents->val, contents->len, enc); + php_tidy_parse_string(obj, ZSTR_VAL(contents), ZSTR_LEN(contents), enc); zend_string_release(contents); } @@ -1602,14 +1602,14 @@ static TIDY_DOC_METHOD(parseFile) RETURN_FALSE; } - if (!(contents = php_tidy_file_to_mem(inputfile->val, use_include_path))) { - php_error_docref(NULL, E_WARNING, "Cannot Load '%s' into memory%s", inputfile->val, (use_include_path) ? " (Using include path)" : ""); + if (!(contents = php_tidy_file_to_mem(ZSTR_VAL(inputfile), use_include_path))) { + php_error_docref(NULL, E_WARNING, "Cannot Load '%s' into memory%s", ZSTR_VAL(inputfile), (use_include_path) ? " (Using include path)" : ""); RETURN_FALSE; } TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options); - if (php_tidy_parse_string(obj, contents->val, contents->len, enc) == FAILURE) { + if (php_tidy_parse_string(obj, ZSTR_VAL(contents), ZSTR_LEN(contents), enc) == FAILURE) { RETVAL_FALSE; } else { RETVAL_TRUE; @@ -1636,7 +1636,7 @@ static TIDY_DOC_METHOD(parseString) TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options); - if(php_tidy_parse_string(obj, input->val, input->len, enc) == SUCCESS) { + if(php_tidy_parse_string(obj, ZSTR_VAL(input), ZSTR_LEN(input), enc) == SUCCESS) { RETURN_TRUE; } diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c index 4e55c715e1..d364115799 100644 --- a/ext/wddx/wddx.c +++ b/ext/wddx/wddx.c @@ -63,7 +63,7 @@ #define EL_DATETIME "dateTime" #define php_wddx_deserialize(a,b) \ - php_wddx_deserialize_ex((a)->value.str.val, (a)->value.str.len, (b)) + php_wddx_deserialize_ex(Z_STRVAL_P(a), Z_STRLEN_P(a), (b)) #define SET_STACK_VARNAME \ if (stack->varname) { \ @@ -394,7 +394,7 @@ static void php_wddx_serialize_string(wddx_packet *packet, zval *var) buf = php_escape_html_entities(Z_STRVAL_P(var), Z_STRLEN_P(var), 0, ENT_QUOTES, NULL); - php_wddx_add_chunk_ex(packet, buf->val, buf->len); + php_wddx_add_chunk_ex(packet, ZSTR_VAL(buf), ZSTR_LEN(buf)); zend_string_release(buf); } @@ -408,7 +408,7 @@ static void php_wddx_serialize_number(wddx_packet *packet, zval *var) { char tmp_buf[WDDX_BUF_LEN]; zend_string *str = zval_get_string(var); - snprintf(tmp_buf, sizeof(tmp_buf), WDDX_NUMBER, str->val); + snprintf(tmp_buf, sizeof(tmp_buf), WDDX_NUMBER, ZSTR_VAL(str)); zend_string_release(str); php_wddx_add_chunk(packet, tmp_buf); @@ -458,7 +458,7 @@ static void php_wddx_serialize_object(wddx_packet *packet, zval *obj) snprintf(tmp_buf, WDDX_BUF_LEN, WDDX_VAR_S, PHP_CLASS_NAME_VAR); php_wddx_add_chunk(packet, tmp_buf); php_wddx_add_chunk_static(packet, WDDX_STRING_S); - php_wddx_add_chunk_ex(packet, class_name->val, class_name->len); + php_wddx_add_chunk_ex(packet, ZSTR_VAL(class_name), ZSTR_LEN(class_name)); php_wddx_add_chunk_static(packet, WDDX_STRING_E); php_wddx_add_chunk_static(packet, WDDX_VAR_E); @@ -488,7 +488,7 @@ static void php_wddx_serialize_object(wddx_packet *packet, zval *obj) snprintf(tmp_buf, WDDX_BUF_LEN, WDDX_VAR_S, PHP_CLASS_NAME_VAR); php_wddx_add_chunk(packet, tmp_buf); php_wddx_add_chunk_static(packet, WDDX_STRING_S); - php_wddx_add_chunk_ex(packet, class_name->val, class_name->len); + php_wddx_add_chunk_ex(packet, ZSTR_VAL(class_name), ZSTR_LEN(class_name)); php_wddx_add_chunk_static(packet, WDDX_STRING_E); php_wddx_add_chunk_static(packet, WDDX_VAR_E); @@ -591,9 +591,9 @@ void php_wddx_serialize_var(wddx_packet *packet, zval *var, zend_string *name) char *tmp_buf; zend_string *name_esc; - name_esc = php_escape_html_entities(name->val, name->len, 0, ENT_QUOTES, NULL); - tmp_buf = emalloc(name_esc->len + sizeof(WDDX_VAR_S)); - snprintf(tmp_buf, name_esc->len + sizeof(WDDX_VAR_S), WDDX_VAR_S, name_esc->val); + name_esc = php_escape_html_entities(ZSTR_VAL(name), ZSTR_LEN(name), 0, ENT_QUOTES, NULL); + tmp_buf = emalloc(ZSTR_LEN(name_esc) + sizeof(WDDX_VAR_S)); + snprintf(tmp_buf, ZSTR_LEN(name_esc) + sizeof(WDDX_VAR_S), WDDX_VAR_S, ZSTR_VAL(name_esc)); php_wddx_add_chunk(packet, tmp_buf); efree(tmp_buf); zend_string_release(name_esc); @@ -1266,7 +1266,7 @@ PHP_FUNCTION(wddx_deserialize) return; } - php_wddx_deserialize_ex(payload->val, payload->len, return_value); + php_wddx_deserialize_ex(ZSTR_VAL(payload), ZSTR_LEN(payload), return_value); if (stream) { efree(payload); diff --git a/ext/xml/xml.c b/ext/xml/xml.c index 386d8ed587..bcded6203a 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -504,7 +504,7 @@ static void xml_call_handler(xml_parser *parser, zval *handler, zend_function *f (method = zend_hash_index_find(Z_ARRVAL_P(handler), 1)) != NULL && Z_TYPE_P(obj) == IS_OBJECT && Z_TYPE_P(method) == IS_STRING) { - php_error_docref(NULL, E_WARNING, "Unable to call handler %s::%s()", Z_OBJCE_P(obj)->name->val, Z_STRVAL_P(method)); + php_error_docref(NULL, E_WARNING, "Unable to call handler %s::%s()", ZSTR_VAL(Z_OBJCE_P(obj)->name), Z_STRVAL_P(method)); } else php_error_docref(NULL, E_WARNING, "Unable to call handler"); } @@ -582,29 +582,29 @@ PHP_XML_API zend_string *xml_utf8_encode(const char *s, size_t len, const XML_Ch /* This is the theoretical max (will never get beyond len * 2 as long * as we are converting from single-byte characters, though) */ str = zend_string_alloc(len * 4, 0); - str->len = 0; + ZSTR_LEN(str) = 0; while (pos > 0) { c = encoder ? encoder((unsigned char)(*s)) : (unsigned short)(*s); if (c < 0x80) { - str->val[str->len++] = (char) c; + ZSTR_VAL(str)[ZSTR_LEN(str)++] = (char) c; } else if (c < 0x800) { - str->val[str->len++] = (0xc0 | (c >> 6)); - str->val[str->len++] = (0x80 | (c & 0x3f)); + ZSTR_VAL(str)[ZSTR_LEN(str)++] = (0xc0 | (c >> 6)); + ZSTR_VAL(str)[ZSTR_LEN(str)++] = (0x80 | (c & 0x3f)); } else if (c < 0x10000) { - str->val[str->len++] = (0xe0 | (c >> 12)); - str->val[str->len++] = (0xc0 | ((c >> 6) & 0x3f)); - str->val[str->len++] = (0x80 | (c & 0x3f)); + ZSTR_VAL(str)[ZSTR_LEN(str)++] = (0xe0 | (c >> 12)); + ZSTR_VAL(str)[ZSTR_LEN(str)++] = (0xc0 | ((c >> 6) & 0x3f)); + ZSTR_VAL(str)[ZSTR_LEN(str)++] = (0x80 | (c & 0x3f)); } else if (c < 0x200000) { - str->val[str->len++] = (0xf0 | (c >> 18)); - str->val[str->len++] = (0xe0 | ((c >> 12) & 0x3f)); - str->val[str->len++] = (0xc0 | ((c >> 6) & 0x3f)); - str->val[str->len++] = (0x80 | (c & 0x3f)); + ZSTR_VAL(str)[ZSTR_LEN(str)++] = (0xf0 | (c >> 18)); + ZSTR_VAL(str)[ZSTR_LEN(str)++] = (0xe0 | ((c >> 12) & 0x3f)); + ZSTR_VAL(str)[ZSTR_LEN(str)++] = (0xc0 | ((c >> 6) & 0x3f)); + ZSTR_VAL(str)[ZSTR_LEN(str)++] = (0x80 | (c & 0x3f)); } pos--; s++; } - str->val[str->len] = '\0'; - str = zend_string_truncate(str, str->len, 0); + ZSTR_VAL(str)[ZSTR_LEN(str)] = '\0'; + str = zend_string_truncate(str, ZSTR_LEN(str), 0); return str; } /* }}} */ @@ -631,7 +631,7 @@ PHP_XML_API zend_string *xml_utf8_decode(const XML_Char *s, size_t len, const XM } str = zend_string_alloc(len, 0); - str->len = 0; + ZSTR_LEN(str) = 0; while (pos < len) { int status = FAILURE; c = php_next_utf8_char((const unsigned char*)s, (size_t) len, &pos, &status); @@ -640,11 +640,11 @@ PHP_XML_API zend_string *xml_utf8_decode(const XML_Char *s, size_t len, const XM c = '?'; } - str->val[str->len++] = decoder ? decoder(c) : c; + ZSTR_VAL(str)[ZSTR_LEN(str)++] = decoder ? decoder(c) : c; } - str->val[str->len] = '\0'; - if (str->len < len) { - str = zend_string_truncate(str, str->len, 0); + ZSTR_VAL(str)[ZSTR_LEN(str)] = '\0'; + if (ZSTR_LEN(str) < len) { + str = zend_string_truncate(str, ZSTR_LEN(str), 0); } return str; @@ -706,7 +706,7 @@ static zend_string *_xml_decode_tag(xml_parser *parser, const char *tag) str = xml_utf8_decode((const XML_Char *)tag, strlen(tag), parser->target_encoding); if (parser->case_folding) { - php_strtoupper(str->val, str->len); + php_strtoupper(ZSTR_VAL(str), ZSTR_LEN(str)); } return str; @@ -728,7 +728,7 @@ void _xml_startElementHandler(void *userData, const XML_Char *name, const XML_Ch if (!Z_ISUNDEF(parser->startElementHandler)) { ZVAL_COPY(&args[0], &parser->index); - ZVAL_STRING(&args[1], tag_name->val + parser->toffset); + ZVAL_STRING(&args[1], ZSTR_VAL(tag_name) + parser->toffset); array_init(&args[2]); while (attributes && *attributes) { @@ -757,13 +757,13 @@ void _xml_startElementHandler(void *userData, const XML_Char *name, const XML_Ch array_init(&tag); array_init(&atr); - _xml_add_to_info(parser, tag_name->val + parser->toffset); + _xml_add_to_info(parser, ZSTR_VAL(tag_name) + parser->toffset); - add_assoc_string(&tag, "tag", tag_name->val + parser->toffset); /* cast to avoid gcc-warning */ + add_assoc_string(&tag, "tag", ZSTR_VAL(tag_name) + parser->toffset); /* cast to avoid gcc-warning */ add_assoc_string(&tag, "type", "open"); add_assoc_long(&tag, "level", parser->level); - parser->ltags[parser->level-1] = estrdup(tag_name->val); + parser->ltags[parser->level-1] = estrdup(ZSTR_VAL(tag_name)); parser->lastwasopen = 1; attributes = (const XML_Char **) attrs; @@ -813,7 +813,7 @@ void _xml_endElementHandler(void *userData, const XML_Char *name) if (!Z_ISUNDEF(parser->endElementHandler)) { ZVAL_COPY(&args[0], &parser->index); - ZVAL_STRING(&args[1], (tag_name->val) + parser->toffset); + ZVAL_STRING(&args[1], ZSTR_VAL(tag_name) + parser->toffset); xml_call_handler(parser, &parser->endElementHandler, parser->endElementPtr, 2, args, &retval); zval_ptr_dtor(&retval); @@ -827,9 +827,9 @@ void _xml_endElementHandler(void *userData, const XML_Char *name) } else { array_init(&tag); - _xml_add_to_info(parser, tag_name->val + parser->toffset); + _xml_add_to_info(parser, ZSTR_VAL(tag_name) + parser->toffset); - add_assoc_string(&tag, "tag", tag_name->val + parser->toffset); /* cast to avoid gcc-warning */ + add_assoc_string(&tag, "tag", ZSTR_VAL(tag_name) + parser->toffset); /* cast to avoid gcc-warning */ add_assoc_string(&tag, "type", "close"); add_assoc_long(&tag, "level", parser->level); @@ -871,8 +871,8 @@ void _xml_characterDataHandler(void *userData, const XML_Char *s, int len) zend_string *decoded_value; decoded_value = xml_utf8_decode(s, len, parser->target_encoding); - for (i = 0; i < decoded_value->len; i++) { - switch (decoded_value->val[i]) { + for (i = 0; i < ZSTR_LEN(decoded_value); i++) { + switch (ZSTR_VAL(decoded_value)[i]) { case ' ': case '\t': case '\n': @@ -891,10 +891,10 @@ void _xml_characterDataHandler(void *userData, const XML_Char *s, int len) /* check if the current tag already has a value - if yes append to that! */ if ((myval = zend_hash_str_find(Z_ARRVAL_P(parser->ctag), "value", sizeof("value") - 1))) { - int newlen = Z_STRLEN_P(myval) + decoded_value->len; + int newlen = Z_STRLEN_P(myval) + ZSTR_LEN(decoded_value); Z_STR_P(myval) = zend_string_extend(Z_STR_P(myval), newlen, 0); - strncpy(Z_STRVAL_P(myval) + Z_STRLEN_P(myval) - decoded_value->len, - decoded_value->val, decoded_value->len + 1); + strncpy(Z_STRVAL_P(myval) + Z_STRLEN_P(myval) - ZSTR_LEN(decoded_value), + ZSTR_VAL(decoded_value), ZSTR_LEN(decoded_value) + 1); zend_string_release(decoded_value); } else { add_assoc_str(parser->ctag, "value", decoded_value); @@ -908,10 +908,10 @@ void _xml_characterDataHandler(void *userData, const XML_Char *s, int len) if ((mytype = zend_hash_str_find(Z_ARRVAL_P(curtag),"type", sizeof("type") - 1))) { if (!strcmp(Z_STRVAL_P(mytype), "cdata")) { if ((myval = zend_hash_str_find(Z_ARRVAL_P(curtag), "value", sizeof("value") - 1))) { - int newlen = Z_STRLEN_P(myval) + decoded_value->len; + int newlen = Z_STRLEN_P(myval) + ZSTR_LEN(decoded_value); Z_STR_P(myval) = zend_string_extend(Z_STR_P(myval), newlen, 0); - strncpy(Z_STRVAL_P(myval) + Z_STRLEN_P(myval) - decoded_value->len, - decoded_value->val, decoded_value->len + 1); + strncpy(Z_STRVAL_P(myval) + Z_STRLEN_P(myval) - ZSTR_LEN(decoded_value), + ZSTR_VAL(decoded_value), ZSTR_LEN(decoded_value) + 1); zend_string_release(decoded_value); return; } diff --git a/ext/xmlrpc/xmlrpc-epi-php.c b/ext/xmlrpc/xmlrpc-epi-php.c index 4c1b6ef785..62bc39dba4 100644 --- a/ext/xmlrpc/xmlrpc-epi-php.c +++ b/ext/xmlrpc/xmlrpc-epi-php.c @@ -406,7 +406,7 @@ static void set_output_options(php_output_options* options, zval* output_opts) options->xmlrpc_out.version = xmlrpc_version_simple; } else if (!strcmp(Z_STRVAL_P(val), VERSION_VALUE_SOAP11)) { options->xmlrpc_out.version = xmlrpc_version_soap_1_1; - } else { /* if(!strcmp((*val)->value.str.val, VERSION_VALUE_AUTO)) { */ + } else { /* if(!strcmp(Z_STRVAL_P(val), VERSION_VALUE_AUTO)) { */ options->b_auto_version = 1; } } @@ -575,7 +575,7 @@ static XMLRPC_VALUE PHP_to_XMLRPC_worker (const char* key, zval* in_val, int dep efree(num_str); } } else { - XMLRPC_AddValueToVector(xReturn, PHP_to_XMLRPC_worker(my_key->val, pIter, depth++)); + XMLRPC_AddValueToVector(xReturn, PHP_to_XMLRPC_worker(ZSTR_VAL(my_key), pIter, depth++)); } if (ht) { ht->u.v.nApplyCount--; @@ -921,25 +921,25 @@ static void php_xmlrpc_introspection_callback(XMLRPC_SERVER server, void* data) if (xData) { if (!XMLRPC_ServerAddIntrospectionData(server, xData)) { - php_error_docref(NULL, E_WARNING, "Unable to add introspection data returned from %s(), improper element structure", php_function_name->val); + php_error_docref(NULL, E_WARNING, "Unable to add introspection data returned from %s(), improper element structure", ZSTR_VAL(php_function_name)); } XMLRPC_CleanupValue(xData); } else { /* could not create description */ if (err.xml_elem_error.parser_code) { php_error_docref(NULL, E_WARNING, "xml parse error: [line %ld, column %ld, message: %s] Unable to add introspection data returned from %s()", - err.xml_elem_error.column, err.xml_elem_error.line, err.xml_elem_error.parser_error, php_function_name->val); + err.xml_elem_error.column, err.xml_elem_error.line, err.xml_elem_error.parser_error, ZSTR_VAL(php_function_name)); } else { - php_error_docref(NULL, E_WARNING, "Unable to add introspection data returned from %s()", php_function_name->val); + php_error_docref(NULL, E_WARNING, "Unable to add introspection data returned from %s()", ZSTR_VAL(php_function_name)); } } zval_ptr_dtor(&retval); } else { /* user func failed */ - php_error_docref(NULL, E_WARNING, "Error calling user introspection callback: %s()", php_function_name->val); + php_error_docref(NULL, E_WARNING, "Error calling user introspection callback: %s()", ZSTR_VAL(php_function_name)); } } else { - php_error_docref(NULL, E_WARNING, "Invalid callback '%s' passed", php_function_name->val); + php_error_docref(NULL, E_WARNING, "Invalid callback '%s' passed", ZSTR_VAL(php_function_name)); } zend_string_release(php_function_name); } ZEND_HASH_FOREACH_END(); diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index f39d17105e..f5a8fa8e33 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -163,7 +163,7 @@ static char **php_xsl_xslt_make_params(HashTable *parht, int xpath_params) xpath_expr = estrndup(Z_STRVAL_P(value), Z_STRLEN_P(value)); } if (xpath_expr) { - params[i++] = estrndup(string_key->val, string_key->len); + params[i++] = estrndup(ZSTR_VAL(string_key), ZSTR_LEN(string_key)); params[i++] = xpath_expr; } } @@ -321,10 +321,10 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t fci.no_separation = 0; /*fci.function_handler_cache = &function_ptr;*/ if (!zend_make_callable(&handler, &callable)) { - php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", callable->val); + php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", ZSTR_VAL(callable)); valuePush(ctxt, xmlXPathNewString("")); } else if ( intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable) == 0) { - php_error_docref(NULL, E_WARNING, "Not allowed to call handler '%s()'", callable->val); + php_error_docref(NULL, E_WARNING, "Not allowed to call handler '%s()'", ZSTR_VAL(callable)); /* Push an empty string, so that we at least have an xslt result... */ valuePush(ctxt, xmlXPathNewString("")); } else { @@ -651,7 +651,7 @@ PHP_FUNCTION(xsl_xsltprocessor_transform_to_doc) if (ce == NULL || !instanceof_function(ce, curce)) { xmlFreeDoc(newdocp); php_error_docref(NULL, E_WARNING, - "Expecting class compatible with %s, '%s' given", curclass_name->val, ret_class->val); + "Expecting class compatible with %s, '%s' given", ZSTR_VAL(curclass_name), ZSTR_VAL(ret_class)); RETURN_FALSE; } diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 7c17fb983a..85bc51f152 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -213,7 +213,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil return 1; } - len = spprintf(&fullpath, 0, "%s/%s", file_dirname_fullpath, file_basename->val); + len = spprintf(&fullpath, 0, "%s/%s", file_dirname_fullpath, ZSTR_VAL(file_basename)); if (!len) { efree(file_dirname_fullpath); zend_string_release(file_basename); @@ -650,10 +650,10 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val char fullpath[MAXPATHLEN]; int ovector[3]; int matches; - int namelist_len = namelist[i]->len; + int namelist_len = ZSTR_LEN(namelist[i]); - if ((namelist_len == 1 && namelist[i]->val[0] == '.') || - (namelist_len == 2 && namelist[i]->val[0] == '.' && namelist[i]->val[1] == '.')) { + if ((namelist_len == 1 && ZSTR_VAL(namelist[i])[0] == '.') || + (namelist_len == 2 && ZSTR_VAL(namelist[i])[0] == '.' && ZSTR_VAL(namelist[i])[1] == '.')) { zend_string_release(namelist[i]); continue; } @@ -665,7 +665,7 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val break; } - snprintf(fullpath, MAXPATHLEN, "%s%c%s", path, DEFAULT_SLASH, namelist[i]->val); + snprintf(fullpath, MAXPATHLEN, "%s%c%s", path, DEFAULT_SLASH, ZSTR_VAL(namelist[i])); if (0 != VCWD_STAT(fullpath, &s)) { php_error_docref(NULL, E_WARNING, "Cannot read <%s>", fullpath); @@ -678,7 +678,7 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val continue; } - matches = pcre_exec(re, NULL, namelist[i]->val, namelist[i]->len, 0, 0, ovector, 3); + matches = pcre_exec(re, NULL, ZSTR_VAL(namelist[i]), ZSTR_LEN(namelist[i]), 0, 0, ovector, 3); /* 0 means that the vector is too small to hold all the captured substring offsets */ if (matches < 0) { zend_string_release(namelist[i]); @@ -1114,16 +1114,16 @@ static PHP_NAMED_FUNCTION(zif_zip_open) return; } - if (filename->len == 0) { + if (ZSTR_LEN(filename) == 0) { php_error_docref(NULL, E_WARNING, "Empty string as source"); RETURN_FALSE; } - if (ZIP_OPENBASEDIR_CHECKPATH(filename->val)) { + if (ZIP_OPENBASEDIR_CHECKPATH(ZSTR_VAL(filename))) { RETURN_FALSE; } - if(!expand_filepath(filename->val, resolved_path)) { + if(!expand_filepath(ZSTR_VAL(filename), resolved_path)) { RETURN_FALSE; } @@ -1283,10 +1283,10 @@ static PHP_NAMED_FUNCTION(zif_zip_entry_read) if (zr_rsrc->zf) { buffer = zend_string_alloc(len, 0); - n = zip_fread(zr_rsrc->zf, buffer->val, buffer->len); + n = zip_fread(zr_rsrc->zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer)); if (n > 0) { - buffer->val[n] = '\0'; - buffer->len = n; + ZSTR_VAL(buffer)[n] = '\0'; + ZSTR_LEN(buffer) = n; RETURN_NEW_STR(buffer); } else { zend_string_free(buffer); @@ -1417,16 +1417,16 @@ static ZIPARCHIVE_METHOD(open) ze_obj = Z_ZIP_P(self); } - if (filename->len == 0) { + if (ZSTR_LEN(filename) == 0) { php_error_docref(NULL, E_WARNING, "Empty string as source"); RETURN_FALSE; } - if (ZIP_OPENBASEDIR_CHECKPATH(filename->val)) { + if (ZIP_OPENBASEDIR_CHECKPATH(ZSTR_VAL(filename))) { RETURN_FALSE; } - if (!(resolved_path = expand_filepath(filename->val, NULL))) { + if (!(resolved_path = expand_filepath(ZSTR_VAL(filename), NULL))) { RETURN_FALSE; } @@ -1634,7 +1634,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* } } - if (pattern->len == 0) { + if (ZSTR_LEN(pattern) == 0) { php_error_docref(NULL, E_NOTICE, "Empty string as pattern"); RETURN_FALSE; } @@ -1651,7 +1651,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* } if (type == 1) { - found = php_zip_glob(pattern->val, pattern->len, flags, return_value); + found = php_zip_glob(ZSTR_VAL(pattern), ZSTR_LEN(pattern), flags, return_value); } else { found = php_zip_pcre(pattern, path, path_len, return_value); } @@ -1669,8 +1669,8 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* if ((zval_file = zend_hash_index_find(Z_ARRVAL_P(return_value), i)) != NULL) { if (remove_all_path) { basename = php_basename(Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file), NULL, 0); - file_stripped = basename->val; - file_stripped_len = basename->len; + file_stripped = ZSTR_VAL(basename); + file_stripped_len = ZSTR_LEN(basename); } else if (remove_path && strstr(Z_STRVAL_P(zval_file), remove_path) != NULL) { file_stripped = Z_STRVAL_P(zval_file) + remove_path_len + 1; file_stripped_len = Z_STRLEN_P(zval_file) - remove_path_len - 1; @@ -1747,17 +1747,17 @@ static ZIPARCHIVE_METHOD(addFile) return; } - if (filename->len == 0) { + if (ZSTR_LEN(filename) == 0) { php_error_docref(NULL, E_NOTICE, "Empty string as filename"); RETURN_FALSE; } if (entry_name_len == 0) { - entry_name = filename->val; - entry_name_len = filename->len; + entry_name = ZSTR_VAL(filename); + entry_name_len = ZSTR_LEN(filename); } - if (php_zip_add_file(intern, filename->val, filename->len, entry_name, entry_name_len, 0, 0) < 0) { + if (php_zip_add_file(intern, ZSTR_VAL(filename), ZSTR_LEN(filename), entry_name, entry_name_len, 0, 0) < 0) { RETURN_FALSE; } else { RETURN_TRUE; @@ -1799,10 +1799,10 @@ static ZIPARCHIVE_METHOD(addFromString) ze_obj->buffers_cnt++; pos = 0; } - ze_obj->buffers[pos] = (char *)emalloc(buffer->len + 1); - memcpy(ze_obj->buffers[pos], buffer->val, buffer->len + 1); + ze_obj->buffers[pos] = (char *)emalloc(ZSTR_LEN(buffer) + 1); + memcpy(ze_obj->buffers[pos], ZSTR_VAL(buffer), ZSTR_LEN(buffer) + 1); - zs = zip_source_buffer(intern, ze_obj->buffers[pos], buffer->len, 0); + zs = zip_source_buffer(intern, ze_obj->buffers[pos], ZSTR_LEN(buffer), 0); if (zs == NULL) { RETURN_FALSE; @@ -1847,7 +1847,7 @@ static ZIPARCHIVE_METHOD(statName) return; } - PHP_ZIP_STAT_PATH(intern, name->val, name->len, flags, sb); + PHP_ZIP_STAT_PATH(intern, ZSTR_VAL(name), ZSTR_LEN(name), flags, sb); RETURN_SB(&sb); } @@ -1901,11 +1901,11 @@ static ZIPARCHIVE_METHOD(locateName) return; } - if (name->len < 1) { + if (ZSTR_LEN(name) < 1) { RETURN_FALSE; } - idx = (zend_long)zip_name_locate(intern, (const char *)name->val, flags); + idx = (zend_long)zip_name_locate(intern, (const char *)ZSTR_VAL(name), flags); if (idx >= 0) { RETURN_LONG(idx); @@ -2698,7 +2698,7 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */ if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|ll", &filename, &len, &flags) == FAILURE) { return; } - PHP_ZIP_STAT_PATH(intern, filename->val, filename->len, flags, sb); + PHP_ZIP_STAT_PATH(intern, ZSTR_VAL(filename), ZSTR_LEN(filename), flags, sb); } else { if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|ll", &index, &len, &flags) == FAILURE) { return; @@ -2716,7 +2716,7 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */ if (index >= 0) { zf = zip_fopen_index(intern, index, flags); } else { - zf = zip_fopen(intern, filename->val, flags); + zf = zip_fopen(intern, ZSTR_VAL(filename), flags); } if (zf == NULL) { @@ -2724,15 +2724,15 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */ } buffer = zend_string_alloc(len, 0); - n = zip_fread(zf, buffer->val, buffer->len); + n = zip_fread(zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer)); if (n < 1) { zend_string_free(buffer); RETURN_EMPTY_STRING(); } zip_fclose(zf); - buffer->val[n] = '\0'; - buffer->len = n; + ZSTR_VAL(buffer)[n] = '\0'; + ZSTR_LEN(buffer) = n; RETURN_NEW_STR(buffer); } /* }}} */ @@ -2775,13 +2775,13 @@ static ZIPARCHIVE_METHOD(getStream) return; } - if (zip_stat(intern, filename->val, 0, &sb) != 0) { + if (zip_stat(intern, ZSTR_VAL(filename), 0, &sb) != 0) { RETURN_FALSE; } obj = Z_ZIP_P(self); - stream = php_stream_zip_open(obj->filename, filename->val, mode STREAMS_CC); + stream = php_stream_zip_open(obj->filename, ZSTR_VAL(filename), mode STREAMS_CC); if (stream) { php_stream_to_zval(stream, return_value); } else { diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index b4b95e85a5..2d141597ed 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -351,9 +351,9 @@ static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encod out = zend_string_alloc(PHP_ZLIB_BUFFER_SIZE_GUESS(in_len), 0); Z.next_in = (Bytef *) in_buf; - Z.next_out = (Bytef *) out->val; + Z.next_out = (Bytef *) ZSTR_VAL(out); Z.avail_in = in_len; - Z.avail_out = out->len; + Z.avail_out = ZSTR_LEN(out); status = deflate(&Z, Z_FINISH); deflateEnd(&Z); @@ -361,7 +361,7 @@ static zend_string *php_zlib_encode(const char *in_buf, size_t in_len, int encod if (Z_STREAM_END == status) { /* size buffer down to actual length */ out = zend_string_truncate(out, Z.total_out, 0); - out->val[out->len] = '\0'; + ZSTR_VAL(out)[ZSTR_LEN(out)] = '\0'; return out; } else { zend_string_free(out); @@ -687,7 +687,7 @@ static PHP_FUNCTION(name) \ php_error_docref(NULL, E_WARNING, "encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE"); \ RETURN_FALSE; \ } \ - if ((out = php_zlib_encode(in->val, in->len, encoding, level)) == NULL) { \ + if ((out = php_zlib_encode(ZSTR_VAL(in), ZSTR_LEN(in), encoding, level)) == NULL) { \ RETURN_FALSE; \ } \ RETURN_STR(out); \ @@ -766,8 +766,8 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict, int i; zend_bool last_null = 1; - for (i = 0; i < str->len; i++) { - if (str->val[i]) { + for (i = 0; i < ZSTR_LEN(str); i++) { + if (ZSTR_VAL(str)[i]) { last_null = 0; } else { if (last_null) { @@ -781,9 +781,9 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict, php_error_docref(NULL, E_WARNING, "dictionary string must be NULL-byte terminated (each dictionary entry has to be NULL-terminated)"); } - *dict = emalloc(str->len); - memcpy(*dict, str->val, str->len); - *dictlen = str->len; + *dict = emalloc(ZSTR_LEN(str)); + memcpy(*dict, ZSTR_VAL(str), ZSTR_LEN(str)); + *dictlen = ZSTR_LEN(str); } break; case IS_ARRAY: { @@ -799,7 +799,7 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict, int i; *++ptr = zval_get_string(cur); - if (!*ptr || (*ptr)->len == 0) { + if (!*ptr || ZSTR_LEN(*ptr) == 0) { if (*ptr) { efree(*ptr); } @@ -810,8 +810,8 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict, php_error_docref(NULL, E_WARNING, "dictionary entries must be non-empty strings"); return 0; } - for (i = 0; i < (*ptr)->len; i++) { - if ((*ptr)->val[i] == 0) { + for (i = 0; i < ZSTR_LEN(*ptr); i++) { + if (ZSTR_VAL(*ptr)[i] == 0) { do { efree(ptr); } while (--ptr >= strings); @@ -821,15 +821,15 @@ static zend_bool zlib_create_dictionary_string(HashTable *options, char **dict, } } - *dictlen += (*ptr)->len + 1; + *dictlen += ZSTR_LEN(*ptr) + 1; } ZEND_HASH_FOREACH_END(); dictptr = *dict = emalloc(*dictlen); ptr = strings; end = strings + zend_hash_num_elements(dictionary); do { - memcpy(dictptr, (*ptr)->val, (*ptr)->len); - dictptr += (*ptr)->len; + memcpy(dictptr, ZSTR_VAL(*ptr), ZSTR_LEN(*ptr)); + dictptr += ZSTR_LEN(*ptr); *dictptr++ = 0; zend_string_release(*ptr); } while (++ptr != end); @@ -947,21 +947,21 @@ PHP_FUNCTION(inflate_add) out = zend_string_alloc((in_len > CHUNK_SIZE) ? in_len : CHUNK_SIZE, 0); ctx->next_in = (Bytef *) in_buf; - ctx->next_out = (Bytef *) out->val; + ctx->next_out = (Bytef *) ZSTR_VAL(out); ctx->avail_in = in_len; - ctx->avail_out = out->len; + ctx->avail_out = ZSTR_LEN(out); do { status = inflate(ctx, flush_type); - buffer_used = out->len - ctx->avail_out; + buffer_used = ZSTR_LEN(out) - ctx->avail_out; switch (status) { case Z_OK: if (ctx->avail_out == 0) { /* more output buffer space needed; realloc and try again */ - out = zend_string_realloc(out, out->len + CHUNK_SIZE, 0); + out = zend_string_realloc(out, ZSTR_LEN(out) + CHUNK_SIZE, 0); ctx->avail_out = CHUNK_SIZE; - ctx->next_out = (Bytef *) out->val + buffer_used; + ctx->next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; break; } else { goto complete; @@ -972,9 +972,9 @@ PHP_FUNCTION(inflate_add) case Z_BUF_ERROR: if (flush_type == Z_FINISH && ctx->avail_out == 0) { /* more output buffer space needed; realloc and try again */ - out = zend_string_realloc(out, out->len + CHUNK_SIZE, 0); + out = zend_string_realloc(out, ZSTR_LEN(out) + CHUNK_SIZE, 0); ctx->avail_out = CHUNK_SIZE; - ctx->next_out = (Bytef *) out->val + buffer_used; + ctx->next_out = (Bytef *) ZSTR_VAL(out) + buffer_used; break; } else { /* No more input data; we're finished */ @@ -1010,7 +1010,7 @@ PHP_FUNCTION(inflate_add) complete: { out = zend_string_realloc(out, buffer_used, 0); - out->val[buffer_used] = 0; + ZSTR_VAL(out)[buffer_used] = 0; RETURN_STR(out); } } @@ -1162,20 +1162,20 @@ PHP_FUNCTION(deflate_add) out = zend_string_alloc(out_size, 0); ctx->next_in = (Bytef *) in_buf; - ctx->next_out = (Bytef *) out->val; + ctx->next_out = (Bytef *) ZSTR_VAL(out); ctx->avail_in = in_len; - ctx->avail_out = out->len; + ctx->avail_out = ZSTR_LEN(out); status = deflate(ctx, flush_type); switch (status) { case Z_OK: - out->len = (char *) ctx->next_out - out->val; - out->val[out->len] = 0; + ZSTR_LEN(out) = (char *) ctx->next_out - ZSTR_VAL(out); + ZSTR_VAL(out)[ZSTR_LEN(out)] = 0; RETURN_STR(out); break; case Z_STREAM_END: - out->len = (char *) ctx->next_out - out->val; - out->val[out->len] = 0; + ZSTR_LEN(out) = (char *) ctx->next_out - ZSTR_VAL(out); + ZSTR_VAL(out)[ZSTR_LEN(out)] = 0; deflateReset(ctx); RETURN_STR(out); break; @@ -1370,12 +1370,12 @@ static PHP_INI_MH(OnUpdate_zlib_output_compression) return FAILURE; } - if (!strncasecmp(new_value->val, "off", sizeof("off"))) { + if (!strncasecmp(ZSTR_VAL(new_value), "off", sizeof("off"))) { int_value = 0; - } else if (!strncasecmp(new_value->val, "on", sizeof("on"))) { + } else if (!strncasecmp(ZSTR_VAL(new_value), "on", sizeof("on"))) { int_value = 1; } else { - int_value = zend_atoi(new_value->val, new_value->len); + int_value = zend_atoi(ZSTR_VAL(new_value), ZSTR_LEN(new_value)); } ini_value = zend_ini_string("output_handler", sizeof("output_handler"), 0); |