Use ZSTR_ API to access zend_string elements (this is just renaming without semantick changes).

This commit is contained in:
Dmitry Stogov 2015-06-30 04:05:24 +03:00
parent 8cce5b2641
commit 4a2e40bb86
169 changed files with 3285 additions and 3175 deletions

View file

@ -552,9 +552,9 @@ END_EXTERN_C()
#if ZEND_DEBUG #if ZEND_DEBUG
#define CHECK_ZVAL_STRING(str) \ #define CHECK_ZVAL_STRING(str) \
if ((str)->val[(str)->len] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s)", (str)->val); } if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s)", ZSTR_VAL(str)); }
#define CHECK_ZVAL_STRING_REL(str) \ #define CHECK_ZVAL_STRING_REL(str) \
if ((str)->val[(str)->len] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", (str)->val ZEND_FILE_LINE_RELAY_CC); } if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
#else #else
#define CHECK_ZVAL_STRING(z) #define CHECK_ZVAL_STRING(z)
#define CHECK_ZVAL_STRING_REL(z) #define CHECK_ZVAL_STRING_REL(z)
@ -918,7 +918,7 @@ ZEND_API void ZEND_FASTCALL zend_wrong_callback_error(int severity, int num, cha
Z_PARAM_PROLOGUE(separate); \ Z_PARAM_PROLOGUE(separate); \
if (UNEXPECTED(!zend_parse_arg_object(_arg, &dest, _ce, check_null))) { \ if (UNEXPECTED(!zend_parse_arg_object(_arg, &dest, _ce, check_null))) { \
if (_ce) { \ if (_ce) { \
_error = (_ce)->name->val; \ _error = ZSTR_VAL((_ce)->name); \
error_code = ZPP_ERROR_WRONG_CLASS; \ error_code = ZPP_ERROR_WRONG_CLASS; \
break; \ break; \
} else { \ } else { \

View file

@ -264,7 +264,7 @@ static zend_always_inline int _zend_handle_numeric_str(const char *key, size_t l
_zend_handle_numeric_str(key, length, &idx) _zend_handle_numeric_str(key, length, &idx)
#define ZEND_HANDLE_NUMERIC(key, idx) \ #define ZEND_HANDLE_NUMERIC(key, idx) \
ZEND_HANDLE_NUMERIC_STR((key)->val, (key)->len, idx) ZEND_HANDLE_NUMERIC_STR(ZSTR_VAL(key), ZSTR_LEN(key), idx)
static zend_always_inline zval *zend_hash_find_ind(const HashTable *ht, zend_string *key) static zend_always_inline zval *zend_hash_find_ind(const HashTable *ht, zend_string *key)
@ -900,7 +900,7 @@ static zend_always_inline zval *_zend_hash_append(HashTable *ht, zend_string *ke
zend_string_hash_val(key); zend_string_hash_val(key);
} }
p->key = key; p->key = key;
p->h = key->h; p->h = ZSTR_H(key);
nIndex = (uint32_t)p->h | ht->nTableMask; nIndex = (uint32_t)p->h | ht->nTableMask;
Z_NEXT(p->val) = HT_HASH(ht, nIndex); Z_NEXT(p->val) = HT_HASH(ht, nIndex);
HT_HASH(ht, nIndex) = HT_IDX_TO_HASH(idx); HT_HASH(ht, nIndex) = HT_IDX_TO_HASH(idx);
@ -922,7 +922,7 @@ static zend_always_inline zval *_zend_hash_append_ptr(HashTable *ht, zend_string
zend_string_hash_val(key); zend_string_hash_val(key);
} }
p->key = key; p->key = key;
p->h = key->h; p->h = ZSTR_H(key);
nIndex = (uint32_t)p->h | ht->nTableMask; nIndex = (uint32_t)p->h | ht->nTableMask;
Z_NEXT(p->val) = HT_HASH(ht, nIndex); Z_NEXT(p->val) = HT_HASH(ht, nIndex);
HT_HASH(ht, nIndex) = HT_IDX_TO_HASH(idx); HT_HASH(ht, nIndex) = HT_IDX_TO_HASH(idx);
@ -944,7 +944,7 @@ static zend_always_inline void _zend_hash_append_ind(HashTable *ht, zend_string
zend_string_hash_val(key); zend_string_hash_val(key);
} }
p->key = key; p->key = key;
p->h = key->h; p->h = ZSTR_H(key);
nIndex = (uint32_t)p->h | ht->nTableMask; nIndex = (uint32_t)p->h | ht->nTableMask;
Z_NEXT(p->val) = HT_HASH(ht, nIndex); Z_NEXT(p->val) = HT_HASH(ht, nIndex);
HT_HASH(ht, nIndex) = HT_IDX_TO_HASH(idx); HT_HASH(ht, nIndex) = HT_IDX_TO_HASH(idx);

View file

@ -52,7 +52,7 @@ static zend_always_inline size_t smart_str_alloc(smart_str *str, size_t len, zen
if (UNEXPECTED(!str->s)) { if (UNEXPECTED(!str->s)) {
goto do_smart_str_realloc; goto do_smart_str_realloc;
} else { } else {
len += str->s->len; len += ZSTR_LEN(str->s);
if (UNEXPECTED(len >= str->a)) { if (UNEXPECTED(len >= str->a)) {
do_smart_str_realloc: do_smart_str_realloc:
if (persistent) { if (persistent) {
@ -75,28 +75,28 @@ static zend_always_inline void smart_str_free(smart_str *str) {
static zend_always_inline void smart_str_0(smart_str *str) { static zend_always_inline void smart_str_0(smart_str *str) {
if (str->s) { if (str->s) {
str->s->val[str->s->len] = '\0'; ZSTR_VAL(str->s)[ZSTR_LEN(str->s)] = '\0';
} }
} }
static zend_always_inline void smart_str_appendc_ex(smart_str *dest, char ch, zend_bool persistent) { static zend_always_inline void smart_str_appendc_ex(smart_str *dest, char ch, zend_bool persistent) {
size_t new_len = smart_str_alloc(dest, 1, persistent); size_t new_len = smart_str_alloc(dest, 1, persistent);
dest->s->val[new_len - 1] = ch; ZSTR_VAL(dest->s)[new_len - 1] = ch;
dest->s->len = new_len; ZSTR_LEN(dest->s) = new_len;
} }
static zend_always_inline void smart_str_appendl_ex(smart_str *dest, const char *str, size_t len, zend_bool persistent) { static zend_always_inline void smart_str_appendl_ex(smart_str *dest, const char *str, size_t len, zend_bool persistent) {
size_t new_len = smart_str_alloc(dest, len, persistent); size_t new_len = smart_str_alloc(dest, len, persistent);
memcpy(dest->s->val + dest->s->len, str, len); memcpy(ZSTR_VAL(dest->s) + ZSTR_LEN(dest->s), str, len);
dest->s->len = new_len; ZSTR_LEN(dest->s) = new_len;
} }
static zend_always_inline void smart_str_append_ex(smart_str *dest, const zend_string *src, zend_bool persistent) { static zend_always_inline void smart_str_append_ex(smart_str *dest, const zend_string *src, zend_bool persistent) {
smart_str_appendl_ex(dest, src->val, src->len, persistent); smart_str_appendl_ex(dest, ZSTR_VAL(src), ZSTR_LEN(src), persistent);
} }
static zend_always_inline void smart_str_append_smart_str_ex(smart_str *dest, const smart_str *src, zend_bool persistent) { static zend_always_inline void smart_str_append_smart_str_ex(smart_str *dest, const smart_str *src, zend_bool persistent) {
if (src->s && src->s->len) { if (src->s && ZSTR_LEN(src->s)) {
smart_str_append_ex(dest, src->s, persistent); smart_str_append_ex(dest, src->s, persistent);
} }
} }

View file

@ -37,8 +37,9 @@ END_EXTERN_C()
/* Shortcuts */ /* Shortcuts */
#define ZSTR_VAL(zstr) zend_string_get_val(zstr) #define ZSTR_VAL(zstr) (zstr)->val
#define ZSTR_LEN(zstr) (zstr)->len #define ZSTR_LEN(zstr) (zstr)->len
#define ZSTR_H(zstr) (zstr)->h
#define ZSTR_HASH(zstr) zend_string_hash_val(zstr) #define ZSTR_HASH(zstr) zend_string_hash_val(zstr)
/* Compatibility macros */ /* Compatibility macros */
@ -65,7 +66,7 @@ END_EXTERN_C()
GC_REFCOUNT(str) = 1; \ GC_REFCOUNT(str) = 1; \
GC_TYPE_INFO(str) = IS_STRING; \ GC_TYPE_INFO(str) = IS_STRING; \
zend_string_forget_hash_val(str); \ zend_string_forget_hash_val(str); \
zend_string_set_len(str, _len); \ ZSTR_LEN(str) = _len; \
} while (0) } while (0)
#define ZSTR_ALLOCA_INIT(str, s, len, use_heap) do { \ #define ZSTR_ALLOCA_INIT(str, s, len, use_heap) do { \
@ -78,27 +79,17 @@ END_EXTERN_C()
/*---*/ /*---*/
static zend_always_inline char * zend_string_get_val(zend_string *s)
{
return s->val;
}
static zend_always_inline void zend_string_set_len(zend_string *s, size_t len)
{
s->len = len;
}
static zend_always_inline zend_ulong zend_string_hash_val(zend_string *s) static zend_always_inline zend_ulong zend_string_hash_val(zend_string *s)
{ {
if (!s->h) { if (!ZSTR_H(s)) {
s->h = zend_hash_func(ZSTR_VAL(s), ZSTR_LEN(s)); ZSTR_H(s) = zend_hash_func(ZSTR_VAL(s), ZSTR_LEN(s));
} }
return s->h; return ZSTR_H(s);
} }
static zend_always_inline void zend_string_forget_hash_val(zend_string *s) static zend_always_inline void zend_string_forget_hash_val(zend_string *s)
{ {
s->h = 0; ZSTR_H(s) = 0;
} }
static zend_always_inline uint32_t zend_string_refcount(const zend_string *s) static zend_always_inline uint32_t zend_string_refcount(const zend_string *s)
@ -139,7 +130,7 @@ static zend_always_inline zend_string *zend_string_alloc(size_t len, int persist
GC_INFO(ret) = 0; GC_INFO(ret) = 0;
#endif #endif
zend_string_forget_hash_val(ret); zend_string_forget_hash_val(ret);
zend_string_set_len(ret, len); ZSTR_LEN(ret) = len;
return ret; return ret;
} }
@ -157,7 +148,7 @@ static zend_always_inline zend_string *zend_string_safe_alloc(size_t n, size_t m
GC_INFO(ret) = 0; GC_INFO(ret) = 0;
#endif #endif
zend_string_forget_hash_val(ret); zend_string_forget_hash_val(ret);
zend_string_set_len(ret, (n * m) + l); ZSTR_LEN(ret) = (n * m) + l;
return ret; return ret;
} }
@ -194,7 +185,7 @@ static zend_always_inline zend_string *zend_string_realloc(zend_string *s, size_
if (!ZSTR_IS_INTERNED(s)) { if (!ZSTR_IS_INTERNED(s)) {
if (EXPECTED(GC_REFCOUNT(s) == 1)) { if (EXPECTED(GC_REFCOUNT(s) == 1)) {
ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent); ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent);
zend_string_set_len(ret, len); ZSTR_LEN(ret) = len;
zend_string_forget_hash_val(ret); zend_string_forget_hash_val(ret);
return ret; return ret;
} else { } else {
@ -214,7 +205,7 @@ static zend_always_inline zend_string *zend_string_extend(zend_string *s, size_t
if (!ZSTR_IS_INTERNED(s)) { if (!ZSTR_IS_INTERNED(s)) {
if (EXPECTED(GC_REFCOUNT(s) == 1)) { if (EXPECTED(GC_REFCOUNT(s) == 1)) {
ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent); ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent);
zend_string_set_len(ret, len); ZSTR_LEN(ret) = len;
zend_string_forget_hash_val(ret); zend_string_forget_hash_val(ret);
return ret; return ret;
} else { } else {
@ -234,7 +225,7 @@ static zend_always_inline zend_string *zend_string_truncate(zend_string *s, size
if (!ZSTR_IS_INTERNED(s)) { if (!ZSTR_IS_INTERNED(s)) {
if (EXPECTED(GC_REFCOUNT(s) == 1)) { if (EXPECTED(GC_REFCOUNT(s) == 1)) {
ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent); ret = (zend_string *)perealloc(s, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(len)), persistent);
zend_string_set_len(ret, len); ZSTR_LEN(ret) = len;
zend_string_forget_hash_val(ret); zend_string_forget_hash_val(ret);
return ret; return ret;
} else { } else {
@ -253,7 +244,7 @@ static zend_always_inline zend_string *zend_string_safe_realloc(zend_string *s,
if (!ZSTR_IS_INTERNED(s)) { if (!ZSTR_IS_INTERNED(s)) {
if (GC_REFCOUNT(s) == 1) { if (GC_REFCOUNT(s) == 1) {
ret = (zend_string *)safe_perealloc(s, n, m, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(l)), persistent); ret = (zend_string *)safe_perealloc(s, n, m, ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(l)), persistent);
zend_string_set_len(ret, (n * m) + l); ZSTR_LEN(ret) = (n * m) + l;
zend_string_forget_hash_val(ret); zend_string_forget_hash_val(ret);
return ret; return ret;
} else { } else {

View file

@ -2863,14 +2863,14 @@ ZEND_VM_HANDLER(56, ZEND_ROPE_END, TMP, CONST|TMPVAR|CV)
} }
} }
for (i = 0; i <= opline->extended_value; i++) { for (i = 0; i <= opline->extended_value; i++) {
len += rope[i]->len; len += ZSTR_LEN(rope[i]);
} }
ret = EX_VAR(opline->result.var); ret = EX_VAR(opline->result.var);
ZVAL_STR(ret, zend_string_alloc(len, 0)); ZVAL_STR(ret, zend_string_alloc(len, 0));
target = Z_STRVAL_P(ret); target = Z_STRVAL_P(ret);
for (i = 0; i <= opline->extended_value; i++) { for (i = 0; i <= opline->extended_value; i++) {
memcpy(target, rope[i]->val, rope[i]->len); memcpy(target, ZSTR_VAL(rope[i]), ZSTR_LEN(rope[i]));
target += rope[i]->len; target += ZSTR_LEN(rope[i]);
zend_string_release(rope[i]); zend_string_release(rope[i]);
} }
*target = '\0'; *target = '\0';

View file

@ -12999,14 +12999,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ROPE_END_SPEC_TMP_CONST_HANDLE
} }
} }
for (i = 0; i <= opline->extended_value; i++) { for (i = 0; i <= opline->extended_value; i++) {
len += rope[i]->len; len += ZSTR_LEN(rope[i]);
} }
ret = EX_VAR(opline->result.var); ret = EX_VAR(opline->result.var);
ZVAL_STR(ret, zend_string_alloc(len, 0)); ZVAL_STR(ret, zend_string_alloc(len, 0));
target = Z_STRVAL_P(ret); target = Z_STRVAL_P(ret);
for (i = 0; i <= opline->extended_value; i++) { for (i = 0; i <= opline->extended_value; i++) {
memcpy(target, rope[i]->val, rope[i]->len); memcpy(target, ZSTR_VAL(rope[i]), ZSTR_LEN(rope[i]));
target += rope[i]->len; target += ZSTR_LEN(rope[i]);
zend_string_release(rope[i]); zend_string_release(rope[i]);
} }
*target = '\0'; *target = '\0';
@ -14283,14 +14283,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ROPE_END_SPEC_TMP_CV_HANDLER(Z
} }
} }
for (i = 0; i <= opline->extended_value; i++) { for (i = 0; i <= opline->extended_value; i++) {
len += rope[i]->len; len += ZSTR_LEN(rope[i]);
} }
ret = EX_VAR(opline->result.var); ret = EX_VAR(opline->result.var);
ZVAL_STR(ret, zend_string_alloc(len, 0)); ZVAL_STR(ret, zend_string_alloc(len, 0));
target = Z_STRVAL_P(ret); target = Z_STRVAL_P(ret);
for (i = 0; i <= opline->extended_value; i++) { for (i = 0; i <= opline->extended_value; i++) {
memcpy(target, rope[i]->val, rope[i]->len); memcpy(target, ZSTR_VAL(rope[i]), ZSTR_LEN(rope[i]));
target += rope[i]->len; target += ZSTR_LEN(rope[i]);
zend_string_release(rope[i]); zend_string_release(rope[i]);
} }
*target = '\0'; *target = '\0';
@ -14796,14 +14796,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ROPE_END_SPEC_TMP_TMPVAR_HANDL
} }
} }
for (i = 0; i <= opline->extended_value; i++) { for (i = 0; i <= opline->extended_value; i++) {
len += rope[i]->len; len += ZSTR_LEN(rope[i]);
} }
ret = EX_VAR(opline->result.var); ret = EX_VAR(opline->result.var);
ZVAL_STR(ret, zend_string_alloc(len, 0)); ZVAL_STR(ret, zend_string_alloc(len, 0));
target = Z_STRVAL_P(ret); target = Z_STRVAL_P(ret);
for (i = 0; i <= opline->extended_value; i++) { for (i = 0; i <= opline->extended_value; i++) {
memcpy(target, rope[i]->val, rope[i]->len); memcpy(target, ZSTR_VAL(rope[i]), ZSTR_LEN(rope[i]));
target += rope[i]->len; target += ZSTR_LEN(rope[i]);
zend_string_release(rope[i]); zend_string_release(rope[i]);
} }
*target = '\0'; *target = '\0';

View file

@ -58,7 +58,7 @@ zend_string
if (str == NULL) bc_out_of_memory(); if (str == NULL) bc_out_of_memory();
/* The negative sign if needed. */ /* The negative sign if needed. */
sptr = str->val; sptr = ZSTR_VAL(str);
if (signch) *sptr++ = '-'; if (signch) *sptr++ = '-';
/* Load the whole number. */ /* Load the whole number. */
@ -76,6 +76,6 @@ zend_string
/* Terminate the string and return it! */ /* Terminate the string and return it! */
*sptr = '\0'; *sptr = '\0';
str->len = sptr - (char *)str->val; ZSTR_LEN(str) = sptr - (char *)ZSTR_VAL(str);
return str; return str;
} }

View file

@ -291,7 +291,7 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
* failed. * failed.
*/ */
if (opened_path && !bz_file && mode[0] == 'w') { 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; RETURN_FALSE;
} }
data = zend_string_alloc(len, 0); data = zend_string_alloc(len, 0);
data->len = php_stream_read(stream, data->val, data->len); ZSTR_LEN(data) = php_stream_read(stream, ZSTR_VAL(data), ZSTR_LEN(data));
data->val[data->len] = '\0'; ZSTR_VAL(data)[ZSTR_LEN(data)] = '\0';
RETURN_NEW_STR(data); RETURN_NEW_STR(data);
} }
@ -539,15 +539,15 @@ static PHP_FUNCTION(bzcompress)
work_factor = zwork_factor; 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) { if (error != BZ_OK) {
zend_string_free(dest); zend_string_free(dest);
RETURN_LONG(error); RETURN_LONG(error);
} else { } else {
/* Copy the buffer, we have perhaps allocate a lot more than we need, /* Copy the buffer, we have perhaps allocate a lot more than we need,
so we erealloc() the buffer to the proper size */ so we erealloc() the buffer to the proper size */
dest->len = dest_len; ZSTR_LEN(dest) = dest_len;
dest->val[dest->len] = '\0'; ZSTR_VAL(dest)[ZSTR_LEN(dest)] = '\0';
RETURN_NEW_STR(dest); RETURN_NEW_STR(dest);
} }
} }

View file

@ -2243,7 +2243,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
#endif #endif
{ {
zend_string *str = zval_get_string(zvalue); 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); zend_string_release(str);
return ret; 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); error = curl_easy_setopt(ch->cp, option, NULL);
} else { } else {
zend_string *str = zval_get_string(zvalue); 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); zend_string_release(str);
return ret; return ret;
} }
@ -2279,7 +2279,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
case CURLOPT_PRIVATE: case CURLOPT_PRIVATE:
{ {
zend_string *str = zval_get_string(zvalue); 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); zend_string_release(str);
return ret; return ret;
} }
@ -2288,7 +2288,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
case CURLOPT_URL: case CURLOPT_URL:
{ {
zend_string *str = zval_get_string(zvalue); 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); zend_string_release(str);
return ret; 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) { ZEND_HASH_FOREACH_VAL(ph, current) {
val = zval_get_string(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); zend_string_release(val);
if (!slist) { if (!slist) {
php_error_docref(NULL, E_WARNING, "Could not build curl_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); prop = zend_read_property(curl_CURLFile_class, current, "name", sizeof("name")-1, 0, &rv);
if (Z_TYPE_P(prop) != IS_STRING) { 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 { } else {
postval = Z_STR_P(prop); postval = Z_STR_P(prop);
if (php_check_open_basedir(postval->val)) { if (php_check_open_basedir(ZSTR_VAL(postval))) {
return 1; return 1;
} }
@ -2539,11 +2539,11 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
filename = Z_STRVAL_P(prop); filename = Z_STRVAL_P(prop);
} }
form_error = curl_formadd(&first, &last, form_error = curl_formadd(&first, &last,
CURLFORM_COPYNAME, string_key->val, CURLFORM_COPYNAME, ZSTR_VAL(string_key),
CURLFORM_NAMELENGTH, string_key->len, CURLFORM_NAMELENGTH, ZSTR_LEN(string_key),
CURLFORM_FILENAME, filename ? filename : postval->val, CURLFORM_FILENAME, filename ? filename : ZSTR_VAL(postval),
CURLFORM_CONTENTTYPE, type ? type : "application/octet-stream", CURLFORM_CONTENTTYPE, type ? type : "application/octet-stream",
CURLFORM_FILE, postval->val, CURLFORM_FILE, ZSTR_VAL(postval),
CURLFORM_END); CURLFORM_END);
if (form_error != CURL_FORMADD_OK) { if (form_error != CURL_FORMADD_OK) {
/* Not nice to convert between enums but we only have place for one error type */ /* 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 * must be explicitly cast to long in curl_formadd
* use since curl needs a long not an int. */ * use since curl needs a long not an int. */
form_error = curl_formadd(&first, &last, form_error = curl_formadd(&first, &last,
CURLFORM_COPYNAME, string_key->val, CURLFORM_COPYNAME, ZSTR_VAL(string_key),
CURLFORM_NAMELENGTH, string_key->len, CURLFORM_NAMELENGTH, ZSTR_LEN(string_key),
CURLFORM_COPYCONTENTS, postval->val, CURLFORM_COPYCONTENTS, ZSTR_VAL(postval),
CURLFORM_CONTENTSLENGTH, postval->len, CURLFORM_CONTENTSLENGTH, ZSTR_LEN(postval),
CURLFORM_END); CURLFORM_END);
if (form_error != CURL_FORMADD_OK) { 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 #if LIBCURL_VERSION_NUM >= 0x071101
zend_string *str = zval_get_string(zvalue); 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 */ /* 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_POSTFIELDSIZE, ZSTR_LEN(str));
error = curl_easy_setopt(ch->cp, CURLOPT_COPYPOSTFIELDS, str->val); error = curl_easy_setopt(ch->cp, CURLOPT_COPYPOSTFIELDS, ZSTR_VAL(str));
zend_string_release(str); zend_string_release(str);
#else #else
char *post = NULL; char *post = NULL;
zend_string *str = zval_get_string(zvalue); 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); zend_llist_add_element(&ch->to_free->str, &post);
curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDS, 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); zend_string_release(str);
#endif #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); zend_string *str = zval_get_string(zvalue);
int ret; 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); zend_string_release(str);
return FAILURE; 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); zend_string_release(str);
return ret; return ret;
} }

View file

@ -1663,7 +1663,7 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
initial buffer is too small. See initial buffer is too small. See
http://connect.microsoft.com/VisualStudio/feedback/details/759720/vs2012-strftime-crash-with-z-formatting-code */ http://connect.microsoft.com/VisualStudio/feedback/details/759720/vs2012-strftime-crash-with-z-formatting-code */
buf = zend_string_alloc(buf_len, 0); 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_len *= 2;
buf = zend_string_extend(buf, buf_len, 0); buf = zend_string_extend(buf, buf_len, 0);
if (!--max_reallocs) { 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); zend_string *tmpstr = zend_string_alloc(sizeof("UTC+05:00")-1, 0);
timelib_sll utc_offset = dateobj->time->z; 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 ? '-' : '+', utc_offset > 0 ? '-' : '+',
abs(utc_offset / 60), abs(utc_offset / 60),
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: { case TIMELIB_ZONETYPE_OFFSET: {
zend_string *tmpstr = zend_string_alloc(sizeof("UTC+05:00")-1, 0); 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 ? '-' : '+', tzobj->tzi.utc_offset > 0 ? '-' : '+',
abs(tzobj->tzi.utc_offset / 60), abs(tzobj->tzi.utc_offset / 60),
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); zend_string *tmpstr = zend_string_alloc(sizeof("UTC+05:00")-1, 0);
timelib_sll utc_offset = tzobj->tzi.utc_offset; 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 ? '-' : '+', utc_offset > 0 ? '-' : '+',
abs(utc_offset / 60), abs(utc_offset / 60),
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); \ zval *z_arg = zend_hash_str_find(myht, element, sizeof(element) - 1); \
if (z_arg) { \ if (z_arg) { \
zend_string *str = zval_get_string(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); \ zend_string_release(str); \
} else { \ } else { \
(*intobj)->diff->member = -1LL; \ (*intobj)->diff->member = -1LL; \

View file

@ -169,7 +169,7 @@ int dom_attr_value_write(dom_object *obj, zval *newval)
str = zval_get_string(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); zend_string_release(str);
return SUCCESS; return SUCCESS;

View file

@ -108,7 +108,7 @@ int dom_characterdata_data_write(dom_object *obj, zval *newval)
str = zval_get_string(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); zend_string_release(str);
return SUCCESS; return SUCCESS;

View file

@ -347,7 +347,7 @@ int dom_document_encoding_write(dom_object *obj, zval *newval)
if (docp->encoding != NULL) { if (docp->encoding != NULL) {
xmlFree((xmlChar *)docp->encoding); xmlFree((xmlChar *)docp->encoding);
} }
docp->encoding = xmlStrdup((const xmlChar *) str->val); docp->encoding = xmlStrdup((const xmlChar *) ZSTR_VAL(str));
} else { } else {
php_error_docref(NULL, E_WARNING, "Invalid Document Encoding"); 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); str = zval_get_string(newval);
docp->version = xmlStrdup((const xmlChar *) str->val); docp->version = xmlStrdup((const xmlChar *) ZSTR_VAL(str));
zend_string_release(str); zend_string_release(str);
return SUCCESS; return SUCCESS;
@ -666,7 +666,7 @@ int dom_document_document_uri_write(dom_object *obj, zval *newval)
str = zval_get_string(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); zend_string_release(str);
return SUCCESS; return SUCCESS;
@ -2223,11 +2223,11 @@ PHP_METHOD(domdocument, registerNodeClass)
DOM_GET_OBJ(docp, id, xmlDocPtr, intern); DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
if (dom_set_doc_classmap(intern->document, basece, ce) == FAILURE) { 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; RETURN_TRUE;
} else { } 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; RETURN_FALSE;

View file

@ -344,7 +344,7 @@ int dom_node_node_value_write(dom_object *obj, zval *newval)
case XML_PI_NODE: case XML_PI_NODE:
{ {
zend_string *str = zval_get_string(newval); 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); zend_string_release(str);
break; break;
} }
@ -721,7 +721,7 @@ int dom_node_prefix_write(dom_object *obj, zval *newval)
} }
} }
str = zval_get_string(newval); str = zval_get_string(newval);
prefix = str->val; prefix = ZSTR_VAL(str);
if (nsnode && nodep->ns != NULL && !xmlStrEqual(nodep->ns->prefix, (xmlChar *)prefix)) { if (nsnode && nodep->ns != NULL && !xmlStrEqual(nodep->ns->prefix, (xmlChar *)prefix)) {
strURI = (char *) nodep->ns->href; strURI = (char *) nodep->ns->href;
if (strURI == NULL || if (strURI == NULL ||
@ -855,7 +855,7 @@ int dom_node_text_content_write(dom_object *obj, zval *newval)
} }
str = zval_get_string(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); xmlNodeSetContent(nodep, enc_str);
xmlFree(enc_str); xmlFree(enc_str);
zend_string_release(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) { ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(tmp), prefix, tmpns) {
if (Z_TYPE_P(tmpns) == IS_STRING) { if (Z_TYPE_P(tmpns) == IS_STRING) {
if (prefix) { 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(); } ZEND_HASH_FOREACH_END();

View file

@ -337,7 +337,7 @@ zval *dom_read_property(zval *object, zval *member, int type, void **cache_slot,
if (obj->prop_handler != NULL) { if (obj->prop_handler != NULL) {
hnd = zend_hash_find_ptr(obj->prop_handler, member_str); hnd = zend_hash_find_ptr(obj->prop_handler, member_str);
} else if (instanceof_function(obj->std.ce, dom_node_class_entry)) { } 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) { if (hnd) {

View file

@ -137,7 +137,7 @@ entry = zend_register_internal_class_ex(&ce, parent_ce);
#define DOM_GET_OBJ(__ptr, __id, __prtype, __intern) { \ #define DOM_GET_OBJ(__ptr, __id, __prtype, __intern) { \
__intern = Z_DOMOBJ_P(__id); \ __intern = Z_DOMOBJ_P(__id); \
if (__intern->ptr == NULL || !(__ptr = (__prtype)((php_libxml_node_ptr *)__intern->ptr)->node)) { \ 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();\ RETURN_NULL();\
} \ } \
} }

View file

@ -143,7 +143,7 @@ int dom_processinginstruction_data_write(dom_object *obj, zval *newval)
str = zval_get_string(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); zend_string_release(str);
return SUCCESS; return SUCCESS;

View file

@ -67,7 +67,7 @@ PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj);
__intern = Z_LIBXML_NODE_P(__id); \ __intern = Z_LIBXML_NODE_P(__id); \
if (__intern->node == NULL || !(__ptr = (__prtype)__intern->node->node)) { \ if (__intern->node == NULL || !(__ptr = (__prtype)__intern->node->node)) { \
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", \ php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", \
__intern->std.ce->name->val);\ ZSTR_VAL(__intern->std.ce->name));\
RETURN_NULL();\ RETURN_NULL();\
} \ } \
} }

View file

@ -194,9 +194,9 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs,
fci.no_separation = 0; fci.no_separation = 0;
if (!zend_make_callable(&fci.function_name, &callable)) { 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) { } 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... */ /* Push an empty string, so that we at least have an xslt result... */
valuePush(ctxt, xmlXPathNewString((xmlChar *)"")); valuePush(ctxt, xmlXPathNewString((xmlChar *)""));
} else { } else {
@ -221,7 +221,7 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs,
valuePush(ctxt, xmlXPathNewString((xmlChar *)"")); valuePush(ctxt, xmlXPathNewString((xmlChar *)""));
} else { } else {
zend_string *str = zval_get_string(&retval); zend_string *str = zval_get_string(&retval);
valuePush(ctxt, xmlXPathNewString((xmlChar *) str->val)); valuePush(ctxt, xmlXPathNewString((xmlChar *) ZSTR_VAL(str)));
zend_string_release(str); zend_string_release(str);
} }
zval_ptr_dtor(&retval); zval_ptr_dtor(&retval);

View file

@ -167,12 +167,12 @@ ZEND_TSRMLS_CACHE_DEFINE();
ZEND_INI_MH(OnUpdateEncode) ZEND_INI_MH(OnUpdateEncode)
{ {
if (new_value && new_value->len) { if (new_value && ZSTR_LEN(new_value)) {
const zend_encoding **return_list; const zend_encoding **return_list;
size_t return_size; 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)) { &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; return FAILURE;
} }
efree(return_list); efree(return_list);
@ -185,9 +185,9 @@ ZEND_INI_MH(OnUpdateDecode)
if (new_value) { if (new_value) {
const zend_encoding **return_list; const zend_encoding **return_list;
size_t return_size; 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)) { &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; return FAILURE;
} }
efree(return_list); 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); 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); zend_string_release(base);
ImageInfo->read_thumbnail = read_thumbnail; ImageInfo->read_thumbnail = read_thumbnail;
ImageInfo->read_all = read_all; ImageInfo->read_all = read_all;

View file

@ -455,8 +455,8 @@ file_replace(struct magic_set *ms, const char *pat, const char *rep)
goto out; goto out;
} }
strncpy(ms->o.buf, res->val, res->len); strncpy(ms->o.buf, ZSTR_VAL(res), ZSTR_LEN(res));
ms->o.buf[res->len] = '\0'; ms->o.buf[ZSTR_LEN(res)] = '\0';
zend_string_release(res); zend_string_release(res);

View file

@ -1812,29 +1812,29 @@ convert_libmagic_pattern(zval *pattern, char *val, int len, int options)
t = zend_string_alloc(len * 2 + 4, 0); t = zend_string_alloc(len * 2 + 4, 0);
t->val[j++] = '~'; ZSTR_VAL(t)[j++] = '~';
for (i = 0; i < len; i++, j++) { for (i = 0; i < len; i++, j++) {
switch (val[i]) { switch (val[i]) {
case '~': case '~':
t->val[j++] = '\\'; ZSTR_VAL(t)[j++] = '\\';
t->val[j] = '~'; ZSTR_VAL(t)[j] = '~';
break; break;
default: default:
t->val[j] = val[i]; ZSTR_VAL(t)[j] = val[i];
break; break;
} }
} }
t->val[j++] = '~'; ZSTR_VAL(t)[j++] = '~';
if (options & PCRE_CASELESS) if (options & PCRE_CASELESS)
t->val[j++] = 'i'; ZSTR_VAL(t)[j++] = 'i';
if (options & PCRE_MULTILINE) if (options & PCRE_MULTILINE)
t->val[j++] = 'm'; ZSTR_VAL(t)[j++] = 'm';
t->val[j]='\0'; ZSTR_VAL(t)[j]='\0';
t->len = j; ZSTR_LEN(t) = j;
ZVAL_NEW_STR(pattern, t); ZVAL_NEW_STR(pattern, t);
} }

View file

@ -162,7 +162,7 @@ static PHP_INI_MH(UpdateDefaultFilter) /* {{{ */
int i, size = sizeof(filter_list) / sizeof(filter_list_entry); int i, size = sizeof(filter_list) / sizeof(filter_list_entry);
for (i = 0; i < size; ++i) { 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; IF_G(default_filter) = filter_list[i].id;
return SUCCESS; return SUCCESS;
} }
@ -180,7 +180,7 @@ static PHP_INI_MH(OnUpdateFlags)
if (!new_value) { if (!new_value) {
IF_G(default_filter_flags) = FILTER_FLAG_NO_ENCODE_QUOTES; IF_G(default_filter_flags) = FILTER_FLAG_NO_ENCODE_QUOTES;
} else { } else {
IF_G(default_filter_flags) = atoi(new_value->val); IF_G(default_filter_flags) = atoi(ZSTR_VAL(new_value));
} }
return SUCCESS; return SUCCESS;
} }
@ -685,14 +685,14 @@ static void php_filter_array_handler(zval *input, zval *op, zval *return_value,
zval_ptr_dtor(return_value); zval_ptr_dtor(return_value);
RETURN_FALSE; 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"); php_error_docref(NULL, E_WARNING, "Empty keys are not allowed in the definition array");
zval_ptr_dtor(return_value); zval_ptr_dtor(return_value);
RETURN_FALSE; RETURN_FALSE;
} }
if ((tmp = zend_hash_find(Z_ARRVAL_P(input), arg_key)) == NULL) { if ((tmp = zend_hash_find(Z_ARRVAL_P(input), arg_key)) == NULL) {
if (add_empty) { 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 { } else {
zval nval; zval nval;

View file

@ -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); 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); s = (unsigned char *) Z_STRVAL_P(value);
e = s + Z_STRLEN_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++; s++;
} }
*p = '\0'; *p = '\0';
str->len = p - (unsigned char *)str->val; ZSTR_LEN(str) = p - (unsigned char *)ZSTR_VAL(str);
zval_ptr_dtor(value); zval_ptr_dtor(value);
ZVAL_NEW_STR(value, str); 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] < 32) && (flags & FILTER_FLAG_STRIP_LOW)) {
} else if ((str[i] == '`') && (flags & FILTER_FLAG_STRIP_BACKTICK)) { } else if ((str[i] == '`') && (flags & FILTER_FLAG_STRIP_BACKTICK)) {
} else { } else {
buf->val[c] = str[i]; ZSTR_VAL(buf)[c] = str[i];
++c; ++c;
} }
} }
/* update zval string data */ /* update zval string data */
buf->val[c] = '\0'; ZSTR_VAL(buf)[c] = '\0';
buf->len = c; ZSTR_LEN(buf) = c;
zval_ptr_dtor(value); zval_ptr_dtor(value);
ZVAL_NEW_STR(value, buf); ZVAL_NEW_STR(value, buf);
} }
@ -166,13 +166,13 @@ static void filter_map_apply(zval *value, filter_map *map)
c = 0; c = 0;
for (i = 0; i < Z_STRLEN_P(value); i++) { for (i = 0; i < Z_STRLEN_P(value); i++) {
if ((*map)[str[i]]) { if ((*map)[str[i]]) {
buf->val[c] = str[i]; ZSTR_VAL(buf)[c] = str[i];
++c; ++c;
} }
} }
/* update zval string data */ /* update zval string data */
buf->val[c] = '\0'; ZSTR_VAL(buf)[c] = '\0';
buf->len = c; ZSTR_LEN(buf) = c;
zval_ptr_dtor(value); zval_ptr_dtor(value);
ZVAL_NEW_STR(value, buf); ZVAL_NEW_STR(value, buf);
} }

View file

@ -1326,7 +1326,7 @@ PHP_FUNCTION(imageloadfont)
return; 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) { if (stream == NULL) {
RETURN_FALSE; 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 */ /* needs to be malloc (persistent) - GD will free() it later */
pstr = pestrndup(buff->val, buff->len, 1); pstr = pestrndup(ZSTR_VAL(buff), ZSTR_LEN(buff), 1);
io_ctx = gdNewDynamicCtxEx(buff->len, pstr, 0); io_ctx = gdNewDynamicCtxEx(ZSTR_LEN(buff), pstr, 0);
if (!io_ctx) { if (!io_ctx) {
pefree(pstr, 1); pefree(pstr, 1);
zend_string_release(buff); zend_string_release(buff);
@ -2635,7 +2635,7 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
} }
fclose(tmp); 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); zend_string_release(path);
} }
RETURN_TRUE; RETURN_TRUE;
@ -3859,7 +3859,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
if (key == NULL) { if (key == NULL) {
continue; continue;
} }
if (strcmp("linespacing", key->val) == 0) { if (strcmp("linespacing", ZSTR_VAL(key)) == 0) {
strex.flags |= gdFTEX_LINESPACE; strex.flags |= gdFTEX_LINESPACE;
strex.linespacing = zval_get_double(item); strex.linespacing = zval_get_double(item);
} }

View file

@ -199,8 +199,8 @@ PHP_NAMED_FUNCTION(zif_gettext)
ZEND_PARSE_PARAMETERS_END(); ZEND_PARSE_PARAMETERS_END();
#endif #endif
PHP_GETTEXT_LENGTH_CHECK("msgid", msgid->len) PHP_GETTEXT_LENGTH_CHECK("msgid", ZSTR_LEN(msgid))
msgstr = gettext(msgid->val); msgstr = gettext(ZSTR_VAL(msgid));
RETURN_STRING(msgstr); RETURN_STRING(msgstr);
} }

View file

@ -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(&buf, &zv, &serialize_data);
PHP_VAR_SERIALIZE_DESTROY(serialize_data); PHP_VAR_SERIALIZE_DESTROY(serialize_data);
*buffer = (unsigned char *) estrndup(buf.s->val, buf.s->len); *buffer = (unsigned char *) estrndup(ZSTR_VAL(buf.s), ZSTR_LEN(buf.s));
*buf_len = buf.s->len; *buf_len = ZSTR_LEN(buf.s);
zend_string_release(buf.s); zend_string_release(buf.s);
return SUCCESS; return SUCCESS;
@ -760,7 +760,7 @@ static void gmp_strval(zval *result, mpz_t gmpnum, int base) /* {{{ */
} }
str = zend_string_alloc(num_len, 0); 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(): * 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... * So let's check to see if we already have a \0 byte...
*/ */
if (str->val[str->len - 1] == '\0') { if (ZSTR_VAL(str)[ZSTR_LEN(str) - 1] == '\0') {
str->len--; ZSTR_LEN(str)--;
} else { } else {
str->val[str->len] = '\0'; ZSTR_VAL(str)[ZSTR_LEN(str)] = '\0';
} }
ZVAL_NEW_STR(result, str); ZVAL_NEW_STR(result, str);
@ -1149,8 +1149,8 @@ ZEND_FUNCTION(gmp_export)
size_t out_len = count * size; size_t out_len = count * size;
zend_string *out_string = zend_string_alloc(out_len, 0); zend_string *out_string = zend_string_alloc(out_len, 0);
mpz_export(out_string->val, NULL, order, size, endian, 0, gmpnumber); mpz_export(ZSTR_VAL(out_string), NULL, order, size, endian, 0, gmpnumber);
out_string->val[out_len] = '\0'; ZSTR_VAL(out_string)[out_len] = '\0';
RETURN_NEW_STR(out_string); RETURN_NEW_STR(out_string);
} }

View file

@ -163,17 +163,17 @@ static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_
} }
digest = zend_string_alloc(ops->digest_size, 0); 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); efree(context);
if (raw_output) { if (raw_output) {
digest->val[ops->digest_size] = 0; ZSTR_VAL(digest)[ops->digest_size] = 0;
RETURN_NEW_STR(digest); RETURN_NEW_STR(digest);
} else { } else {
zend_string *hex_digest = zend_string_safe_alloc(ops->digest_size, 2, 0, 0); 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); php_hash_bin2hex(ZSTR_VAL(hex_digest), (unsigned char *) ZSTR_VAL(digest), ops->digest_size);
hex_digest->val[2 * ops->digest_size] = 0; ZSTR_VAL(hex_digest)[2 * ops->digest_size] = 0;
zend_string_release(digest); zend_string_release(digest);
RETURN_NEW_STR(hex_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); ops->hash_update(context, (unsigned char *) buf, n);
} }
php_stream_close(stream); php_stream_close(stream);
ops->hash_final((unsigned char *) digest->val, context); ops->hash_final((unsigned char *) ZSTR_VAL(digest), context);
} else { } 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_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 */ /* Zero the key */
ZEND_SECURE_ZERO(K, ops->block_size); 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); efree(context);
if (raw_output) { if (raw_output) {
digest->val[ops->digest_size] = 0; ZSTR_VAL(digest)[ops->digest_size] = 0;
RETURN_NEW_STR(digest); RETURN_NEW_STR(digest);
} else { } else {
zend_string *hex_digest = zend_string_safe_alloc(ops->digest_size, 2, 0, 0); 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); php_hash_bin2hex(ZSTR_VAL(hex_digest), (unsigned char *) ZSTR_VAL(digest), ops->digest_size);
hex_digest->val[2 * ops->digest_size] = 0; ZSTR_VAL(hex_digest)[2 * ops->digest_size] = 0;
zend_string_release(digest); zend_string_release(digest);
RETURN_NEW_STR(hex_digest); RETURN_NEW_STR(hex_digest);
} }
@ -513,7 +513,7 @@ PHP_FUNCTION(hash_final)
digest_len = hash->ops->digest_size; digest_len = hash->ops->digest_size;
digest = zend_string_alloc(digest_len, 0); 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) { if (hash->options & PHP_HASH_HMAC) {
int i; int i;
@ -525,15 +525,15 @@ PHP_FUNCTION(hash_final)
/* Feed this result into the outter hash */ /* Feed this result into the outter hash */
hash->ops->hash_init(hash->context); hash->ops->hash_init(hash->context);
hash->ops->hash_update(hash->context, hash->key, hash->ops->block_size); 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_update(hash->context, (unsigned char *) ZSTR_VAL(digest), hash->ops->digest_size);
hash->ops->hash_final((unsigned char *) digest->val, hash->context); hash->ops->hash_final((unsigned char *) ZSTR_VAL(digest), hash->context);
/* Zero the key */ /* Zero the key */
ZEND_SECURE_ZERO(hash->key, hash->ops->block_size); ZEND_SECURE_ZERO(hash->key, hash->ops->block_size);
efree(hash->key); efree(hash->key);
hash->key = NULL; hash->key = NULL;
} }
digest->val[digest_len] = 0; ZSTR_VAL(digest)[digest_len] = 0;
efree(hash->context); efree(hash->context);
hash->context = NULL; hash->context = NULL;
zend_list_close(Z_RES_P(zhash)); zend_list_close(Z_RES_P(zhash));
@ -543,8 +543,8 @@ PHP_FUNCTION(hash_final)
} else { } else {
zend_string *hex_digest = zend_string_safe_alloc(digest_len, 2, 0, 0); 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); php_hash_bin2hex(ZSTR_VAL(hex_digest), (unsigned char *) ZSTR_VAL(digest), digest_len);
hex_digest->val[2 * digest_len] = 0; ZSTR_VAL(hex_digest)[2 * digest_len] = 0;
zend_string_release(digest); zend_string_release(digest);
RETURN_NEW_STR(hex_digest); RETURN_NEW_STR(hex_digest);
} }
@ -718,11 +718,11 @@ PHP_FUNCTION(hash_pbkdf2)
returnval = zend_string_alloc(length, 0); returnval = zend_string_alloc(length, 0);
if (raw_output) { if (raw_output) {
memcpy(returnval->val, result, length); memcpy(ZSTR_VAL(returnval), result, length);
} else { } 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); efree(result);
RETURN_NEW_STR(returnval); RETURN_NEW_STR(returnval);
} }
@ -1087,7 +1087,7 @@ PHP_MINFO_FUNCTION(hash)
char *s = buffer, *e = s + sizeof(buffer); char *s = buffer, *e = s + sizeof(buffer);
ZEND_HASH_FOREACH_STR_KEY(&php_hash_hashtable, str) { 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(); } ZEND_HASH_FOREACH_END();
*s = 0; *s = 0;

View file

@ -229,7 +229,7 @@ static char _generic_superset_name[] = ICONV_UCS4_ENCODING;
static PHP_INI_MH(OnUpdateInputEncoding) static PHP_INI_MH(OnUpdateInputEncoding)
{ {
if (new_value->len >= ICONV_CSNMAXLEN) { if (ZSTR_LEN(new_value) >= ICONV_CSNMAXLEN) {
return FAILURE; return FAILURE;
} }
if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) { if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) {
@ -242,7 +242,7 @@ static PHP_INI_MH(OnUpdateInputEncoding)
static PHP_INI_MH(OnUpdateOutputEncoding) static PHP_INI_MH(OnUpdateOutputEncoding)
{ {
if(new_value->len >= ICONV_CSNMAXLEN) { if (ZSTR_LEN(new_value) >= ICONV_CSNMAXLEN) {
return FAILURE; return FAILURE;
} }
if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) { if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) {
@ -255,7 +255,7 @@ static PHP_INI_MH(OnUpdateOutputEncoding)
static PHP_INI_MH(OnUpdateInternalEncoding) static PHP_INI_MH(OnUpdateInternalEncoding)
{ {
if(new_value->len >= ICONV_CSNMAXLEN) { if (ZSTR_LEN(new_value) >= ICONV_CSNMAXLEN) {
return FAILURE; return FAILURE;
} }
if (stage & (PHP_INI_STAGE_ACTIVATE | PHP_INI_STAGE_RUNTIME)) { 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; 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()); _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) { if (out) {
output_context->out.data = estrndup(out->val, out->len); output_context->out.data = estrndup(ZSTR_VAL(out), ZSTR_LEN(out));
output_context->out.used = out->len; output_context->out.used = ZSTR_LEN(out);
zend_string_free(out); zend_string_free(out);
} else { } else {
output_context->out.data = NULL; 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; out_left = buf_growth - out_left;
smart_str_alloc(d, out_left, 0); 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(cd, (char **)&in_p, &in_left, (char **) &out_p, &out_left) == (size_t)-1) {
#if ICONV_SUPPORTS_ERRNO #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 #if !ICONV_SUPPORTS_ERRNO
prev_in_left = in_left; prev_in_left = in_left;
#endif #endif
(d)->s->len += (buf_growth - out_left); ZSTR_LEN((d)->s) += (buf_growth - out_left);
buf_growth <<= 1; buf_growth <<= 1;
} }
} else { } 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; out_left = buf_growth - out_left;
smart_str_alloc(d, out_left, 0); 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) { 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; break;
} else { } else {
#if ICONV_SUPPORTS_ERRNO #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 #endif
} }
(d)->s->len += (buf_growth - out_left); ZSTR_LEN((d)->s) += (buf_growth - out_left);
buf_growth <<= 1; 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_buffer = zend_string_alloc(out_size, 0);
out_p = out_buffer->val; out_p = ZSTR_VAL(out_buffer);
#ifdef NETWARE #ifdef NETWARE
result = iconv(cd, (char **) &in_p, &in_size, (char **) 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) { 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_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_size += 7;
out_left += 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; return PHP_ICONV_ERR_UNKNOWN;
} }
out_buffer->val[out_size - out_left] = '\0'; ZSTR_VAL(out_buffer)[out_size - out_left] = '\0';
out_buffer->len = out_size - out_left; ZSTR_LEN(out_buffer) = out_size - out_left;
iconv_close(cd); 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; out_size = 0;
bsz = out_left; bsz = out_left;
out_buf = zend_string_alloc(bsz, 0); out_buf = zend_string_alloc(bsz, 0);
out_p = out_buf->val; out_p = ZSTR_VAL(out_buf);
while (in_left > 0) { while (in_left > 0) {
result = iconv(cd, (char **) &in_p, &in_left, (char **) &out_p, &out_left); 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; bsz += in_len;
out_buf = zend_string_extend(out_buf, bsz, 0); 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_p += out_size;
out_left = bsz - out_size; out_left = bsz - out_size;
continue; 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) { if (errno == E2BIG) {
bsz += 16; bsz += 16;
out_buf = zend_string_extend(out_buf, bsz, 0); 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_p += out_size;
out_left = bsz - out_size; out_left = bsz - out_size;
} else { } 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_p = '\0';
out_buf->len = out_size; ZSTR_LEN(out_buf) = out_size;
*out = out_buf; *out = out_buf;
return retval; return retval;
#endif #endif
@ -1018,8 +1018,8 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval,
#endif #endif
} }
ndl_buf_p = ndl_buf->val; ndl_buf_p = ZSTR_VAL(ndl_buf);
ndl_buf_left = ndl_buf->len; ndl_buf_left = ZSTR_LEN(ndl_buf);
match_ofs = (size_t)-1; match_ofs = (size_t)-1;
for (in_p = haystk, in_left = haystk_nbytes, cnt = 0; in_left > 0; ++cnt) { 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; i = 0;
j = GENERIC_SUPERSET_NBYTES; 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) { 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)) { GENERIC_SUPERSET_NBYTES)) {
i += GENERIC_SUPERSET_NBYTES; i += GENERIC_SUPERSET_NBYTES;
} else { } else {
@ -1082,15 +1082,15 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval,
j += GENERIC_SUPERSET_NBYTES; 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; match_ofs += (lim - i) / GENERIC_SUPERSET_NBYTES;
i += GENERIC_SUPERSET_NBYTES; i += GENERIC_SUPERSET_NBYTES;
ndl_buf_p = &ndl_buf->val[i]; ndl_buf_p = &ZSTR_VAL(ndl_buf)[i];
ndl_buf_left = ndl_buf->len - i; ndl_buf_left = ZSTR_LEN(ndl_buf) - i;
} else { } else {
match_ofs = (size_t)-1; match_ofs = (size_t)-1;
ndl_buf_p = ndl_buf->val; ndl_buf_p = ZSTR_VAL(ndl_buf);
ndl_buf_left = ndl_buf->len; 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; ndl_buf_left -= GENERIC_SUPERSET_NBYTES;
if (ndl_buf_left == 0) { if (ndl_buf_left == 0) {
*pretval = match_ofs; *pretval = match_ofs;
ndl_buf_p = ndl_buf->val; ndl_buf_p = ZSTR_VAL(ndl_buf);
ndl_buf_left = ndl_buf->len; ndl_buf_left = ZSTR_LEN(ndl_buf);
match_ofs = -1; match_ofs = -1;
} }
} else { } else {
@ -1112,10 +1112,10 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval,
i = 0; i = 0;
j = GENERIC_SUPERSET_NBYTES; 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) { 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)) { GENERIC_SUPERSET_NBYTES)) {
i += GENERIC_SUPERSET_NBYTES; i += GENERIC_SUPERSET_NBYTES;
} else { } else {
@ -1125,15 +1125,15 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval,
j += GENERIC_SUPERSET_NBYTES; 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; match_ofs += (lim - i) / GENERIC_SUPERSET_NBYTES;
i += GENERIC_SUPERSET_NBYTES; i += GENERIC_SUPERSET_NBYTES;
ndl_buf_p = &ndl_buf->val[i]; ndl_buf_p = &ZSTR_VAL(ndl_buf)[i];
ndl_buf_left = ndl_buf->len - i; ndl_buf_left = ZSTR_LEN(ndl_buf) - i;
} else { } else {
match_ofs = (size_t)-1; match_ofs = (size_t)-1;
ndl_buf_p = ndl_buf->val; ndl_buf_p = ZSTR_VAL(ndl_buf);
ndl_buf_left = ndl_buf->len; 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)); 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! */ /* something went wrong! */
err = PHP_ICONV_ERR_UNKNOWN; err = PHP_ICONV_ERR_UNKNOWN;
goto out; goto out;
} }
smart_str_appendl(pretval, encoded->val, encoded->len); smart_str_appendl(pretval, ZSTR_VAL(encoded), ZSTR_LEN(encoded));
char_cnt -= encoded->len; char_cnt -= ZSTR_LEN(encoded);
smart_str_appendl(pretval, "?=", sizeof("?=") - 1); smart_str_appendl(pretval, "?=", sizeof("?=") - 1);
char_cnt -= 2; 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); zend_string_release(decoded_text);
if (err != PHP_ICONV_ERR_SUCCESS) { if (err != PHP_ICONV_ERR_SUCCESS) {
@ -2068,7 +2068,7 @@ PHP_FUNCTION(iconv_strlen)
RETURN_FALSE; 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); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset);
if (err == PHP_ICONV_ERR_SUCCESS) { if (err == PHP_ICONV_ERR_SUCCESS) {
RETVAL_LONG(retval); RETVAL_LONG(retval);
@ -2103,13 +2103,13 @@ PHP_FUNCTION(iconv_substr)
} }
if (ZEND_NUM_ARGS() < 3) { 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); _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); RETURN_NEW_STR(retval.s);
} }
smart_str_free(&retval); smart_str_free(&retval);
@ -2147,11 +2147,11 @@ PHP_FUNCTION(iconv_strpos)
RETURN_FALSE; RETURN_FALSE;
} }
if (ndl->len < 1) { if (ZSTR_LEN(ndl) < 1) {
RETURN_FALSE; 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); offset, charset);
_php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset);
@ -2182,7 +2182,7 @@ PHP_FUNCTION(iconv_strrpos)
RETURN_FALSE; RETURN_FALSE;
} }
if (ndl->len < 1) { if (ZSTR_LEN(ndl) < 1) {
RETURN_FALSE; RETURN_FALSE;
} }
@ -2191,7 +2191,7 @@ PHP_FUNCTION(iconv_strrpos)
RETURN_FALSE; 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); -1, charset);
_php_iconv_show_error(err, GENERIC_SUPERSET_NAME, 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 ((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) { if (Z_TYPE_P(pzval) != IS_STRING) {
tmp_str = zval_get_string(pzval); tmp_str = zval_get_string(pzval);
lfchars = tmp_str->val; lfchars = ZSTR_VAL(tmp_str);
} else { } else {
lfchars = Z_STRVAL_P(pzval); lfchars = Z_STRVAL_P(pzval);
} }
} }
} }
err = _php_iconv_mime_encode(&retval, field_name->val, field_name->len, err = _php_iconv_mime_encode(&retval, ZSTR_VAL(field_name), ZSTR_LEN(field_name),
field_value->val, field_value->len, line_len, lfchars, scheme_id, ZSTR_VAL(field_value), ZSTR_LEN(field_value), line_len, lfchars, scheme_id,
out_charset, in_charset); out_charset, in_charset);
_php_iconv_show_error(err, out_charset, in_charset); _php_iconv_show_error(err, out_charset, in_charset);
@ -2327,7 +2327,7 @@ PHP_FUNCTION(iconv_mime_decode)
RETURN_FALSE; 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, "???"); _php_iconv_show_error(err, charset, "???");
if (err == PHP_ICONV_ERR_SUCCESS) { if (err == PHP_ICONV_ERR_SUCCESS) {
@ -2369,8 +2369,8 @@ PHP_FUNCTION(iconv_mime_decode_headers)
array_init(return_value); array_init(return_value);
enc_str_tmp = encoded_str->val; enc_str_tmp = ZSTR_VAL(encoded_str);
enc_str_len_tmp = encoded_str->len; enc_str_len_tmp = ZSTR_LEN(encoded_str);
while (enc_str_len_tmp > 0) { while (enc_str_len_tmp > 0) {
smart_str decoded_header = {0}; smart_str decoded_header = {0};
char *header_name = NULL; char *header_name = NULL;
@ -2389,12 +2389,12 @@ PHP_FUNCTION(iconv_mime_decode_headers)
break; break;
} }
limit = decoded_header.s->val + decoded_header.s->len; limit = ZSTR_VAL(decoded_header.s) + ZSTR_LEN(decoded_header.s);
for (p = decoded_header.s->val; p < limit; p++) { for (p = ZSTR_VAL(decoded_header.s); p < limit; p++) {
if (*p == ':') { if (*p == ':') {
*p = '\0'; *p = '\0';
header_name = decoded_header.s->val; header_name = ZSTR_VAL(decoded_header.s);
header_name_len = p - decoded_header.s->val; header_name_len = p - ZSTR_VAL(decoded_header.s);
while (++p < limit) { while (++p < limit) {
if (*p != ' ' && *p != '\t') { if (*p != ' ' && *p != '\t') {
@ -2460,7 +2460,7 @@ PHP_NAMED_FUNCTION(php_if_iconv)
RETURN_FALSE; 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); _php_iconv_show_error(err, out_charset, in_charset);
if (err == PHP_ICONV_ERR_SUCCESS && out_buffer != NULL) { if (err == PHP_ICONV_ERR_SUCCESS && out_buffer != NULL) {
RETVAL_STR(out_buffer); 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) if (zend_parse_parameters(ZEND_NUM_ARGS(), "sS", &type, &type_len, &charset) == FAILURE)
return; 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); php_error_docref(NULL, E_WARNING, "Charset parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
RETURN_FALSE; RETURN_FALSE;
} }

View file

@ -120,7 +120,7 @@ static zend_object *BreakIterator_clone_obj(zval *object)
intl_errors_set_custom_msg(BREAKITER_ERROR_P(bio_orig), intl_errors_set_custom_msg(BREAKITER_ERROR_P(bio_orig),
"Could not clone BreakIterator", 0); "Could not clone BreakIterator", 0);
err_msg = intl_error_get_message(BREAKITER_ERROR_P(bio_orig)); 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); zend_string_free(err_msg);
} else { } else {
bio_new->biter = new_biter; bio_new->biter = new_biter;

View file

@ -177,8 +177,8 @@ static void _breakiterator_parts_move_forward(zend_object_iterator *iter)
assert(next <= slen && next >= cur); assert(next <= slen && next >= cur);
res = zend_string_alloc(next - cur, 0); res = zend_string_alloc(next - cur, 0);
memcpy(res->val, &s[cur], res->len); memcpy(ZSTR_VAL(res), &s[cur], ZSTR_LEN(res));
res->val[res->len] = '\0'; ZSTR_VAL(res)[ZSTR_LEN(res)] = '\0';
ZVAL_STR(&zoi_bit->zoi_cur.current, res); 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); ALLOCA_FLAG(use_heap);
if (key == NULL) { if (key == NULL) {
ZSTR_ALLOCA_ALLOC(lc_method_name, method->len, use_heap); ZSTR_ALLOCA_ALLOC(lc_method_name, ZSTR_LEN(method), use_heap);
zend_str_tolower_copy(lc_method_name->val, method->val, method->len); zend_str_tolower_copy(ZSTR_VAL(lc_method_name), ZSTR_VAL(method), ZSTR_LEN(method));
} else { } else {
lc_method_name = Z_STR_P(key); lc_method_name = Z_STR_P(key);
} }
if (method->len == sizeof("getrulestatus") - 1 if (ZSTR_LEN(method) == sizeof("getrulestatus") - 1
&& memcmp("getrulestatus", lc_method_name->val, lc_method_name->len) == 0) { && memcmp("getrulestatus", ZSTR_VAL(lc_method_name), ZSTR_LEN(lc_method_name)) == 0) {
IntlIterator_object *obj = php_intl_iterator_fetch_object(*object_ptr); IntlIterator_object *obj = php_intl_iterator_fetch_object(*object_ptr);
if (obj->iterator && !Z_ISUNDEF(obj->iterator->data)) { if (obj->iterator && !Z_ISUNDEF(obj->iterator->data)) {
zval *break_iter_zv = &obj->iterator->data; zval *break_iter_zv = &obj->iterator->data;

View file

@ -161,7 +161,7 @@ U_CFUNC PHP_FUNCTION(breakiter_set_text)
BREAKITER_METHOD_FETCH_OBJECT; 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"); INTL_METHOD_CHECK_STATUS_OR_NULL(bio, "breakiter_set_text: error opening UText");
bio->biter->setText(ut, BREAKITER_ERROR_CODE(bio)); bio->biter->setText(ut, BREAKITER_ERROR_CODE(bio));

View file

@ -66,7 +66,7 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
smart_str parse_error_str; smart_str parse_error_str;
parse_error_str = intl_parse_error_to_string(&parseError); parse_error_str = intl_parse_error_to_string(&parseError);
spprintf(&msg, 0, "rbbi_create_instance: unable to create " 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); smart_str_free(&parse_error_str);
intl_error_set_custom_msg(NULL, msg, 1); intl_error_set_custom_msg(NULL, msg, 1);
efree(msg); efree(msg);
@ -211,8 +211,8 @@ U_CFUNC PHP_FUNCTION(rbbi_get_binary_rules)
} }
zend_string *ret_rules = zend_string_alloc(rules_len, 0); zend_string *ret_rules = zend_string_alloc(rules_len, 0);
memcpy(ret_rules->val, rules, rules_len); memcpy(ZSTR_VAL(ret_rules), rules, rules_len);
ret_rules->val[rules_len] = '\0'; ZSTR_VAL(ret_rules)[rules_len] = '\0';
RETURN_STR(ret_rules); RETURN_STR(ret_rules);
} }

View file

@ -101,7 +101,7 @@ static zend_object *Calendar_clone_obj(zval *object)
intl_errors_set_custom_msg(CALENDAR_ERROR_P(co_orig), intl_errors_set_custom_msg(CALENDAR_ERROR_P(co_orig),
"Could not clone IntlCalendar", 0); "Could not clone IntlCalendar", 0);
err_msg = intl_error_get_message(CALENDAR_ERROR_P(co_orig)); 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); zend_string_free(err_msg);
} else { } else {
co_new->ucal = newCalendar; co_new->ucal = newCalendar;

View file

@ -1068,7 +1068,7 @@ static zend_object *php_converter_clone_object(zval *object) {
THROW_UFAILURE(oldobj, "ucnv_safeClone", error); THROW_UFAILURE(oldobj, "ucnv_safeClone", error);
err_msg = intl_error_get_message(&oldobj->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); zend_string_release(err_msg);
return retval; return retval;

View file

@ -153,10 +153,10 @@ static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS,
if (mode == INTL_IDN_TO_ASCII) { if (mode == INTL_IDN_TO_ASCII) {
len = uidna_nameToASCII_UTF8(uts46, domain, domain_len, len = uidna_nameToASCII_UTF8(uts46, domain, domain_len,
buffer->val, buffer_capac, &info, &status); ZSTR_VAL(buffer), buffer_capac, &info, &status);
} else { } else {
len = uidna_nameToUnicodeUTF8(uts46, domain, domain_len, 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", if (php_intl_idn_check_status(status, "failed to convert name",
mode) == FAILURE) { 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"); php_error_docref(NULL, E_ERROR, "ICU returned an unexpected length");
} }
buffer->val[len] = '\0'; ZSTR_VAL(buffer)[len] = '\0';
buffer->len = len; ZSTR_LEN(buffer) = len;
if (info.errors == 0) { if (info.errors == 0) {
RETVAL_STR(buffer); RETVAL_STR(buffer);

View file

@ -235,7 +235,7 @@ PHP_NAMED_FUNCTION(zif_locale_set_default)
RETURN_FALSE; RETURN_FALSE;
} }
if (locale_name->len == 0) { if (ZSTR_LEN(locale_name) == 0) {
default_locale = (char *)uloc_getDefault(); default_locale = (char *)uloc_getDefault();
locale_name = zend_string_init(default_locale, strlen(default_locale), 0); locale_name = zend_string_init(default_locale, strlen(default_locale), 0);
} }

View file

@ -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); storedArgType = (Formattable::Type*)zend_hash_index_find_ptr(types, (zend_ulong)num_index);
} else { //string; assumed to be in UTF-8 } 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)) { if (U_FAILURE(err.code)) {
char *message; char *message;
spprintf(&message, 0, 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); intl_errors_set(&err, err.code, message, 1);
efree(message); efree(message);
continue; continue;

View file

@ -248,7 +248,7 @@ static zend_object *TimeZone_clone_obj(zval *object)
intl_errors_set_custom_msg(TIMEZONE_ERROR_P(to_orig), intl_errors_set_custom_msg(TIMEZONE_ERROR_P(to_orig),
"Could not clone IntlTimeZone", 0); "Could not clone IntlTimeZone", 0);
err_msg = intl_error_get_message(TIMEZONE_ERROR_P(to_orig)); 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); zend_string_free(err_msg);
} else { } else {
to_new->utimezone = newTimeZone; to_new->utimezone = newTimeZone;

View file

@ -182,7 +182,7 @@ err:
"Could not clone transliterator", 0 ); "Could not clone transliterator", 0 );
err_msg = intl_error_get_message( TRANSLITERATOR_ERROR_P( to_orig ) ); 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 */ zend_string_free( err_msg ); /* if it's changed into a warning */
/* do not destroy tempz; we need to return something */ /* do not destroy tempz; we need to return something */
} }

View file

@ -185,7 +185,7 @@ PHP_FUNCTION( transliterator_create_from_rules )
smart_str parse_error_str; smart_str parse_error_str;
parse_error_str = intl_parse_error_to_string( &parse_error ); parse_error_str = intl_parse_error_to_string( &parse_error );
spprintf( &msg, 0, "transliterator_create_from_rules: unable to " 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 ); smart_str_free( &parse_error_str );
if( msg != NULL ) if( msg != NULL )
{ {
@ -348,7 +348,7 @@ PHP_FUNCTION( transliterator_transliterate )
{ {
zend_string *message = intl_error_get_message( NULL ); zend_string *message = intl_error_get_message( NULL );
php_error_docref0( NULL, E_WARNING, "Could not create " 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 ); zend_string_free( message );
ZVAL_UNDEF(&tmp_object); ZVAL_UNDEF(&tmp_object);
/* don't set U_ILLEGAL_ARGUMENT_ERROR to allow fetching of inner error */ /* don't set U_ILLEGAL_ARGUMENT_ERROR to allow fetching of inner error */

View file

@ -247,7 +247,7 @@ IC_METHOD(charName) {
buffer_len = u_charName(cp, (UCharNameChoice)nameChoice, NULL, 0, &error); buffer_len = u_charName(cp, (UCharNameChoice)nameChoice, NULL, 0, &error);
buffer = zend_string_alloc(buffer_len, 0); buffer = zend_string_alloc(buffer_len, 0);
error = U_ZERO_ERROR; 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)) { if (U_FAILURE(error)) {
zend_string_free(buffer); zend_string_free(buffer);
INTL_CHECK_STATUS(error, "Failure getting character name"); INTL_CHECK_STATUS(error, "Failure getting character name");

View file

@ -169,7 +169,7 @@ static void php_json_encode_array(smart_str *buf, zval *val, int options) /* {{{
php_json_encode(buf, data, options); php_json_encode(buf, data, options);
} else if (r == PHP_JSON_OUTPUT_OBJECT) { } else if (r == PHP_JSON_OUTPUT_OBJECT) {
if (key) { 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. */ /* Skip protected and private members. */
if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) { if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) {
ZEND_HASH_DEC_APPLY_COUNT(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_char(buf, options, '\n');
php_json_pretty_print_indent(buf, options); 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, ':'); smart_str_appendc(buf, ':');
php_json_pretty_print_char(buf, options, ' '); 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; 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 */ /* pre-allocate for string length plus 2 quotes */
smart_str_alloc(buf, len+2, 0); 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); us = php_next_utf8_char((const unsigned char *)s, len, &pos, &status);
if (status != SUCCESS) { if (status != SUCCESS) {
if (buf->s) { if (buf->s) {
buf->s->len = checkpoint; ZSTR_LEN(buf->s) = checkpoint;
} }
JSON_G(error_code) = PHP_JSON_ERROR_UTF8; JSON_G(error_code) = PHP_JSON_ERROR_UTF8;
smart_str_appendl(buf, "null", 4); 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"); 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) { 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); smart_str_appendl(buf, "null", sizeof("null") - 1);
zval_ptr_dtor(&fname); zval_ptr_dtor(&fname);
return; return;

File diff suppressed because it is too large Load diff

View file

@ -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 /* 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 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */ 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 special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public Bison output files to be licensed under the GNU General Public
License without this special exception. License without this special exception.
This special exception was added by the Free Software Foundation in This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */ version 2.2 of Bison. */
#ifndef YY_PHP_JSON_YY_HOME_JAKUB_PROG_PHP_MASTER_EXT_JSON_JSON_PARSER_TAB_H_INCLUDED #ifndef YY_PHP_JSON_YY_HOME_DMITRY_PHP_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 # define YY_PHP_JSON_YY_HOME_DMITRY_PHP_PHP_MASTER_EXT_JSON_JSON_PARSER_TAB_H_INCLUDED
/* Debug traces. */ /* Enabling traces. */
#ifndef YYDEBUG #ifndef YYDEBUG
# define YYDEBUG 0 # define YYDEBUG 0
#endif #endif
@ -40,21 +40,22 @@
extern int php_json_yydebug; extern int php_json_yydebug;
#endif #endif
/* Token type. */ /* Tokens. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
# define YYTOKENTYPE # define YYTOKENTYPE
enum yytokentype /* Put the tokens into the symbol table, so that GDB and other debuggers
{ know about them. */
PHP_JSON_T_NUL = 258, enum yytokentype {
PHP_JSON_T_TRUE = 259, PHP_JSON_T_NUL = 258,
PHP_JSON_T_FALSE = 260, PHP_JSON_T_TRUE = 259,
PHP_JSON_T_INT = 261, PHP_JSON_T_FALSE = 260,
PHP_JSON_T_DOUBLE = 262, PHP_JSON_T_INT = 261,
PHP_JSON_T_STRING = 263, PHP_JSON_T_DOUBLE = 262,
PHP_JSON_T_ESTRING = 264, PHP_JSON_T_STRING = 263,
PHP_JSON_T_EOI = 265, PHP_JSON_T_ESTRING = 264,
PHP_JSON_T_ERROR = 266 PHP_JSON_T_EOI = 265,
}; PHP_JSON_T_ERROR = 266
};
#endif #endif
/* Tokens. */ /* Tokens. */
#define PHP_JSON_T_NUL 258 #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_EOI 265
#define PHP_JSON_T_ERROR 266 #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; } pair;
};
typedef union YYSTYPE YYSTYPE; } YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
#endif #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); 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 */

View file

@ -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); zend_symtable_update(Z_ARRVAL_P(object), key, zvalue);
} else { } else {
zval zkey; zval zkey;
if (key->len == 0) { if (ZSTR_LEN(key) == 0) {
zend_string_release(key); zend_string_release(key);
key = zend_string_init("_empty_", sizeof("_empty_") - 1, 0); 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; parser->scanner.errcode = PHP_JSON_ERROR_INVALID_PROPERTY_NAME;
zend_string_release(key); zend_string_release(key);
zval_dtor(zvalue); zval_dtor(zvalue);

File diff suppressed because it is too large Load diff

View file

@ -254,7 +254,7 @@ std:
return PHP_JSON_T_ESTRING; return PHP_JSON_T_ESTRING;
} }
str = zend_string_alloc(len, 0); str = zend_string_alloc(len, 0);
str->val[len] = '\0'; ZSTR_VAL(str)[len] = '\0';
ZVAL_STR(&s->value, str); ZVAL_STR(&s->value, str);
if (s->str_esc) { if (s->str_esc) {
s->pstr = (php_json_ctype *) Z_STRVAL(s->value); s->pstr = (php_json_ctype *) Z_STRVAL(s->value);

View file

@ -1,4 +1,4 @@
/* Generated by re2c 0.14.3 */ /* Generated by re2c 0.13.5 */
enum YYCONDTYPE { enum YYCONDTYPE {
yycJS, yycJS,

View file

@ -551,17 +551,17 @@ static void php_libxml_internal_error_handler(int error_type, void *ctx, const c
if (output == 1) { if (output == 1) {
if (LIBXML(error_list)) { 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 { } else {
switch (error_type) { switch (error_type) {
case PHP_LIBXML_CTX_ERROR: 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; break;
case PHP_LIBXML_CTX_WARNING: 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; break;
default: 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)); smart_str_free(&LIBXML(error_buffer));

View file

@ -377,7 +377,7 @@ SAPI_POST_HANDLER_FUNC(php_mb_post_handler)
php_stream_rewind(SG(request_info).request_body); 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); 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); zend_string_release(post_data_str);
MBSTRG(http_input_identify) = detected; MBSTRG(http_input_identify) = detected;

View file

@ -1205,7 +1205,7 @@ static PHP_INI_MH(OnUpdate_mbstring_language)
{ {
enum mbfl_no_language no_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) { if (no_language == mbfl_no_language_invalid) {
MBSTRG(language) = mbfl_no_language_neutral; MBSTRG(language) = mbfl_no_language_neutral;
return FAILURE; return FAILURE;
@ -1231,7 +1231,7 @@ static PHP_INI_MH(OnUpdate_mbstring_detect_order)
return SUCCESS; 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; return FAILURE;
} }
@ -1264,7 +1264,7 @@ static PHP_INI_MH(OnUpdate_mbstring_http_input)
return SUCCESS; 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; return FAILURE;
} }
@ -1287,7 +1287,7 @@ static PHP_INI_MH(OnUpdate_mbstring_http_output)
{ {
const mbfl_encoding *encoding; 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()); encoding = mbfl_name2encoding(get_output_encoding());
if (!encoding) { if (!encoding) {
MBSTRG(http_output_encoding) = &mbfl_encoding_pass; MBSTRG(http_output_encoding) = &mbfl_encoding_pass;
@ -1295,7 +1295,7 @@ static PHP_INI_MH(OnUpdate_mbstring_http_output)
return SUCCESS; return SUCCESS;
} }
} else { } else {
encoding = mbfl_name2encoding(new_value->val); encoding = mbfl_name2encoding(ZSTR_VAL(new_value));
if (!encoding) { if (!encoding) {
MBSTRG(http_output_encoding) = &mbfl_encoding_pass; MBSTRG(http_output_encoding) = &mbfl_encoding_pass;
MBSTRG(current_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 (stage & (PHP_INI_STAGE_STARTUP | PHP_INI_STAGE_SHUTDOWN | PHP_INI_STAGE_RUNTIME)) {
if (new_value && new_value->len) { if (new_value && ZSTR_LEN(new_value)) {
return _php_mb_ini_mbstring_internal_encoding_set(new_value->val, new_value->len); return _php_mb_ini_mbstring_internal_encoding_set(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
} else { } else {
return _php_mb_ini_mbstring_internal_encoding_set(get_internal_encoding(), strlen(get_internal_encoding())+1); 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; char *endptr = NULL;
if (new_value != 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(filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE;
MBSTRG(current_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(filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG;
MBSTRG(current_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(filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY;
MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY; MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY;
} else { } else {
MBSTRG(filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR; MBSTRG(filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR; MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
if (new_value->len >0) { if (ZSTR_LEN(new_value) > 0) {
c = strtol(new_value->val, &endptr, 0); c = strtol(ZSTR_VAL(new_value), &endptr, 0);
if (*endptr == '\0') { if (*endptr == '\0') {
MBSTRG(filter_illegal_substchar) = c; MBSTRG(filter_illegal_substchar) = c;
MBSTRG(current_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); tmp = php_trim(new_value, NULL, 0, 3);
if (tmp->len > 0) { if (ZSTR_LEN(tmp) > 0) {
if (!(re = _php_mb_compile_regex(tmp->val))) { if (!(re = _php_mb_compile_regex(ZSTR_VAL(tmp)))) {
zend_string_release(tmp); zend_string_release(tmp);
return FAILURE; return FAILURE;
} }
@ -1751,7 +1751,7 @@ PHP_FUNCTION(mb_language)
} else { } else {
zend_string *ini_name = zend_string_init("mbstring.language", sizeof("mbstring.language") - 1, 0); 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)) { 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; RETVAL_FALSE;
} else { } else {
RETVAL_TRUE; RETVAL_TRUE;
@ -3994,7 +3994,7 @@ static int _php_mbstr_parse_mail_headers(HashTable *ht, const char *str, size_t
zval val; zval val;
/* FIXME: some locale free implementation is /* FIXME: some locale free implementation is
* really required here,,, */ * 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); ZVAL_STR(&val, fld_val);
zend_hash_update(ht, fld_name, &val); zend_hash_update(ht, fld_name, &val);
@ -4042,7 +4042,7 @@ out:
zval val; zval val;
/* FIXME: some locale free implementation is /* FIXME: some locale free implementation is
* really required here,,, */ * 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); ZVAL_STR(&val, fld_val);
zend_hash_update(ht, fld_name, &val); zend_hash_update(ht, fld_name, &val);
@ -4116,7 +4116,7 @@ PHP_FUNCTION(mb_send_mail)
MAIL_ASCIIZ_CHECK_MBSTRING(headers, headers_len); MAIL_ASCIIZ_CHECK_MBSTRING(headers, headers_len);
} }
if (extra_cmd) { 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); zend_hash_init(&ht_headers, 0, NULL, ZVAL_PTR_DTOR, 0);
@ -4304,10 +4304,10 @@ PHP_FUNCTION(mb_send_mail)
if (force_extra_parameters) { if (force_extra_parameters) {
extra_cmd = php_escape_shell_cmd(force_extra_parameters); extra_cmd = php_escape_shell_cmd(force_extra_parameters);
} else if (extra_cmd) { } 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; RETVAL_TRUE;
} else { } else {
RETVAL_FALSE; RETVAL_FALSE;

View file

@ -941,9 +941,9 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
/* null terminate buffer */ /* null terminate buffer */
smart_str_0(&eval_buf); smart_str_0(&eval_buf);
/* do eval */ /* 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); 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 */ /* 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); convert_to_string(&v);
smart_str_appendl(&out_buf, Z_STRVAL(v), Z_STRLEN(v)); smart_str_appendl(&out_buf, Z_STRVAL(v), Z_STRLEN(v));
/* Clean up */ /* Clean up */
eval_buf.s->len = 0; ZSTR_LEN(eval_buf.s) = 0;
zval_dtor(&v); zval_dtor(&v);
} else if (is_callable) { } else if (is_callable) {
zval args[1]; zval args[1];
@ -975,7 +975,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
convert_to_string_ex(&retval); convert_to_string_ex(&retval);
smart_str_appendl(&out_buf, Z_STRVAL(retval), Z_STRLEN(retval)); smart_str_appendl(&out_buf, Z_STRVAL(retval), Z_STRLEN(retval));
if (eval_buf.s) { if (eval_buf.s) {
eval_buf.s->len = 0; ZSTR_LEN(eval_buf.s) = 0;
} }
zval_ptr_dtor(&retval); zval_ptr_dtor(&retval);
} else { } else {

View file

@ -467,8 +467,8 @@ PHP_MINFO_FUNCTION(mcrypt) /* {{{ */
php_info_print_table_header(2, "mcrypt_filter support", "enabled"); 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, "Version", LIBMCRYPT_VERSION);
php_info_print_table_row(2, "Api No", mcrypt_api_no); 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 ciphers", ZSTR_VAL(tmp1.s));
php_info_print_table_row(2, "Supported modes", tmp2.s->val); php_info_print_table_row(2, "Supported modes", ZSTR_VAL(tmp2.s));
smart_str_free(&tmp1); smart_str_free(&tmp1);
smart_str_free(&tmp2); smart_str_free(&tmp2);
@ -1140,7 +1140,7 @@ static char *php_mcrypt_get_key_size_str(
smart_str_appends(&str, " supported"); smart_str_appends(&str, " supported");
smart_str_0(&str); 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); smart_str_free(&str);
return result; return result;

View file

@ -496,7 +496,7 @@ static MYSQLND *mysqli_convert_zv_to_mysqlnd(zval * zv)
mysqli_object *intern = Z_MYSQLI_P(zv); mysqli_object *intern = Z_MYSQLI_P(zv);
if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) { if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) {
/* We know that we have a mysqli object, so this failure should be emitted */ /* 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; return NULL;
} }
mysql = (MY_MYSQL *)(my_res->ptr); 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); ce = zend_fetch_class(class_name, ZEND_FETCH_CLASS_AUTO);
} }
if (!ce) { 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; return;
} }
fetchtype = MYSQLI_ASSOC; 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); fcc.object = Z_OBJ_P(return_value);
if (zend_call_function(&fci, &fcc) == FAILURE) { 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 { } else {
zval_ptr_dtor(&retval); zval_ptr_dtor(&retval);
} }
@ -1327,7 +1327,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
efree(fci.params); efree(fci.params);
} }
} else if (ctor_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));
} }
} }
} }

View file

@ -1967,8 +1967,8 @@ PHP_FUNCTION(mysqli_real_escape_string) {
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID); MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
newstr = zend_string_alloc(2 * escapestr_len, 0); newstr = zend_string_alloc(2 * escapestr_len, 0);
newstr->len = mysql_real_escape_string(mysql->mysql, newstr->val, escapestr, escapestr_len); ZSTR_LEN(newstr) = mysql_real_escape_string(mysql->mysql, ZSTR_VAL(newstr), escapestr, escapestr_len);
newstr = zend_string_truncate(newstr, newstr->len, 0); newstr = zend_string_truncate(newstr, ZSTR_LEN(newstr), 0);
RETURN_NEW_STR(newstr); RETURN_NEW_STR(newstr);
} }

View file

@ -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)); le.ptr = plist = calloc(1, sizeof(mysqli_plist_entry));
zend_ptr_stack_init_ex(&plist->free_links, 1); 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_RESOURCE *my_res;
mysqli_object *intern = Z_MYSQLI_P(elem); mysqli_object *intern = Z_MYSQLI_P(elem);
if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) { 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; continue;
} }
mysql = (MY_MYSQL*) my_res->ptr; mysql = (MY_MYSQL*) my_res->ptr;
if (MYSQLI_STATUS_VALID && my_res->status < MYSQLI_STATUS_VALID) { 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; continue;
} }
(*out_array)[current++] = mysql->mysql; (*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_RESOURCE *my_res;
mysqli_object *intern = Z_MYSQLI_P(elem); mysqli_object *intern = Z_MYSQLI_P(elem);
if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) { 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; continue;
} }
mysql = (MY_MYSQL *) my_res->ptr; 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 * name_esc = mysqli_escape_string_for_tx_name_in_comment(name);
char * query; char * query;
unsigned int query_len = spprintf(&query, 0, "START TRANSACTION%s %s", 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); smart_str_free(&tmp_str);
if (name_esc) { if (name_esc) {

View file

@ -41,7 +41,7 @@
#define MYSQLI_GET_MYSQL(statusval) \ #define MYSQLI_GET_MYSQL(statusval) \
MYSQL *p; \ MYSQL *p; \
if (!obj->ptr || !(MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr) { \ 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);\ ZVAL_NULL(retval);\
return retval; \ return retval; \
} else { \ } else { \
@ -52,7 +52,7 @@ if (!obj->ptr || !(MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr) { \
#define MYSQLI_GET_RESULT(statusval) \ #define MYSQLI_GET_RESULT(statusval) \
MYSQL_RES *p; \ MYSQL_RES *p; \
if (!obj->ptr) { \ 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);\ ZVAL_NULL(retval);\
return retval; \ return retval; \
} else { \ } else { \
@ -64,7 +64,7 @@ if (!obj->ptr) { \
#define MYSQLI_GET_STMT(statusval) \ #define MYSQLI_GET_STMT(statusval) \
MYSQL_STMT *p; \ MYSQL_STMT *p; \
if (!obj->ptr) { \ 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);\ ZVAL_NULL(retval);\
return retval; \ return retval; \
} else { \ } else { \

View file

@ -259,12 +259,12 @@ extern PHPAPI zend_class_entry *spl_ce_RuntimeException;
MYSQLI_RESOURCE *my_res; \ MYSQLI_RESOURCE *my_res; \
mysqli_object *intern = Z_MYSQLI_P(__id); \ mysqli_object *intern = Z_MYSQLI_P(__id); \
if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) {\ 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();\ RETURN_NULL();\
}\ }\
__ptr = (__type)my_res->ptr; \ __ptr = (__type)my_res->ptr; \
if (__check && my_res->status < __check) { \ 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();\ RETURN_NULL();\
}\ }\
} }
@ -273,12 +273,12 @@ extern PHPAPI zend_class_entry *spl_ce_RuntimeException;
{ \ { \
MYSQLI_RESOURCE *my_res; \ MYSQLI_RESOURCE *my_res; \
if (!(my_res = (MYSQLI_RESOURCE *)(__obj->ptr))) {\ 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;\ return;\
}\ }\
__ptr = (__type)my_res->ptr; \ __ptr = (__type)my_res->ptr; \
if (__check && my_res->status < __check) { \ 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;\ return;\
}\ }\
} }
@ -288,7 +288,7 @@ extern PHPAPI zend_class_entry *spl_ce_RuntimeException;
MYSQLI_FETCH_RESOURCE((__ptr), MY_MYSQL *, (__id), "mysqli_link", (__check)); \ MYSQLI_FETCH_RESOURCE((__ptr), MY_MYSQL *, (__id), "mysqli_link", (__check)); \
if (!(__ptr)->mysql) { \ if (!(__ptr)->mysql) { \
mysqli_object *intern = Z_MYSQLI_P(__id); \ 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(); \ RETURN_NULL(); \
} \ } \
} }
@ -298,7 +298,7 @@ extern PHPAPI zend_class_entry *spl_ce_RuntimeException;
MYSQLI_FETCH_RESOURCE((__ptr), MY_STMT *, (__id), "mysqli_stmt", (__check)); \ MYSQLI_FETCH_RESOURCE((__ptr), MY_STMT *, (__id), "mysqli_stmt", (__check)); \
if (!(__ptr)->stmt) { \ if (!(__ptr)->stmt) { \
mysqli_object *intern = Z_MYSQLI_P(__id); \ 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();\ RETURN_NULL();\
} \ } \
} }

View file

@ -1750,7 +1750,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, statistic)(MYSQLND_CONN_DATA * conn, zend_stri
if (PASS == (ret = PACKET_READ(stats_header, conn))) { if (PASS == (ret = PACKET_READ(stats_header, conn))) {
/* will be freed by Zend, thus don't use the mnd_ allocator */ /* will be freed by Zend, thus don't use the mnd_ allocator */
*message = zend_string_init(stats_header->message, stats_header->message_len, 0); *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); PACKET_FREE(stats_header);
} while (0); } 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) 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 (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, " ", sizeof(" ") - 1);
} }
smart_str_appendl(str, "AND CHAIN", sizeof("AND CHAIN") - 1); smart_str_appendl(str, "AND CHAIN", sizeof("AND CHAIN") - 1);
} else if (mode & TRANS_COR_AND_NO_CHAIN && !(mode & TRANS_COR_AND_CHAIN)) { } 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, " ", sizeof(" ") - 1);
} }
smart_str_appendl(str, "AND NO CHAIN", sizeof("AND NO CHAIN") - 1); smart_str_appendl(str, "AND NO CHAIN", sizeof("AND NO CHAIN") - 1);
} }
if (mode & TRANS_COR_RELEASE && !(mode & TRANS_COR_NO_RELEASE)) { 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, " ", sizeof(" ") - 1);
} }
smart_str_appendl(str, "RELEASE", sizeof("RELEASE") - 1); smart_str_appendl(str, "RELEASE", sizeof("RELEASE") - 1);
} else if (mode & TRANS_COR_NO_RELEASE && !(mode & TRANS_COR_RELEASE)) { } 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, " ", sizeof(" ") - 1);
} }
smart_str_appendl(str, "NO RELEASE", sizeof("NO RELEASE") - 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); 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"), 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); smart_str_free(&tmp_str);
if (name_esc) { if (name_esc) {
mnd_efree(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); smart_str_free(&tmp_str);
break; break;
} else if (mode & TRANS_START_READ_WRITE) { } 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, ", ", sizeof(", ") - 1);
} }
smart_str_appendl(&tmp_str, "READ WRITE", sizeof("READ WRITE") - 1); smart_str_appendl(&tmp_str, "READ WRITE", sizeof("READ WRITE") - 1);
} else if (mode & TRANS_START_READ_ONLY) { } 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, ", ", sizeof(", ") - 1);
} }
smart_str_appendl(&tmp_str, "READ ONLY", sizeof("READ ONLY") - 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 * name_esc = mysqlnd_escape_string_for_tx_name_in_comment(name);
char * query; 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); smart_str_free(&tmp_str);
if (name_esc) { if (name_esc) {
mnd_efree(name_esc); mnd_efree(name_esc);

View file

@ -597,11 +597,11 @@ char * _mysqlnd_pestrdup(const char * const ptr, zend_bool persistent MYSQLND_ME
smart_str_appendc(&tmp_str, *p); smart_str_appendc(&tmp_str, *p);
} while (*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); 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), tmp_str.s->val, tmp_str.s->len); memcpy(FAKE_PTR(ret), ZSTR_VAL(tmp_str.s), ZSTR_LEN(tmp_str.s));
if (ret && collect_memory_statistics) { 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); MYSQLND_INC_GLOBAL_STATISTIC(persistent? STAT_MEM_STRDUP_COUNT : STAT_MEM_ESTRDUP_COUNT);
} }
smart_str_free(&tmp_str); smart_str_free(&tmp_str);

View file

@ -548,11 +548,11 @@ mysqlnd_sha256_get_rsa_key(MYSQLND_CONN_DATA * conn,
if (stream) { if (stream) {
if ((key_str = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0)) != NULL) { 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); ret = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL);
BIO_free(bio); BIO_free(bio);
DBG_INF("Successfully loaded"); 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); zend_string_release(key_str);
} }
php_stream_close(stream); php_stream_close(stream);

View file

@ -440,7 +440,7 @@ MYSQLND_METHOD(mysqlnd_debug, close)(MYSQLND_DEBUG * self)
" min_own=%5llu max_own=%7llu avg_own=%7llu " " min_own=%5llu max_own=%7llu avg_own=%7llu "
" min_in_calls=%5llu max_in_calls=%7llu avg_in_calls=%7llu" " min_in_calls=%5llu max_in_calls=%7llu avg_in_calls=%7llu"
" min_total=%5llu max_total=%7llu avg_total=%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->calls
,(uint64_t) f_profile->own_underporm_calls ,(uint64_t) f_profile->own_underporm_calls
,(uint64_t) f_profile->in_calls_underporm_calls ,(uint64_t) f_profile->in_calls_underporm_calls

View file

@ -190,7 +190,7 @@ MYSQLND_METHOD(mysqlnd_net, open_tcp_or_unix)(MYSQLND_NET * const net, const cha
mnd_sprintf_free(hashed_details); mnd_sprintf_free(hashed_details);
} }
errcode = CR_CONNECTION_ERROR; 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) { if (errstr) {
/* no mnd_ since we don't allocate it */ /* no mnd_ since we don't allocate it */
zend_string_release(errstr); zend_string_release(errstr);

View file

@ -227,8 +227,8 @@ MYSQLND_METHOD(mysqlnd_res_meta, clone_metadata)(const MYSQLND_RES_METADATA * co
if (orig_fields[i].sname) { if (orig_fields[i].sname) {
new_fields[i].sname = zend_string_copy(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 = ZSTR_VAL(new_fields[i].sname);
new_fields[i].name_length = new_fields[i].sname->len; 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) { if (orig_fields[i].org_name && orig_fields[i].org_name != mysqlnd_empty_string) {

View file

@ -588,8 +588,8 @@ size_t php_mysqlnd_auth_write(void * _packet, MYSQLND_CONN_DATA * conn)
if (key) { /* HASH_KEY_IS_STRING */ if (key) { /* HASH_KEY_IS_STRING */
size_t value_len = Z_STRLEN_P(entry_value); size_t value_len = Z_STRLEN_P(entry_value);
ca_payload_len += php_mysqlnd_net_store_length_size(key->len); ca_payload_len += php_mysqlnd_net_store_length_size(ZSTR_LEN(key));
ca_payload_len += key->len; ca_payload_len += ZSTR_LEN(key);
ca_payload_len += php_mysqlnd_net_store_length_size(value_len); ca_payload_len += php_mysqlnd_net_store_length_size(value_len);
ca_payload_len += 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); size_t value_len = Z_STRLEN_P(entry_value);
/* copy key */ /* copy key */
p = php_mysqlnd_net_store_length(p, key->len); p = php_mysqlnd_net_store_length(p, ZSTR_LEN(key));
memcpy(p, key->val, key->len); memcpy(p, ZSTR_VAL(key), ZSTR_LEN(key));
p+= key->len; p+= ZSTR_LEN(key);
/* copy value */ /* copy value */
p = php_mysqlnd_net_store_length(p, value_len); p = php_mysqlnd_net_store_length(p, value_len);
memcpy(p, Z_STRVAL_P(entry_value), 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 { } else {
meta->sname = ZSTR_EMPTY_ALLOC(); meta->sname = ZSTR_EMPTY_ALLOC();
} }
meta->name = meta->sname->val; meta->name = ZSTR_VAL(meta->sname);
meta->name_length = meta->sname->len; meta->name_length = ZSTR_LEN(meta->sname);
/* Now do allocs */ /* Now do allocs */
if (meta->catalog && meta->catalog != mysqlnd_empty_string) { if (meta->catalog && meta->catalog != mysqlnd_empty_string) {

View file

@ -48,7 +48,7 @@ mysqlnd_minfo_print_hash(zval *values)
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(values), string_key, values_entry) { ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(values), string_key, values_entry) {
convert_to_string(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(); } ZEND_HASH_FOREACH_END();
} }
/* }}} */ /* }}} */
@ -154,12 +154,12 @@ PHP_MINFO_FUNCTION(mysqlnd)
smart_str tmp_str = {0}; smart_str tmp_str = {0};
mysqlnd_plugin_apply_with_argument(mysqlnd_minfo_dump_loaded_plugins, &tmp_str); mysqlnd_plugin_apply_with_argument(mysqlnd_minfo_dump_loaded_plugins, &tmp_str);
smart_str_0(&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); smart_str_free(&tmp_str);
mysqlnd_minfo_dump_api_plugins(&tmp_str); mysqlnd_minfo_dump_api_plugins(&tmp_str);
smart_str_0(&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); smart_str_free(&tmp_str);
} }
@ -211,7 +211,7 @@ static PHP_INI_MH(OnUpdateNetCmdBufferSize)
{ {
zend_long long_value; 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) { if (long_value < MYSQLND_NET_CMD_BUFFER_MIN_SIZE) {
return FAILURE; return FAILURE;
} }

View file

@ -38,11 +38,11 @@ int zend_optimizer_get_persistent_constant(zend_string *name, zval *result, int
ALLOCA_FLAG(use_heap); ALLOCA_FLAG(use_heap);
if ((c = zend_hash_find_ptr(EG(zend_constants), name)) == NULL) { if ((c = zend_hash_find_ptr(EG(zend_constants), name)) == NULL) {
lookup_name = DO_ALLOCA(name->len + 1); lookup_name = DO_ALLOCA(ZSTR_LEN(name) + 1);
memcpy(lookup_name, name->val, name->len + 1); memcpy(lookup_name, ZSTR_VAL(name), ZSTR_LEN(name) + 1);
zend_str_tolower(lookup_name, name->len); 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)) { if (!(c->flags & CONST_CT_SUBST) || (c->flags & CONST_CS)) {
retval = 0; 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)); l = old_len + Z_STRLEN(ZEND_OP1_LITERAL(opline));
if (!Z_REFCOUNTED(ZEND_OP1_LITERAL(last_op))) { if (!Z_REFCOUNTED(ZEND_OP1_LITERAL(last_op))) {
zend_string *tmp = zend_string_alloc(l, 0); 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; Z_STR(ZEND_OP1_LITERAL(last_op)) = tmp;
} else { } else {
Z_STR(ZEND_OP1_LITERAL(last_op)) = zend_string_extend(Z_STR(ZEND_OP1_LITERAL(last_op)), l, 0); 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)); l = old_len + Z_STRLEN(ZEND_OP2_LITERAL(opline));
if (!Z_REFCOUNTED(ZEND_OP2_LITERAL(src))) { if (!Z_REFCOUNTED(ZEND_OP2_LITERAL(src))) {
zend_string *tmp = zend_string_alloc(l, 0); 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; Z_STR(ZEND_OP2_LITERAL(last_op)) = tmp;
} else { } else {
Z_STR(ZEND_OP2_LITERAL(src)) = zend_string_extend(Z_STR(ZEND_OP2_LITERAL(src)), l, 0); Z_STR(ZEND_OP2_LITERAL(src)) = zend_string_extend(Z_STR(ZEND_OP2_LITERAL(src)), l, 0);

View file

@ -422,22 +422,22 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
if (info[i].flags & LITERAL_EX_OBJ) { if (info[i].flags & LITERAL_EX_OBJ) {
int key_len = MAX_LENGTH_OF_LONG + sizeof("->") + Z_STRLEN(op_array->literals[i]); int key_len = MAX_LENGTH_OF_LONG + sizeof("->") + Z_STRLEN(op_array->literals[i]);
key = zend_string_alloc(key_len, 0); 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) { } else if (info[i].flags & LITERAL_EX_CLASS) {
int key_len; int key_len;
zval *class_name = &op_array->literals[(info[i].u.num < i) ? map[info[i].u.num] : info[i].u.num]; 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_len = Z_STRLEN_P(class_name) + sizeof("::") + Z_STRLEN(op_array->literals[i]);
key = zend_string_alloc(key_len, 0); key = zend_string_alloc(key_len, 0);
memcpy(key->val, Z_STRVAL_P(class_name), Z_STRLEN_P(class_name)); memcpy(ZSTR_VAL(key), Z_STRVAL_P(class_name), Z_STRLEN_P(class_name));
memcpy(key->val + Z_STRLEN_P(class_name), "::", sizeof("::") - 1); memcpy(ZSTR_VAL(key) + Z_STRLEN_P(class_name), "::", sizeof("::") - 1);
memcpy(key->val + 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_STRVAL(op_array->literals[i]),
Z_STRLEN(op_array->literals[i]) + 1); Z_STRLEN(op_array->literals[i]) + 1);
} else { } else {
key = zend_string_init(Z_STRVAL(op_array->literals[i]), Z_STRLEN(op_array->literals[i]), 0); 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); ZSTR_H(key) = zend_hash_func(ZSTR_VAL(key), ZSTR_LEN(key));
key->h += info[i].flags; ZSTR_H(key) += info[i].flags;
} }
if ((info[i].flags & LITERAL_MAY_MERGE) && if ((info[i].flags & LITERAL_MAY_MERGE) &&
(pos = zend_hash_find(&hash, key)) != NULL && (pos = zend_hash_find(&hash, key)) != NULL &&

View file

@ -296,7 +296,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
/* for A::B */ /* for A::B */
if (op_array->scope && if (op_array->scope &&
!strncasecmp(Z_STRVAL(ZEND_OP1_LITERAL(opline)), !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; ce = op_array->scope;
} else { } else {
if ((ce = zend_hash_find_ptr(EG(class_table), 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) && !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)))) { 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); 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); ZSTR_LEN(dirname) = zend_dirname(ZSTR_VAL(dirname), ZSTR_LEN(dirname));
if (IS_ABSOLUTE_PATH(dirname->val, dirname->len)) { if (IS_ABSOLUTE_PATH(ZSTR_VAL(dirname), ZSTR_LEN(dirname))) {
zval t; zval t;
ZVAL_STR(&t, dirname); ZVAL_STR(&t, dirname);

View file

@ -62,9 +62,9 @@ int zend_optimizer_lookup_cv(zend_op_array *op_array, zend_string* name)
while (i < op_array->last_var) { while (i < op_array->last_var) {
if (op_array->vars[i] == name || if (op_array->vars[i] == name ||
(op_array->vars[i]->h == hash_value && (ZSTR_H(op_array->vars[i]) == hash_value &&
op_array->vars[i]->len == name->len && ZSTR_LEN(op_array->vars[i]) == ZSTR_LEN(name) &&
memcmp(op_array->vars[i]->val, name->val, name->len) == 0)) { 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); return (int)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, i);
} }
i++; i++;

View file

@ -295,8 +295,8 @@ static zend_string *accel_find_interned_string(zend_string *str)
arData = ZCSG(interned_strings).arData; arData = ZCSG(interned_strings).arData;
while (idx != HT_INVALID_IDX) { while (idx != HT_INVALID_IDX) {
p = HT_HASH_TO_BUCKET_EX(arData, idx); p = HT_HASH_TO_BUCKET_EX(arData, idx);
if ((p->h == h) && (p->key->len == str->len)) { if ((p->h == h) && (ZSTR_LEN(p->key) == ZSTR_LEN(str))) {
if (!memcmp(p->key->val, str->val, str->len)) { if (!memcmp(ZSTR_VAL(p->key), ZSTR_VAL(str), ZSTR_LEN(str))) {
return p->key; return p->key;
} }
} }
@ -334,8 +334,8 @@ zend_string *accel_new_interned_string(zend_string *str)
idx = HT_HASH(&ZCSG(interned_strings), nIndex); idx = HT_HASH(&ZCSG(interned_strings), nIndex);
while (idx != HT_INVALID_IDX) { while (idx != HT_INVALID_IDX) {
p = HT_HASH_TO_BUCKET(&ZCSG(interned_strings), idx); p = HT_HASH_TO_BUCKET(&ZCSG(interned_strings), idx);
if ((p->h == h) && (p->key->len == str->len)) { if ((p->h == h) && (ZSTR_LEN(p->key) == ZSTR_LEN(str))) {
if (!memcmp(p->key->val, str->val, str->len)) { if (!memcmp(ZSTR_VAL(p->key), ZSTR_VAL(str), ZSTR_LEN(str))) {
zend_string_release(str); zend_string_release(str);
return p->key; return p->key;
} }
@ -366,9 +366,9 @@ zend_string *accel_new_interned_string(zend_string *str)
GC_TYPE(p->key) = IS_STRING; GC_TYPE(p->key) = IS_STRING;
GC_FLAGS(p->key) = IS_STR_INTERNED | IS_STR_PERMANENT; GC_FLAGS(p->key) = IS_STR_INTERNED | IS_STR_PERMANENT;
#endif #endif
p->key->h = str->h; ZSTR_H(p->key) = ZSTR_H(str);
p->key->len = str->len; ZSTR_LEN(p->key) = ZSTR_LEN(str);
memcpy(p->key->val, str->val, str->len); memcpy(ZSTR_VAL(p->key), ZSTR_VAL(str), ZSTR_LEN(str));
ZVAL_INTERNED_STR(&p->val, p->key); ZVAL_INTERNED_STR(&p->val, p->key);
Z_NEXT(p->val) = HT_HASH(&ZCSG(interned_strings), nIndex); Z_NEXT(p->val) = HT_HASH(&ZCSG(interned_strings), nIndex);
HT_HASH(&ZCSG(interned_strings), nIndex) = HT_IDX_TO_HASH(idx); 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_FILENAME:
case ZEND_HANDLE_MAPPED: case ZEND_HANDLE_MAPPED:
if (file_handle->opened_path) { 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 (is_stream_path(file_path)) {
if (zend_get_stream_timestamp(file_path, &statbuf) == SUCCESS) { 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 (file_handle->opened_path) {
if (persistent_script->full_path != file_handle->opened_path && if (persistent_script->full_path != file_handle->opened_path &&
(persistent_script->full_path->len != file_handle->opened_path->len || (ZSTR_LEN(persistent_script->full_path) != ZSTR_LEN(file_handle->opened_path) ||
memcmp(persistent_script->full_path->val, file_handle->opened_path->val, file_handle->opened_path->len) != 0)) { memcmp(ZSTR_VAL(persistent_script->full_path), ZSTR_VAL(file_handle->opened_path), ZSTR_LEN(file_handle->opened_path)) != 0)) {
return FAILURE; return FAILURE;
} }
} else { } else {
full_path_ptr = accelerator_orig_zend_resolve_path(file_handle->filename, strlen(file_handle->filename)); full_path_ptr = accelerator_orig_zend_resolve_path(file_handle->filename, strlen(file_handle->filename));
if (full_path_ptr && if (full_path_ptr &&
persistent_script->full_path != full_path_ptr && persistent_script->full_path != full_path_ptr &&
(persistent_script->full_path->len != full_path_ptr->len || (ZSTR_LEN(persistent_script->full_path) != ZSTR_LEN(full_path_ptr) ||
memcmp(persistent_script->full_path->val, full_path_ptr->val, full_path_ptr->len) != 0)) { memcmp(ZSTR_VAL(persistent_script->full_path), ZSTR_VAL(full_path_ptr), ZSTR_LEN(full_path_ptr)) != 0)) {
zend_string_release(full_path_ptr); zend_string_release(full_path_ptr);
return FAILURE; 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.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; ps_handle.opened_path = persistent_script->full_path;
if (zend_get_file_handle_timestamp(&ps_handle, NULL) == persistent_script->timestamp) { 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); 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; return NULL;
} }
cwd = cwd_str->val; cwd = ZSTR_VAL(cwd_str);
cwd_len = cwd_str->len; cwd_len = ZSTR_LEN(cwd_str);
#ifndef ZTS #ifndef ZTS
if (ZCG(cwd_check)) { if (ZCG(cwd_check)) {
ZCG(cwd_check) = 0; ZCG(cwd_check) = 0;
@ -961,7 +961,7 @@ char *accel_make_persistent_key(const char *path, int path_length, int *key_len)
} }
if (str) { if (str) {
char buf[32]; 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_len = ZCG(cwd_key_len) = buf + sizeof(buf) - 1 - res;
cwd = ZCG(cwd_key); 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))) { if (EXPECTED(ZCG(include_path_key_len))) {
include_path = ZCG(include_path_key); include_path = ZCG(include_path_key);
include_path_len = ZCG(include_path_key_len); 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 = "";
include_path_len = 0; include_path_len = 0;
} else { } else {
include_path = ZCG(include_path)->val; include_path = ZSTR_VAL(ZCG(include_path));
include_path_len = ZCG(include_path)->len; include_path_len = ZSTR_LEN(ZCG(include_path));
#ifndef ZTS #ifndef ZTS
if (ZCG(include_path_check)) { 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) { if (str) {
char buf[32]; 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_len = ZCG(include_path_key_len) = buf + sizeof(buf) - 1 - res;
include_path = ZCG(include_path_key); 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)) && if (EXPECTED(EG(current_execute_data)) &&
EXPECTED((parent_script = zend_get_executed_filename_ex()) != NULL)) { EXPECTED((parent_script = zend_get_executed_filename_ex()) != NULL)) {
parent_script_len = parent_script->len; parent_script_len = ZSTR_LEN(parent_script);
while ((--parent_script_len > 0) && !IS_SLASH(parent_script->val[parent_script_len])); 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)))) { if (UNEXPECTED((size_t)(key_length + parent_script_len + 1) >= sizeof(ZCG(key)))) {
return NULL; return NULL;
} }
ZCG(key)[key_length] = ':'; ZCG(key)[key_length] = ':';
key_length += 1; 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; key_length += parent_script_len;
} }
ZCG(key)[key_length] = '\0'; 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; zend_file_handle file_handle;
file_handle.type = ZEND_HANDLE_FILENAME; file_handle.type = ZEND_HANDLE_FILENAME;
file_handle.filename = realpath->val; file_handle.filename = ZSTR_VAL(realpath);
file_handle.opened_path = realpath; file_handle.opened_path = realpath;
if (force || 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->is_phar =
new_persistent_script->full_path && new_persistent_script->full_path &&
strstr(new_persistent_script->full_path->val, ".phar") && strstr(ZSTR_VAL(new_persistent_script->full_path), ".phar") &&
!strstr(new_persistent_script->full_path->val, "://"); !strstr(ZSTR_VAL(new_persistent_script->full_path), "://");
/* Consistency check */ /* Consistency check */
if ((char*)new_persistent_script->mem + new_persistent_script->size != (char*)ZCG(mem)) { if ((char*)new_persistent_script->mem + new_persistent_script->size != (char*)ZCG(mem)) {
zend_accel_error( zend_accel_error(
((char*)new_persistent_script->mem + new_persistent_script->size < (char*)ZCG(mem)) ? ACCEL_LOG_ERROR : ACCEL_LOG_WARNING, ((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", "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, new_persistent_script->mem,
(char *)new_persistent_script->mem + new_persistent_script->size, (char *)new_persistent_script->mem + new_persistent_script->size,
ZCG(mem)); 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->is_phar =
new_persistent_script->full_path && new_persistent_script->full_path &&
strstr(new_persistent_script->full_path->val, ".phar") && strstr(ZSTR_VAL(new_persistent_script->full_path), ".phar") &&
!strstr(new_persistent_script->full_path->val, "://"); !strstr(ZSTR_VAL(new_persistent_script->full_path), "://");
/* Consistency check */ /* Consistency check */
if ((char*)new_persistent_script->mem + new_persistent_script->size != (char*)ZCG(mem)) { if ((char*)new_persistent_script->mem + new_persistent_script->size != (char*)ZCG(mem)) {
zend_accel_error( zend_accel_error(
((char*)new_persistent_script->mem + new_persistent_script->size < (char*)ZCG(mem)) ? ACCEL_LOG_ERROR : ACCEL_LOG_WARNING, ((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", "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, new_persistent_script->mem,
(char *)new_persistent_script->mem + new_persistent_script->size, (char *)new_persistent_script->mem + new_persistent_script->size,
ZCG(mem)); 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); new_persistent_script->dynamic_members.checksum = zend_accel_script_checksum(new_persistent_script);
/* store script structure in the hash table */ /* 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) { if (bucket) {
zend_accel_error(ACCEL_LOG_INFO, "Cached script '%s'", new_persistent_script->full_path); zend_accel_error(ACCEL_LOG_INFO, "Cached script '%s'", new_persistent_script->full_path);
if (key && if (key &&
/* key may contain non-persistent PHAR aliases (see issues #115 and #149) */ /* key may contain non-persistent PHAR aliases (see issues #115 and #149) */
memcmp(key, "phar://", sizeof("phar://") - 1) != 0 && memcmp(key, "phar://", sizeof("phar://") - 1) != 0 &&
(new_persistent_script->full_path->len != key_length || (ZSTR_LEN(new_persistent_script->full_path) != key_length ||
memcmp(new_persistent_script->full_path->val, key, key_length) != 0)) { memcmp(ZSTR_VAL(new_persistent_script->full_path), key, key_length) != 0)) {
/* link key to the same persistent script in hash table */ /* link key to the same persistent script in hash table */
if (zend_accel_hash_update(&ZCSG(hash), key, key_length, 1, bucket)) { if (zend_accel_hash_update(&ZCSG(hash), key, key_length, 1, bucket)) {
zend_accel_error(ACCEL_LOG_INFO, "Added key '%s'", key); 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 */ /* 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)++; ZCSG(blacklist_misses)++;
*op_array_p = accelerator_orig_compile_file(file_handle, type); *op_array_p = accelerator_orig_compile_file(file_handle, type);
return NULL; 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 */ /* ext/phar has to load phar's metadata into memory */
if (persistent_script->is_phar) { if (persistent_script->is_phar) {
php_stream_statbuf ssb; 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, "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); php_stream_stat_path(fname, &ssb);
efree(fname); 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 */ /* ext/phar has to load phar's metadata into memory */
if (persistent_script->is_phar) { if (persistent_script->is_phar) {
php_stream_statbuf ssb; 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, "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); php_stream_stat_path(fname, &ssb);
efree(fname); efree(fname);
} }

View file

@ -172,8 +172,8 @@ void* zend_accel_hash_find(zend_accel_hash *accel_hash, zend_string *key)
{ {
return zend_accel_hash_find_ex( return zend_accel_hash_find_ex(
accel_hash, accel_hash,
key->val, ZSTR_VAL(key),
key->len, ZSTR_LEN(key),
zend_string_hash_val(key), zend_string_hash_val(key),
1); 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( return (zend_accel_hash_entry *)zend_accel_hash_find_ex(
accel_hash, accel_hash,
key->val, ZSTR_VAL(key),
key->len, ZSTR_LEN(key),
zend_string_hash_val(key), zend_string_hash_val(key),
0); 0);
} }

View file

@ -112,7 +112,7 @@ static ZEND_INI_MH(OnUpdateMemoryConsumption)
(void)entry; (void)mh_arg2; (void)mh_arg3; (void)stage; (void)entry; (void)mh_arg2; (void)mh_arg3; (void)stage;
p = (zend_long *) (base + (size_t)mh_arg1); 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 */ /* sanity check we must use at least 8 MB */
if (memsize < 8) { if (memsize < 8) {
const char *new_new_value = "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; (void)entry; (void)mh_arg2; (void)mh_arg3; (void)stage;
p = (zend_long *) (base + (size_t)mh_arg1); 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 */ /* sanity check we must use a value between MIN_ACCEL_FILES and MAX_ACCEL_FILES */
if (size < MIN_ACCEL_FILES || size > 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; (void)entry; (void)mh_arg2; (void)mh_arg3; (void)stage;
p = (double *) (base + (size_t)mh_arg1); p = (double *) (base + (size_t)mh_arg1);
percentage = atoi(new_value->val); percentage = atoi(ZSTR_VAL(new_value));
if (percentage <= 0 || percentage > 50) { if (percentage <= 0 || percentage > 50) {
const char *new_new_value = "5"; const char *new_new_value = "5";
@ -228,10 +228,10 @@ static ZEND_INI_MH(OnEnable)
#endif #endif
p = (zend_bool *) (base+(size_t) mh_arg1); p = (zend_bool *) (base+(size_t) mh_arg1);
if ((new_value->len == 2 && strcasecmp("on", new_value->val) == 0) || if ((ZSTR_LEN(new_value) == 2 && strcasecmp("on", ZSTR_VAL(new_value)) == 0) ||
(new_value->len == 3 && strcasecmp("yes", new_value->val) == 0) || (ZSTR_LEN(new_value) == 3 && strcasecmp("yes", ZSTR_VAL(new_value)) == 0) ||
(new_value->len == 4 && strcasecmp("true", new_value->val) == 0) || (ZSTR_LEN(new_value) == 4 && strcasecmp("true", ZSTR_VAL(new_value)) == 0) ||
atoi(new_value->val) != 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)"); zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME " can't be temporary enabled (it may be only disabled till the end of request)");
return FAILURE; return FAILURE;
} else { } else {
@ -246,18 +246,18 @@ static ZEND_INI_MH(OnEnable)
static ZEND_INI_MH(OnUpdateFileCache) static ZEND_INI_MH(OnUpdateFileCache)
{ {
if (new_value) { if (new_value) {
if (!new_value->len) { if (!ZSTR_LEN(new_value)) {
new_value = NULL; new_value = NULL;
} else { } else {
zend_stat_t buf; zend_stat_t buf;
if (!IS_ABSOLUTE_PATH(new_value->val, new_value->len) || if (!IS_ABSOLUTE_PATH(ZSTR_VAL(new_value), ZSTR_LEN(new_value)) ||
zend_stat(new_value->val, &buf) != 0 || zend_stat(ZSTR_VAL(new_value), &buf) != 0 ||
!S_ISDIR(buf.st_mode) || !S_ISDIR(buf.st_mode) ||
#ifndef ZEND_WIN32 #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 #else
_access(new_value->val, 06) != 0) { _access(ZSTR_VAL(new_value), 06) != 0) {
#endif #endif
zend_accel_error(ACCEL_LOG_WARNING, "opcache.file_cache must be a full path of accessable directory.\n"); zend_accel_error(ACCEL_LOG_WARNING, "opcache.file_cache must be a full path of accessable directory.\n");
new_value = NULL; new_value = NULL;
@ -316,13 +316,13 @@ static int filename_is_in_cache(zend_string *filename)
char *key; char *key;
int key_length; 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) { if (key != NULL) {
zend_persistent_script *persistent_script = zend_accel_hash_str_find(&ZCSG(hash), key, key_length); zend_persistent_script *persistent_script = zend_accel_hash_str_find(&ZCSG(hash), key, key_length);
if (persistent_script && !persistent_script->corrupted) { if (persistent_script && !persistent_script->corrupted) {
zend_file_handle handle = {{0}, NULL, NULL, 0, 0}; zend_file_handle handle = {{0}, NULL, NULL, 0, 0};
handle.filename = filename->val; handle.filename = ZSTR_VAL(filename);
handle.type = ZEND_HANDLE_FILENAME; handle.type = ZEND_HANDLE_FILENAME;
if (ZCG(accel_directives).validate_timestamps) { if (ZCG(accel_directives).validate_timestamps) {

View file

@ -534,7 +534,7 @@ static void zend_accel_function_hash_copy(HashTable *target, HashTable *source)
ZEND_ASSERT(p->key); ZEND_ASSERT(p->key);
t = zend_hash_find(target, p->key); t = zend_hash_find(target, p->key);
if (UNEXPECTED(t != NULL)) { 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 */ /* Mangled key */
t = zend_hash_update(target, p->key, &p->val); t = zend_hash_update(target, p->key, &p->val);
} else { } else {
@ -556,11 +556,11 @@ failure:
if (function2->type == ZEND_USER_FUNCTION if (function2->type == ZEND_USER_FUNCTION
&& function2->op_array.last > 0) { && function2->op_array.last > 0) {
zend_error(E_ERROR, "Cannot redeclare %s() (previously declared in %s:%d)", zend_error(E_ERROR, "Cannot redeclare %s() (previously declared in %s:%d)",
function1->common.function_name->val, ZSTR_VAL(function1->common.function_name),
function2->op_array.filename->val, ZSTR_VAL(function2->op_array.filename),
(int)function2->op_array.opcodes[0].lineno); (int)function2->op_array.opcodes[0].lineno);
} else { } 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); ZEND_ASSERT(p->key);
t = zend_hash_find(target, p->key); t = zend_hash_find(target, p->key);
if (UNEXPECTED(t != NULL)) { 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 */ /* Mangled key */
zend_hash_update_ptr(target, p->key, ARENA_REALLOC(Z_PTR(p->val))); zend_hash_update_ptr(target, p->key, ARENA_REALLOC(Z_PTR(p->val)));
} else { } else {
@ -600,11 +600,11 @@ failure:
if (function2->type == ZEND_USER_FUNCTION if (function2->type == ZEND_USER_FUNCTION
&& function2->op_array.last > 0) { && function2->op_array.last > 0) {
zend_error(E_ERROR, "Cannot redeclare %s() (previously declared in %s:%d)", zend_error(E_ERROR, "Cannot redeclare %s() (previously declared in %s:%d)",
function1->common.function_name->val, ZSTR_VAL(function1->common.function_name),
function2->op_array.filename->val, ZSTR_VAL(function2->op_array.filename),
(int)function2->op_array.opcodes[0].lineno); (int)function2->op_array.opcodes[0].lineno);
} else { } 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); ZEND_ASSERT(p->key);
t = zend_hash_find(target, p->key); t = zend_hash_find(target, p->key);
if (UNEXPECTED(t != NULL)) { 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 */ /* Mangled key - ignore and wait for runtime */
continue; continue;
} else if (UNEXPECTED(!ZCG(accel_directives).ignore_dups)) { } else if (UNEXPECTED(!ZCG(accel_directives).ignore_dups)) {
@ -643,7 +643,7 @@ failure:
CG(in_compilation) = 1; CG(in_compilation) = 1;
zend_set_compiled_filename(ce1->info.user.filename); zend_set_compiled_filename(ce1->info.user.filename);
CG(zend_lineno) = ce1->info.user.line_start; 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__ #ifdef __SSE2__
@ -713,9 +713,9 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script,
zend_string *name; zend_string *name;
char haltoff[] = "__COMPILER_HALT_OFFSET__"; 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)) { 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); zend_string_release(name);
} }

View file

@ -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))); len = ZEND_MM_ALIGNED_SIZE(_ZSTR_STRUCT_SIZE(ZSTR_LEN(str)));
ret = (void*)(info->str_size | Z_UL(1)); ret = (void*)(info->str_size | Z_UL(1));
zend_shared_alloc_register_xlat_entry(str, ret); 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; size_t new_len = info->str_size + len;
ZCG(mem) = (void*)zend_string_realloc( ZCG(mem) = (void*)zend_string_realloc(
(zend_string*)ZCG(mem), (zend_string*)ZCG(mem),
((_ZSTR_HEADER_SIZE + 1 + new_len + 4095) & ~0xfff) - (_ZSTR_HEADER_SIZE + 1), ((_ZSTR_HEADER_SIZE + 1 + new_len + 4095) & ~0xfff) - (_ZSTR_HEADER_SIZE + 1),
0); 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; info->str_size += len;
return ret; return ret;
} }
@ -677,12 +677,12 @@ int zend_file_cache_script_store(zend_persistent_script *script, int in_shm)
void *mem, *buf; void *mem, *buf;
len = strlen(ZCG(accel_directives).file_cache); 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); memcpy(filename, ZCG(accel_directives).file_cache, len);
filename[len] = '/'; filename[len] = '/';
memcpy(filename + len + 1, ZCG(system_id), 32); memcpy(filename + len + 1, ZCG(system_id), 32);
memcpy(filename + len + 33, script->full_path->val, script->full_path->len); memcpy(filename + len + 33, ZSTR_VAL(script->full_path), ZSTR_LEN(script->full_path));
memcpy(filename + len + 33 + script->full_path->len, SUFFIX, sizeof(SUFFIX)); memcpy(filename + len + 33 + ZSTR_LEN(script->full_path), SUFFIX, sizeof(SUFFIX));
if (zend_file_cache_mkdir(filename, len) != SUCCESS) { if (zend_file_cache_mkdir(filename, len) != SUCCESS) {
zend_accel_error(ACCEL_LOG_WARNING, "opcache cannot create directory for file '%s'\n", filename); 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(); zend_shared_alloc_destroy_xlat_table();
info.checksum = zend_adler32(ADLER32_INIT, buf, script->size); 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 #ifndef ZEND_WIN32
vec[0].iov_base = &info; vec[0].iov_base = &info;
vec[0].iov_len = sizeof(info); vec[0].iov_len = sizeof(info);
vec[1].iov_base = buf; vec[1].iov_base = buf;
vec[1].iov_len = script->size; 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; vec[2].iov_len = info.str_size;
if (writev(fd, vec, 3) != (ssize_t)(sizeof(info) + script->size + 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; return NULL;
} }
len = strlen(ZCG(accel_directives).file_cache); 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); memcpy(filename, ZCG(accel_directives).file_cache, len);
filename[len] = '/'; filename[len] = '/';
memcpy(filename + len + 1, ZCG(system_id), 32); memcpy(filename + len + 1, ZCG(system_id), 32);
memcpy(filename + len + 33, full_path->val, full_path->len); memcpy(filename + len + 33, ZSTR_VAL(full_path), ZSTR_LEN(full_path));
memcpy(filename + len + 33 + full_path->len, SUFFIX, sizeof(SUFFIX)); memcpy(filename + len + 33 + ZSTR_LEN(full_path), SUFFIX, sizeof(SUFFIX));
fd = open(filename, O_RDONLY | O_BINARY); fd = open(filename, O_RDONLY | O_BINARY);
if (fd < 0) { if (fd < 0) {
@ -1316,7 +1316,7 @@ use_process_mem:
if (cache_it) { if (cache_it) {
script->dynamic_members.checksum = zend_accel_script_checksum(script); 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_shared_alloc_unlock();
zend_arena_release(&CG(arena), checkpoint); zend_arena_release(&CG(arena), checkpoint);
@ -1332,12 +1332,12 @@ void zend_file_cache_invalidate(zend_string *full_path)
char *filename; char *filename;
len = strlen(ZCG(accel_directives).file_cache); 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); memcpy(filename, ZCG(accel_directives).file_cache, len);
filename[len] = '/'; filename[len] = '/';
memcpy(filename + len + 1, ZCG(system_id), 32); memcpy(filename + len + 1, ZCG(system_id), 32);
memcpy(filename + len + 33, full_path->val, full_path->len); memcpy(filename + len + 33, ZSTR_VAL(full_path), ZSTR_LEN(full_path));
memcpy(filename + len + 33 + full_path->len, SUFFIX, sizeof(SUFFIX)); memcpy(filename + len + 33 + ZSTR_LEN(full_path), SUFFIX, sizeof(SUFFIX));
unlink(filename); unlink(filename);
efree(filename); efree(filename);

View file

@ -1538,8 +1538,8 @@ PHP_FUNCTION(openssl_spki_new)
} }
s = zend_string_alloc(strlen(spkac) + strlen(spkstr), 0); s = zend_string_alloc(strlen(spkac) + strlen(spkstr), 0);
sprintf(s->val, "%s%s", spkac, spkstr); sprintf(ZSTR_VAL(s), "%s%s", spkac, spkstr);
s->len = strlen(s->val); ZSTR_LEN(s) = strlen(ZSTR_VAL(s));
RETVAL_STR(s); RETVAL_STR(s);
goto cleanup; goto cleanup;
@ -1556,7 +1556,7 @@ cleanup:
efree(spkstr); efree(spkstr);
} }
if (s && s->len <= 0) { if (s && ZSTR_LEN(s) <= 0) {
RETVAL_FALSE; 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); ret = zend_string_init((char*)md, n, 0);
} else { } else {
ret = zend_string_alloc(n * 2, 0); ret = zend_string_alloc(n * 2, 0);
make_digest_ex(ret->val, md, n); make_digest_ex(ZSTR_VAL(ret), md, n);
ret->val[n * 2] = '\0'; ZSTR_VAL(ret)[n * 2] = '\0';
} }
return ret; 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); convert_to_string_ex(item);
nid = OBJ_txt2nid(strindex->val); nid = OBJ_txt2nid(ZSTR_VAL(strindex));
if (nid != NID_undef) { if (nid != NID_undef) {
if (!X509_NAME_add_entry_by_NID(subj, nid, MBSTRING_UTF8, if (!X509_NAME_add_entry_by_NID(subj, nid, MBSTRING_UTF8,
(unsigned char*)Z_STRVAL_P(item), -1, -1, 0)) (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; return FAILURE;
} }
} else { } 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(); } 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); convert_to_string_ex(item);
nid = OBJ_txt2nid(strindex->val); nid = OBJ_txt2nid(ZSTR_VAL(strindex));
if (nid != NID_undef) { if (nid != NID_undef) {
if (!X509_NAME_add_entry_by_NID(subj, nid, MBSTRING_UTF8, (unsigned char*)Z_STRVAL_P(item), -1, -1, 0)) { 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)); php_error_docref(NULL, E_WARNING, "attribs: add_entry_by_NID %d -> %s (failed)", nid, Z_STRVAL_P(item));
return FAILURE; return FAILURE;
} }
} else { } 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(); } ZEND_HASH_FOREACH_END();
for (i = 0; i < sk_CONF_VALUE_num(attr_sk); i++) { 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 { \ #define OPENSSL_PKEY_GET_BN(_type, _name) do { \
if (pkey->pkey._type->_name != NULL) { \ if (pkey->pkey._type->_name != NULL) { \
int len = BN_num_bytes(pkey->pkey._type->_name); \ int len = BN_num_bytes(pkey->pkey._type->_name); \
zend_string *str = zend_string_alloc(len, 0); \ zend_string *str = zend_string_alloc(len, 0); \
BN_bn2bin(pkey->pkey._type->_name, (unsigned char*)str->val); \ BN_bn2bin(pkey->pkey._type->_name, (unsigned char*)ZSTR_VAL(str)); \
str->val[len] = 0; \ ZSTR_VAL(str)[len] = 0; \
add_assoc_str(&_type, #_name, str); \ add_assoc_str(&_type, #_name, str); \
} \ } \
} while (0) } while (0)
@ -4020,8 +4020,8 @@ PHP_FUNCTION(openssl_pbkdf2)
out_buffer = zend_string_alloc(key_length, 0); 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) { 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) {
out_buffer->val[key_length] = 0; ZSTR_VAL(out_buffer)[key_length] = 0;
RETURN_NEW_STR(out_buffer); RETURN_NEW_STR(out_buffer);
} else { } else {
zend_string_release(out_buffer); zend_string_release(out_buffer);
@ -4249,7 +4249,7 @@ PHP_FUNCTION(openssl_pkcs7_encrypt)
convert_to_string_ex(zcertval); convert_to_string_ex(zcertval);
if (strindex) { 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 { } else {
BIO_printf(outfile, "%s\n", Z_STRVAL_P(zcertval)); BIO_printf(outfile, "%s\n", Z_STRVAL_P(zcertval));
} }
@ -4353,7 +4353,7 @@ PHP_FUNCTION(openssl_pkcs7_sign)
convert_to_string_ex(hval); convert_to_string_ex(hval);
if (strindex) { 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 { } else {
BIO_printf(outfile, "%s\n", Z_STRVAL_P(hval)); BIO_printf(outfile, "%s\n", Z_STRVAL_P(hval));
} }
@ -4489,7 +4489,7 @@ PHP_FUNCTION(openssl_private_encrypt)
case EVP_PKEY_RSA2: case EVP_PKEY_RSA2:
successful = (RSA_private_encrypt((int)data_len, successful = (RSA_private_encrypt((int)data_len,
(unsigned char *)data, (unsigned char *)data,
(unsigned char *)cryptedbuf->val, (unsigned char *)ZSTR_VAL(cryptedbuf),
pkey->pkey.rsa, pkey->pkey.rsa,
(int)padding) == cryptedlen); (int)padding) == cryptedlen);
break; break;
@ -4499,7 +4499,7 @@ PHP_FUNCTION(openssl_private_encrypt)
if (successful) { if (successful) {
zval_dtor(crypted); zval_dtor(crypted);
cryptedbuf->val[cryptedlen] = '\0'; ZSTR_VAL(cryptedbuf)[cryptedlen] = '\0';
ZVAL_NEW_STR(crypted, cryptedbuf); ZVAL_NEW_STR(crypted, cryptedbuf);
cryptedbuf = NULL; cryptedbuf = NULL;
RETVAL_TRUE; RETVAL_TRUE;
@ -4555,7 +4555,7 @@ PHP_FUNCTION(openssl_private_decrypt)
(int)padding); (int)padding);
if (cryptedlen != -1) { if (cryptedlen != -1) {
cryptedbuf = zend_string_alloc(cryptedlen, 0); cryptedbuf = zend_string_alloc(cryptedlen, 0);
memcpy(cryptedbuf->val, crypttemp, cryptedlen); memcpy(ZSTR_VAL(cryptedbuf), crypttemp, cryptedlen);
successful = 1; successful = 1;
} }
break; break;
@ -4567,7 +4567,7 @@ PHP_FUNCTION(openssl_private_decrypt)
if (successful) { if (successful) {
zval_dtor(crypted); zval_dtor(crypted);
cryptedbuf->val[cryptedlen] = '\0'; ZSTR_VAL(cryptedbuf)[cryptedlen] = '\0';
ZVAL_NEW_STR(crypted, cryptedbuf); ZVAL_NEW_STR(crypted, cryptedbuf);
cryptedbuf = NULL; cryptedbuf = NULL;
RETVAL_TRUE; RETVAL_TRUE;
@ -4617,7 +4617,7 @@ PHP_FUNCTION(openssl_public_encrypt)
case EVP_PKEY_RSA2: case EVP_PKEY_RSA2:
successful = (RSA_public_encrypt((int)data_len, successful = (RSA_public_encrypt((int)data_len,
(unsigned char *)data, (unsigned char *)data,
(unsigned char *)cryptedbuf->val, (unsigned char *)ZSTR_VAL(cryptedbuf),
pkey->pkey.rsa, pkey->pkey.rsa,
(int)padding) == cryptedlen); (int)padding) == cryptedlen);
break; break;
@ -4628,7 +4628,7 @@ PHP_FUNCTION(openssl_public_encrypt)
if (successful) { if (successful) {
zval_dtor(crypted); zval_dtor(crypted);
cryptedbuf->val[cryptedlen] = '\0'; ZSTR_VAL(cryptedbuf)[cryptedlen] = '\0';
ZVAL_NEW_STR(crypted, cryptedbuf); ZVAL_NEW_STR(crypted, cryptedbuf);
cryptedbuf = NULL; cryptedbuf = NULL;
RETVAL_TRUE; RETVAL_TRUE;
@ -4684,7 +4684,7 @@ PHP_FUNCTION(openssl_public_decrypt)
(int)padding); (int)padding);
if (cryptedlen != -1) { if (cryptedlen != -1) {
cryptedbuf = zend_string_alloc(cryptedlen, 0); cryptedbuf = zend_string_alloc(cryptedlen, 0);
memcpy(cryptedbuf->val, crypttemp, cryptedlen); memcpy(ZSTR_VAL(cryptedbuf), crypttemp, cryptedlen);
successful = 1; successful = 1;
} }
break; break;
@ -4698,7 +4698,7 @@ PHP_FUNCTION(openssl_public_decrypt)
if (successful) { if (successful) {
zval_dtor(crypted); zval_dtor(crypted);
cryptedbuf->val[cryptedlen] = '\0'; ZSTR_VAL(cryptedbuf)[cryptedlen] = '\0';
ZVAL_NEW_STR(crypted, cryptedbuf); ZVAL_NEW_STR(crypted, cryptedbuf);
cryptedbuf = NULL; cryptedbuf = NULL;
RETVAL_TRUE; RETVAL_TRUE;
@ -4779,10 +4779,10 @@ PHP_FUNCTION(openssl_sign)
EVP_SignInit(&md_ctx, mdtype); EVP_SignInit(&md_ctx, mdtype);
EVP_SignUpdate(&md_ctx, data, data_len); 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); zval_dtor(signature);
sigbuf->val[siglen] = '\0'; ZSTR_VAL(sigbuf)[siglen] = '\0';
sigbuf->len = siglen; ZSTR_LEN(sigbuf) = siglen;
ZVAL_NEW_STR(signature, sigbuf); ZVAL_NEW_STR(signature, sigbuf);
RETVAL_TRUE; RETVAL_TRUE;
} else { } else {
@ -5122,17 +5122,17 @@ PHP_FUNCTION(openssl_digest)
EVP_DigestInit(&md_ctx, mdtype); EVP_DigestInit(&md_ctx, mdtype);
EVP_DigestUpdate(&md_ctx, (unsigned char *)data, data_len); 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) { if (raw_output) {
sigbuf->val[siglen] = '\0'; ZSTR_VAL(sigbuf)[siglen] = '\0';
sigbuf->len = siglen; ZSTR_LEN(sigbuf) = siglen;
RETVAL_STR(sigbuf); RETVAL_STR(sigbuf);
} else { } else {
int digest_str_len = siglen * 2; int digest_str_len = siglen * 2;
zend_string *digest_str = zend_string_alloc(digest_str_len, 0); zend_string *digest_str = zend_string_alloc(digest_str_len, 0);
make_digest_ex(digest_str->val, (unsigned char*)sigbuf->val, siglen); make_digest_ex(ZSTR_VAL(digest_str), (unsigned char*)ZSTR_VAL(sigbuf), siglen);
digest_str->val[digest_str_len] = '\0'; ZSTR_VAL(digest_str)[digest_str_len] = '\0';
zend_string_release(sigbuf); zend_string_release(sigbuf);
RETVAL_STR(digest_str); RETVAL_STR(digest_str);
} }
@ -5230,19 +5230,19 @@ PHP_FUNCTION(openssl_encrypt)
EVP_CIPHER_CTX_set_padding(&cipher_ctx, 0); EVP_CIPHER_CTX_set_padding(&cipher_ctx, 0);
} }
if (data_len > 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; 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; outlen += i;
if (options & OPENSSL_RAW_DATA) { if (options & OPENSSL_RAW_DATA) {
outbuf->val[outlen] = '\0'; ZSTR_VAL(outbuf)[outlen] = '\0';
outbuf->len = outlen; ZSTR_LEN(outbuf) = outlen;
RETVAL_STR(outbuf); RETVAL_STR(outbuf);
} else { } else {
zend_string *base64_str; 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); zend_string_release(outbuf);
RETVAL_STR(base64_str); RETVAL_STR(base64_str);
} }
@ -5299,8 +5299,8 @@ PHP_FUNCTION(openssl_decrypt)
php_error_docref(NULL, E_WARNING, "Failed to base64 decode the input"); php_error_docref(NULL, E_WARNING, "Failed to base64 decode the input");
RETURN_FALSE; RETURN_FALSE;
} }
data_len = base64_str->len; data_len = ZSTR_LEN(base64_str);
data = base64_str->val; data = ZSTR_VAL(base64_str);
} }
keylen = EVP_CIPHER_key_length(cipher_type); keylen = EVP_CIPHER_key_length(cipher_type);
@ -5325,12 +5325,12 @@ PHP_FUNCTION(openssl_decrypt)
if (options & OPENSSL_ZERO_PADDING) { if (options & OPENSSL_ZERO_PADDING) {
EVP_CIPHER_CTX_set_padding(&cipher_ctx, 0); 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; 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; outlen += i;
outbuf->val[outlen] = '\0'; ZSTR_VAL(outbuf)[outlen] = '\0';
outbuf->len = outlen; ZSTR_LEN(outbuf) = outlen;
RETVAL_STR(outbuf); RETVAL_STR(outbuf);
} else { } else {
zend_string_release(outbuf); 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); pub = BN_bin2bn((unsigned char*)pub_str, (int)pub_len, NULL);
data = zend_string_alloc(DH_size(pkey->pkey.dh), 0); 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) { if (len >= 0) {
data->len = len; ZSTR_LEN(data) = len;
data->val[len] = 0; ZSTR_VAL(data)[len] = 0;
RETVAL_STR(data); RETVAL_STR(data);
} else { } else {
zend_string_release(data); zend_string_release(data);
@ -5451,7 +5451,7 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
RETURN_FALSE; RETURN_FALSE;
} }
#else #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); zend_string_release(buffer);
if (zstrong_result_returned) { if (zstrong_result_returned) {
ZVAL_FALSE(zstrong_result_returned); ZVAL_FALSE(zstrong_result_returned);
@ -5460,7 +5460,7 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
} }
#endif #endif
buffer->val[buffer_length] = 0; ZSTR_VAL(buffer)[buffer_length] = 0;
RETVAL_STR(buffer); RETVAL_STR(buffer);
if (zstrong_result_returned) { if (zstrong_result_returned) {

View file

@ -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", "SSL operation failed with code %d. %s%s",
err, err,
ebuf.s ? "OpenSSL Error messages:\n" : "", ebuf.s ? "OpenSSL Error messages:\n" : "",
ebuf.s ? ebuf.s->val : ""); ebuf.s ? ZSTR_VAL(ebuf.s) : "");
if (ebuf.s) { if (ebuf.s) {
smart_str_free(&ebuf); 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); fingerprint = php_openssl_x509_fingerprint(peer, method, 0);
if (fingerprint) { if (fingerprint) {
result = strcasecmp(expected, fingerprint->val); result = strcasecmp(expected, ZSTR_VAL(fingerprint));
zend_string_release(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"); php_error_docref(NULL, E_WARNING, "Invalid peer_fingerprint array; [algo => fingerprint] form required");
return 0; 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; return 0;
} }
} ZEND_HASH_FOREACH_END(); } 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); SSL_CTX_free(ctx);
return FAILURE; return FAILURE;
} else { } 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; sslsock->sni_certs[i].ctx = ctx;
++i; ++i;
} }

View file

@ -908,9 +908,9 @@ PHP_FUNCTION(pcntl_exec)
convert_to_string_ex(element); convert_to_string_ex(element);
/* Length of element + equal sign + length of key + null */ /* 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); *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, "=", pair_length);
strlcat(*pair, Z_STRVAL_P(element), 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)) { if (!zend_is_callable(handle, 0, &func_name)) {
PCNTL_G(last_error) = EINVAL; 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); zend_string_release(func_name);
RETURN_FALSE; RETURN_FALSE;
} }

View file

@ -281,14 +281,14 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
#if HAVE_SETLOCALE #if HAVE_SETLOCALE
if (pce->locale == BG(locale_string) || if (pce->locale == BG(locale_string) ||
(pce->locale && BG(locale_string) && (pce->locale && BG(locale_string) &&
pce->locale->len == BG(locale_string)->len && ZSTR_LEN(pce->locale) == ZSTR_LEN(BG(locale_string)) &&
!memcmp(pce->locale->val, BG(locale_string)->val, pce->locale->len)) || !memcmp(ZSTR_VAL(pce->locale), ZSTR_VAL(BG(locale_string)), ZSTR_LEN(pce->locale))) ||
(!pce->locale && (!pce->locale &&
BG(locale_string)->len == 1 && ZSTR_LEN(BG(locale_string)) == 1 &&
BG(locale_string)->val[0] == 'C') || ZSTR_VAL(BG(locale_string))[0] == 'C') ||
(!BG(locale_string) && (!BG(locale_string) &&
pce->locale->len == 1 && ZSTR_LEN(pce->locale) == 1 &&
pce->locale->val[0] == 'C')) { ZSTR_VAL(pce->locale)[0] == 'C')) {
return pce; return pce;
} }
#else #else
@ -296,14 +296,14 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
#endif #endif
} }
p = regex->val; p = ZSTR_VAL(regex);
/* Parse through the leading whitespace, and display a warning if we /* Parse through the leading whitespace, and display a warning if we
get to the end without encountering a delimiter. */ get to the end without encountering a delimiter. */
while (isspace((int)*(unsigned char *)p)) p++; while (isspace((int)*(unsigned char *)p)) p++;
if (*p == 0) { if (*p == 0) {
php_error_docref(NULL, E_WARNING, 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; return NULL;
} }
@ -350,7 +350,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
} }
if (*pp == 0) { 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"); php_error_docref(NULL,E_WARNING, "Null byte in regex");
} else if (start_delimiter == end_delimiter) { } else if (start_delimiter == end_delimiter) {
php_error_docref(NULL,E_WARNING, "No ending delimiter '%c' found", 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 /* Parse through the options, setting appropriate flags. Display
a warning if we encounter an unknown modifier. */ a warning if we encounter an unknown modifier. */
while (pp < regex->val + regex->len) { while (pp < ZSTR_VAL(regex) + ZSTR_LEN(regex)) {
switch (*pp++) { switch (*pp++) {
/* Perl compatible options */ /* Perl compatible options */
case 'i': coptions |= PCRE_CASELESS; break; 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 HAVE_SETLOCALE
if (BG(locale_string) && 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(); tables = pcre_maketables();
} }
#endif #endif
@ -477,7 +477,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
new_entry.locale = BG(locale_string) ? new_entry.locale = BG(locale_string) ?
((GC_FLAGS(BG(locale_string)) & IS_STR_PERSISTENT) ? ((GC_FLAGS(BG(locale_string)) & IS_STR_PERSISTENT) ?
zend_string_copy(BG(locale_string)) : 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; NULL;
new_entry.tables = tables; new_entry.tables = tables;
#endif #endif
@ -504,9 +504,9 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
* See bug #63180 * See bug #63180
*/ */
if (!ZSTR_IS_INTERNED(regex) || !(GC_FLAGS(regex) & IS_STR_PERMANENT)) { 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() */ GC_REFCOUNT(str) = 0; /* will be incremented by zend_hash_update_mem() */
str->h = regex->h; ZSTR_H(str) = ZSTR_H(regex);
regex = str; regex = str;
} }
@ -606,7 +606,7 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* {{{ *
} }
pce->refcount++; 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); global, ZEND_NUM_ARGS() >= 4, flags, start_offset);
pce->refcount--; 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 */ /* 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); result_len += (int)(match-piece);
/* copy replacement and backrefs */ /* copy replacement and backrefs */
walkbuf = result->val + result_len; walkbuf = ZSTR_VAL(result) + result_len;
walk = replace; walk = replace;
walk_last = 0; walk_last = 0;
@ -1232,12 +1232,12 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su
} }
*walkbuf = '\0'; *walkbuf = '\0';
/* increment the result length by how much we've added to the string */ /* 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 { } else {
/* Use custom function to get replacement string and its length. */ /* Use custom function to get replacement string and its length. */
eval_result = preg_do_repl_func(replace_val, subject, offsets, subpat_names, count, mark); eval_result = preg_do_repl_func(replace_val, subject, offsets, subpat_names, count, mark);
ZEND_ASSERT(eval_result); ZEND_ASSERT(eval_result);
new_len += (int)eval_result->len; new_len += (int)ZSTR_LEN(eval_result);
if (new_len >= alloc_len) { if (new_len >= alloc_len) {
alloc_len = alloc_len + 2 * new_len; alloc_len = alloc_len + 2 * new_len;
if (result == NULL) { 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 */ /* 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); result_len += (int)(match-piece);
/* copy replacement and backrefs */ /* 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. */ /* If using custom function, copy result to the buffer and clean up. */
memcpy(walkbuf, eval_result->val, eval_result->len); memcpy(walkbuf, ZSTR_VAL(eval_result), ZSTR_LEN(eval_result));
result_len += (int)eval_result->len; result_len += (int)ZSTR_LEN(eval_result);
zend_string_release(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[0] = start_offset;
offsets[1] = start_offset + unit_len; 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; result_len += unit_len;
} else { } else {
if (!result && subject_str) { 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 */ /* 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_len += subject_len - start_offset;
result->val[result_len] = '\0'; ZSTR_VAL(result)[result_len] = '\0';
result->len = result_len; ZSTR_LEN(result) = result_len;
break; break;
} }
} else { } else {
@ -1379,8 +1379,8 @@ static zend_string *php_replace_in_subject(zval *regex, zval *replace, zval *sub
for further replacements. */ for further replacements. */
if ((result = php_pcre_replace(regex_str, if ((result = php_pcre_replace(regex_str,
subject_str, subject_str,
subject_str->val, ZSTR_VAL(subject_str),
(int)subject_str->len, (int)ZSTR_LEN(subject_str),
replace_value, replace_value,
is_callable_replace, is_callable_replace,
limit, limit,
@ -1400,8 +1400,8 @@ static zend_string *php_replace_in_subject(zval *regex, zval *replace, zval *sub
} else { } else {
result = php_pcre_replace(Z_STR_P(regex), result = php_pcre_replace(Z_STR_P(regex),
subject_str, subject_str,
subject_str->val, ZSTR_VAL(subject_str),
(int)subject_str->len, (int)ZSTR_LEN(subject_str),
replace, replace,
is_callable_replace, is_callable_replace,
limit, limit,
@ -1535,7 +1535,7 @@ static PHP_FUNCTION(preg_replace_callback)
#endif #endif
if (!zend_is_callable(replace, 0, &callback_name)) { 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); zend_string_release(callback_name);
ZVAL_COPY(return_value, subject); ZVAL_COPY(return_value, subject);
return; return;
@ -1586,7 +1586,7 @@ static PHP_FUNCTION(preg_replace_callback_array)
} }
if (!zend_is_callable(replace, 0, &callback_name)) { 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); zend_string_release(callback_name);
zval_ptr_dtor(&regex); zval_ptr_dtor(&regex);
zval_ptr_dtor(return_value); zval_ptr_dtor(return_value);
@ -1692,7 +1692,7 @@ static PHP_FUNCTION(preg_split)
} }
pce->refcount++; 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--; pce->refcount--;
} }
/* }}} */ /* }}} */
@ -1922,7 +1922,7 @@ static PHP_FUNCTION(preg_quote)
out_str = zend_string_safe_alloc(4, in_str_len, 0, 0); out_str = zend_string_safe_alloc(4, in_str_len, 0, 0);
/* Go through the string and quote necessary characters */ /* 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; c = *p;
switch(c) { switch(c) {
case '.': case '.':
@ -1966,7 +1966,7 @@ static PHP_FUNCTION(preg_quote)
*q = '\0'; *q = '\0';
/* Reallocate string and return it */ /* 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); 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); zend_string *subject_str = zval_get_string(entry);
/* Perform the match */ /* Perform the match */
count = pcre_exec(pce->re, extra, subject_str->val, count = pcre_exec(pce->re, extra, ZSTR_VAL(subject_str),
(int)subject_str->len, 0, (int)ZSTR_LEN(subject_str), 0,
0, offsets, size_offsets); 0, offsets, size_offsets);
/* Check for too many substrings condition. */ /* Check for too many substrings condition. */

View file

@ -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) { 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) { } else if (EG(exception) == NULL) {
zval ex; zval ex;
zend_class_entry *def_ex = php_pdo_get_exception_base(1), *pdo_ex = php_pdo_get_exception(); 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); pdo_dbh_object_t *dbh_obj = php_pdo_dbh_fetch_object(*object);
zend_string *lc_method_name; zend_string *lc_method_name;
lc_method_name = zend_string_init(method_name->val, method_name->len, 0); lc_method_name = zend_string_init(ZSTR_VAL(method_name), ZSTR_LEN(method_name), 0);
zend_str_tolower_copy(lc_method_name->val, method_name->val, method_name->len); 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) { if ((fbc = std_object_handlers.get_method(object, method_name, key)) == NULL) {
/* not a pre-defined method, nor a user-defined method; check /* not a pre-defined method, nor a user-defined method; check

View file

@ -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) { if (stmt->named_rewrite_template) {
/* magic/hack. /* 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 * it was named so that we fall into the
* named rewrite case below. Not too pretty, * named rewrite case below. Not too pretty,
* but it works. */ * but it works. */
@ -575,7 +575,7 @@ safe:
zend_string *buf; zend_string *buf;
buf = php_stream_copy_to_mem(stm, PHP_STREAM_COPY_ALL, 0); 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)) { param->param_type)) {
/* bork */ /* bork */
ret = -1; ret = -1;

View file

@ -217,7 +217,7 @@ safe:
zend_string *buf; zend_string *buf;
buf = php_stream_copy_to_mem(stm, PHP_STREAM_COPY_ALL, 0); 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)) { param->param_type)) {
/* bork */ /* bork */
ret = -1; ret = -1;

View file

@ -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) { 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++; position++;
continue; 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 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) { 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) { switch (stmt->dbh->desired_case) {
case PDO_CASE_UPPER: case PDO_CASE_UPPER:
@ -345,8 +345,8 @@ static int really_register_bound_param(struct pdo_bound_param_data *param, pdo_s
int i; int i;
for (i = 0; i < stmt->column_count; i++) { for (i = 0; i < stmt->column_count; i++) {
if (stmt->columns[i].name->len == param->name->len && if (ZSTR_LEN(stmt->columns[i].name) == ZSTR_LEN(param->name) &&
strncmp(stmt->columns[i].name->val, param->name->val, param->name->len + 1) == 0) { strncmp(ZSTR_VAL(stmt->columns[i].name), ZSTR_VAL(param->name), ZSTR_LEN(param->name) + 1) == 0) {
param->paramno = i; param->paramno = i;
break; 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 */ * then this will trigger, and we don't want that */
if (param->paramno == -1) { if (param->paramno == -1) {
char *tmp; 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); pdo_raise_impl_error(stmt->dbh, stmt, "HY000", tmp);
efree(tmp); efree(tmp);
} }
} }
if (param->name) { if (param->name) {
if (is_param && param->name->val[0] != ':') { if (is_param && ZSTR_VAL(param->name)[0] != ':') {
zend_string *temp = zend_string_alloc(param->name->len + 1, 0); zend_string *temp = zend_string_alloc(ZSTR_LEN(param->name) + 1, 0);
temp->val[0] = ':'; ZSTR_VAL(temp)[0] = ':';
memmove(temp->val + 1, param->name->val, param->name->len + 1); memmove(ZSTR_VAL(temp) + 1, ZSTR_VAL(param->name), ZSTR_LEN(param->name) + 1);
param->name = temp; param->name = temp;
} else { } 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_string *key = NULL;
ZEND_HASH_FOREACH_KEY_PTR(stmt->bound_params, num, key, param) { ZEND_HASH_FOREACH_KEY_PTR(stmt->bound_params, num, key, param) {
if (key) { 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 { } else {
php_stream_printf(out, "Key: Position #%pd:\n", num); 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", 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->paramno, param->name? ZSTR_LEN(param->name) : 0, param->name? ZSTR_LEN(param->name) : 0,
param->name ? param->name->val : "", param->name ? ZSTR_VAL(param->name) : "",
param->is_param, param->is_param,
param->param_type); 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_string *lc_method_name;
zend_object *object = *object_pp; zend_object *object = *object_pp;
lc_method_name = zend_string_alloc(method_name->len, 0); lc_method_name = zend_string_alloc(ZSTR_LEN(method_name), 0);
zend_str_tolower_copy(lc_method_name->val, method_name->val, method_name->len); 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) { if ((fbc = zend_hash_find_ptr(&object->ce->function_table, lc_method_name)) == NULL) {
pdo_stmt_t *stmt = php_pdo_stmt_fetch_object(object); 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 /* TODO: replace this with a hash of available column names to column
* numbers */ * numbers */
for (colno = 0; colno < stmt->column_count; colno++) { for (colno = 0; colno < stmt->column_count; colno++) {
if (stmt->columns[colno].name->len == Z_STRLEN_P(member) && if (ZSTR_LEN(stmt->columns[colno].name) == Z_STRLEN_P(member) &&
strncmp(stmt->columns[colno].name->val, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) { strncmp(ZSTR_VAL(stmt->columns[colno].name), Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) {
fetch_value(stmt, rv, colno, NULL); fetch_value(stmt, rv, colno, NULL);
//??? //???
//Z_SET_REFCOUNT_P(rv, 0); //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 /* TODO: replace this with a hash of available column names to column
* numbers */ * numbers */
for (colno = 0; colno < stmt->column_count; colno++) { for (colno = 0; colno < stmt->column_count; colno++) {
if (stmt->columns[colno].name->len == Z_STRLEN_P(member) && if (ZSTR_LEN(stmt->columns[colno].name) == Z_STRLEN_P(member) &&
strncmp(stmt->columns[colno].name->val, Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) { strncmp(ZSTR_VAL(stmt->columns[colno].name), Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) {
return 1; return 1;
} }
} }
@ -2621,8 +2621,8 @@ static union _zend_function *row_method_get(
zend_function *fbc; zend_function *fbc;
zend_string *lc_method_name; zend_string *lc_method_name;
lc_method_name = zend_string_alloc(method_name->len, 0); lc_method_name = zend_string_alloc(ZSTR_LEN(method_name), 0);
zend_str_tolower_copy(lc_method_name->val, method_name->val, method_name->len); 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) { if ((fbc = zend_hash_find_ptr(&pdo_row_ce->function_table, lc_method_name)) == NULL) {
zend_string_release(lc_method_name); zend_string_release(lc_method_name);

View file

@ -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 */ /* support both full connection string & connection string + login and/or password */
if (tmp_user && tmp_pass) { 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) { } 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) { } 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 { } else {
spprintf(&conn_str, 0, "%s connect_timeout=%pd", (char *) dbh->data_source, connect_timeout); spprintf(&conn_str, 0, "%s connect_timeout=%pd", (char *) dbh->data_source, connect_timeout);
} }

View file

@ -255,8 +255,8 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
case PDO_PARAM_EVT_NORMALIZE: case PDO_PARAM_EVT_NORMALIZE:
/* decode name from $1, $2 into 0, 1 etc. */ /* decode name from $1, $2 into 0, 1 etc. */
if (param->name) { if (param->name) {
if (param->name->val[0] == '$') { if (ZSTR_VAL(param->name)[0] == '$') {
ZEND_ATOL(param->paramno, param->name->val + 1); ZEND_ATOL(param->paramno, ZSTR_VAL(param->name) + 1);
} else { } else {
/* resolve parameter name to rewritten name */ /* resolve parameter name to rewritten name */
char *namevar; 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); ZEND_ATOL(param->paramno, namevar + 1);
param->paramno--; param->paramno--;
} else { } 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; return 0;
} }
} }

View file

@ -533,7 +533,7 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
PDO_CONSTRUCT_CHECK; PDO_CONSTRUCT_CHECK;
if (!zend_is_callable(callback, 0, &cbname)) { 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); zend_string_release(cbname);
RETURN_FALSE; RETURN_FALSE;
} }
@ -603,13 +603,13 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
PDO_CONSTRUCT_CHECK; PDO_CONSTRUCT_CHECK;
if (!zend_is_callable(step_callback, 0, &cbname)) { 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); zend_string_release(cbname);
RETURN_FALSE; RETURN_FALSE;
} }
zend_string_release(cbname); zend_string_release(cbname);
if (!zend_is_callable(fini_callback, 0, &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); zend_string_release(cbname);
RETURN_FALSE; RETURN_FALSE;
} }
@ -663,7 +663,7 @@ static PHP_METHOD(SQLite, sqliteCreateCollation)
PDO_CONSTRUCT_CHECK; PDO_CONSTRUCT_CHECK;
if (!zend_is_callable(callback, 0, &cbname)) { 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); zend_string_release(cbname);
RETURN_FALSE; RETURN_FALSE;
} }

View file

@ -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->is_param) {
if (param->paramno == -1) { 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)) { switch (PDO_PARAM_TYPE(param->param_type)) {

View file

@ -1364,7 +1364,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
/* hash it up */ /* hash it up */
new_le.type = le_plink; new_le.type = le_plink;
new_le.ptr = pgsql; 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; goto err;
} }
PGG(num_links)++; PGG(num_links)++;
@ -2368,7 +2368,7 @@ static char *get_field_name(PGconn *pgsql, Oid oid, HashTable *list)
continue; continue;
} }
str.s->len = 0; ZSTR_LEN(str.s) = 0;
smart_str_appends(&str, "pgsql_oid_"); smart_str_appends(&str, "pgsql_oid_");
smart_str_appends(&str, tmp_oid); smart_str_appends(&str, tmp_oid);
smart_str_0(&str); smart_str_0(&str);
@ -2453,7 +2453,7 @@ PHP_FUNCTION(pg_field_table)
smart_str_append_unsigned(&querystr, oid); smart_str_append_unsigned(&querystr, oid);
smart_str_0(&querystr); 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) { if (tmp_res) {
PQclear(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); ce = zend_fetch_class(class_name, ZEND_FETCH_CLASS_AUTO);
} }
if (!ce) { 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; return;
} }
result_type = PGSQL_ASSOC; result_type = PGSQL_ASSOC;
@ -3507,13 +3507,13 @@ PHP_FUNCTION(pg_lo_read)
} }
buf = zend_string_alloc(buf_len, 0); 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); zend_string_free(buf);
RETURN_FALSE; RETURN_FALSE;
} }
buf->len = nbytes; ZSTR_LEN(buf) = nbytes;
buf->val[buf->len] = '\0'; ZSTR_VAL(buf)[ZSTR_LEN(buf)] = '\0';
RETURN_NEW_STR(buf); RETURN_NEW_STR(buf);
} }
/* }}} */ /* }}} */
@ -4348,20 +4348,20 @@ PHP_FUNCTION(pg_escape_string)
break; break;
} }
to = zend_string_alloc(from->len * 2, 0); to = zend_string_alloc(ZSTR_LEN(from) * 2, 0);
#ifdef HAVE_PQESCAPE_CONN #ifdef HAVE_PQESCAPE_CONN
if (link) { if (link) {
if ((pgsql = (PGconn *)zend_fetch_resource2(link, "PostgreSQL link", le_link, le_plink)) == NULL) { if ((pgsql = (PGconn *)zend_fetch_resource2(link, "PostgreSQL link", le_link, le_plink)) == NULL) {
RETURN_FALSE; 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 } else
#endif #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); 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); smart_str_0(&querystr);
efree(src); 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) { 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); php_error_docref(NULL, E_WARNING, "Table '%s' doesn't exists", table_name);
smart_str_free(&querystr); 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 */ \ /* 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) { \ 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; \ 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) { 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; err = 1;
} }
if (!err && (type = zend_hash_str_find(Z_ARRVAL_P(def), "type", sizeof("type") - 1)) == NULL) { 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); ZVAL_STRINGL(&new_val, "'f'", sizeof("'f'")-1);
} }
else { 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; 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(); PGSQL_CONV_CHECK_IGNORE();
if (err) { 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; break;
@ -5967,7 +5967,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
} }
PGSQL_CONV_CHECK_IGNORE(); PGSQL_CONV_CHECK_IGNORE();
if (err) { 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; break;
@ -6013,7 +6013,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
} }
PGSQL_CONV_CHECK_IGNORE(); PGSQL_CONV_CHECK_IGNORE();
if (err) { 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; break;
@ -6050,8 +6050,8 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
/* PostgreSQL ignores \0 */ /* PostgreSQL ignores \0 */
str = zend_string_alloc(Z_STRLEN_P(val) * 2, 0); str = zend_string_alloc(Z_STRLEN_P(val) * 2, 0);
/* better to use PGSQLescapeLiteral since PGescapeStringConn does not handle special \ */ /* 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); ZSTR_LEN(str) = PQescapeStringConn(pg_link, ZSTR_VAL(str), Z_STRVAL_P(val), Z_STRLEN_P(val), NULL);
str = zend_string_truncate(str, str->len, 0); str = zend_string_truncate(str, ZSTR_LEN(str), 0);
ZVAL_NEW_STR(&new_val, str); ZVAL_NEW_STR(&new_val, str);
php_pgsql_add_quotes(&new_val, 1); 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(); PGSQL_CONV_CHECK_IGNORE();
if (err) { 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; break;
@ -6118,7 +6118,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
} }
PGSQL_CONV_CHECK_IGNORE(); PGSQL_CONV_CHECK_IGNORE();
if (err) { 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; break;
@ -6150,7 +6150,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
} }
PGSQL_CONV_CHECK_IGNORE(); PGSQL_CONV_CHECK_IGNORE();
if (err) { 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; break;
@ -6183,7 +6183,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
} }
PGSQL_CONV_CHECK_IGNORE(); PGSQL_CONV_CHECK_IGNORE();
if (err) { 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; break;
@ -6214,7 +6214,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
} }
PGSQL_CONV_CHECK_IGNORE(); PGSQL_CONV_CHECK_IGNORE();
if (err) { 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; break;
@ -6245,7 +6245,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
} }
PGSQL_CONV_CHECK_IGNORE(); PGSQL_CONV_CHECK_IGNORE();
if (err) { 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; break;
@ -6324,7 +6324,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
} }
PGSQL_CONV_CHECK_IGNORE(); PGSQL_CONV_CHECK_IGNORE();
if (err) { 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; break;
#ifdef HAVE_PQESCAPE #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(); PGSQL_CONV_CHECK_IGNORE();
if (err) { 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; break;
@ -6403,13 +6403,13 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
} }
PGSQL_CONV_CHECK_IGNORE(); PGSQL_CONV_CHECK_IGNORE();
if (err) { 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; break;
default: default:
/* should not happen */ /* 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; err = 1;
break; break;
} /* switch */ } /* switch */
@ -6422,10 +6422,10 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con
if (!skip_field) { if (!skip_field) {
char *escaped; 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); zend_hash_update(Z_ARRVAL_P(result), field, &new_val);
} else { } 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); add_assoc_zval(result, escaped, &new_val);
PGSQLfree(escaped); 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) /* {{{ */ static int do_exec(smart_str *querystr, int expect, PGconn *pg_link, zend_ulong opt) /* {{{ */
{ {
if (opt & PGSQL_DML_ASYNC) { if (opt & PGSQL_DML_ASYNC) {
if (PQsendQuery(pg_link, querystr->s->val)) { if (PQsendQuery(pg_link, ZSTR_VAL(querystr->s))) {
return 0; return 0;
} }
} }
else { else {
PGresult *pg_result; 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) { if (PQresultStatus(pg_result) == expect) {
PQclear(pg_result); PQclear(pg_result);
return 0; return 0;
@ -6585,15 +6585,15 @@ PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var
goto cleanup; goto cleanup;
} }
if (opt & PGSQL_DML_ESCAPE) { 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); smart_str_appends(&querystr, tmp);
PGSQLfree(tmp); PGSQLfree(tmp);
} else { } else {
smart_str_appendl(&querystr, fld->val, fld->len); smart_str_appendl(&querystr, ZSTR_VAL(fld), ZSTR_LEN(fld));
} }
smart_str_appendc(&querystr, ','); smart_str_appendc(&querystr, ',');
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
querystr.s->len--; ZSTR_LEN(querystr.s)--;
smart_str_appends(&querystr, ") VALUES ("); smart_str_appends(&querystr, ") VALUES (");
/* make values string */ /* 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, ','); smart_str_appendc(&querystr, ',');
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
/* Remove the trailing "," */ /* Remove the trailing "," */
querystr.s->len--; ZSTR_LEN(querystr.s)--;
smart_str_appends(&querystr, ");"); smart_str_appends(&querystr, ");");
no_values: no_values:
@ -6696,11 +6696,11 @@ PHP_FUNCTION(pg_insert)
if (php_pgsql_insert(pg_link, table, values, option|PGSQL_DML_STRING, &sql) == FAILURE) { if (php_pgsql_insert(pg_link, table, values, option|PGSQL_DML_STRING, &sql) == FAILURE) {
RETURN_FALSE; 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) { if ((PGG(auto_reset_persistent) & 2) && PQstatus(pg_link) != CONNECTION_OK) {
PQclear(pg_result); PQclear(pg_result);
PQreset(pg_link); PQreset(pg_link);
pg_result = PQexec(pg_link, sql->val); pg_result = PQexec(pg_link, ZSTR_VAL(sql));
} }
efree(sql); efree(sql);
@ -6758,11 +6758,11 @@ static inline int build_assignment_string(PGconn *pg_link, smart_str *querystr,
return -1; return -1;
} }
if (opt & PGSQL_DML_ESCAPE) { 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); smart_str_appends(querystr, tmp);
PGSQLfree(tmp); PGSQLfree(tmp);
} else { } 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")))) { 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 "); 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); smart_str_appendl(querystr, pad, pad_len);
} ZEND_HASH_FOREACH_END(); } ZEND_HASH_FOREACH_END();
if (querystr->s) { if (querystr->s) {
querystr->s->len -= pad_len; ZSTR_LEN(querystr->s) -= pad_len;
} }
return 0; 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_appendc(&querystr, ';');
smart_str_0(&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) { if (PQresultStatus(pg_result) == PGRES_TUPLES_OK) {
ret = php_pgsql_result2array(pg_result, ret_array); ret = php_pgsql_result2array(pg_result, ret_array);
} else { } 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); PQclear(pg_result);

View file

@ -102,14 +102,14 @@ static size_t phar_dir_read(php_stream *stream, char *buf, size_t count) /* {{{
} }
zend_hash_move_forward(data); 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; return 0;
} }
memset(buf, 0, sizeof(php_stream_dirent)); 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'; ((php_stream_dirent *) buf)->d_name[to_read + 1] = '\0';
return sizeof(php_stream_dirent); return sizeof(php_stream_dirent);
@ -160,7 +160,7 @@ static int phar_compare_dir_name(const void *a, const void *b) /* {{{ */
f = (Bucket *) a; f = (Bucket *) a;
s = (Bucket *) b; 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) { if (result < 0) {
return -1; return -1;
@ -203,9 +203,9 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest) /* {{{ */
break; break;
} }
keylen = str_key->len; keylen = ZSTR_LEN(str_key);
if (keylen <= (uint)dirlen) { 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)) { if (SUCCESS != zend_hash_move_forward(manifest)) {
break; break;
} }
@ -215,7 +215,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest) /* {{{ */
if (*dir == '/') { if (*dir == '/') {
/* root directory */ /* 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 */ /* do not add any magic entries to this directory */
if (SUCCESS != zend_hash_move_forward(manifest)) { if (SUCCESS != zend_hash_move_forward(manifest)) {
break; break;
@ -223,28 +223,28 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest) /* {{{ */
continue; 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 */ /* the entry has a path separator and is a subdirectory */
entry = (char *) safe_emalloc(found - str_key->val, 1, 1); entry = (char *) safe_emalloc(found - ZSTR_VAL(str_key), 1, 1);
memcpy(entry, str_key->val, found - str_key->val); memcpy(entry, ZSTR_VAL(str_key), found - ZSTR_VAL(str_key));
keylen = found - str_key->val; keylen = found - ZSTR_VAL(str_key);
entry[keylen] = '\0'; entry[keylen] = '\0';
} else { } else {
entry = (char *) safe_emalloc(keylen, 1, 1); entry = (char *) safe_emalloc(keylen, 1, 1);
memcpy(entry, str_key->val, keylen); memcpy(entry, ZSTR_VAL(str_key), keylen);
entry[keylen] = '\0'; entry[keylen] = '\0';
} }
goto PHAR_ADD_ENTRY; goto PHAR_ADD_ENTRY;
} else { } else {
if (0 != memcmp(str_key->val, dir, dirlen)) { if (0 != memcmp(ZSTR_VAL(str_key), dir, dirlen)) {
/* entry in directory not found */ /* entry in directory not found */
if (SUCCESS != zend_hash_move_forward(manifest)) { if (SUCCESS != zend_hash_move_forward(manifest)) {
break; break;
} }
continue; continue;
} else { } else {
if (str_key->val[dirlen] != '/') { if (ZSTR_VAL(str_key)[dirlen] != '/') {
if (SUCCESS != zend_hash_move_forward(manifest)) { if (SUCCESS != zend_hash_move_forward(manifest)) {
break; 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 */ save += dirlen + 1; /* seek to just past the path separator */
if (NULL != (found = (char *) memchr(save, '/', keylen - dirlen - 1))) { 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)) { while (FAILURE != zend_hash_has_more_elements(&phar->manifest)) {
if (HASH_KEY_NON_EXISTENT != if (HASH_KEY_NON_EXISTENT !=
zend_hash_get_current_key(&phar->manifest, &str_key, &unused)) { 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 */ /* directory found */
internal_file = estrndup(internal_file, internal_file = estrndup(internal_file,
i_len); 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); HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&phar->manifest, &str_key, &unused);
zend_hash_move_forward(&phar->manifest) zend_hash_move_forward(&phar->manifest)
) { ) {
if (str_key->len > path_len && if (ZSTR_LEN(str_key) > path_len &&
memcmp(str_key->val, resource->path+1, path_len) == 0 && memcmp(ZSTR_VAL(str_key), resource->path+1, path_len) == 0 &&
IS_SLASH(str_key->val[path_len])) { IS_SLASH(ZSTR_VAL(str_key)[path_len])) {
php_stream_wrapper_log_error(wrapper, options, "phar error: Directory not empty"); php_stream_wrapper_log_error(wrapper, options, "phar error: Directory not empty");
if (entry->is_temp_dir) { if (entry->is_temp_dir) {
efree(entry->filename); 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); HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&phar->virtual_dirs, &str_key, &unused);
zend_hash_move_forward(&phar->virtual_dirs)) { zend_hash_move_forward(&phar->virtual_dirs)) {
if (str_key->len > path_len && if (ZSTR_LEN(str_key) > path_len &&
memcmp(str_key->val, resource->path+1, path_len) == 0 && memcmp(ZSTR_VAL(str_key), resource->path+1, path_len) == 0 &&
IS_SLASH(str_key->val[path_len])) { IS_SLASH(ZSTR_VAL(str_key)[path_len])) {
php_stream_wrapper_log_error(wrapper, options, "phar error: Directory not empty"); php_stream_wrapper_log_error(wrapper, options, "phar error: Directory not empty");
if (entry->is_temp_dir) { if (entry->is_temp_dir) {
efree(entry->filename); efree(entry->filename);

View file

@ -150,7 +150,7 @@ PHAR_FUNC(phar_file_get_contents) /* {{{ */
} }
if (use_include_path) { if (use_include_path) {
if ((entry_str = phar_find_in_include_path(entry, entry_len, NULL))) { if ((entry_str = phar_find_in_include_path(entry, entry_len, NULL))) {
name = entry_str->val; name = ZSTR_VAL(entry_str);
goto phar_it; goto phar_it;
} else { } else {
/* this file is not in the phar, use the original path */ /* this file is not in the phar, use the original path */
@ -207,7 +207,7 @@ phar_it:
/* uses mmap if possible */ /* uses mmap if possible */
contents = php_stream_copy_to_mem(stream, maxlen, 0); contents = php_stream_copy_to_mem(stream, maxlen, 0);
if (contents && contents->len > 0) { if (contents && ZSTR_LEN(contents) > 0) {
RETVAL_STR(contents); RETVAL_STR(contents);
} else if (contents) { } else if (contents) {
zend_string_release(contents); zend_string_release(contents);
@ -278,7 +278,7 @@ PHAR_FUNC(phar_readfile) /* {{{ */
efree(arch); efree(arch);
goto skip_phar; goto skip_phar;
} else { } else {
name = entry_str->val; name = ZSTR_VAL(entry_str);
} }
} else { } else {
entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1); entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1);
@ -379,7 +379,7 @@ PHAR_FUNC(phar_fopen) /* {{{ */
efree(arch); efree(arch);
goto skip_phar; goto skip_phar;
} else { } else {
name = entry_str->val; name = ZSTR_VAL(entry_str);
} }
} else { } else {
entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1); entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1);

View file

@ -50,28 +50,28 @@ ZEND_INI_MH(phar_ini_modify_handler) /* {{{ */
{ {
zend_bool old, ini; 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); old = PHAR_G(readonly_orig);
} else { } else {
old = PHAR_G(require_hash_orig); 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; 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; 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; ini = (zend_bool) 1;
} }
else { else {
ini = (zend_bool) atoi(new_value->val); ini = (zend_bool) atoi(ZSTR_VAL(new_value));
} }
/* do not allow unsetting in runtime */ /* do not allow unsetting in runtime */
if (stage == ZEND_INI_STAGE_STARTUP) { 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; PHAR_G(readonly_orig) = ini;
} else { } else {
PHAR_G(require_hash_orig) = ini; PHAR_G(require_hash_orig) = ini;
@ -80,7 +80,7 @@ ZEND_INI_MH(phar_ini_modify_handler) /* {{{ */
return FAILURE; return FAILURE;
} }
if (entry->name->len == sizeof("phar.readonly")-1) { if (ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1) {
PHAR_G(readonly) = ini; PHAR_G(readonly) = ini;
if (PHAR_G(request_init) && PHAR_G(phar_fname_map.u.flags)) { 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); 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) /* {{{ */ 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) { if (stage == ZEND_INI_STAGE_STARTUP) {
phar_split_cache_list(); 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); fp = php_stream_open_wrapper(fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|0, &actual);
if (actual) { if (actual) {
fname = actual->val; fname = ZSTR_VAL(actual);
fname_len = actual->len; fname_len = ZSTR_LEN(actual);
} }
if (fp) { if (fp) {
@ -1514,8 +1514,8 @@ int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_l
} }
if (actual) { if (actual) {
fname = actual->val; fname = ZSTR_VAL(actual);
fname_len = actual->len; fname_len = ZSTR_LEN(actual);
} }
ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len, options, pphar, is_data, error); 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); 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))) 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; continue;
} }
if (!memcmp(filename, str_key->val, str_key->len) && ((uint)filename_len == str_key->len if (!memcmp(filename, ZSTR_VAL(str_key), ZSTR_LEN(str_key)) && ((uint)filename_len == ZSTR_LEN(str_key)
|| filename[str_key->len] == '/' || filename[str_key->len] == '\0')) { || 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))))) { if (NULL == (pphar = zend_hash_get_current_data_ptr(&(PHAR_G(phar_fname_map))))) {
break; break;
} }
*ext_str = filename + (str_key->len - pphar->ext_len); *ext_str = filename + (ZSTR_LEN(str_key) - pphar->ext_len);
goto woohoo; goto woohoo;
} }
} }
@ -1981,16 +1981,16 @@ woohoo:
HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&cached_phars, &str_key, &unused); HASH_KEY_NON_EXISTENT != zend_hash_get_current_key(&cached_phars, &str_key, &unused);
zend_hash_move_forward(&cached_phars) zend_hash_move_forward(&cached_phars)
) { ) {
if (str_key->len > (uint) filename_len) { if (ZSTR_LEN(str_key) > (uint) filename_len) {
continue; continue;
} }
if (!memcmp(filename, str_key->val, str_key->len) && ((uint)filename_len == str_key->len if (!memcmp(filename, ZSTR_VAL(str_key), ZSTR_LEN(str_key)) && ((uint)filename_len == ZSTR_LEN(str_key)
|| filename[str_key->len] == '/' || filename[str_key->len] == '\0')) { || filename[ZSTR_LEN(str_key)] == '/' || filename[ZSTR_LEN(str_key)] == '\0')) {
if (NULL == (pphar = zend_hash_get_current_data_ptr(&cached_phars))) { if (NULL == (pphar = zend_hash_get_current_data_ptr(&cached_phars))) {
break; break;
} }
*ext_str = filename + (str_key->len - pphar->ext_len); *ext_str = filename + (ZSTR_LEN(str_key) - pphar->ext_len);
goto woohoo; goto woohoo;
} }
} }
@ -2303,8 +2303,8 @@ int phar_open_executed_filename(char *alias, int alias_len, char **error) /* {{{
} }
if (actual) { if (actual) {
fname = actual->val; fname = ZSTR_VAL(actual);
fname_len = actual->len; fname_len = ZSTR_LEN(actual);
} }
ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len, REPORT_ERRORS, NULL, 0, error); 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; return EOF;
} }
free_user_stub = 1; free_user_stub = 1;
user_stub = suser_stub->val; user_stub = ZSTR_VAL(suser_stub);
len = suser_stub->len; len = ZSTR_LEN(suser_stub);
} else { } else {
free_user_stub = 0; 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 */ /* 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 */ /* compress and rehash as necessary */
if ((oldfile && !entry->is_modified) || entry->is_dir) { 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; 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); phar_set_32(manifest, manifest_len);
/* Hack - see bug #65028, add padding byte to the end of the manifest */ /* Hack - see bug #65028, add padding byte to the end of the manifest */
if(manifest[0] == '\r' || manifest[0] == '\n') { 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->alias_len = restore_alias_len;
phar_set_32(manifest, main_metadata_str.s ? main_metadata_str.s->len : 0); 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 ? main_metadata_str.s->len : 0) if (4 != php_stream_write(newfile, manifest, 4) || ((main_metadata_str.s ? ZSTR_LEN(main_metadata_str.s) : 0)
&& main_metadata_str.s->len != php_stream_write(newfile, main_metadata_str.s->val, main_metadata_str.s->len))) { && 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); smart_str_free(&main_metadata_str);
if (closeoldfile) { 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+8, entry->compressed_filesize);
phar_set_32(entry_buffer+12, entry->crc32); phar_set_32(entry_buffer+12, entry->crc32);
phar_set_32(entry_buffer+16, entry->flags); 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)) if (sizeof(entry_buffer) != php_stream_write(newfile, entry_buffer, sizeof(entry_buffer))
|| (entry->metadata_str.s && || (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) { if (closeoldfile) {
php_stream_close(oldfile); php_stream_close(oldfile);
} }

View file

@ -1423,7 +1423,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */
if (!value) { if (!value) {
/* failure in get_current_data */ /* 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; 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); php_stream_from_zval_no_verify(fp, value);
if (!fp) { 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; 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) { if (Z_TYPE(key) != IS_STRING) {
zval_dtor(&key); 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; return ZEND_HASH_APPLY_STOP;
} }
@ -1458,7 +1458,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */
save = str_key; save = str_key;
zval_dtor(&key); zval_dtor(&key);
} else { } 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; 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); spl_filesystem_object *intern = (spl_filesystem_object*)((char*)Z_OBJ_P(value) - Z_OBJ_P(value)->handlers->offset);
if (!base_len) { 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; return ZEND_HASH_APPLY_STOP;
} }
@ -1516,7 +1516,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */
} }
/* fall-through */ /* fall-through */
default: 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; return ZEND_HASH_APPLY_STOP;
} }
@ -1556,7 +1556,7 @@ phar_spl_fileinfo:
} }
} else { } 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) { if (save) {
efree(save); efree(save);
@ -1576,7 +1576,7 @@ phar_spl_fileinfo:
if (Z_TYPE(key) != IS_STRING) { if (Z_TYPE(key) != IS_STRING) {
zval_dtor(&key); 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; return ZEND_HASH_APPLY_STOP;
} }
@ -1586,13 +1586,13 @@ phar_spl_fileinfo:
save = str_key; save = str_key;
zval_dtor(&key); zval_dtor(&key);
} else { } 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; return ZEND_HASH_APPLY_STOP;
} }
} }
#if PHP_API_VERSION < 20100412 #if PHP_API_VERSION < 20100412
if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) { 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) { if (save) {
efree(save); efree(save);
@ -1607,7 +1607,7 @@ phar_spl_fileinfo:
#endif #endif
if (php_check_open_basedir(fname)) { 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) { if (save) {
efree(save); efree(save);
@ -1624,7 +1624,7 @@ phar_spl_fileinfo:
fp = php_stream_open_wrapper(fname, "rb", STREAM_MUST_SEEK|0, &opened); fp = php_stream_open_wrapper(fname, "rb", STREAM_MUST_SEEK|0, &opened);
if (!fp) { 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) { if (save) {
efree(save); efree(save);
@ -3916,7 +3916,7 @@ PHP_METHOD(Phar, getStub)
carry_on: carry_on:
buf = zend_string_alloc(len, 0); 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) { if (fp != phar_obj->archive->fp) {
php_stream_close(fp); php_stream_close(fp);
} }
@ -3935,8 +3935,8 @@ carry_on:
php_stream_close(fp); php_stream_close(fp);
} }
buf->val[len] = '\0'; ZSTR_VAL(buf)[len] = '\0';
buf->len = len; ZSTR_LEN(buf) = len;
RETVAL_STR(buf); RETVAL_STR(buf);
} }
/* }}}*/ /* }}}*/

View file

@ -629,7 +629,7 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int f
zend_string *str_key; zend_string *str_key;
ZEND_HASH_FOREACH_STR_KEY(&phar->mounted_dirs, 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; continue;
} else { } else {
char *test; 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) { if (!entry->tmp || !entry->is_mounted) {
goto free_resource; 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)) { if (SUCCESS != php_stream_stat_path(test, &ssbi)) {
efree(test); efree(test);
continue; continue;
@ -902,21 +902,21 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
str_key = b->key; str_key = b->key;
entry = Z_PTR(b->val); entry = Z_PTR(b->val);
if (!entry->is_deleted && if (!entry->is_deleted &&
str_key->len > from_len && ZSTR_LEN(str_key) > from_len &&
memcmp(str_key->val, resource_from->path+1, from_len) == 0 && memcmp(ZSTR_VAL(str_key), resource_from->path+1, from_len) == 0 &&
IS_SLASH(str_key->val[from_len])) { IS_SLASH(ZSTR_VAL(str_key)[from_len])) {
new_str_key = zend_string_alloc(str_key->len + to_len - from_len, 0); new_str_key = zend_string_alloc(ZSTR_LEN(str_key) + to_len - from_len, 0);
memcpy(new_str_key->val, resource_to->path + 1, to_len); memcpy(ZSTR_VAL(new_str_key), resource_to->path + 1, to_len);
memcpy(new_str_key->val + to_len, str_key->val + from_len, str_key->len - from_len); memcpy(ZSTR_VAL(new_str_key) + to_len, ZSTR_VAL(str_key) + from_len, ZSTR_LEN(str_key) - from_len);
new_str_key->val[new_str_key->len] = 0; ZSTR_VAL(new_str_key)[ZSTR_LEN(new_str_key)] = 0;
is_modified = 1; is_modified = 1;
entry->is_modified = 1; entry->is_modified = 1;
efree(entry->filename); efree(entry->filename);
// TODO: avoid reallocation (make entry->filename zend_string*) // TODO: avoid reallocation (make entry->filename zend_string*)
entry->filename = estrndup(new_str_key->val, new_str_key->len); entry->filename = estrndup(ZSTR_VAL(new_str_key), ZSTR_LEN(new_str_key));
entry->filename_len = new_str_key->len; entry->filename_len = ZSTR_LEN(new_str_key);
zend_string_release(str_key); zend_string_release(str_key);
b->h = zend_string_hash_val(new_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) { ZEND_HASH_FOREACH_BUCKET(&phar->virtual_dirs, b) {
str_key = b->key; str_key = b->key;
if (str_key->len >= from_len && if (ZSTR_LEN(str_key) >= from_len &&
memcmp(str_key->val, resource_from->path+1, from_len) == 0 && memcmp(ZSTR_VAL(str_key), resource_from->path+1, from_len) == 0 &&
(str_key->len == from_len || IS_SLASH(str_key->val[from_len]))) { (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); new_str_key = zend_string_alloc(ZSTR_LEN(str_key) + to_len - from_len, 0);
memcpy(new_str_key->val, resource_to->path + 1, to_len); memcpy(ZSTR_VAL(new_str_key), resource_to->path + 1, to_len);
memcpy(new_str_key->val + to_len, str_key->val + from_len, str_key->len - from_len); memcpy(ZSTR_VAL(new_str_key) + to_len, ZSTR_VAL(str_key) + from_len, ZSTR_LEN(str_key) - from_len);
new_str_key->val[new_str_key->len] = 0; ZSTR_VAL(new_str_key)[ZSTR_LEN(new_str_key)] = 0;
zend_string_release(str_key); zend_string_release(str_key);
b->h = zend_string_hash_val(new_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) { ZEND_HASH_FOREACH_BUCKET(&phar->mounted_dirs, b) {
str_key = b->key; str_key = b->key;
if (str_key->len >= from_len && if (ZSTR_LEN(str_key) >= from_len &&
memcmp(str_key->val, resource_from->path+1, from_len) == 0 && memcmp(ZSTR_VAL(str_key), resource_from->path+1, from_len) == 0 &&
(str_key->len == from_len || IS_SLASH(str_key->val[from_len]))) { (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); new_str_key = zend_string_alloc(ZSTR_LEN(str_key) + to_len - from_len, 0);
memcpy(new_str_key->val, resource_to->path + 1, to_len); memcpy(ZSTR_VAL(new_str_key), resource_to->path + 1, to_len);
memcpy(new_str_key->val + to_len, str_key->val + from_len, str_key->len - from_len); memcpy(ZSTR_VAL(new_str_key) + to_len, ZSTR_VAL(str_key) + from_len, ZSTR_LEN(str_key) - from_len);
new_str_key->val[new_str_key->len] = 0; ZSTR_VAL(new_str_key)[ZSTR_LEN(new_str_key)] = 0;
zend_string_release(str_key); zend_string_release(str_key);
b->h = zend_string_hash_val(new_str_key); b->h = zend_string_hash_val(new_str_key);

View file

@ -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_INIT(metadata_hash);
php_var_serialize(&entry->metadata_str, metadata, &metadata_hash); php_var_serialize(&entry->metadata_str, metadata, &metadata_hash);
PHP_VAR_SERIALIZE_DESTROY(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) { if (entry->fp && entry->fp_type == PHAR_MOD) {
php_stream_close(entry->fp); 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"); spprintf(error, 0, "phar error: unable to create temporary file");
return -1; 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); 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); zend_hash_str_del(&(entry->phar->manifest), entry->filename, entry->filename_len);
return ZEND_HASH_APPLY_STOP; 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); zend_string *str = php_stream_copy_to_mem(stubfile, len, 0);
if (str) { if (str) {
len = str->len; len = ZSTR_LEN(str);
user_stub = estrndup(str->val, str->len); user_stub = estrndup(ZSTR_VAL(str), ZSTR_LEN(str));
zend_string_release(str); zend_string_release(str);
} else { } else {
user_stub = NULL; user_stub = NULL;

View file

@ -321,9 +321,9 @@ splitted:
ret = php_resolve_path(filename, filename_len, path); ret = php_resolve_path(filename, filename_len, path);
efree(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:// */ /* 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; 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_string *str_key;
ZEND_HASH_FOREACH_STR_KEY(&phar->mounted_dirs, 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; continue;
} else { } else {
char *test; 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 (NULL == (entry = zend_hash_find_ptr(&phar->manifest, str_key))) {
if (error) { 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; return NULL;
} }
if (!entry->tmp || !entry->is_mounted) { if (!entry->tmp || !entry->is_mounted) {
if (error) { 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; 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)) { if (SUCCESS != php_stream_stat_path(test, &ssb)) {
efree(test); 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); pfp = php_stream_open_wrapper(pfile, "rb", 0, NULL);
efree(pfile); 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) { if (pfp) {
php_stream_close(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 #ifndef PHAR_HAVE_OPENSSL
tempsig = sig_len; 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) { if (pubkey) {
zend_string_release(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; sig_len = tempsig;
#else #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) { if (NULL == in) {
zend_string_release(pubkey); zend_string_release(pubkey);

View file

@ -584,8 +584,8 @@ foundit:
{ {
zend_string *str = php_stream_copy_to_mem(fp, entry.uncompressed_filesize, 0); zend_string *str = php_stream_copy_to_mem(fp, entry.uncompressed_filesize, 0);
if (str) { if (str) {
entry.uncompressed_filesize = str->len; entry.uncompressed_filesize = ZSTR_LEN(str);
actual_alias = estrndup(str->val, str->len); actual_alias = estrndup(ZSTR_VAL(str), ZSTR_LEN(str));
zend_string_release(str); zend_string_release(str);
} else { } else {
actual_alias = NULL; actual_alias = NULL;
@ -616,8 +616,8 @@ foundit:
{ {
zend_string *str = php_stream_copy_to_mem(fp, entry.uncompressed_filesize, 0); zend_string *str = php_stream_copy_to_mem(fp, entry.uncompressed_filesize, 0);
if (str) { if (str) {
entry.uncompressed_filesize = str->len; entry.uncompressed_filesize = ZSTR_LEN(str);
actual_alias = estrndup(str->val, str->len); actual_alias = estrndup(ZSTR_VAL(str), ZSTR_LEN(str));
zend_string_release(str); zend_string_release(str);
} else { } else {
actual_alias = NULL; actual_alias = NULL;
@ -638,8 +638,8 @@ foundit:
{ {
zend_string *str = php_stream_copy_to_mem(fp, entry.uncompressed_filesize, 0); zend_string *str = php_stream_copy_to_mem(fp, entry.uncompressed_filesize, 0);
if (str) { if (str) {
entry.uncompressed_filesize = str->len; entry.uncompressed_filesize = ZSTR_LEN(str);
actual_alias = estrndup(str->val, str->len); actual_alias = estrndup(ZSTR_VAL(str), ZSTR_LEN(str));
zend_string_release(str); zend_string_release(str);
} else { } else {
actual_alias = NULL; actual_alias = NULL;
@ -969,7 +969,7 @@ continue_dir:
PHP_VAR_SERIALIZE_INIT(metadata_hash); PHP_VAR_SERIALIZE_INIT(metadata_hash);
php_var_serialize(&entry->metadata_str, &entry->metadata, &metadata_hash); php_var_serialize(&entry->metadata_str, &entry->metadata, &metadata_hash);
PHP_VAR_SERIALIZE_DESTROY(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); entry->header_offset = php_stream_tell(p->filefp);
@ -1080,7 +1080,7 @@ continue_dir:
entry->fp_type = PHAR_FP; entry->fp_type = PHAR_FP;
if (entry->metadata_str.s) { 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); 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); smart_str_free(&entry->metadata_str);
return ZEND_HASH_APPLY_STOP; 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_seek(pass->centralfp, 0, SEEK_SET);
php_stream_copy_to_stream_ex(pass->centralfp, newfile, tell, NULL); php_stream_copy_to_stream_ex(pass->centralfp, newfile, tell, NULL);
if (metadata->s) { 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)) { 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); zend_string *str = php_stream_copy_to_mem(stubfile, len, 0);
if (str) { if (str) {
len = str->len; len = ZSTR_LEN(str);
user_stub = estrndup(str->val, str->len); user_stub = estrndup(ZSTR_VAL(str), ZSTR_LEN(str));
zend_string_release(str); zend_string_release(str);
} else { } else {
user_stub = NULL; user_stub = NULL;
@ -1483,7 +1483,7 @@ nocentralerror:
if (Z_TYPE(phar->metadata) != IS_UNDEF) { if (Z_TYPE(phar->metadata) != IS_UNDEF) {
/* set phar metadata */ /* 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 (sizeof(eocd) != php_stream_write(pass.filefp, (char *)&eocd, sizeof(eocd))) {
if (error) { if (error) {
@ -1492,7 +1492,7 @@ nocentralerror:
goto 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) { if (error) {
spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write metadata to zip comment", phar->fname); spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write metadata to zip comment", phar->fname);
} }

View file

@ -520,7 +520,7 @@ PHP_FUNCTION(readline_completion_function)
} }
if (!zend_is_callable(arg, 0, &name)) { 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); zend_string_release(name);
RETURN_FALSE; RETURN_FALSE;
} }
@ -569,7 +569,7 @@ PHP_FUNCTION(readline_callback_handler_install)
} }
if (!zend_is_callable(callback, 0, &name)) { 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); zend_string_release(name);
RETURN_FALSE; RETURN_FALSE;
} }

View file

@ -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) { while(zend_hash_has_more_elements(ht) == SUCCESS) {
zend_hash_get_current_key(ht, &name, &number); 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) { if (pData) {
*pData = zend_hash_get_current_data_ptr(ht); *pData = zend_hash_get_current_data_ptr(ht);
} }
zend_hash_move_forward(ht); zend_hash_move_forward(ht);
return name->val; return ZSTR_VAL(name);
} }
if (zend_hash_move_forward(ht) == FAILURE) { if (zend_hash_move_forward(ht) == FAILURE) {
break; 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); char *retval = cli_completion_generator_ht(text, textlen, state, ht, (void**)&func);
if (retval) { if (retval) {
rl_completion_append_character = '('; rl_completion_append_character = '(';
retval = strdup(func->common.function_name->val); retval = strdup(ZSTR_VAL(func->common.function_name));
} }
return retval; 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); char *retval = cli_completion_generator_ht(text, textlen, state, EG(class_table), (void**)&ce);
if (retval) { if (retval) {
rl_completion_append_character = '\0'; rl_completion_append_character = '\0';
retval = strdup(ce->name->val); retval = strdup(ZSTR_VAL(ce->name));
} }
return retval; return retval;
@ -522,7 +522,7 @@ TODO:
if (class_name_end) { if (class_name_end) {
class_name_len = class_name_end - text; class_name_len = class_name_end - text;
class_name = zend_string_alloc(class_name_len, 0); 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) { if ((ce = zend_lookup_class(class_name)) == NULL) {
zend_string_release(class_name); zend_string_release(class_name);
return NULL; return NULL;
@ -561,7 +561,7 @@ TODO:
int len = class_name_len + 2 + strlen(retval) + 1; int len = class_name_len + 2 + strlen(retval) + 1;
char *tmp = malloc(len); 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); free(retval);
retval = tmp; retval = tmp;
} }
@ -604,7 +604,7 @@ static int readline_shell_run(void) /* {{{ */
read_history(history_file); read_history(history_file);
EG(exit_status) = 0; 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) { if (strcmp(line, "exit") == 0 || strcmp(line, "quit") == 0) {
free(line); free(line);
break; break;

View file

@ -127,8 +127,8 @@ static void string_init(string *str)
{ {
str->buf= zend_string_alloc(1024, 0); str->buf= zend_string_alloc(1024, 0);
str->alloced = 1024; str->alloced = 1024;
str->buf->val[0] = '\0'; ZSTR_VAL(str->buf)[0] = '\0';
str->buf->len = 0; ZSTR_LEN(str->buf) = 0;
} }
static string *string_printf(string *str, const char *format, ...) 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); va_start(arg, format);
len = zend_vspprintf(&s_tmp, 0, format, arg); len = zend_vspprintf(&s_tmp, 0, format, arg);
if (len) { 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) { if (str->alloced < nlen) {
size_t old_len = str->buf->len; size_t old_len = ZSTR_LEN(str->buf);
str->alloced = nlen; str->alloced = nlen;
str->buf = zend_string_extend(str->buf, str->alloced, 0); 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); memcpy(ZSTR_VAL(str->buf) + ZSTR_LEN(str->buf), s_tmp, len + 1);
str->buf->len += len; ZSTR_LEN(str->buf) += len;
} }
efree(s_tmp); efree(s_tmp);
va_end(arg); 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) 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) { if (str->alloced < nlen) {
size_t old_len = str->buf->len; size_t old_len = ZSTR_LEN(str->buf);
str->alloced = nlen; str->alloced = nlen;
str->buf = zend_string_extend(str->buf, str->alloced, 0); 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); memcpy(ZSTR_VAL(str->buf) + ZSTR_LEN(str->buf), buf, len);
str->buf->len += len; ZSTR_LEN(str->buf) += len;
str->buf->val[str->buf->len] = '\0'; ZSTR_VAL(str->buf)[ZSTR_LEN(str->buf)] = '\0';
return str; return str;
} }
static string *string_append(string *str, string *append) static string *string_append(string *str, string *append)
{ {
if (append->buf->len > 0) { if (ZSTR_LEN(append->buf) > 0) {
string_write(str, append->buf->val, append->buf->len); string_write(str, ZSTR_VAL(append->buf), ZSTR_LEN(append->buf));
} }
return str; 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, "class ");
} }
string_printf(str, "%s", ce->name->val); string_printf(str, "%s", ZSTR_VAL(ce->name));
if (ce->parent) { 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) { if (ce->num_interfaces) {
uint32_t i; uint32_t i;
if (ce->ce_flags & ZEND_ACC_INTERFACE) { 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 { } 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) { 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"); string_printf(str, " ] {\n");
/* The information where a class is declared is only available for user classes */ /* The information where a class is declared is only available for user classes */
if (ce->type == ZEND_USER_CLASS) { 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); 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) { ZEND_HASH_FOREACH_STR_KEY_VAL(&ce->constants_table, key, value) {
zval_update_constant_ex(value, 1, NULL); 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(); } ZEND_HASH_FOREACH_END();
} }
string_printf(str, "%s }\n", indent); 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) { ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) {
if ((prop->flags & ZEND_ACC_STATIC) && !(prop->flags & ZEND_ACC_SHADOW)) { 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(); } 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)) && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce))
{ {
string_printf(str, "\n"); 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(); } ZEND_HASH_FOREACH_END();
} else { } 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) { ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) {
if (!(prop->flags & (ZEND_ACC_STATIC|ZEND_ACC_SHADOW))) { 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(); } 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)) { if (properties && zend_hash_num_elements(properties)) {
ZEND_HASH_FOREACH_STR_KEY(properties, prop_name) { 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)) { if (!zend_hash_exists(&ce->properties_info, prop_name)) {
count++; 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(); } 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 if ((mptr->common.fn_flags & ZEND_ACC_STATIC) == 0
&& ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) && ((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 */ /* Do not display old-style inherited constructors */
if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0
|| mptr->common.scope == ce || mptr->common.scope == ce
|| !key || !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; zend_function *closure;
/* see if this is a closure */ /* see if this is a closure */
if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) 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) && (closure = zend_get_closure_invoke_method(Z_OBJ_P(obj))) != NULL)
{ {
mptr = closure; mptr = closure;
@ -601,7 +601,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
closure = NULL; closure = NULL;
} }
string_printf(&dyn, "\n"); string_printf(&dyn, "\n");
_function_string(&dyn, mptr, ce, sub_indent.buf->val); _function_string(&dyn, mptr, ce, ZSTR_VAL(sub_indent.buf));
count++; count++;
_free_function(closure); _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); zend_string *value_str = zval_get_string(value);
string_printf(str, "%s Constant [ %s %s ] { %s }\n", 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); 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->type == ZEND_INTERNAL_FUNCTION &&
!(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ? !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ?
((zend_internal_arg_info*)arg_info)->class_name : ((zend_internal_arg_info*)arg_info)->class_name :
arg_info->class_name->val); ZSTR_VAL(arg_info->class_name));
if (arg_info->allow_null) { if (arg_info->allow_null) {
string_printf(str, "or 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->type == ZEND_INTERNAL_FUNCTION &&
!(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ? !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ?
((zend_internal_arg_info*)arg_info)->name : ((zend_internal_arg_info*)arg_info)->name :
arg_info->name->val); ZSTR_VAL(arg_info->name));
} else { } else {
string_printf(str, "$param%d", offset); 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); string_write(str, "Array", sizeof("Array")-1);
} else { } else {
zend_string *zv_str = zval_get_string(&zv); 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); zend_string_release(zv_str);
} }
zval_ptr_dtor(&zv); 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)); string_printf(str, "%s- Bound Variables [%d] {\n", indent, zend_hash_num_elements(static_variables));
i = 0; i = 0;
ZEND_HASH_FOREACH_STR_KEY(static_variables, key) { 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(); } ZEND_HASH_FOREACH_END();
string_printf(str, "%s}\n", indent); 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. * swallowed, leading to an unaligned comment.
*/ */
if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_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)); 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 (scope && fptr->common.scope) {
if (fptr->common.scope != 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) { } 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); 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 ((overwrites = zend_hash_find_ptr(&fptr->common.scope->parent->function_table, lc_name)) != NULL) {
if (fptr->common.scope != overwrites->common.scope) { 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); efree(lc_name);
} }
} }
if (fptr->common.prototype && fptr->common.prototype->common.scope) { 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) { if (fptr->common.fn_flags & ZEND_ACC_CTOR) {
string_printf(str, ", 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) { if (fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) {
string_printf(str, "&"); 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 */ /* The information where a function is declared is only available for user classes */
if (fptr->type == ZEND_USER_FUNCTION) { if (fptr->type == ZEND_USER_FUNCTION) {
string_printf(str, "%s @@ %s %d - %d\n", indent, 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_start,
fptr->op_array.line_end); fptr->op_array.line_end);
} }
string_init(&param_indent); string_init(&param_indent);
string_printf(&param_indent, "%s ", indent); string_printf(&param_indent, "%s ", indent);
if (fptr->common.fn_flags & ZEND_ACC_CLOSURE) { 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(&param_indent); string_free(&param_indent);
if (fptr->op_array.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) { if (fptr->op_array.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
string_printf(str, " %s- Return [ ", indent); 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->type == ZEND_INTERNAL_FUNCTION &&
!(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ? !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ?
((zend_internal_arg_info*)(fptr->common.arg_info - 1))->class_name : ((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) { if (fptr->common.arg_info[-1].allow_null) {
string_printf(str, "or 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 = ""; char *comma = "";
if (number == ini_entry->module_number) { 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) { if (ini_entry->modifiable == ZEND_INI_ALL) {
string_printf(str, "ALL"); string_printf(str, "ALL");
} else { } 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, "> ]\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) { 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); 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)) { 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 */ /* 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"); string_printf(str, "\n");
_class_string(str, ce, NULL, indent); _class_string(str, ce, NULL, indent);
(*num_classes)++; (*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*); int *num_classes = va_arg(args, int*);
if (constant->module_number == module->module_number) { 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)++; (*num_classes)++;
} }
return ZEND_HASH_APPLY_KEEP; 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 str_ini;
string_init(&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); 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_printf(str, "\n - INI {\n");
string_append(str, &str_ini); string_append(str, &str_ini);
string_printf(str, "%s }\n", indent); 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_init(&sub_indent);
string_printf(&sub_indent, "%s ", indent); string_printf(&sub_indent, "%s ", indent);
string_init(&str_classes); 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) { if (num_classes) {
string_printf(str, "\n - Classes [%d] {", num_classes); string_printf(str, "\n - Classes [%d] {", num_classes);
string_append(str, &str_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; struct _zend_module_entry *module;
lcname = zend_string_alloc(name_len, 0); 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); module = zend_hash_find_ptr(&module_registry, lcname);
zend_string_free(lcname); zend_string_free(lcname);
if (!module) { if (!module) {
@ -1544,7 +1544,7 @@ ZEND_METHOD(reflection, export)
} }
if (Z_TYPE(retval) == IS_UNDEF) { 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; RETURN_FALSE;
} }
@ -1952,7 +1952,7 @@ ZEND_METHOD(reflection_function, invoke)
if (result == FAILURE) { if (result == FAILURE) {
zend_throw_exception_ex(reflection_exception_ptr, 0, 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; return;
} }
@ -2017,7 +2017,7 @@ ZEND_METHOD(reflection_function, invokeArgs)
if (result == FAILURE) { if (result == FAILURE) {
zend_throw_exception_ex(reflection_exception_ptr, 0, 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; 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) { } else if ((fptr = zend_hash_str_find_ptr(&ce->function_table, lcname, lcname_len)) == NULL) {
efree(lcname); efree(lcname);
zend_throw_exception_ex(reflection_exception_ptr, 0, 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; return;
} }
efree(lcname); efree(lcname);
@ -2427,7 +2427,7 @@ ZEND_METHOD(reflection_parameter, __construct)
is_closure = 1; is_closure = 1;
} else if ((fptr = zend_hash_str_find_ptr(&ce->function_table, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME))) == NULL) { } 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, 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; return;
} }
} }
@ -2478,7 +2478,7 @@ ZEND_METHOD(reflection_parameter, __construct)
} else { } else {
for (i = 0; i < num_args; i++) { for (i = 0; i < num_args; i++) {
if (arg_info[i].name) { 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; position= i;
break; break;
} }
@ -2629,8 +2629,8 @@ ZEND_METHOD(reflection_parameter, getClass)
class_name = ((zend_internal_arg_info*)param->arg_info)->class_name; class_name = ((zend_internal_arg_info*)param->arg_info)->class_name;
class_name_len = strlen(class_name); class_name_len = strlen(class_name);
} else { } else {
class_name = param->arg_info->class_name->val; class_name = ZSTR_VAL(param->arg_info->class_name);
class_name_len = param->arg_info->class_name->len; class_name_len = ZSTR_LEN(param->arg_info->class_name);
} }
if (0 == zend_binary_strcasecmp(class_name, class_name_len, "self", sizeof("self")- 1)) { if (0 == zend_binary_strcasecmp(class_name, class_name_len, "self", sizeof("self")- 1)) {
ce = param->fptr->common.scope; 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) { } else if ((mptr = zend_hash_str_find_ptr(&ce->function_table, lcname, name_len)) == NULL) {
efree(lcname); efree(lcname);
zend_throw_exception_ex(reflection_exception_ptr, 0, 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; return;
} }
efree(lcname); efree(lcname);
@ -3192,13 +3192,13 @@ ZEND_METHOD(reflection_method, invoke)
if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) { if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) {
zend_throw_exception_ex(reflection_exception_ptr, 0, zend_throw_exception_ex(reflection_exception_ptr, 0,
"Trying to invoke abstract method %s::%s()", "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 { } else {
zend_throw_exception_ex(reflection_exception_ptr, 0, zend_throw_exception_ex(reflection_exception_ptr, 0,
"Trying to invoke %s method %s::%s() from scope %s", "Trying to invoke %s method %s::%s() from scope %s",
mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private", mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private",
mptr->common.scope->name->val, mptr->common.function_name->val, ZSTR_VAL(mptr->common.scope->name), ZSTR_VAL(mptr->common.function_name),
Z_OBJCE_P(getThis())->name->val); ZSTR_VAL(Z_OBJCE_P(getThis())->name));
} }
return; return;
} }
@ -3252,7 +3252,7 @@ ZEND_METHOD(reflection_method, invoke)
if (result == FAILURE) { if (result == FAILURE) {
zend_throw_exception_ex(reflection_exception_ptr, 0, 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; return;
} }
@ -3292,13 +3292,13 @@ ZEND_METHOD(reflection_method, invokeArgs)
if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) { if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) {
zend_throw_exception_ex(reflection_exception_ptr, 0, zend_throw_exception_ex(reflection_exception_ptr, 0,
"Trying to invoke abstract method %s::%s()", "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 { } else {
zend_throw_exception_ex(reflection_exception_ptr, 0, zend_throw_exception_ex(reflection_exception_ptr, 0,
"Trying to invoke %s method %s::%s() from scope %s", "Trying to invoke %s method %s::%s() from scope %s",
mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private", mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private",
mptr->common.scope->name->val, mptr->common.function_name->val, ZSTR_VAL(mptr->common.scope->name), ZSTR_VAL(mptr->common.function_name),
Z_OBJCE_P(getThis())->name->val); ZSTR_VAL(Z_OBJCE_P(getThis())->name));
} }
return; return;
} }
@ -3326,7 +3326,7 @@ ZEND_METHOD(reflection_method, invokeArgs)
efree(params); efree(params);
zend_throw_exception_ex(reflection_exception_ptr, 0, zend_throw_exception_ex(reflection_exception_ptr, 0,
"Trying to invoke non static method %s::%s() without an object", "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; return;
} }
@ -3371,7 +3371,7 @@ ZEND_METHOD(reflection_method, invokeArgs)
if (result == FAILURE) { if (result == FAILURE) {
zend_throw_exception_ex(reflection_exception_ptr, 0, 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; return;
} }
@ -3644,7 +3644,7 @@ ZEND_METHOD(reflection_method, getPrototype)
if (!mptr->common.prototype) { if (!mptr->common.prototype) {
zend_throw_exception_ex(reflection_exception_ptr, 0, 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; return;
} }
@ -3829,7 +3829,7 @@ ZEND_METHOD(reflection_class, getStaticPropertyValue)
ZVAL_COPY(return_value, def_value); ZVAL_COPY(return_value, def_value);
} else { } else {
zend_throw_exception_ex(reflection_exception_ptr, 0, 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; return;
} else { } else {
@ -3860,7 +3860,7 @@ ZEND_METHOD(reflection_class, setStaticPropertyValue)
variable_ptr = zend_std_get_static_property(ce, name, 1); variable_ptr = zend_std_get_static_property(ce, name, 1);
if (!variable_ptr) { if (!variable_ptr) {
zend_throw_exception_ex(reflection_exception_ptr, 0, 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; return;
} }
zval_ptr_dtor(variable_ptr); 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) static void _addmethod(zend_function *mptr, zend_class_entry *ce, zval *retval, zend_long filter, zval *obj)
{ {
zval method; zval method;
size_t len = mptr->common.function_name->len; size_t len = ZSTR_LEN(mptr->common.function_name);
zend_function *closure; zend_function *closure;
if (mptr->common.fn_flags & filter) { if (mptr->common.fn_flags & filter) {
if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) 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) && (closure = zend_get_closure_invoke_method(Z_OBJ_P(obj))) != NULL)
{ {
mptr = closure; mptr = closure;
@ -4269,20 +4269,20 @@ ZEND_METHOD(reflection_class, getProperty)
return; return;
} }
} }
str_name = name->val; str_name = ZSTR_VAL(name);
str_name_len = name->len; str_name_len = ZSTR_LEN(name);
if ((tmp = strstr(name->val, "::")) != NULL) { if ((tmp = strstr(ZSTR_VAL(name), "::")) != NULL) {
classname_len = tmp - name->val; classname_len = tmp - ZSTR_VAL(name);
classname = zend_string_alloc(classname_len, 0); classname = zend_string_alloc(classname_len, 0);
zend_str_tolower_copy(classname->val, name->val, classname_len); zend_str_tolower_copy(ZSTR_VAL(classname), ZSTR_VAL(name), classname_len);
classname->val[classname_len] = '\0'; ZSTR_VAL(classname)[classname_len] = '\0';
str_name_len = name->len - (classname_len + 2); str_name_len = ZSTR_LEN(name) - (classname_len + 2);
str_name = tmp + 2; str_name = tmp + 2;
ce2 = zend_lookup_class(classname); ce2 = zend_lookup_class(classname);
if (!ce2) { if (!ce2) {
if (!EG(exception)) { 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); zend_string_release(classname);
return; return;
@ -4290,7 +4290,7 @@ ZEND_METHOD(reflection_class, getProperty)
zend_string_release(classname); zend_string_release(classname);
if (!instanceof_function(ce, ce2)) { 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; return;
} }
ce = ce2; ce = ce2;
@ -4340,7 +4340,7 @@ static int _adddynproperty(zval *ptr, int num_args, va_list args, zend_hash_key
return 0; return 0;
} }
if (hash_key->key->val[0] == '\0') { if (ZSTR_VAL(hash_key->key)[0] == '\0') {
return 0; /* non public cannot be dynamic */ return 0; /* non public cannot be dynamic */
} }
@ -4629,7 +4629,7 @@ ZEND_METHOD(reflection_class, newInstance)
zend_fcall_info_cache fcc; zend_fcall_info_cache fcc;
if (!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)) { 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); zval_dtor(return_value);
RETURN_NULL(); RETURN_NULL();
} }
@ -4665,12 +4665,12 @@ ZEND_METHOD(reflection_class, newInstance)
zval_ptr_dtor(&params[i]); zval_ptr_dtor(&params[i]);
} }
if (ret == FAILURE) { 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); zval_dtor(return_value);
RETURN_NULL(); RETURN_NULL();
} }
} else if (ZEND_NUM_ARGS()) { } 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); GET_REFLECTION_OBJECT_PTR(ce);
if (ce->create_object != NULL && ce->ce_flags & ZEND_ACC_FINAL) { 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; return;
} }
@ -4733,7 +4733,7 @@ ZEND_METHOD(reflection_class, newInstanceArgs)
zend_fcall_info_cache fcc; zend_fcall_info_cache fcc;
if (!(constructor->common.fn_flags & ZEND_ACC_PUBLIC)) { 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); zval_dtor(return_value);
RETURN_NULL(); RETURN_NULL();
} }
@ -4773,12 +4773,12 @@ ZEND_METHOD(reflection_class, newInstanceArgs)
} }
if (ret == FAILURE) { if (ret == FAILURE) {
zval_ptr_dtor(&retval); 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); zval_dtor(return_value);
RETURN_NULL(); RETURN_NULL();
} }
} else if (argc) { } 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) { if (ce->trait_aliases[i]->alias) {
mname = zend_string_alloc(cur_ref->ce->name->len + cur_ref->method_name->len + 2, 0); mname = zend_string_alloc(ZSTR_LEN(cur_ref->ce->name) + ZSTR_LEN(cur_ref->method_name) + 2, 0);
snprintf(mname->val, mname->len + 1, "%s::%s", cur_ref->ce->name->val, cur_ref->method_name->val); 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, ce->trait_aliases[i]->alias->val, ce->trait_aliases[i]->alias->len, mname); add_assoc_str_ex(return_value, ZSTR_VAL(ce->trait_aliases[i]->alias), ZSTR_LEN(ce->trait_aliases[i]->alias), mname);
} }
i++; i++;
} }
@ -5014,7 +5014,7 @@ ZEND_METHOD(reflection_class, implementsInterface)
if (!(interface_ce->ce_flags & ZEND_ACC_INTERFACE)) { if (!(interface_ce->ce_flags & ZEND_ACC_INTERFACE)) {
zend_throw_exception_ex(reflection_exception_ptr, 0, 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;
} }
RETURN_BOOL(instanceof_function(ce, interface_ce)); RETURN_BOOL(instanceof_function(ce, interface_ce));
@ -5226,7 +5226,7 @@ ZEND_METHOD(reflection_property, __construct)
} }
} }
if (dynam_prop == 0) { 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; 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) { if (!(ref->prop.flags & (ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC)) && intern->ignore_visibility == 0) {
name = _default_load_entry(getThis(), "name", sizeof("name")-1); name = _default_load_entry(getThis(), "name", sizeof("name")-1);
zend_throw_exception_ex(reflection_exception_ptr, 0, 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; return;
} }
@ -5395,7 +5395,7 @@ ZEND_METHOD(reflection_property, getValue)
return; return;
} }
if (Z_TYPE(CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) == IS_UNDEF) { 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 */ /* Bails out */
} }
ZVAL_DUP(return_value, &CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]); 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) { if (!(ref->prop.flags & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) {
name = _default_load_entry(getThis(), "name", sizeof("name")-1); name = _default_load_entry(getThis(), "name", sizeof("name")-1);
zend_throw_exception_ex(reflection_exception_ptr, 0, 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; return;
} }
@ -5447,7 +5447,7 @@ ZEND_METHOD(reflection_property, setValue)
} }
if (Z_TYPE(CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) == IS_UNDEF) { 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 */ /* Bails out */
} }
variable_ptr = &CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]; 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)) { if ((ce->type == ZEND_INTERNAL_CLASS) && ce->info.internal.module && !strcasecmp(ce->info.internal.module->name, module->name)) {
zend_string *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 */ /* This is an class alias, use alias name */
name = hash_key->key; name = hash_key->key;
} else { } else {
@ -5879,7 +5879,7 @@ ZEND_METHOD(reflection_extension, getDependencies)
} }
relation = zend_string_alloc(len, 0); 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, rel_type,
dep->rel ? " " : "", dep->rel ? " " : "",
dep->rel ? 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"))))) || (Z_STRLEN_P(member) == sizeof("class") - 1 && !memcmp(Z_STRVAL_P(member), "class", sizeof("class")))))
{ {
zend_throw_exception_ex(reflection_exception_ptr, 0, 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 else
{ {

Some files were not shown because too many files have changed in this diff Show more