summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2000-11-27 13:31:21 +0000
committerSascha Schumann <sas@php.net>2000-11-27 13:31:21 +0000
commit949b0893dce45312291273b731e89a1a5ad6389d (patch)
tree6a52049e065eb9c42551ff3d2b8113fc70e220f5
parent1626ba7ee9f5b2f15a4b769c8db429ce8056a21a (diff)
downloadphp-git-949b0893dce45312291273b731e89a1a5ad6389d.tar.gz
The result of conv_z_macros and some manual conversion of
"return_value.*=.*IS_STRING" constructs to RETVAL_STRINGL.
-rw-r--r--ext/standard/array.c383
-rw-r--r--ext/standard/base64.c12
-rw-r--r--ext/standard/basic_functions.c136
-rw-r--r--ext/standard/crypt.c5
-rw-r--r--ext/standard/dns.c32
-rw-r--r--ext/standard/exec.c57
6 files changed, 304 insertions, 321 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 8e6b55ab9b..2ae6f15b2c 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -126,31 +126,31 @@ static int array_key_compare(const void *a, const void *b)
s = *((Bucket **) b);
if (f->nKeyLength == 0) {
- first.type = IS_LONG;
- first.value.lval = f->h;
+ Z_TYPE(first) = IS_LONG;
+ Z_LVAL(first) = f->h;
} else {
- first.type = IS_STRING;
- first.value.str.val = f->arKey;
- first.value.str.len = f->nKeyLength;
+ Z_TYPE(first) = IS_STRING;
+ Z_STRVAL(first) = f->arKey;
+ Z_STRLEN(first) = f->nKeyLength;
}
if (s->nKeyLength == 0) {
- second.type = IS_LONG;
- second.value.lval = s->h;
+ Z_TYPE(second) = IS_LONG;
+ Z_LVAL(second) = s->h;
} else {
- second.type = IS_STRING;
- second.value.str.val = s->arKey;
- second.value.str.len = s->nKeyLength;
+ Z_TYPE(second) = IS_STRING;
+ Z_STRVAL(second) = s->arKey;
+ Z_STRLEN(second) = s->nKeyLength;
}
if (ARRAYG(compare_func)(&result, &first, &second) == FAILURE) {
return 0;
}
- if (result.type == IS_DOUBLE) {
- if (result.value.dval < 0) {
+ if (Z_TYPE(result) == IS_DOUBLE) {
+ if (Z_DVAL(result) < 0) {
return -1;
- } else if (result.value.dval > 0) {
+ } else if (Z_DVAL(result) > 0) {
return 1;
} else {
return 0;
@@ -159,9 +159,9 @@ static int array_key_compare(const void *a, const void *b)
convert_to_long(&result);
- if (result.value.lval < 0) {
+ if (Z_LVAL(result) < 0) {
return -1;
- } else if (result.value.lval > 0) {
+ } else if (Z_LVAL(result) > 0) {
return 1;
}
@@ -242,7 +242,7 @@ PHP_FUNCTION(count)
}
target_hash = HASH_OF(*array);
if (!target_hash) {
- if ((*array)->type == IS_NULL) {
+ if (Z_TYPE_PP(array) == IS_NULL) {
RETURN_LONG(0);
} else {
RETURN_LONG(1);
@@ -279,10 +279,10 @@ static int array_data_compare(const void *a, const void *b)
return 0;
}
- if (result.type == IS_DOUBLE) {
- if (result.value.dval < 0) {
+ if (Z_TYPE(result) == IS_DOUBLE) {
+ if (Z_DVAL(result) < 0) {
return -1;
- } else if (result.value.dval > 0) {
+ } else if (Z_DVAL(result) > 0) {
return 1;
} else {
return 0;
@@ -291,9 +291,9 @@ static int array_data_compare(const void *a, const void *b)
convert_to_long(&result);
- if (result.value.lval < 0) {
+ if (Z_LVAL(result) < 0) {
return -1;
- } else if (result.value.lval > 0) {
+ } else if (Z_LVAL(result) > 0) {
return 1;
}
@@ -319,21 +319,21 @@ static int array_natural_general_compare(const void *a, const void *b, int fold_
sval = *((pval **) s->pData);
first = *fval;
second = *sval;
- if (fval->type != IS_STRING) {
+ if (Z_TYPE_P(fval) != IS_STRING) {
zval_copy_ctor(&first);
convert_to_string(&first);
}
- if (sval->type != IS_STRING) {
+ if (Z_TYPE_P(sval) != IS_STRING) {
zval_copy_ctor(&first);
convert_to_string(&second);
}
- result = strnatcmp_ex(first.value.str.val, first.value.str.len,
- second.value.str.val, second.value.str.len, fold_case);
+ result = strnatcmp_ex(Z_STRVAL(first), Z_STRLEN(first),
+ Z_STRVAL(second), Z_STRLEN(second), fold_case);
- if (fval->type != IS_STRING)
+ if (Z_TYPE_P(fval) != IS_STRING)
zval_dtor(&first);
- if (sval->type != IS_STRING)
+ if (Z_TYPE_P(sval) != IS_STRING)
zval_dtor(&second);
return result;
@@ -367,18 +367,18 @@ static int array_type_data_compare(const void *a, const void *b)
first = *((pval **) f->pData);
second = *((pval **) s->pData);
- diff = first->type - second->type;
- if (diff && ((first->type == IS_STRING) || (second->type == IS_STRING)))
+ diff = Z_TYPE_P(first) - Z_TYPE_P(second);
+ if (diff && ((Z_TYPE_P(first) == IS_STRING) || (Z_TYPE_P(second) == IS_STRING)))
return diff;
if (ARRAYG(compare_func)(&result, first, second) == FAILURE) {
return 0;
}
- if (result.type == IS_DOUBLE) {
- if (result.value.dval < 0) {
+ if (Z_TYPE(result) == IS_DOUBLE) {
+ if (Z_DVAL(result) < 0) {
return -1;
- } else if (result.value.dval > 0) {
+ } else if (Z_DVAL(result) > 0) {
return 1;
} else {
return 0;
@@ -387,9 +387,9 @@ static int array_type_data_compare(const void *a, const void *b)
convert_to_long(&result);
- if (result.value.lval < 0) {
+ if (Z_LVAL(result) < 0) {
return -1;
- } else if (result.value.lval > 0) {
+ } else if (Z_LVAL(result) > 0) {
return 1;
}
@@ -580,7 +580,7 @@ static int array_user_compare(const void *a, const void *b)
long retval;
convert_to_long_ex(&retval_ptr);
- retval = retval_ptr->value.lval;
+ retval = Z_LVAL_P(retval_ptr);
zval_ptr_dtor(&retval_ptr);
return retval;
} else {
@@ -666,20 +666,20 @@ static int array_user_key_compare(const void *a, const void *b)
s = *((Bucket **) b);
if (f->nKeyLength) {
- key1.value.str.val = estrndup(f->arKey, f->nKeyLength);
- key1.value.str.len = f->nKeyLength-1;
- key1.type = IS_STRING;
+ Z_STRVAL(key1) = estrndup(f->arKey, f->nKeyLength);
+ Z_STRLEN(key1) = f->nKeyLength-1;
+ Z_TYPE(key1) = IS_STRING;
} else {
- key1.value.lval = f->h;
- key1.type = IS_LONG;
+ Z_LVAL(key1) = f->h;
+ Z_TYPE(key1) = IS_LONG;
}
if (s->nKeyLength) {
- key2.value.str.val = estrndup(s->arKey, s->nKeyLength);
- key2.value.str.len = s->nKeyLength-1;
- key2.type = IS_STRING;
+ Z_STRVAL(key2) = estrndup(s->arKey, s->nKeyLength);
+ Z_STRLEN(key2) = s->nKeyLength-1;
+ Z_TYPE(key2) = IS_STRING;
} else {
- key2.value.lval = s->h;
- key2.type = IS_LONG;
+ Z_LVAL(key2) = s->h;
+ Z_TYPE(key2) = IS_LONG;
}
status = call_user_function(CG(function_table), NULL, *BG(user_compare_func_name), &retval, 2, args);
@@ -689,7 +689,7 @@ static int array_user_key_compare(const void *a, const void *b)
if (status==SUCCESS) {
convert_to_long(&retval);
- return retval.value.lval;
+ return Z_LVAL(retval);
} else {
return 0;
}
@@ -878,13 +878,10 @@ PHP_FUNCTION(key)
}
switch (zend_hash_get_current_key(target_hash, &string_key, &num_key)) {
case HASH_KEY_IS_STRING:
- return_value->value.str.val = string_key;
- return_value->value.str.len = strlen(string_key);
- return_value->type = IS_STRING;
+ RETVAL_STRING(string_key, 0);
break;
case HASH_KEY_IS_LONG:
- return_value->type = IS_LONG;
- return_value->value.lval = num_key;
+ RETVAL_LONG(num_key);
break;
case HASH_KEY_NON_EXISTANT:
return;
@@ -907,10 +904,10 @@ PHP_FUNCTION(min)
if (argc == 1) {
pval **arr;
- if (zend_get_parameters_ex(1, &arr) == FAILURE || (*arr)->type != IS_ARRAY) {
+ if (zend_get_parameters_ex(1, &arr) == FAILURE || Z_TYPE_PP(arr) != IS_ARRAY) {
WRONG_PARAM_COUNT;
}
- if (zend_hash_minmax((*arr)->value.ht, array_data_compare, 0, (void **) &result)==SUCCESS) {
+ if (zend_hash_minmax(Z_ARRVAL_PP(arr), array_data_compare, 0, (void **) &result)==SUCCESS) {
*return_value = **result;
zval_copy_ctor(return_value);
} else {
@@ -931,7 +928,7 @@ PHP_FUNCTION(min)
for (i=1; i<ZEND_NUM_ARGS(); i++) {
is_smaller_function(&result, *args[i], *min);
- if (result.value.lval == 1) {
+ if (Z_LVAL(result) == 1) {
min = args[i];
}
}
@@ -959,10 +956,10 @@ PHP_FUNCTION(max)
if (argc == 1) {
pval **arr;
- if (zend_get_parameters_ex(1, &arr) == FAILURE || (*arr)->type != IS_ARRAY) {
+ if (zend_get_parameters_ex(1, &arr) == FAILURE || Z_TYPE_PP(arr) != IS_ARRAY) {
WRONG_PARAM_COUNT;
}
- if (zend_hash_minmax((*arr)->value.ht, array_data_compare, 1, (void **) &result)==SUCCESS) {
+ if (zend_hash_minmax(Z_ARRVAL_PP(arr), array_data_compare, 1, (void **) &result)==SUCCESS) {
*return_value = **result;
zval_copy_ctor(return_value);
} else {
@@ -983,7 +980,7 @@ PHP_FUNCTION(max)
for (i=1; i<ZEND_NUM_ARGS(); i++) {
is_smaller_or_equal_function(&result, *args[i], *max);
- if (result.value.lval == 0) {
+ if (Z_LVAL(result) == 0) {
max = args[i];
}
}
@@ -1019,12 +1016,12 @@ static int php_array_walk(HashTable *target_hash, zval **userdata)
while(zend_hash_get_current_data(target_hash, (void **)&args[0]) == SUCCESS) {
/* Set up the key */
if (zend_hash_get_current_key(target_hash, &string_key, &num_key) == HASH_KEY_IS_LONG) {
- key->type = IS_LONG;
- key->value.lval = num_key;
+ Z_TYPE_P(key) = IS_LONG;
+ Z_LVAL_P(key) = num_key;
} else {
- key->type = IS_STRING;
- key->value.str.val = string_key;
- key->value.str.len = strlen(string_key);
+ Z_TYPE_P(key) = IS_STRING;
+ Z_STRVAL_P(key) = string_key;
+ Z_STRLEN_P(key) = strlen(string_key);
}
/* Call the userland function */
@@ -1038,7 +1035,7 @@ static int php_array_walk(HashTable *target_hash, zval **userdata)
/* Clean up the key */
if (zend_hash_get_current_key_type(target_hash) == HASH_KEY_IS_STRING)
- efree(key->value.str.val);
+ efree(Z_STRVAL_P(key));
zend_hash_move_forward(target_hash);
}
@@ -1102,12 +1099,12 @@ PHP_FUNCTION(in_array)
WRONG_PARAM_COUNT;
}
- if ((*value)->type == IS_ARRAY || (*value)->type == IS_OBJECT) {
+ if (Z_TYPE_PP(value) == IS_ARRAY || Z_TYPE_PP(value) == IS_OBJECT) {
php_error(E_WARNING, "Wrong datatype for first argument in call to in_array()");
RETURN_FALSE;
}
- if ((*array)->type != IS_ARRAY) {
+ if (Z_TYPE_PP(array) != IS_ARRAY) {
php_error(E_WARNING, "Wrong datatype for second argument in call to in_array()");
RETURN_FALSE;
}
@@ -1183,7 +1180,7 @@ PHP_FUNCTION(extract)
WRONG_PARAM_COUNT;
}
convert_to_long_ex(etype);
- extype = (*etype)->value.lval;
+ extype = Z_LVAL_PP(etype);
if (extype > EXTR_SKIP && extype <= EXTR_PREFIX_ALL) {
WRONG_PARAM_COUNT;
}
@@ -1194,7 +1191,7 @@ PHP_FUNCTION(extract)
WRONG_PARAM_COUNT;
}
convert_to_long_ex(etype);
- extype = (*etype)->value.lval;
+ extype = Z_LVAL_PP(etype);
convert_to_string_ex(prefix);
break;
@@ -1208,15 +1205,15 @@ PHP_FUNCTION(extract)
RETURN_FALSE;
}
- if ((*var_array)->type != IS_ARRAY) {
+ if (Z_TYPE_PP(var_array) != IS_ARRAY) {
php_error(E_WARNING, "Wrong datatype in call to extract()");
RETURN_FALSE;
}
- zend_hash_internal_pointer_reset((*var_array)->value.ht);
- while(zend_hash_get_current_data((*var_array)->value.ht, (void **)&entry) == SUCCESS) {
+ zend_hash_internal_pointer_reset(Z_ARRVAL_PP(var_array));
+ while(zend_hash_get_current_data(Z_ARRVAL_PP(var_array), (void **)&entry) == SUCCESS) {
- if (zend_hash_get_current_key((*var_array)->value.ht, &varname, &lkey) == HASH_KEY_IS_STRING) {
+ if (zend_hash_get_current_key(Z_ARRVAL_PP(var_array), &varname, &lkey) == HASH_KEY_IS_STRING) {
if (_valid_var_name(varname)) {
finalname = NULL;
@@ -1234,8 +1231,8 @@ PHP_FUNCTION(extract)
case EXTR_PREFIX_ALL:
if (!finalname) {
- finalname = emalloc(strlen(varname) + (*prefix)->value.str.len + 2);
- strcpy(finalname, (*prefix)->value.str.val);
+ finalname = emalloc(strlen(varname) + Z_STRLEN_PP(prefix) + 2);
+ strcpy(finalname, Z_STRVAL_PP(prefix));
strcat(finalname, "_");
strcat(finalname, varname);
}
@@ -1260,7 +1257,7 @@ PHP_FUNCTION(extract)
efree(varname);
}
- zend_hash_move_forward((*var_array)->value.ht);
+ zend_hash_move_forward(Z_ARRVAL_PP(var_array));
}
}
/* }}} */
@@ -1271,27 +1268,27 @@ static void _compact_var(HashTable *eg_active_symbol_table, zval *return_value,
{
zval **value_ptr, *value, *data;
- if (entry->type == IS_STRING) {
- if (zend_hash_find(eg_active_symbol_table, entry->value.str.val,
- entry->value.str.len+1, (void **)&value_ptr) != FAILURE) {
+ if (Z_TYPE_P(entry) == IS_STRING) {
+ if (zend_hash_find(eg_active_symbol_table, Z_STRVAL_P(entry),
+ Z_STRLEN_P(entry)+1, (void **)&value_ptr) != FAILURE) {
value = *value_ptr;
ALLOC_ZVAL(data);
*data = *value;
zval_copy_ctor(data);
INIT_PZVAL(data);
- zend_hash_update(return_value->value.ht, entry->value.str.val,
- entry->value.str.len+1, &data, sizeof(zval *), NULL);
+ zend_hash_update(Z_ARRVAL_P(return_value), Z_STRVAL_P(entry),
+ Z_STRLEN_P(entry)+1, &data, sizeof(zval *), NULL);
}
}
- else if (entry->type == IS_ARRAY) {
- zend_hash_internal_pointer_reset(entry->value.ht);
+ else if (Z_TYPE_P(entry) == IS_ARRAY) {
+ zend_hash_internal_pointer_reset(Z_ARRVAL_P(entry));
- while(zend_hash_get_current_data(entry->value.ht, (void**)&value_ptr) == SUCCESS) {
+ while(zend_hash_get_current_data(Z_ARRVAL_P(entry), (void**)&value_ptr) == SUCCESS) {
value = *value_ptr;
_compact_var(eg_active_symbol_table, return_value, value);
- zend_hash_move_forward(entry->value.ht);
+ zend_hash_move_forward(Z_ARRVAL_P(entry));
}
}
}
@@ -1335,8 +1332,8 @@ PHP_FUNCTION(range)
}
convert_to_long_ex(zlow);
convert_to_long_ex(zhigh);
- low = (*zlow)->value.lval;
- high = (*zhigh)->value.lval;
+ low = Z_LVAL_PP(zlow);
+ high = Z_LVAL_PP(zhigh);
/* allocate an array for return */
if (array_init(return_value) == FAILURE) {
@@ -1375,11 +1372,11 @@ PHP_FUNCTION(shuffle)
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &array) == FAILURE) {
WRONG_PARAM_COUNT;
}
- if ((*array)->type != IS_ARRAY) {
+ if (Z_TYPE_PP(array) != IS_ARRAY) {
php_error(E_WARNING, "Wrong datatype in shuffle() call");
RETURN_FALSE;
}
- if (zend_hash_sort((*array)->value.ht, (sort_func_t)php_mergesort, array_data_shuffle, 1) == FAILURE) {
+ if (zend_hash_sort(Z_ARRVAL_PP(array), (sort_func_t)php_mergesort, array_data_shuffle, 1) == FAILURE) {
RETURN_FALSE;
}
RETURN_TRUE;
@@ -1502,7 +1499,7 @@ PHP_FUNCTION(array_push)
/* Get first argument and check that it's an array */
stack = *args[0];
- if (stack->type != IS_ARRAY) {
+ if (Z_TYPE_P(stack) != IS_ARRAY) {
php_error(E_WARNING, "First argument to array_push() needs to be an array");
RETURN_FALSE;
}
@@ -1513,12 +1510,12 @@ PHP_FUNCTION(array_push)
new_var = *args[i];
new_var->refcount++;
- zend_hash_next_index_insert(stack->value.ht, &new_var, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(Z_ARRVAL_P(stack), &new_var, sizeof(zval *), NULL);
}
/* Clean up and return the number of values in the stack */
efree(args);
- RETVAL_LONG(zend_hash_num_elements(stack->value.ht));
+ RETVAL_LONG(zend_hash_num_elements(Z_ARRVAL_P(stack)));
}
/* }}} */
@@ -1535,30 +1532,30 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
WRONG_PARAM_COUNT;
}
- if ((*stack)->type != IS_ARRAY) {
+ if (Z_TYPE_PP(stack) != IS_ARRAY) {
php_error(E_WARNING, "The argument needs to be an array");
return;
}
- if (zend_hash_num_elements((*stack)->value.ht) == 0) {
+ if (zend_hash_num_elements(Z_ARRVAL_PP(stack)) == 0) {
return;
}
/* Get the first or last value and copy it into the return value */
if (off_the_end)
- zend_hash_internal_pointer_end((*stack)->value.ht);
+ zend_hash_internal_pointer_end(Z_ARRVAL_PP(stack));
else
- zend_hash_internal_pointer_reset((*stack)->value.ht);
- zend_hash_get_current_data((*stack)->value.ht, (void **)&val);
+ zend_hash_internal_pointer_reset(Z_ARRVAL_PP(stack));
+ zend_hash_get_current_data(Z_ARRVAL_PP(stack), (void **)&val);
*return_value = **val;
zval_copy_ctor(return_value);
INIT_PZVAL(return_value);
/* Delete the first or last value */
- new_hash = php_splice((*stack)->value.ht, (off_the_end) ? -1 : 0, 1, NULL, 0, NULL);
- zend_hash_destroy((*stack)->value.ht);
- efree((*stack)->value.ht);
- (*stack)->value.ht = new_hash;
+ new_hash = php_splice(Z_ARRVAL_PP(stack), (off_the_end) ? -1 : 0, 1, NULL, 0, NULL);
+ zend_hash_destroy(Z_ARRVAL_PP(stack));
+ efree(Z_ARRVAL_PP(stack));
+ Z_ARRVAL_PP(stack) = new_hash;
}
/* }}} */
@@ -1606,21 +1603,21 @@ PHP_FUNCTION(array_unshift)
/* Get first argument and check that it's an array */
stack = *args[0];
- if (stack->type != IS_ARRAY) {
+ if (Z_TYPE_P(stack) != IS_ARRAY) {
php_error(E_WARNING, "First argument to array_unshift() needs to be an array");
RETURN_FALSE;
}
/* Use splice to insert the elements at the beginning. Destroy old
hashtable and replace it with new one */
- new_hash = php_splice(stack->value.ht, 0, 0, &args[1], argc-1, NULL);
- zend_hash_destroy(stack->value.ht);
- efree(stack->value.ht);
- stack->value.ht = new_hash;
+ new_hash = php_splice(Z_ARRVAL_P(stack), 0, 0, &args[1], argc-1, NULL);
+ zend_hash_destroy(Z_ARRVAL_P(stack));
+ efree(Z_ARRVAL_P(stack));
+ Z_ARRVAL_P(stack) = new_hash;
/* Clean up and return the number of elements in the stack */
efree(args);
- RETVAL_LONG(zend_hash_num_elements(stack->value.ht));
+ RETVAL_LONG(zend_hash_num_elements(Z_ARRVAL_P(stack)));
}
/* }}} */
@@ -1655,7 +1652,7 @@ PHP_FUNCTION(array_splice)
/* Get first argument and check that it's an array */
array = *args[0];
- if (array->type != IS_ARRAY) {
+ if (Z_TYPE_P(array) != IS_ARRAY) {
php_error(E_WARNING, "First argument to array_splice() should be an array");
efree(args);
return;
@@ -1664,21 +1661,21 @@ PHP_FUNCTION(array_splice)
/* Get the next two arguments. If length is omitted,
it's assumed to be until the end of the array */
convert_to_long_ex(args[1]);
- offset = (*args[1])->value.lval;
+ offset = Z_LVAL_PP(args[1]);
if (argc > 2) {
convert_to_long_ex(args[2]);
- length = (*args[2])->value.lval;
+ length = Z_LVAL_PP(args[2]);
} else
- length = zend_hash_num_elements(array->value.ht);
+ length = zend_hash_num_elements(Z_ARRVAL_P(array));
if (argc == 4) {
/* Make sure the last argument, if passed, is an array */
convert_to_array_ex(args[3]);
/* Create the array of replacement elements */
- repl_num = zend_hash_num_elements((*args[3])->value.ht);
+ repl_num = zend_hash_num_elements(Z_ARRVAL_PP(args[3]));
repl = (zval ***)emalloc(repl_num * sizeof(zval **));
- for (p=(*args[3])->value.ht->pListHead, i=0; p; p=p->pListNext, i++) {
+ for (p=Z_ARRVAL_PP(args[3])->pListHead, i=0; p; p=p->pListNext, i++) {
repl[i] = ((zval **)p->pData);
}
}
@@ -1687,14 +1684,14 @@ PHP_FUNCTION(array_splice)
array_init(return_value);
/* Perform splice */
- new_hash = php_splice(array->value.ht, offset, length,
+ new_hash = php_splice(Z_ARRVAL_P(array), offset, length,
repl, repl_num,
- &return_value->value.ht);
+ &Z_ARRVAL_P(return_value));
/* Replace input array's hashtable with the new one */
- zend_hash_destroy(array->value.ht);
- efree(array->value.ht);
- array->value.ht = new_hash;
+ zend_hash_destroy(Z_ARRVAL_P(array));
+ efree(Z_ARRVAL_P(array));
+ Z_ARRVAL_P(array) = new_hash;
/* Clean up */
if (argc == 4)
@@ -1728,7 +1725,7 @@ PHP_FUNCTION(array_slice)
WRONG_PARAM_COUNT;
}
- if ((*input)->type != IS_ARRAY) {
+ if (Z_TYPE_PP(input) != IS_ARRAY) {
php_error(E_WARNING, "First argument to array_slice() should be an array");
return;
}
@@ -1737,18 +1734,18 @@ PHP_FUNCTION(array_slice)
we want all entries from offset to the end if length
is not passed */
convert_to_long_ex(offset);
- offset_val = (*offset)->value.lval;
+ offset_val = Z_LVAL_PP(offset);
if (argc == 3) {
convert_to_long_ex(length);
- length_val = (*length)->value.lval;
+ length_val = Z_LVAL_PP(length);
} else
- length_val = zend_hash_num_elements((*input)->value.ht);
+ length_val = zend_hash_num_elements(Z_ARRVAL_PP(input));
/* Initialize returned array */
array_init(return_value);
/* Get number of entries in the input hash */
- num_in = zend_hash_num_elements((*input)->value.ht);
+ num_in = zend_hash_num_elements(Z_ARRVAL_PP(input));
/* Clamp the offset.. */
if (offset_val > num_in)
@@ -1767,33 +1764,33 @@ PHP_FUNCTION(array_slice)
/* Start at the beginning and go until we hit offset */
pos = 0;
- zend_hash_internal_pointer_reset((*input)->value.ht);
+ zend_hash_internal_pointer_reset(Z_ARRVAL_PP(input));
while(pos < offset_val &&
- zend_hash_get_current_data((*input)->value.ht, (void **)&entry) == SUCCESS) {
+ zend_hash_get_current_data(Z_ARRVAL_PP(input), (void **)&entry) == SUCCESS) {
pos++;
- zend_hash_move_forward((*input)->value.ht);
+ zend_hash_move_forward(Z_ARRVAL_PP(input));
}
/* Copy elements from input array to the one that's returned */
while(pos < offset_val+length_val &&
- zend_hash_get_current_data((*input)->value.ht, (void **)&entry) == SUCCESS) {
+ zend_hash_get_current_data(Z_ARRVAL_PP(input), (void **)&entry) == SUCCESS) {
(*entry)->refcount++;
- switch (zend_hash_get_current_key((*input)->value.ht, &string_key, &num_key)) {
+ switch (zend_hash_get_current_key(Z_ARRVAL_PP(input), &string_key, &num_key)) {
case HASH_KEY_IS_STRING:
- zend_hash_update(return_value->value.ht, string_key, strlen(string_key)+1,
+ zend_hash_update(Z_ARRVAL_P(return_value), string_key, strlen(string_key)+1,
entry, sizeof(zval *), NULL);
efree(string_key);
break;
case HASH_KEY_IS_LONG:
- zend_hash_next_index_insert(return_value->value.ht,
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value),
entry, sizeof(zval *), NULL);
break;
}
pos++;
- zend_hash_move_forward((*input)->value.ht);
+ zend_hash_move_forward(Z_ARRVAL_PP(input));
}
}
/* }}} */
@@ -1905,7 +1902,7 @@ PHP_FUNCTION(array_keys)
WRONG_PARAM_COUNT;
}
- if ((*input)->type != IS_ARRAY) {
+ if (Z_TYPE_PP(input) != IS_ARRAY) {
php_error(E_WARNING, "First argument to array_keys() should be an array");
return;
}
@@ -1915,8 +1912,8 @@ PHP_FUNCTION(array_keys)
add_key = 1;
/* Go through input array and add keys to the return array */
- zend_hash_internal_pointer_reset((*input)->value.ht);
- while(zend_hash_get_current_data((*input)->value.ht, (void **)&entry) == SUCCESS) {
+ zend_hash_internal_pointer_reset(Z_ARRVAL_PP(input));
+ while(zend_hash_get_current_data(Z_ARRVAL_PP(input), (void **)&entry) == SUCCESS) {
if (search_value != NULL) {
is_equal_function(&res, *search_value, *entry);
add_key = zval_is_true(&res);
@@ -1925,25 +1922,25 @@ PHP_FUNCTION(array_keys)
if (add_key) {
MAKE_STD_ZVAL(new_val);
- switch (zend_hash_get_current_key((*input)->value.ht, &string_key, &num_key)) {
+ switch (zend_hash_get_current_key(Z_ARRVAL_PP(input), &string_key, &num_key)) {
case HASH_KEY_IS_STRING:
- new_val->type = IS_STRING;
- new_val->value.str.val = string_key;
- new_val->value.str.len = strlen(string_key);
- zend_hash_next_index_insert(return_value->value.ht, &new_val,
+ Z_TYPE_P(new_val) = IS_STRING;
+ Z_STRVAL_P(new_val) = string_key;
+ Z_STRLEN_P(new_val) = strlen(string_key);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &new_val,
sizeof(zval *), NULL);
break;
case HASH_KEY_IS_LONG:
- new_val->type = IS_LONG;
- new_val->value.lval = num_key;
- zend_hash_next_index_insert(return_value->value.ht, &new_val,
+ Z_TYPE_P(new_val) = IS_LONG;
+ Z_LVAL_P(new_val) = num_key;
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &new_val,
sizeof(zval *), NULL);
break;
}
}
- zend_hash_move_forward((*input)->value.ht);
+ zend_hash_move_forward(Z_ARRVAL_PP(input));
}
}
/* }}} */
@@ -1961,7 +1958,7 @@ PHP_FUNCTION(array_values)
WRONG_PARAM_COUNT;
}
- if ((*input)->type != IS_ARRAY) {
+ if (Z_TYPE_PP(input) != IS_ARRAY) {
php_error(E_WARNING, "Argument to array_values() should be an array");
return;
}
@@ -1970,14 +1967,14 @@ PHP_FUNCTION(array_values)
array_init(return_value);
/* Go through input array and add values to the return array */
- zend_hash_internal_pointer_reset((*input)->value.ht);
- while(zend_hash_get_current_data((*input)->value.ht, (void **)&entry) == SUCCESS) {
+ zend_hash_internal_pointer_reset(Z_ARRVAL_PP(input));
+ while(zend_hash_get_current_data(Z_ARRVAL_PP(input), (void **)&entry) == SUCCESS) {
(*entry)->refcount++;
- zend_hash_next_index_insert(return_value->value.ht, entry,
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), entry,
sizeof(zval *), NULL);
- zend_hash_move_forward((*input)->value.ht);
+ zend_hash_move_forward(Z_ARRVAL_PP(input));
}
}
/* }}} */
@@ -1997,7 +1994,7 @@ PHP_FUNCTION(array_count_values)
WRONG_PARAM_COUNT;
}
- if ((*input)->type != IS_ARRAY) {
+ if (Z_TYPE_PP(input) != IS_ARRAY) {
php_error(E_WARNING, "Argument to array_count_values() should be an array");
return;
}
@@ -2006,33 +2003,33 @@ PHP_FUNCTION(array_count_values)
array_init(return_value);
/* Go through input array and add values to the return array */
- myht = (*input)->value.ht;
+ myht = Z_ARRVAL_PP(input);
zend_hash_internal_pointer_reset(myht);
while (zend_hash_get_current_data(myht, (void **)&entry) == SUCCESS) {
- if ((*entry)->type == IS_LONG) {
- if (zend_hash_index_find(return_value->value.ht,
- (*entry)->value.lval,
+ if (Z_TYPE_PP(entry) == IS_LONG) {
+ if (zend_hash_index_find(Z_ARRVAL_P(return_value),
+ Z_LVAL_PP(entry),
(void**)&tmp) == FAILURE) {
zval *data;
MAKE_STD_ZVAL(data);
- data->type = IS_LONG;
- data->value.lval = 1;
- zend_hash_index_update(return_value->value.ht,(*entry)->value.lval, &data, sizeof(data), NULL);
+ Z_TYPE_P(data) = IS_LONG;
+ Z_LVAL_P(data) = 1;
+ zend_hash_index_update(Z_ARRVAL_P(return_value),Z_LVAL_PP(entry), &data, sizeof(data), NULL);
} else {
- (*tmp)->value.lval++;
+ Z_LVAL_PP(tmp)++;
}
- } else if ((*entry)->type == IS_STRING) {
- if (zend_hash_find(return_value->value.ht,
- (*entry)->value.str.val,
- (*entry)->value.str.len+1,
+ } else if (Z_TYPE_PP(entry) == IS_STRING) {
+ if (zend_hash_find(Z_ARRVAL_P(return_value),
+ Z_STRVAL_PP(entry),
+ Z_STRLEN_PP(entry)+1,
(void**)&tmp) == FAILURE) {
zval *data;
MAKE_STD_ZVAL(data);
- data->type = IS_LONG;
- data->value.lval = 1;
- zend_hash_update(return_value->value.ht,(*entry)->value.str.val,(*entry)->value.str.len + 1, &data, sizeof(data), NULL);
+ Z_TYPE_P(data) = IS_LONG;
+ Z_LVAL_P(data) = 1;
+ zend_hash_update(Z_ARRVAL_P(return_value),Z_STRVAL_PP(entry),Z_STRLEN_PP(entry) + 1, &data, sizeof(data), NULL);
} else {
- (*tmp)->value.lval++;
+ Z_LVAL_PP(tmp)++;
}
} else {
php_error(E_WARNING, "Can only count STRING and INTEGER values!");
@@ -2122,7 +2119,7 @@ PHP_FUNCTION(array_pad)
}
/* Make sure arguments are of the proper type */
- if ((*input)->type != IS_ARRAY) {
+ if (Z_TYPE_PP(input) != IS_ARRAY) {
php_error(E_WARNING, "Argument to %s() should be an array",
get_active_function_name());
return;
@@ -2130,8 +2127,8 @@ PHP_FUNCTION(array_pad)
convert_to_long_ex(pad_size);
/* Do some initial calculations */
- input_size = zend_hash_num_elements((*input)->value.ht);
- pad_size_abs = abs((*pad_size)->value.lval);
+ input_size = zend_hash_num_elements(Z_ARRVAL_PP(input));
+ pad_size_abs = abs(Z_LVAL_PP(pad_size));
do_pad = (input_size >= pad_size_abs) ? 0 : 1;
/* Copy the original array */
@@ -2149,16 +2146,16 @@ PHP_FUNCTION(array_pad)
pads[i] = pad_value;
/* Pad on the right or on the left */
- if ((*pad_size)->value.lval > 0)
- new_hash = php_splice(return_value->value.ht, input_size, 0, pads, num_pads, NULL);
+ if (Z_LVAL_PP(pad_size) > 0)
+ new_hash = php_splice(Z_ARRVAL_P(return_value), input_size, 0, pads, num_pads, NULL);
else
- new_hash = php_splice(return_value->value.ht, 0, 0, pads, num_pads, NULL);
+ new_hash = php_splice(Z_ARRVAL_P(return_value), 0, 0, pads, num_pads, NULL);
/* Copy the result hash into return value */
- zend_hash_destroy(return_value->value.ht);
- efree(return_value->value.ht);
- return_value->value.ht = new_hash;
+ zend_hash_destroy(Z_ARRVAL_P(return_value));
+ efree(Z_ARRVAL_P(return_value));
+ Z_ARRVAL_P(return_value) = new_hash;
/* Clean up */
efree(pads);
@@ -2191,20 +2188,20 @@ PHP_FUNCTION(array_flip)
MAKE_STD_ZVAL(data);
switch (zend_hash_get_current_key(target_hash, &string_key, &num_key)) {
case HASH_KEY_IS_STRING:
- data->value.str.val = string_key;
- data->value.str.len = strlen(string_key);
- data->type = IS_STRING;
+ Z_STRVAL_P(data) = string_key;
+ Z_STRLEN_P(data) = strlen(string_key);
+ Z_TYPE_P(data) = IS_STRING;
break;
case HASH_KEY_IS_LONG:
- data->type = IS_LONG;
- data->value.lval = num_key;
+ Z_TYPE_P(data) = IS_LONG;
+ Z_LVAL_P(data) = num_key;
break;
}
- if ((*entry)->type == IS_LONG) {
- zend_hash_index_update(return_value->value.ht,(*entry)->value.lval, &data, sizeof(data), NULL);
- } else if ((*entry)->type == IS_STRING) {
- zend_hash_update(return_value->value.ht,(*entry)->value.str.val,(*entry)->value.str.len + 1, &data, sizeof(data), NULL);
+ if (Z_TYPE_PP(entry) == IS_LONG) {
+ zend_hash_index_update(Z_ARRVAL_P(return_value),Z_LVAL_PP(entry), &data, sizeof(data), NULL);
+ } else if (Z_TYPE_PP(entry) == IS_STRING) {
+ zend_hash_update(Z_ARRVAL_P(return_value),Z_STRVAL_PP(entry),Z_STRLEN_PP(entry) + 1, &data, sizeof(data), NULL);
} else {
zval_dtor(data);
php_error(E_WARNING, "Can only flip STRING and INTEGER values!");
@@ -2259,9 +2256,9 @@ PHP_FUNCTION(array_unique)
} else {
p = *cmpdata;
if (p->nKeyLength)
- zend_hash_del(return_value->value.ht, p->arKey, p->nKeyLength);
+ zend_hash_del(Z_ARRVAL_P(return_value), p->arKey, p->nKeyLength);
else
- zend_hash_index_del(return_value->value.ht, p->h);
+ zend_hash_index_del(Z_ARRVAL_P(return_value), p->h);
}
}
pefree(arTmp, target_hash->persistent);
@@ -2293,7 +2290,7 @@ PHP_FUNCTION(array_intersect)
ptrs = (Bucket ***)emalloc(argc * sizeof(Bucket **));
set_compare_func(SORT_REGULAR);
for (i=0; i<argc; i++) {
- if ((*args[i])->type != IS_ARRAY) {
+ if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
php_error(E_WARNING, "Argument #%d to array_intersect() is not an array", i+1);
argc = i; /* only free up to i-1 */
goto out;
@@ -2327,9 +2324,9 @@ PHP_FUNCTION(array_intersect)
if (!p)
goto out;
if (p->nKeyLength)
- zend_hash_del(return_value->value.ht, p->arKey, p->nKeyLength);
+ zend_hash_del(Z_ARRVAL_P(return_value), p->arKey, p->nKeyLength);
else
- zend_hash_index_del(return_value->value.ht, p->h);
+ zend_hash_index_del(Z_ARRVAL_P(return_value), p->h);
}
}
if (c)
@@ -2342,9 +2339,9 @@ PHP_FUNCTION(array_intersect)
for (;;) {
p = *ptrs[0];
if (p->nKeyLength)
- zend_hash_del(return_value->value.ht, p->arKey, p->nKeyLength);
+ zend_hash_del(Z_ARRVAL_P(return_value), p->arKey, p->nKeyLength);
else
- zend_hash_index_del(return_value->value.ht, p->h);
+ zend_hash_index_del(Z_ARRVAL_P(return_value), p->h);
if (!*++ptrs[0])
goto out;
if (0 <= array_type_data_compare(ptrs[0], ptrs[i]))
@@ -2398,7 +2395,7 @@ PHP_FUNCTION(array_diff)
ptrs = (Bucket ***)emalloc(argc * sizeof(Bucket **));
set_compare_func(SORT_REGULAR);
for (i=0; i<argc; i++) {
- if ((*args[i])->type != IS_ARRAY) {
+ if (Z_TYPE_PP(args[i]) != IS_ARRAY) {
php_error(E_WARNING, "Argument #%d to array_diff() is not an array", i+1);
argc = i; /* only free up to i-1 */
goto out;
@@ -2438,9 +2435,9 @@ PHP_FUNCTION(array_diff)
for (;;) {
p = *ptrs[0];
if (p->nKeyLength)
- zend_hash_del(return_value->value.ht, p->arKey, p->nKeyLength);
+ zend_hash_del(Z_ARRVAL_P(return_value), p->arKey, p->nKeyLength);
else
- zend_hash_index_del(return_value->value.ht, p->h);
+ zend_hash_index_del(Z_ARRVAL_P(return_value), p->h);
if (!*++ptrs[0])
goto out;
if (array_type_data_compare(ptrs[0]-1, ptrs[0]))
@@ -2486,7 +2483,7 @@ int multisort_compare(const void *a, const void *b)
set_compare_func(ARRAYG(multisort_flags)[MULTISORT_TYPE][r]);
ARRAYG(compare_func)(&temp, *((zval **)ab[r]->pData), *((zval **)bb[r]->pData));
- result = ARRAYG(multisort_flags)[MULTISORT_ORDER][r] * temp.value.lval;
+ result = ARRAYG(multisort_flags)[MULTISORT_ORDER][r] * Z_LVAL(temp);
if (result != 0)
return result;
r++;
@@ -2650,7 +2647,7 @@ PHP_FUNCTION(array_multisort)
taken from zend_hash_sort() function. */
HANDLE_BLOCK_INTERRUPTIONS();
for (i = 0; i < num_arrays; i++) {
- hash = (*arrays[i])->value.ht;
+ hash = Z_ARRVAL_PP(arrays[i]);
hash->pListHead = indirect[0][i];;
hash->pListTail = NULL;
hash->pInternalPointer = hash->pListHead;
diff --git a/ext/standard/base64.c b/ext/standard/base64.c
index c8f037654c..82e35f5efe 100644
--- a/ext/standard/base64.c
+++ b/ext/standard/base64.c
@@ -160,11 +160,9 @@ PHP_FUNCTION(base64_encode) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(str);
- result = php_base64_encode((*str)->value.str.val, (*str)->value.str.len, &ret_length);
+ result = php_base64_encode(Z_STRVAL_PP(str), Z_STRLEN_PP(str), &ret_length);
if (result != NULL) {
- return_value->value.str.val = result;
- return_value->value.str.len = ret_length;
- return_value->type = IS_STRING;
+ RETVAL_STRINGL(result, ret_length, 0);
} else {
RETURN_FALSE;
}
@@ -183,11 +181,9 @@ PHP_FUNCTION(base64_decode) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(str);
- result = php_base64_decode((*str)->value.str.val, (*str)->value.str.len, &ret_length);
+ result = php_base64_decode(Z_STRVAL_PP(str), Z_STRLEN_PP(str), &ret_length);
if (result != NULL) {
- return_value->value.str.val = result;
- return_value->value.str.len = ret_length;
- return_value->type = IS_STRING;
+ RETVAL_STRINGL(result, ret_length, 0);
} else {
RETURN_FALSE;
}
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 8015c6288f..ca00d8abed 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -896,7 +896,7 @@ PHP_FUNCTION(ip2long)
convert_to_string_ex(str);
- RETURN_LONG(ntohl(inet_addr((*str)->value.str.val)));
+ RETURN_LONG(ntohl(inet_addr(Z_STRVAL_PP(str))));
}
/* }}} */
@@ -912,7 +912,7 @@ PHP_FUNCTION(long2ip)
}
convert_to_long_ex(num);
- myaddr.s_addr = htonl((unsigned long)(*num)->value.lval);
+ myaddr.s_addr = htonl((unsigned long)Z_LVAL_PP(num));
RETURN_STRING (inet_ntoa(myaddr), 1);
}
@@ -936,14 +936,14 @@ PHP_FUNCTION(getenv)
}
convert_to_string_ex(str);
- if ((*str)->type != IS_STRING) {
+ if (Z_TYPE_PP(str) != IS_STRING) {
RETURN_FALSE;
}
- ptr = sapi_getenv((*str)->value.str.val, (*str)->value.str.len);
+ ptr = sapi_getenv(Z_STRVAL_PP(str), Z_STRLEN_PP(str));
if (!ptr) {
- ptr = getenv((*str)->value.str.val);
+ ptr = getenv(Z_STRVAL_PP(str));
}
if (ptr) {
RETURN_STRING(ptr, 1);
@@ -966,14 +966,14 @@ PHP_FUNCTION(putenv)
}
convert_to_string_ex(str);
- if ((*str)->value.str.val && *((*str)->value.str.val)) {
+ if (Z_STRVAL_PP(str) && *(Z_STRVAL_PP(str))) {
int ret;
char *p,**env;
putenv_entry pe;
PLS_FETCH();
- pe.putenv_string = estrndup((*str)->value.str.val,(*str)->value.str.len);
- pe.key = estrndup((*str)->value.str.val, (*str)->value.str.len);
+ pe.putenv_string = estrndup(Z_STRVAL_PP(str),Z_STRLEN_PP(str));
+ pe.key = estrndup(Z_STRVAL_PP(str), Z_STRLEN_PP(str));
if ((p=strchr(pe.key,'='))) { /* nullify the '=' if there is one */
*p='\0';
}
@@ -1058,7 +1058,7 @@ PHP_FUNCTION(intval)
WRONG_PARAM_COUNT;
}
convert_to_long_ex(arg_base);
- base = (*arg_base)->value.lval;
+ base = Z_LVAL_PP(arg_base);
break;
default:
WRONG_PARAM_COUNT;
@@ -1117,7 +1117,7 @@ PHP_FUNCTION(sleep)
WRONG_PARAM_COUNT;
}
convert_to_long_ex(num);
- php_sleep((*num)->value.lval);
+ php_sleep(Z_LVAL_PP(num));
}
/* }}} */
@@ -1132,7 +1132,7 @@ PHP_FUNCTION(usleep)
WRONG_PARAM_COUNT;
}
convert_to_long_ex(num);
- usleep((*num)->value.lval);
+ usleep(Z_LVAL_PP(num));
#endif
}
/* }}} */
@@ -1146,7 +1146,7 @@ PHP_FUNCTION(gettype)
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
- switch ((*arg)->type) {
+ switch (Z_TYPE_PP(arg)) {
case IS_NULL:
RETVAL_STRING("NULL",1);
break;
@@ -1200,7 +1200,7 @@ PHP_FUNCTION(settype)
WRONG_PARAM_COUNT;
}
convert_to_string_ex(type);
- new_type = (*type)->value.str.val;
+ new_type = Z_STRVAL_PP(type);
if (!strcasecmp(new_type, "integer")) {
convert_to_long(*var);
@@ -1246,7 +1246,7 @@ PHP_FUNCTION(get_cfg_var)
convert_to_string_ex(varname);
- if (cfg_get_string((*varname)->value.str.val,&value)==FAILURE) {
+ if (cfg_get_string(Z_STRVAL_PP(varname),&value)==FAILURE) {
RETURN_FALSE;
}
RETURN_STRING(value,1);
@@ -1266,7 +1266,7 @@ PHP_FUNCTION(set_magic_quotes_runtime)
}
convert_to_boolean_ex(new_setting);
- PG(magic_quotes_runtime) = (zend_bool) (*new_setting)->value.lval;
+ PG(magic_quotes_runtime) = (zend_bool) Z_LVAL_PP(new_setting);
RETURN_TRUE;
}
/* }}} */
@@ -1299,7 +1299,7 @@ void php_is_type(INTERNAL_FUNCTION_PARAMETERS,int type)
if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &arg)==FAILURE) {
RETURN_FALSE;
}
- if ((*arg)->type == type) {
+ if (Z_TYPE_PP(arg) == type) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -1373,14 +1373,14 @@ PHP_FUNCTION(is_numeric)
WRONG_PARAM_COUNT;
}
- switch ((*arg)->type) {
+ switch (Z_TYPE_PP(arg)) {
case IS_LONG:
case IS_DOUBLE:
RETURN_TRUE;
break;
case IS_STRING:
- result = is_numeric_string((*arg)->value.str.val, (*arg)->value.str.len, NULL, NULL);
+ result = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), NULL, NULL);
if (result == IS_LONG || result == IS_DOUBLE) {
RETURN_TRUE;
} else {
@@ -1429,7 +1429,7 @@ PHP_FUNCTION(error_log)
RETURN_FALSE;
}
convert_to_long_ex(erropt);
- opt_err=(*erropt)->value.lval;
+ opt_err=Z_LVAL_PP(erropt);
break;
case 3:
if (zend_get_parameters_ex(3,&string,&erropt,&option) == FAILURE){
@@ -1437,9 +1437,9 @@ PHP_FUNCTION(error_log)
RETURN_FALSE;
}
convert_to_long_ex(erropt);
- opt_err=(*erropt)->value.lval;
+ opt_err=Z_LVAL_PP(erropt);
convert_to_string_ex(option);
- opt=(*option)->value.str.val;
+ opt=Z_STRVAL_PP(option);
break;
case 4:
if (zend_get_parameters_ex(4,&string,&erropt,&option,&emailhead) == FAILURE){
@@ -1452,18 +1452,18 @@ PHP_FUNCTION(error_log)
}
convert_to_string_ex(string);
- message=(*string)->value.str.val;
+ message=Z_STRVAL_PP(string);
if (erropt != NULL) {
convert_to_long_ex(erropt);
- opt_err=(*erropt)->value.lval;
+ opt_err=Z_LVAL_PP(erropt);
}
if (option != NULL) {
convert_to_string_ex(option);
- opt=(*option)->value.str.val;
+ opt=Z_STRVAL_PP(option);
}
if (emailhead != NULL) {
convert_to_string_ex(emailhead);
- headers=(*emailhead)->value.str.val;
+ headers=Z_STRVAL_PP(emailhead);
}
if (_php_error_log(opt_err,message,opt,headers)==FAILURE) {
@@ -1534,7 +1534,7 @@ PHP_FUNCTION(call_user_func)
&& retval_ptr) {
COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
} else {
- php_error(E_WARNING,"Unable to call %s() - function does not exist", (*params[0])->value.str.val);
+ php_error(E_WARNING,"Unable to call %s() - function does not exist", Z_STRVAL_PP(params[0]));
}
efree(params);
}
@@ -1598,7 +1598,7 @@ PHP_FUNCTION(call_user_method)
efree(params);
RETURN_FALSE;
}
- if ((*params[1])->type != IS_OBJECT) {
+ if (Z_TYPE_PP(params[1]) != IS_OBJECT) {
php_error(E_WARNING,"2nd argument is not an object\n");
efree(params);
RETURN_FALSE;
@@ -1610,7 +1610,7 @@ PHP_FUNCTION(call_user_method)
&& retval_ptr) {
COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
} else {
- php_error(E_WARNING,"Unable to call %s() - function does not exist", (*params[0])->value.str.val);
+ php_error(E_WARNING,"Unable to call %s() - function does not exist", Z_STRVAL_PP(params[0]));
}
efree(params);
}
@@ -1645,7 +1645,7 @@ static int user_shutdown_function_call(php_shutdown_function_entry *shutdown_fun
zval_dtor(&retval);
} else {
php_error(E_WARNING,"Unable to call %s() - function does not exist",
- shutdown_function_entry->arguments[0]->value.str.val);
+ Z_STRVAL_P(shutdown_function_entry->arguments[0]));
}
return 0;
}
@@ -1666,8 +1666,8 @@ static void user_tick_function_call(user_tick_function_entry *tick_fe)
php_error(E_WARNING, "Unable to call %s() - function does not exist",
Z_STRVAL_P(function));
} else if (Z_TYPE_P(function) == IS_ARRAY &&
- zend_hash_index_find(function->value.ht, 0, (void **) &obj) == SUCCESS &&
- zend_hash_index_find(function->value.ht, 1, (void **) &method) == SUCCESS &&
+ zend_hash_index_find(Z_ARRVAL_P(function), 0, (void **) &obj) == SUCCESS &&
+ zend_hash_index_find(Z_ARRVAL_P(function), 1, (void **) &method) == SUCCESS &&
Z_TYPE_PP(obj) == IS_OBJECT &&
Z_TYPE_PP(method) == IS_STRING) {
php_error(E_WARNING, "Unable to call %s::%s() - function does not exist",
@@ -1778,7 +1778,7 @@ PHP_FUNCTION(highlight_file)
php_get_highlight_struct(&syntax_highlighter_ini);
- if (highlight_file((*filename)->value.str.val, &syntax_highlighter_ini)==FAILURE) {
+ if (highlight_file(Z_STRVAL_PP(filename), &syntax_highlighter_ini)==FAILURE) {
RETURN_FALSE;
}
RETURN_TRUE;
@@ -1825,7 +1825,7 @@ pval test_class_get_property(zend_property_reference *property_reference)
for (element=property_reference->elements_list->head; element; element=element->next) {
overloaded_property = (zend_overloaded_element *) element->data;
- switch (overloaded_property->type) {
+ switch (Z_TYPE_P(overloaded_property)) {
case OE_IS_ARRAY:
printf("Array offset: ");
break;
@@ -1833,20 +1833,20 @@ pval test_class_get_property(zend_property_reference *property_reference)
printf("Object property: ");
break;
}
- switch (overloaded_property->element.type) {
+ switch (Z_TYPE(overloaded_property->element)) {
case IS_LONG:
- printf("%ld (numeric)\n", overloaded_property->element.value.lval);
+ printf("%ld (numeric)\n", Z_LVAL(overloaded_property->element));
break;
case IS_STRING:
- printf("'%s'\n", overloaded_property->element.value.str.val);
+ printf("'%s'\n", Z_STRVAL(overloaded_property->element));
break;
}
pval_destructor(&overloaded_property->element);
}
- result.value.str.val = estrndup("testing", 7);
- result.value.str.len = 7;
- result.type = IS_STRING;
+ Z_STRVAL(result) = estrndup("testing", 7);
+ Z_STRLEN(result) = 7;
+ Z_TYPE(result) = IS_STRING;
return result;
}
@@ -1863,7 +1863,7 @@ int test_class_set_property(zend_property_reference *property_reference, pval *v
for (element=property_reference->elements_list->head; element; element=element->next) {
overloaded_property = (zend_overloaded_element *) element->data;
- switch (overloaded_property->type) {
+ switch (Z_TYPE_P(overloaded_property)) {
case OE_IS_ARRAY:
printf("Array offset: ");
break;
@@ -1871,12 +1871,12 @@ int test_class_set_property(zend_property_reference *property_reference, pval *v
printf("Object property: ");
break;
}
- switch (overloaded_property->element.type) {
+ switch (Z_TYPE(overloaded_property->element)) {
case IS_LONG:
- printf("%ld (numeric)\n", overloaded_property->element.value.lval);
+ printf("%ld (numeric)\n", Z_LVAL(overloaded_property->element));
break;
case IS_STRING:
- printf("'%s'\n", overloaded_property->element.value.str.val);
+ printf("'%s'\n", Z_STRVAL(overloaded_property->element));
break;
}
pval_destructor(&overloaded_property->element);
@@ -1897,7 +1897,7 @@ void test_class_call_function(INTERNAL_FUNCTION_PARAMETERS, zend_property_refere
for (element=property_reference->elements_list->head; element; element=element->next) {
overloaded_property = (zend_overloaded_element *) element->data;
- switch (overloaded_property->type) {
+ switch (Z_TYPE_P(overloaded_property)) {
case OE_IS_ARRAY:
printf("Array offset: ");
break;
@@ -1907,21 +1907,19 @@ void test_class_call_function(INTERNAL_FUNCTION_PARAMETERS, zend_property_refere
case OE_IS_METHOD:
printf("Overloaded method: ");
}
- switch (overloaded_property->element.type) {
+ switch (Z_TYPE(overloaded_property->element)) {
case IS_LONG:
- printf("%ld (numeric)\n", overloaded_property->element.value.lval);
+ printf("%ld (numeric)\n", Z_LVAL(overloaded_property->element));
break;
case IS_STRING:
- printf("'%s'\n", overloaded_property->element.value.str.val);
+ printf("'%s'\n", Z_STRVAL(overloaded_property->element));
break;
}
pval_destructor(&overloaded_property->element);
}
printf("%d arguments\n", ZEND_NUM_ARGS());
- return_value->value.str.val = estrndup("testing", 7);
- return_value->value.str.len = 7;
- return_value->type = IS_STRING;
+ RETVAL_STRING("testing", 1);
}
@@ -1950,7 +1948,7 @@ PHP_FUNCTION(ini_get)
convert_to_string_ex(varname);
- str = php_ini_string((*varname)->value.str.val, (*varname)->value.str.len+1, 0);
+ str = php_ini_string(Z_STRVAL_PP(varname), Z_STRLEN_PP(varname)+1, 0);
if (!str) {
RETURN_FALSE;
@@ -1974,7 +1972,7 @@ PHP_FUNCTION(ini_set)
convert_to_string_ex(varname);
convert_to_string_ex(new_value);
- old_value = php_ini_string((*varname)->value.str.val, (*varname)->value.str.len+1, 0);
+ old_value = php_ini_string(Z_STRVAL_PP(varname), Z_STRLEN_PP(varname)+1, 0);
/* copy to return here, because alter might free it! */
if (old_value) {
RETVAL_STRING(old_value, 1);
@@ -1982,7 +1980,7 @@ PHP_FUNCTION(ini_set)
RETVAL_FALSE;
}
- if (zend_alter_ini_entry((*varname)->value.str.val, (*varname)->value.str.len+1, (*new_value)->value.str.val, (*new_value)->value.str.len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME)==FAILURE) {
+ if (zend_alter_ini_entry(Z_STRVAL_PP(varname), Z_STRLEN_PP(varname)+1, Z_STRVAL_PP(new_value), Z_STRLEN_PP(new_value), PHP_INI_USER, PHP_INI_STAGE_RUNTIME)==FAILURE) {
zval_dtor(return_value);
RETURN_FALSE;
}
@@ -2001,7 +1999,7 @@ PHP_FUNCTION(ini_restore)
convert_to_string_ex(varname);
- zend_restore_ini_entry((*varname)->value.str.val, (*varname)->value.str.len+1, PHP_INI_STAGE_RUNTIME);
+ zend_restore_ini_entry(Z_STRVAL_PP(varname), Z_STRLEN_PP(varname)+1, PHP_INI_STAGE_RUNTIME);
}
/* }}} */
@@ -2071,7 +2069,7 @@ PHP_FUNCTION(ignore_user_abort)
RETURN_FALSE;
}
convert_to_boolean_ex(arg);
- PG(ignore_user_abort) = (zend_bool) (*arg)->value.lval;
+ PG(ignore_user_abort) = (zend_bool) Z_LVAL_PP(arg);
break;
default:
WRONG_PARAM_COUNT;
@@ -2094,7 +2092,7 @@ PHP_FUNCTION(getservbyname)
convert_to_string_ex(name);
convert_to_string_ex(proto);
- serv = getservbyname((*name)->value.str.val,(*proto)->value.str.val);
+ serv = getservbyname(Z_STRVAL_PP(name),Z_STRVAL_PP(proto));
if(serv == NULL)
RETURN_FALSE;
@@ -2117,7 +2115,7 @@ PHP_FUNCTION(getservbyport)
convert_to_long_ex(port);
convert_to_string_ex(proto);
- serv = getservbyport(htons((unsigned short) (*port)->value.lval),(*proto)->value.str.val);
+ serv = getservbyport(htons((unsigned short) Z_LVAL_PP(port)),Z_STRVAL_PP(proto));
if(serv == NULL)
RETURN_FALSE;
@@ -2140,11 +2138,11 @@ PHP_FUNCTION(getprotobyname)
convert_to_string_ex(name);
- ent = getprotobyname((*name)->value.str.val);
+ ent = getprotobyname(Z_STRVAL_PP(name));
if(ent == NULL) {
- return_value->value.lval = -1;
- return_value->type = IS_LONG;
+ Z_LVAL_P(return_value) = -1;
+ Z_TYPE_P(return_value) = IS_LONG;
return;
}
@@ -2166,7 +2164,7 @@ PHP_FUNCTION(getprotobynumber)
convert_to_long_ex(proto);
- ent = getprotobynumber((*proto)->value.lval);
+ ent = getprotobynumber(Z_LVAL_PP(proto));
if(ent == NULL)
RETURN_FALSE;
@@ -2208,7 +2206,7 @@ PHP_FUNCTION(extension_loaded)
}
convert_to_string_ex(extension_name);
- if (zend_hash_exists(&module_registry, (*extension_name)->value.str.val, (*extension_name)->value.str.len+1)) {
+ if (zend_hash_exists(&module_registry, Z_STRVAL_PP(extension_name), Z_STRLEN_PP(extension_name)+1)) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -2230,8 +2228,8 @@ PHP_FUNCTION(get_extension_funcs)
}
convert_to_string_ex(extension_name);
- if (zend_hash_find(&module_registry, (*extension_name)->value.str.val,
- (*extension_name)->value.str.len+1, (void**)&module) == FAILURE) {
+ if (zend_hash_find(&module_registry, Z_STRVAL_PP(extension_name),
+ Z_STRLEN_PP(extension_name)+1, (void**)&module) == FAILURE) {
return;
}
@@ -2392,7 +2390,7 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, int callback_type,
*element = *arg2;
zval_copy_ctor(element);
INIT_PZVAL(element);
- zend_hash_update(arr->value.ht, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL);
+ zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL);
break;
case ZEND_INI_PARSER_SECTION:
break;
@@ -2418,13 +2416,13 @@ static void php_ini_parser_cb_with_sections(zval *arg1, zval *arg2, int callback
*element = *arg2;
zval_copy_ctor(element);
INIT_PZVAL(element);
- zend_hash_update(active_arr->value.ht, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL);
+ zend_hash_update(Z_ARRVAL_P(active_arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL);
}
break;
case ZEND_INI_PARSER_SECTION:
MAKE_STD_ZVAL(BG(active_ini_file_section));
array_init(BG(active_ini_file_section));
- zend_hash_update(arr->value.ht, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &BG(active_ini_file_section), sizeof(zval *), NULL);
+ zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &BG(active_ini_file_section), sizeof(zval *), NULL);
break;
}
}
@@ -2467,10 +2465,10 @@ PHP_FUNCTION(parse_ini_file)
convert_to_string_ex(filename);
fh.handle.fp = V_FOPEN(Z_STRVAL_PP(filename), "r");
if (!fh.handle.fp) {
- php_error(E_WARNING,"Cannot open '%s' for reading", (*filename)->value.str.val);
+ php_error(E_WARNING,"Cannot open '%s' for reading", Z_STRVAL_PP(filename));
return;
}
- fh.type = ZEND_HANDLE_FP;
+ Z_TYPE(fh) = ZEND_HANDLE_FP;
fh.filename = Z_STRVAL_PP(filename);
array_init(return_value);
zend_parse_ini_file(&fh, 0, ini_parser_cb, return_value);
diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c
index 5ca0fa11f5..3c1172d381 100644
--- a/ext/standard/crypt.c
+++ b/ext/standard/crypt.c
@@ -169,10 +169,7 @@ PHP_FUNCTION(crypt)
#endif
}
- return_value->value.str.val = (char *) crypt(Z_STRVAL_PP(arg1), salt);
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
- pval_copy_constructor(return_value);
+ RETVAL_STRING(crypt(Z_STRVAL_PP(arg1), salt), 1);
}
/* }}} */
#endif
diff --git a/ext/standard/dns.c b/ext/standard/dns.c
index ac366126ba..2787e87f4c 100644
--- a/ext/standard/dns.c
+++ b/ext/standard/dns.c
@@ -62,9 +62,7 @@ PHP_FUNCTION(gethostbyaddr)
}
convert_to_string_ex(arg);
- return_value->value.str.val = php_gethostbyaddr((*arg)->value.str.val);
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
+ RETVAL_STRING(php_gethostbyaddr(Z_STRVAL_PP(arg)), 0);
}
/* }}} */
@@ -102,9 +100,7 @@ PHP_FUNCTION(gethostbyname)
}
convert_to_string_ex(arg);
- return_value->value.str.val = php_gethostbyname((*arg)->value.str.val);
- return_value->value.str.len = strlen(return_value->value.str.val);
- return_value->type = IS_STRING;
+ RETVAL_STRING(php_gethostbyname(Z_STRVAL_PP(arg)), 0);
}
/* }}} */
@@ -126,10 +122,10 @@ PHP_FUNCTION(gethostbynamel)
RETURN_FALSE;
}
- hp = gethostbyname((*arg)->value.str.val);
+ hp = gethostbyname(Z_STRVAL_PP(arg));
if (hp == NULL || hp->h_addr_list == NULL) {
#if PHP_DEBUG
- php_error(E_WARNING, "Unable to resolve %s\n", (*arg)->value.str.val);
+ php_error(E_WARNING, "Unable to resolve %s\n", Z_STRVAL_PP(arg));
#endif
return;
}
@@ -186,22 +182,22 @@ PHP_FUNCTION(checkdnsrr)
}
convert_to_string_ex(arg1);
convert_to_string_ex(arg2);
- if ( !strcasecmp("A",(*arg2)->value.str.val) ) type = T_A;
- else if ( !strcasecmp("NS",(*arg2)->value.str.val) ) type = T_NS;
- else if ( !strcasecmp("MX",(*arg2)->value.str.val) ) type = T_MX;
- else if ( !strcasecmp("PTR",(*arg2)->value.str.val) ) type = T_PTR;
- else if ( !strcasecmp("ANY",(*arg2)->value.str.val) ) type = T_ANY;
- else if ( !strcasecmp("SOA",(*arg2)->value.str.val) ) type = T_SOA;
- else if ( !strcasecmp("CNAME",(*arg2)->value.str.val) ) type = T_CNAME;
+ if ( !strcasecmp("A",Z_STRVAL_PP(arg2)) ) type = T_A;
+ else if ( !strcasecmp("NS",Z_STRVAL_PP(arg2)) ) type = T_NS;
+ else if ( !strcasecmp("MX",Z_STRVAL_PP(arg2)) ) type = T_MX;
+ else if ( !strcasecmp("PTR",Z_STRVAL_PP(arg2)) ) type = T_PTR;
+ else if ( !strcasecmp("ANY",Z_STRVAL_PP(arg2)) ) type = T_ANY;
+ else if ( !strcasecmp("SOA",Z_STRVAL_PP(arg2)) ) type = T_SOA;
+ else if ( !strcasecmp("CNAME",Z_STRVAL_PP(arg2)) ) type = T_CNAME;
else {
- php_error(E_WARNING,"Type '%s' not supported",(*arg2)->value.str.val);
+ php_error(E_WARNING,"Type '%s' not supported",Z_STRVAL_PP(arg2));
RETURN_FALSE;
}
break;
default:
WRONG_PARAM_COUNT;
}
- i = res_search((*arg1)->value.str.val,C_IN,type,ans,sizeof(ans));
+ i = res_search(Z_STRVAL_PP(arg1),C_IN,type,ans,sizeof(ans));
if ( i < 0 ) {
RETURN_FALSE;
}
@@ -270,7 +266,7 @@ PHP_FUNCTION(getmxrr)
}
/* Go! */
- i = res_search(host->value.str.val,C_IN,T_MX,(u_char *)&ans,sizeof(ans));
+ i = res_search(Z_STRVAL_P(host),C_IN,T_MX,(u_char *)&ans,sizeof(ans));
if ( i < 0 ) {
RETURN_FALSE;
}
diff --git a/ext/standard/exec.c b/ext/standard/exec.c
index 088f856d18..1adaa2b2e6 100644
--- a/ext/standard/exec.c
+++ b/ext/standard/exec.c
@@ -111,7 +111,7 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value)
}
buf[0] = '\0';
if (type==2) {
- if (array->type != IS_ARRAY) {
+ if (Z_TYPE_P(array) != IS_ARRAY) {
pval_destructor(array);
array_init(array);
}
@@ -209,13 +209,13 @@ PHP_FUNCTION(exec)
}
switch (arg_count) {
case 1:
- ret = _Exec(0, (*arg1)->value.str.val, NULL,return_value);
+ ret = _Exec(0, Z_STRVAL_PP(arg1), NULL,return_value);
break;
case 2:
if (!ParameterPassedByReference(ht,2)) {
php_error(E_WARNING,"Array argument to exec() not passed by reference");
}
- ret = _Exec(2, (*arg1)->value.str.val,*arg2,return_value);
+ ret = _Exec(2, Z_STRVAL_PP(arg1),*arg2,return_value);
break;
case 3:
if (!ParameterPassedByReference(ht,2)) {
@@ -224,9 +224,9 @@ PHP_FUNCTION(exec)
if (!ParameterPassedByReference(ht,3)) {
php_error(E_WARNING,"return_status argument to exec() not passed by reference");
}
- ret = _Exec(2,(*arg1)->value.str.val,*arg2,return_value);
- (*arg3)->type = IS_LONG;
- (*arg3)->value.lval=ret;
+ ret = _Exec(2,Z_STRVAL_PP(arg1),*arg2,return_value);
+ Z_TYPE_PP(arg3) = IS_LONG;
+ Z_LVAL_PP(arg3)=ret;
break;
}
}
@@ -246,15 +246,15 @@ PHP_FUNCTION(system)
}
switch (arg_count) {
case 1:
- ret = _Exec(1, (*arg1)->value.str.val, NULL,return_value);
+ ret = _Exec(1, Z_STRVAL_PP(arg1), NULL,return_value);
break;
case 2:
if (!ParameterPassedByReference(ht,2)) {
php_error(E_WARNING,"return_status argument to system() not passed by reference");
}
- ret = _Exec(1, (*arg1)->value.str.val, NULL,return_value);
- (*arg2)->type = IS_LONG;
- (*arg2)->value.lval=ret;
+ ret = _Exec(1, Z_STRVAL_PP(arg1), NULL,return_value);
+ Z_TYPE_PP(arg2) = IS_LONG;
+ Z_LVAL_PP(arg2)=ret;
break;
}
}
@@ -273,15 +273,15 @@ PHP_FUNCTION(passthru)
}
switch (arg_count) {
case 1:
- ret = _Exec(3, (*arg1)->value.str.val, NULL,return_value);
+ ret = _Exec(3, Z_STRVAL_PP(arg1), NULL,return_value);
break;
case 2:
if (!ParameterPassedByReference(ht,2)) {
php_error(E_WARNING,"return_status argument to system() not passed by reference");
}
- ret = _Exec(3, (*arg1)->value.str.val, NULL,return_value);
- (*arg2)->type = IS_LONG;
- (*arg2)->value.lval=ret;
+ ret = _Exec(3, Z_STRVAL_PP(arg1), NULL,return_value);
+ Z_TYPE_PP(arg2) = IS_LONG;
+ Z_LVAL_PP(arg2)=ret;
break;
}
}
@@ -363,8 +363,8 @@ PHP_FUNCTION(escapeshellcmd)
}
convert_to_string_ex(arg1);
- if ((*arg1)->value.str.len) {
- cmd = php_escape_shell_cmd((*arg1)->value.str.val);
+ if (Z_STRLEN_PP(arg1)) {
+ cmd = php_escape_shell_cmd(Z_STRVAL_PP(arg1));
RETVAL_STRING(cmd, 1);
efree(cmd);
}
@@ -383,8 +383,8 @@ PHP_FUNCTION(escapeshellarg)
}
convert_to_string_ex(arg1);
- if ((*arg1)->value.str.len) {
- cmd = php_escape_shell_arg((*arg1)->value.str.val);
+ if (Z_STRLEN_PP(arg1)) {
+ cmd = php_escape_shell_arg(Z_STRVAL_PP(arg1));
RETVAL_STRING(cmd, 1);
efree(cmd);
}
@@ -398,6 +398,7 @@ PHP_FUNCTION(shell_exec)
FILE *in;
int readbytes,total_readbytes=0,allocated_space;
pval **cmd;
+ char *ret;
PLS_FETCH();
if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1,&cmd)==FAILURE) {
@@ -411,29 +412,27 @@ PHP_FUNCTION(shell_exec)
convert_to_string_ex(cmd);
#ifdef PHP_WIN32
- if ((in=V_POPEN((*cmd)->value.str.val,"rt"))==NULL) {
+ if ((in=V_POPEN(Z_STRVAL_PP(cmd),"rt"))==NULL) {
#else
- if ((in=V_POPEN((*cmd)->value.str.val,"r"))==NULL) {
+ if ((in=V_POPEN(Z_STRVAL_PP(cmd),"r"))==NULL) {
#endif
- php_error(E_WARNING,"Unable to execute '%s'",(*cmd)->value.str.val);
+ php_error(E_WARNING,"Unable to execute '%s'",Z_STRVAL_PP(cmd));
}
allocated_space = EXEC_INPUT_BUF;
- return_value->value.str.val = (char *) emalloc(allocated_space);
+ ret = (char *) emalloc(allocated_space);
while (1) {
- readbytes = fread(return_value->value.str.val+total_readbytes,1,EXEC_INPUT_BUF,in);
+ readbytes = fread(ret+total_readbytes,1,EXEC_INPUT_BUF,in);
if (readbytes<=0) {
break;
}
total_readbytes += readbytes;
allocated_space = total_readbytes+EXEC_INPUT_BUF;
- return_value->value.str.val = (char *) erealloc(return_value->value.str.val,allocated_space);
+ ret = (char *) erealloc(ret,allocated_space);
}
pclose(in);
-
- return_value->value.str.val = erealloc(return_value->value.str.val,total_readbytes+1);
- return_value->value.str.val[total_readbytes]=0;
- return_value->value.str.len = total_readbytes;
- return_value->type = IS_STRING;
+
+ RETVAL_STRINGL(ret, total_readbytes, 0);
+ Z_STRVAL_P(return_value)[total_readbytes] = '\0';
}
/* }}} */