summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend_operators.h2
-rw-r--r--ext/standard/assert.c91
-rw-r--r--ext/standard/browscap.c200
-rw-r--r--ext/standard/crypt.c7
-rw-r--r--ext/standard/cyr_convert.c3
-rw-r--r--ext/standard/dir.c50
-rw-r--r--ext/standard/dns.c132
-rw-r--r--ext/standard/exec.c11
-rw-r--r--ext/standard/file.c236
-rw-r--r--ext/standard/filestat.c132
-rw-r--r--ext/standard/formatted_print.c248
-rw-r--r--ext/standard/fsock.c5
-rw-r--r--ext/standard/ftp_fopen_wrapper.c18
-rw-r--r--ext/standard/head.c4
-rw-r--r--ext/standard/html.c93
-rw-r--r--ext/standard/html.h6
-rw-r--r--ext/standard/http_fopen_wrapper.c163
-rw-r--r--ext/standard/image.c54
-rw-r--r--ext/standard/incomplete_class.c65
-rw-r--r--ext/standard/info.c103
-rw-r--r--ext/standard/info.h2
-rw-r--r--ext/standard/iptc.c14
-rw-r--r--ext/standard/link.c2
-rw-r--r--ext/standard/math.c160
-rw-r--r--ext/standard/md5.c10
-rw-r--r--ext/standard/metaphone.c20
-rw-r--r--ext/standard/microtime.c2
-rw-r--r--ext/standard/pack.c62
-rw-r--r--ext/standard/php_filestat.h5
-rw-r--r--ext/standard/php_incomplete_class.h16
-rw-r--r--ext/standard/php_math.h8
-rw-r--r--ext/standard/php_var.h8
-rw-r--r--ext/standard/quot_print.c48
-rw-r--r--ext/standard/quot_print.h4
-rw-r--r--ext/standard/scanf.c95
-rw-r--r--ext/standard/scanf.h4
-rw-r--r--ext/standard/sha1.c8
-rw-r--r--ext/standard/soundex.c2
-rw-r--r--ext/standard/string.c4
-rw-r--r--ext/standard/type.c63
-rw-r--r--ext/standard/uniqid.c3
-rw-r--r--ext/standard/url.c78
-rw-r--r--ext/standard/url_scanner_ex.c7
-rw-r--r--ext/standard/url_scanner_ex.re5
-rw-r--r--ext/standard/var.c292
-rw-r--r--main/main.c30
-rw-r--r--main/php_streams.h4
-rw-r--r--main/streams/php_stream_context.h2
48 files changed, 1256 insertions, 1325 deletions
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h
index 31701a98e0..a6640075fd 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -433,7 +433,7 @@ END_EXTERN_C()
if (!Z_ISREF_P(pzv)) { \
SEPARATE_ZVAL(pzv); \
} \
- convert_scalar_to_number(ppzv TSRMLS_CC); \
+ convert_scalar_to_number(pzv TSRMLS_CC); \
}
#if HAVE_SETLOCALE && defined(ZEND_WIN32) && !defined(ZTS) && defined(_MSC_VER) && (_MSC_VER >= 1400)
diff --git a/ext/standard/assert.c b/ext/standard/assert.c
index a9567f3b0a..7791dafd43 100644
--- a/ext/standard/assert.c
+++ b/ext/standard/assert.c
@@ -29,7 +29,7 @@ ZEND_BEGIN_MODULE_GLOBALS(assert)
long bail;
long warning;
long quiet_eval;
- zval *callback;
+ zval callback;
char *cb;
ZEND_END_MODULE_GLOBALS(assert)
@@ -54,13 +54,12 @@ enum {
static PHP_INI_MH(OnChangeCallback) /* {{{ */
{
if (EG(in_execution)) {
- if (ASSERTG(callback)) {
+ if (Z_TYPE(ASSERTG(callback)) != IS_UNDEF) {
zval_ptr_dtor(&ASSERTG(callback));
- ASSERTG(callback) = NULL;
+ ZVAL_UNDEF(&ASSERTG(callback));
}
- if (new_value && (ASSERTG(callback) || new_value_length)) {
- MAKE_STD_ZVAL(ASSERTG(callback));
- ZVAL_STRINGL(ASSERTG(callback), new_value, new_value_length, 1);
+ if (new_value && (Z_TYPE(ASSERTG(callback)) != IS_UNDEF || new_value_length)) {
+ ZVAL_STRINGL(&ASSERTG(callback), new_value, new_value_length);
}
} else {
if (ASSERTG(cb)) {
@@ -88,7 +87,7 @@ PHP_INI_END()
static void php_assert_init_globals(zend_assert_globals *assert_globals_p TSRMLS_DC) /* {{{ */
{
- assert_globals_p->callback = NULL;
+ ZVAL_UNDEF(&assert_globals_p->callback);
assert_globals_p->cb = NULL;
}
/* }}} */
@@ -121,9 +120,9 @@ PHP_MSHUTDOWN_FUNCTION(assert) /* {{{ */
PHP_RSHUTDOWN_FUNCTION(assert) /* {{{ */
{
- if (ASSERTG(callback)) {
+ if (Z_TYPE(ASSERTG(callback)) != IS_UNDEF) {
zval_ptr_dtor(&ASSERTG(callback));
- ASSERTG(callback) = NULL;
+ ZVAL_UNDEF(&ASSERTG(callback));
}
return SUCCESS;
@@ -140,7 +139,7 @@ PHP_MINFO_FUNCTION(assert) /* {{{ */
Checks if assertion is false */
PHP_FUNCTION(assert)
{
- zval **assertion;
+ zval *assertion;
int val, description_len = 0;
char *myeval = NULL;
char *compiled_string_description, *description = NULL;
@@ -149,15 +148,15 @@ PHP_FUNCTION(assert)
RETURN_TRUE;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|s", &assertion, &description, &description_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|s", &assertion, &description, &description_len) == FAILURE) {
return;
}
- if (Z_TYPE_PP(assertion) == IS_STRING) {
+ if (Z_TYPE_P(assertion) == IS_STRING) {
zval retval;
int old_error_reporting = 0; /* shut up gcc! */
- myeval = Z_STRVAL_PP(assertion);
+ myeval = Z_STRVAL_P(assertion);
if (ASSERTG(quiet_eval)) {
old_error_reporting = EG(error_reporting);
@@ -165,7 +164,7 @@ PHP_FUNCTION(assert)
}
compiled_string_description = zend_make_compiled_string_description("assert code" TSRMLS_CC);
- if (zend_eval_stringl(myeval, Z_STRLEN_PP(assertion), &retval, compiled_string_description TSRMLS_CC) == FAILURE) {
+ if (zend_eval_stringl(myeval, Z_STRLEN_P(assertion), &retval, compiled_string_description TSRMLS_CC) == FAILURE) {
efree(compiled_string_description);
if (description_len == 0) {
php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Failure evaluating code: %s%s", PHP_EOL, myeval);
@@ -187,47 +186,40 @@ PHP_FUNCTION(assert)
val = Z_LVAL(retval);
} else {
convert_to_boolean_ex(assertion);
- val = Z_LVAL_PP(assertion);
+ val = Z_LVAL_P(assertion);
}
if (val) {
RETURN_TRUE;
}
- if (!ASSERTG(callback) && ASSERTG(cb)) {
- MAKE_STD_ZVAL(ASSERTG(callback));
- ZVAL_STRING(ASSERTG(callback), ASSERTG(cb), 1);
+ if (Z_TYPE(ASSERTG(callback)) == IS_UNDEF && ASSERTG(cb)) {
+ ZVAL_STRING(&ASSERTG(callback), ASSERTG(cb));
}
- if (ASSERTG(callback)) {
- zval **args = safe_emalloc(description_len == 0 ? 3 : 4, sizeof(zval *), 0);
- zval *retval;
+ if (Z_TYPE(ASSERTG(callback)) != IS_UNDEF) {
+ zval *args = safe_emalloc(description_len == 0 ? 3 : 4, sizeof(zval), 0);
+ zval retval;
int i;
uint lineno = zend_get_executed_lineno(TSRMLS_C);
const char *filename = zend_get_executed_filename(TSRMLS_C);
- MAKE_STD_ZVAL(args[0]);
- MAKE_STD_ZVAL(args[1]);
- MAKE_STD_ZVAL(args[2]);
-
- ZVAL_STRING(args[0], SAFE_STRING(filename), 1);
- ZVAL_LONG (args[1], lineno);
- ZVAL_STRING(args[2], SAFE_STRING(myeval), 1);
+ ZVAL_STRING(&args[0], SAFE_STRING(filename));
+ ZVAL_LONG (&args[1], lineno);
+ ZVAL_STRING(&args[2], SAFE_STRING(myeval));
- MAKE_STD_ZVAL(retval);
- ZVAL_FALSE(retval);
+ ZVAL_FALSE(&retval);
/* XXX do we want to check for error here? */
if (description_len == 0) {
- call_user_function(CG(function_table), NULL, ASSERTG(callback), retval, 3, args TSRMLS_CC);
+ call_user_function(CG(function_table), NULL, &ASSERTG(callback), &retval, 3, args TSRMLS_CC);
for (i = 0; i <= 2; i++) {
zval_ptr_dtor(&(args[i]));
}
} else {
- MAKE_STD_ZVAL(args[3]);
- ZVAL_STRINGL(args[3], SAFE_STRING(description), description_len, 1);
+ ZVAL_STRINGL(&args[3], SAFE_STRING(description), description_len);
- call_user_function(CG(function_table), NULL, ASSERTG(callback), retval, 4, args TSRMLS_CC);
+ call_user_function(CG(function_table), NULL, &ASSERTG(callback), &retval, 4, args TSRMLS_CC);
for (i = 0; i <= 3; i++) {
zval_ptr_dtor(&(args[i]));
}
@@ -263,12 +255,13 @@ PHP_FUNCTION(assert)
Set/get the various assert flags */
PHP_FUNCTION(assert_options)
{
- zval **value = NULL;
+ zval *value = NULL;
long what;
int oldint;
int ac = ZEND_NUM_ARGS();
+ zend_string *key;
- if (zend_parse_parameters(ac TSRMLS_CC, "l|Z", &what, &value) == FAILURE) {
+ if (zend_parse_parameters(ac TSRMLS_CC, "l|z", &what, &value) == FAILURE) {
return;
}
@@ -277,7 +270,9 @@ PHP_FUNCTION(assert_options)
oldint = ASSERTG(active);
if (ac == 2) {
convert_to_string_ex(value);
- zend_alter_ini_entry_ex("assert.active", sizeof("assert.active"), Z_STRVAL_PP(value), Z_STRLEN_PP(value), PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
+ key = STR_INIT("assert.active", sizeof("assert.active")-1, 0);
+ zend_alter_ini_entry_ex(key, Z_STRVAL_P(value), Z_STRLEN_P(value), PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
+ STR_RELEASE(key);
}
RETURN_LONG(oldint);
break;
@@ -286,7 +281,9 @@ PHP_FUNCTION(assert_options)
oldint = ASSERTG(bail);
if (ac == 2) {
convert_to_string_ex(value);
- zend_alter_ini_entry_ex("assert.bail", sizeof("assert.bail"), Z_STRVAL_PP(value), Z_STRLEN_PP(value), PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
+ key = STR_INIT("assert.bail", sizeof("assert.bail")-1, 0);
+ zend_alter_ini_entry_ex(key, Z_STRVAL_P(value), Z_STRLEN_P(value), PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
+ STR_RELEASE(key);
}
RETURN_LONG(oldint);
break;
@@ -295,7 +292,9 @@ PHP_FUNCTION(assert_options)
oldint = ASSERTG(quiet_eval);
if (ac == 2) {
convert_to_string_ex(value);
- zend_alter_ini_entry_ex("assert.quiet_eval", sizeof("assert.quiet_eval"), Z_STRVAL_PP(value), Z_STRLEN_PP(value), PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
+ key = STR_INIT("assert.quiet_eval", sizeof("assert.quiet_eval")-1, 0);
+ zend_alter_ini_entry_ex(key, Z_STRVAL_P(value), Z_STRLEN_P(value), PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
+ STR_RELEASE(key);
}
RETURN_LONG(oldint);
break;
@@ -304,23 +303,23 @@ PHP_FUNCTION(assert_options)
oldint = ASSERTG(warning);
if (ac == 2) {
convert_to_string_ex(value);
- zend_alter_ini_entry_ex("assert.warning", sizeof("assert.warning"), Z_STRVAL_PP(value), Z_STRLEN_PP(value), PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
+ key = STR_INIT("assert.warning", sizeof("assert.warning")-1, 0);
+ zend_alter_ini_entry_ex(key, Z_STRVAL_P(value), Z_STRLEN_P(value), PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
+ STR_RELEASE(key);
}
RETURN_LONG(oldint);
break;
case ASSERT_CALLBACK:
- if (ASSERTG(callback) != NULL) {
- RETVAL_ZVAL(ASSERTG(callback), 1, 0);
+ if (Z_TYPE(ASSERTG(callback)) != IS_UNDEF) {
+ RETVAL_ZVAL(&ASSERTG(callback), 1, 0);
} else if (ASSERTG(cb)) {
- RETVAL_STRING(ASSERTG(cb), 1);
+ RETVAL_STRING(ASSERTG(cb));
} else {
RETVAL_NULL();
}
if (ac == 2) {
- if (ASSERTG(callback)) {
- zval_ptr_dtor(&ASSERTG(callback));
- }
+ zval_ptr_dtor(&ASSERTG(callback));
ASSERTG(callback) = *value;
zval_add_ref(value);
}
diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c
index 241c9a7dc2..0ce985a1db 100644
--- a/ext/standard/browscap.c
+++ b/ext/standard/browscap.c
@@ -29,7 +29,7 @@
typedef struct {
HashTable *htab;
- zval *current_section;
+ zval current_section;
char *current_section_name;
char filename[MAXPATHLEN];
} browser_data;
@@ -55,30 +55,24 @@ ZEND_DECLARE_MODULE_GLOBALS(browscap)
/* OBJECTS_FIXME: This whole extension needs going through. The use of objects looks pretty broken here */
-static void browscap_entry_dtor_request(zval **zvalue) /* {{{ */
+static void browscap_entry_dtor_request(zval *zvalue) /* {{{ */
{
- if (Z_TYPE_PP(zvalue) == IS_ARRAY) {
- zend_hash_destroy(Z_ARRVAL_PP(zvalue));
- efree(Z_ARRVAL_PP(zvalue));
- } else if (Z_TYPE_PP(zvalue) == IS_STRING) {
- if (Z_STRVAL_PP(zvalue)) {
- efree(Z_STRVAL_PP(zvalue));
- }
+ if (Z_TYPE_P(zvalue) == IS_ARRAY) {
+ zend_hash_destroy(Z_ARRVAL_P(zvalue));
+ efree(Z_ARR_P(zvalue));
+ } else if (Z_TYPE_P(zvalue) == IS_STRING) {
+ STR_RELEASE(Z_STR_P(zvalue));
}
- efree(*zvalue);
}
/* }}} */
-static void browscap_entry_dtor_persistent(zval **zvalue) /* {{{ */ {
- if (Z_TYPE_PP(zvalue) == IS_ARRAY) {
- zend_hash_destroy(Z_ARRVAL_PP(zvalue));
- free(Z_ARRVAL_PP(zvalue));
- } else if (Z_TYPE_PP(zvalue) == IS_STRING) {
- if (Z_STRVAL_PP(zvalue)) {
- free(Z_STRVAL_PP(zvalue));
- }
+static void browscap_entry_dtor_persistent(zval *zvalue) /* {{{ */ {
+ if (Z_TYPE_P(zvalue) == IS_ARRAY) {
+ zend_hash_destroy(Z_ARRVAL_P(zvalue));
+ free(Z_ARR_P(zvalue));
+ } else if (Z_TYPE_P(zvalue) == IS_STRING) {
+ STR_RELEASE(Z_STR_P(zvalue));
}
- free(*zvalue);
}
/* }}} */
@@ -86,10 +80,14 @@ static void convert_browscap_pattern(zval *pattern, int persistent) /* {{{ */
{
int i, j=0;
char *t;
+ zend_string *res;
- php_strtolower(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern));
+ // TODO: overflow check???
+//??? t = (char *) safe_pemalloc(Z_STRLEN_P(pattern), 2, 5, persistent);
+ res = STR_ALLOC(Z_STRLEN_P(pattern) * 2 + 5, persistent);
+ t = res->val;
- t = (char *) safe_pemalloc(Z_STRLEN_P(pattern), 2, 5, persistent);
+ php_strtolower(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern));
t[j++] = '\xA7'; /* section sign */
t[j++] = '^';
@@ -133,8 +131,8 @@ static void convert_browscap_pattern(zval *pattern, int persistent) /* {{{ */
t[j++] = '\xA7';
t[j]=0;
- Z_STRVAL_P(pattern) = t;
- Z_STRLEN_P(pattern) = j;
+ res->len = j;
+ Z_STR_P(pattern) = res;
}
/* }}} */
@@ -149,9 +147,9 @@ static void php_browscap_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callb
switch (callback_type) {
case ZEND_INI_PARSER_ENTRY:
- if (bdata->current_section && arg2) {
- zval *new_property;
- char *new_key;
+ if (Z_TYPE(bdata->current_section) != IS_UNDEF && arg2) {
+ zval new_property;
+ zend_string *new_key;
/* parent entry can not be same as current section -> causes infinite loop! */
if (!strcasecmp(Z_STRVAL_P(arg1), "parent") &&
@@ -164,75 +162,57 @@ static void php_browscap_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callb
return;
}
- new_property = (zval *) pemalloc(sizeof(zval), persistent);
- INIT_PZVAL(new_property);
- Z_TYPE_P(new_property) = IS_STRING;
-
/* Set proper value for true/false settings */
if ((Z_STRLEN_P(arg2) == 2 && !strncasecmp(Z_STRVAL_P(arg2), "on", sizeof("on") - 1)) ||
(Z_STRLEN_P(arg2) == 3 && !strncasecmp(Z_STRVAL_P(arg2), "yes", sizeof("yes") - 1)) ||
(Z_STRLEN_P(arg2) == 4 && !strncasecmp(Z_STRVAL_P(arg2), "true", sizeof("true") - 1))
) {
- Z_STRVAL_P(new_property) = pestrndup("1", 1, persistent);
- Z_STRLEN_P(new_property) = 1;
+ ZVAL_STR(&new_property, STR_INIT("1", sizeof("1")-1, persistent));
} else if (
(Z_STRLEN_P(arg2) == 2 && !strncasecmp(Z_STRVAL_P(arg2), "no", sizeof("no") - 1)) ||
(Z_STRLEN_P(arg2) == 3 && !strncasecmp(Z_STRVAL_P(arg2), "off", sizeof("off") - 1)) ||
(Z_STRLEN_P(arg2) == 4 && !strncasecmp(Z_STRVAL_P(arg2), "none", sizeof("none") - 1)) ||
(Z_STRLEN_P(arg2) == 5 && !strncasecmp(Z_STRVAL_P(arg2), "false", sizeof("false") - 1))
) {
- Z_STRVAL_P(new_property) = pestrndup("", 0, persistent);
- Z_STRLEN_P(new_property) = 0;
+ // TODO: USE STR_EMPTY_ALLOC()?
+ ZVAL_STR(&new_property, STR_INIT("", sizeof("")-1, persistent));
} else { /* Other than true/false setting */
- Z_STRVAL_P(new_property) = pestrndup(Z_STRVAL_P(arg2),
- Z_STRLEN_P(arg2), persistent);
- Z_STRLEN_P(new_property) = Z_STRLEN_P(arg2);
+ ZVAL_STR(&new_property, STR_DUP(Z_STR_P(arg2), persistent));
}
- new_key = pestrndup(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), persistent);
- zend_str_tolower(new_key, Z_STRLEN_P(arg1));
- zend_hash_update(Z_ARRVAL_P(bdata->current_section), new_key, Z_STRLEN_P(arg1) + 1, &new_property, sizeof(zval *), NULL);
- pefree(new_key, persistent);
+ new_key = STR_DUP(Z_STR_P(arg1), persistent);
+ zend_str_tolower(new_key->val, new_key->len);
+ zend_hash_update(Z_ARRVAL(bdata->current_section), new_key, &new_property);
+ STR_RELEASE(new_key);
}
break;
case ZEND_INI_PARSER_SECTION: {
- zval *processed;
- zval *unprocessed;
- HashTable *section_properties;
+ zval processed;
+ zval unprocessed;
/*printf("'%s' (%d)\n",$1.value.str.val,$1.value.str.len + 1);*/
- bdata->current_section = (zval *) pemalloc(sizeof(zval), persistent);
- INIT_PZVAL(bdata->current_section);
- processed = (zval *) pemalloc(sizeof(zval), persistent);
- INIT_PZVAL(processed);
- unprocessed = (zval *) pemalloc(sizeof(zval), persistent);
- INIT_PZVAL(unprocessed);
-
- section_properties = (HashTable *) pemalloc(sizeof(HashTable), persistent);
- zend_hash_init(section_properties, 0, NULL,
+ if (persistent) {
+ ZVAL_NEW_PERSISTENT_ARR(&bdata->current_section);
+ } else {
+ ZVAL_NEW_ARR(&bdata->current_section);
+ }
+ zend_hash_init(Z_ARRVAL(bdata->current_section), 0, NULL,
(dtor_func_t) (persistent?browscap_entry_dtor_persistent
:browscap_entry_dtor_request),
persistent);
- Z_ARRVAL_P(bdata->current_section) = section_properties;
- Z_TYPE_P(bdata->current_section) = IS_ARRAY;
if (bdata->current_section_name) {
pefree(bdata->current_section_name, persistent);
}
bdata->current_section_name = pestrndup(Z_STRVAL_P(arg1),
Z_STRLEN_P(arg1), persistent);
- zend_hash_update(bdata->htab, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, (void *) &bdata->current_section, sizeof(zval *), NULL);
+ zend_hash_update(bdata->htab, Z_STR_P(arg1), &bdata->current_section);
- Z_STRVAL_P(processed) = Z_STRVAL_P(arg1);
- Z_STRLEN_P(processed) = Z_STRLEN_P(arg1);
- Z_TYPE_P(processed) = IS_STRING;
- Z_STRVAL_P(unprocessed) = Z_STRVAL_P(arg1);
- Z_STRLEN_P(unprocessed) = Z_STRLEN_P(arg1);
- Z_TYPE_P(unprocessed) = IS_STRING;
- Z_STRVAL_P(unprocessed) = pestrndup(Z_STRVAL_P(unprocessed), Z_STRLEN_P(unprocessed), persistent);
+ ZVAL_STR(&processed, Z_STR_P(arg1));
+ ZVAL_STR(&unprocessed, STR_DUP(Z_STR_P(arg1), persistent));
- convert_browscap_pattern(processed, persistent);
- zend_hash_update(section_properties, "browser_name_regex", sizeof("browser_name_regex"), (void *) &processed, sizeof(zval *), NULL);
- zend_hash_update(section_properties, "browser_name_pattern", sizeof("browser_name_pattern"), (void *) &unprocessed, sizeof(zval *), NULL);
+ convert_browscap_pattern(&processed, persistent);
+ zend_hash_str_update(Z_ARRVAL(bdata->current_section), "browser_name_regex", sizeof("browser_name_regex")-1, &processed);
+ zend_hash_str_update(Z_ARRVAL(bdata->current_section), "browser_name_pattern", sizeof("browser_name_pattern")-1, &unprocessed);
}
break;
}
@@ -289,7 +269,7 @@ static int browscap_read_file(char *filename, browser_data *browdata, int persis
static void browscap_globals_ctor(zend_browscap_globals *browscap_globals TSRMLS_DC) /* {{{ */
{
browscap_globals->activation_bdata.htab = NULL;
- browscap_globals->activation_bdata.current_section = NULL;
+ ZVAL_UNDEF(&browscap_globals->activation_bdata.current_section);
browscap_globals->activation_bdata.current_section_name = NULL;
browscap_globals->activation_bdata.filename[0] = '\0';
}
@@ -369,33 +349,31 @@ PHP_MSHUTDOWN_FUNCTION(browscap) /* {{{ */
}
/* }}} */
-static int browser_reg_compare(zval **browser TSRMLS_DC, int num_args, va_list args, zend_hash_key *key) /* {{{ */
+static int browser_reg_compare(zval *browser TSRMLS_DC, int num_args, va_list args, zend_hash_key *key) /* {{{ */
{
- zval **browser_regex, **previous_match;
+ zval *browser_regex, *previous_match;
pcre *re;
int re_options;
pcre_extra *re_extra;
char *lookup_browser_name = va_arg(args, char *);
int lookup_browser_length = va_arg(args, int);
- zval **found_browser_entry = va_arg(args, zval **);
+ zval *found_browser_entry = va_arg(args, zval *);
/* See if we have an exact match, if so, we're done... */
- if (*found_browser_entry) {
- if (zend_hash_find(Z_ARRVAL_PP(found_browser_entry), "browser_name_pattern", sizeof("browser_name_pattern"), (void**) &previous_match) == FAILURE) {
+ if (Z_TYPE_P(found_browser_entry) == IS_ARRAY) {
+ if ((previous_match = zend_hash_str_find(Z_ARRVAL_P(found_browser_entry), "browser_name_pattern", sizeof("browser_name_pattern")-1)) == NULL) {
return 0;
}
- else if (!strcasecmp(Z_STRVAL_PP(previous_match), lookup_browser_name)) {
+ else if (!strcasecmp(Z_STRVAL_P(previous_match), lookup_browser_name)) {
return 0;
}
}
- if (zend_hash_find(Z_ARRVAL_PP(browser), "browser_name_regex", sizeof("browser_name_regex"), (void **) &browser_regex) == FAILURE) {
+ if ((browser_regex = zend_hash_str_find(Z_ARRVAL_P(browser), "browser_name_regex", sizeof("browser_name_regex")-1)) == NULL) {
return 0;
}
-//???
-#if 0
- re = pcre_get_compiled_regex(Z_STRVAL_PP(browser_regex), &re_extra, &re_options TSRMLS_CC);
+ re = pcre_get_compiled_regex(Z_STR_P(browser_regex), &re_extra, &re_options TSRMLS_CC);
if (re == NULL) {
return 0;
}
@@ -404,18 +382,18 @@ static int browser_reg_compare(zval **browser TSRMLS_DC, int num_args, va_list a
/* If we've found a possible browser, we need to do a comparison of the
number of characters changed in the user agent being checked versus
the previous match found and the current match. */
- if (*found_browser_entry) {
+ if (Z_TYPE_P(found_browser_entry) == IS_ARRAY) {
int i, prev_len = 0, curr_len = 0, ua_len;
- zval **current_match;
+ zval *current_match;
- if (zend_hash_find(Z_ARRVAL_PP(browser), "browser_name_pattern", sizeof("browser_name_pattern"), (void**) &current_match) == FAILURE) {
+ if ((current_match = zend_hash_str_find(Z_ARRVAL_P(browser), "browser_name_pattern", sizeof("browser_name_pattern")-1)) == NULL) {
return 0;
}
ua_len = lookup_browser_length;
- for (i = 0; i < Z_STRLEN_PP(previous_match); i++) {
- switch (Z_STRVAL_PP(previous_match)[i]) {
+ for (i = 0; i < Z_STRLEN_P(previous_match); i++) {
+ switch (Z_STRVAL_P(previous_match)[i]) {
case '?':
case '*':
/* do nothing, ignore these characters in the count */
@@ -426,8 +404,8 @@ static int browser_reg_compare(zval **browser TSRMLS_DC, int num_args, va_list a
}
}
- for (i = 0; i < Z_STRLEN_PP(current_match); i++) {
- switch (Z_STRVAL_PP(current_match)[i]) {
+ for (i = 0; i < Z_STRLEN_P(current_match); i++) {
+ switch (Z_STRVAL_P(current_match)[i]) {
case '?':
case '*':
/* do nothing, ignore these characters in the count */
@@ -441,30 +419,22 @@ static int browser_reg_compare(zval **browser TSRMLS_DC, int num_args, va_list a
/* Pick which browser pattern replaces the least amount of
characters when compared to the original user agent string... */
if (ua_len - prev_len > ua_len - curr_len) {
- *found_browser_entry = *browser;
+ ZVAL_COPY_VALUE(found_browser_entry, browser);
}
}
else {
- *found_browser_entry = *browser;
+ ZVAL_COPY_VALUE(found_browser_entry, browser);
}
}
-#endif
return 0;
}
/* }}} */
-static void browscap_zval_copy_ctor(zval **p) /* {{{ */
+static void browscap_zval_copy_ctor(zval *p) /* {{{ */
{
- zval *new;
-
- ALLOC_ZVAL(new);
- *new = **p;
-
- zval_copy_ctor(new);
-
- INIT_PZVAL(new);
- *p = new;
+ zval_copy_ctor(p);
+//??? INIT_PZVAL(p);
} /* }}} */
/* {{{ proto mixed get_browser([string browser_name [, bool return_array]])
@@ -474,8 +444,8 @@ PHP_FUNCTION(get_browser)
char *agent_name = NULL;
int agent_name_len = 0;
zend_bool return_array = 0;
- zval **agent, **z_agent_name, **http_user_agent;
- zval *found_browser_entry, *tmp_copy;
+ zval *agent, *z_agent_name, *http_user_agent;
+ zval found_browser_entry;
char *lookup_browser_name;
browser_data *bdata;
@@ -499,27 +469,29 @@ PHP_FUNCTION(get_browser)
}
if (agent_name == NULL) {
- zend_is_auto_global("_SERVER", sizeof("_SERVER") - 1 TSRMLS_CC);
- if (!PG(http_globals)[TRACK_VARS_SERVER] ||
- zend_hash_find(HASH_OF(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT"), (void **) &http_user_agent) == FAILURE
+ zend_string *key = STR_INIT("_SERVER", sizeof("_SERVER") - 1, 0);
+ zend_is_auto_global(key TSRMLS_CC);
+ STR_RELEASE(key);
+ if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) != IS_UNDEF ||
+ (http_user_agent = zend_hash_str_find(HASH_OF(&PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT")-1)) == NULL
) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "HTTP_USER_AGENT variable is not set, cannot determine user agent name");
RETURN_FALSE;
}
- agent_name = Z_STRVAL_PP(http_user_agent);
- agent_name_len = Z_STRLEN_PP(http_user_agent);
+ agent_name = Z_STRVAL_P(http_user_agent);
+ agent_name_len = Z_STRLEN_P(http_user_agent);
}
lookup_browser_name = estrndup(agent_name, agent_name_len);
php_strtolower(lookup_browser_name, agent_name_len);
- if (zend_hash_find(bdata->htab, lookup_browser_name, agent_name_len + 1, (void **) &agent) == FAILURE) {
- found_browser_entry = NULL;
+ if ((agent = zend_hash_str_find(bdata->htab, lookup_browser_name, agent_name_len)) == NULL) {
+ ZVAL_UNDEF(&found_browser_entry);
zend_hash_apply_with_arguments(bdata->htab TSRMLS_CC, (apply_func_args_t) browser_reg_compare, 3, lookup_browser_name, agent_name_len, &found_browser_entry);
- if (found_browser_entry) {
+ if (Z_TYPE(found_browser_entry) != IS_UNDEF) {
agent = &found_browser_entry;
- } else if (zend_hash_find(bdata->htab, DEFAULT_SECTION_NAME, sizeof(DEFAULT_SECTION_NAME), (void **) &agent) == FAILURE) {
+ } else if ((agent = zend_hash_str_find(bdata->htab, DEFAULT_SECTION_NAME, sizeof(DEFAULT_SECTION_NAME)-1)) == NULL) {
efree(lookup_browser_name);
RETURN_FALSE;
}
@@ -527,23 +499,23 @@ PHP_FUNCTION(get_browser)
if (return_array) {
array_init(return_value);
- zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_PP(agent), (copy_ctor_func_t) browscap_zval_copy_ctor, (void *) &tmp_copy, sizeof(zval *));
+ zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(agent), (copy_ctor_func_t) browscap_zval_copy_ctor);
}
else {
object_init(return_value);
- zend_hash_copy(Z_OBJPROP_P(return_value), Z_ARRVAL_PP(agent), (copy_ctor_func_t) browscap_zval_copy_ctor, (void *) &tmp_copy, sizeof(zval *));
+ zend_hash_copy(Z_OBJPROP_P(return_value), Z_ARRVAL_P(agent), (copy_ctor_func_t) browscap_zval_copy_ctor);
}
- while (zend_hash_find(Z_ARRVAL_PP(agent), "parent", sizeof("parent"), (void **) &z_agent_name) == SUCCESS) {
- if (zend_hash_find(bdata->htab, Z_STRVAL_PP(z_agent_name), Z_STRLEN_PP(z_agent_name) + 1, (void **)&agent) == FAILURE) {
+ while ((z_agent_name = zend_hash_str_find(Z_ARRVAL_P(agent), "parent", sizeof("parent")-1)) != NULL) {
+ if ((agent = zend_hash_find(bdata->htab, Z_STR_P(z_agent_name))) == NULL) {
break;
}
if (return_array) {
- zend_hash_merge(Z_ARRVAL_P(return_value), Z_ARRVAL_PP(agent), (copy_ctor_func_t) browscap_zval_copy_ctor, (void *) &tmp_copy, sizeof(zval *), 0);
+ zend_hash_merge(Z_ARRVAL_P(return_value), Z_ARRVAL_P(agent), (copy_ctor_func_t) browscap_zval_copy_ctor, 0);
}
else {
- zend_hash_merge(Z_OBJPROP_P(return_value), Z_ARRVAL_PP(agent), (copy_ctor_func_t) browscap_zval_copy_ctor, (void *) &tmp_copy, sizeof(zval *), 0);
+ zend_hash_merge(Z_OBJPROP_P(return_value), Z_ARRVAL_P(agent), (copy_ctor_func_t) browscap_zval_copy_ctor, 0);
}
}
diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c
index 3419f09dd7..c789a3593d 100644
--- a/ext/standard/crypt.c
+++ b/ext/standard/crypt.c
@@ -295,12 +295,13 @@ PHP_FUNCTION(crypt)
if (php_crypt(str, str_len, salt, salt_in_len, &result) == FAILURE) {
if (salt[0] == '*' && salt[1] == '0') {
- RETURN_STRING("*1", 1);
+ RETURN_STRING("*1");
} else {
- RETURN_STRING("*0", 1);
+ RETURN_STRING("*0");
}
}
- RETURN_STRING(result, 0);
+//??? RETURN_STRING(result, 0);
+ RETURN_STRING(result);
}
/* }}} */
#endif
diff --git a/ext/standard/cyr_convert.c b/ext/standard/cyr_convert.c
index d8d40cb10f..bc482367af 100644
--- a/ext/standard/cyr_convert.c
+++ b/ext/standard/cyr_convert.c
@@ -282,7 +282,8 @@ PHP_FUNCTION(convert_cyr_string)
str = (unsigned char*) estrndup(input, input_len);
php_convert_cyr_string(str, input_len, fr_cs[0], to_cs[0] TSRMLS_CC);
- RETVAL_STRING((char *)str, 0);
+//??? RETVAL_STRING((char *)str, 0);
+ RETVAL_STRING((char *)str);
}
/* }}} */
diff --git a/ext/standard/dir.c b/ext/standard/dir.c
index c64f37c2d6..c92e3bb1c7 100644
--- a/ext/standard/dir.c
+++ b/ext/standard/dir.c
@@ -52,7 +52,7 @@
#endif
typedef struct {
- int default_dir;
+ zend_resource *default_dir;
} php_dir_globals;
#ifdef ZTS
@@ -81,16 +81,16 @@ static zend_class_entry *dir_class_entry_ptr;
if (ZEND_NUM_ARGS() == 0) { \
myself = getThis(); \
if (myself) { \
- if (zend_hash_find(Z_OBJPROP_P(myself), "handle", sizeof("handle"), (void **)&tmp) == FAILURE) { \
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(myself), "handle", sizeof("handle")-1)) == NULL) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find my handle property"); \
RETURN_FALSE; \
} \
ZEND_FETCH_RESOURCE(dirp, php_stream *, tmp, -1, "Directory", php_file_le_stream()); \
} else { \
- ZEND_FETCH_RESOURCE(dirp, php_stream *, 0, DIRG(default_dir), "Directory", php_file_le_stream()); \
+ ZEND_FETCH_RESOURCE(dirp, php_stream *, 0, DIRG(default_dir)->handle, "Directory", php_file_le_stream()); \
} \
} else { \
- dirp = (php_stream *) zend_fetch_resource(&id TSRMLS_CC, -1, "Directory", NULL, 1, php_file_le_stream()); \
+ dirp = (php_stream *) zend_fetch_resource(id TSRMLS_CC, -1, "Directory", NULL, 1, php_file_le_stream()); \
if (!dirp) \
RETURN_FALSE; \
}
@@ -109,22 +109,22 @@ static const zend_function_entry php_dir_class_functions[] = {
};
-static void php_set_default_dir(int id TSRMLS_DC)
+static void php_set_default_dir(zend_resource *res TSRMLS_DC)
{
- if (DIRG(default_dir)!=-1) {
+ if (DIRG(default_dir)) {
zend_list_delete(DIRG(default_dir));
}
- if (id != -1) {
- zend_list_addref(id);
+ if (res) {
+ res->gc.refcount++;
}
- DIRG(default_dir) = id;
+ DIRG(default_dir) = res;
}
PHP_RINIT_FUNCTION(dir)
{
- DIRG(default_dir) = -1;
+ DIRG(default_dir) = NULL;
return SUCCESS;
}
@@ -233,12 +233,12 @@ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject)
dirp->flags |= PHP_STREAM_FLAG_NO_FCLOSE;
- php_set_default_dir(dirp->rsrc_id TSRMLS_CC);
+ php_set_default_dir(dirp->res TSRMLS_CC);
if (createobject) {
object_init_ex(return_value, dir_class_entry_ptr);
add_property_stringl(return_value, "path", dirname, dir_len, 1);
- add_property_resource(return_value, "handle", dirp->rsrc_id);
+ add_property_resource(return_value, "handle", dirp->res);
php_stream_auto_cleanup(dirp); /* so we don't get warnings under debug */
} else {
php_stream_to_zval(dirp, return_value);
@@ -266,22 +266,22 @@ PHP_FUNCTION(getdir)
Close directory connection identified by the dir_handle */
PHP_FUNCTION(closedir)
{
- zval *id = NULL, **tmp, *myself;
+ zval *id = NULL, *tmp, *myself;
php_stream *dirp;
- int rsrc_id;
+ zend_resource *res;
FETCH_DIRP();
if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid Directory resource", dirp->rsrc_id);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%ld is not a valid Directory resource", dirp->res->handle);
RETURN_FALSE;
}
- rsrc_id = dirp->rsrc_id;
- zend_list_delete(dirp->rsrc_id);
+ res = dirp->res;
+ zend_list_delete(dirp->res);
- if (rsrc_id == DIRG(default_dir)) {
- php_set_default_dir(-1 TSRMLS_CC);
+ if (res == DIRG(default_dir)) {
+ php_set_default_dir(NULL TSRMLS_CC);
}
}
/* }}} */
@@ -370,7 +370,7 @@ PHP_FUNCTION(getcwd)
#endif
if (ret) {
- RETURN_STRING(path, 1);
+ RETURN_STRING(path);
} else {
RETURN_FALSE;
}
@@ -381,13 +381,13 @@ PHP_FUNCTION(getcwd)
Rewind dir_handle back to the start */
PHP_FUNCTION(rewinddir)
{
- zval *id = NULL, **tmp, *myself;
+ zval *id = NULL, *tmp, *myself;
php_stream *dirp;
FETCH_DIRP();
if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid Directory resource", dirp->rsrc_id);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%ld is not a valid Directory resource", dirp->res->handle);
RETURN_FALSE;
}
@@ -399,19 +399,19 @@ PHP_FUNCTION(rewinddir)
Read directory entry from dir_handle */
PHP_NAMED_FUNCTION(php_if_readdir)
{
- zval *id = NULL, **tmp, *myself;
+ zval *id = NULL, *tmp, *myself;
php_stream *dirp;
php_stream_dirent entry;
FETCH_DIRP();
if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid Directory resource", dirp->rsrc_id);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%ld is not a valid Directory resource", dirp->res->handle);
RETURN_FALSE;
}
if (php_stream_readdir(dirp, &entry)) {
- RETURN_STRINGL(entry.d_name, strlen(entry.d_name), 1);
+ RETURN_STRINGL(entry.d_name, strlen(entry.d_name));
}
RETURN_FALSE;
}
diff --git a/ext/standard/dns.c b/ext/standard/dns.c
index 6a894467ff..1d8670fa66 100644
--- a/ext/standard/dns.c
+++ b/ext/standard/dns.c
@@ -139,7 +139,7 @@ PHP_FUNCTION(gethostname)
RETURN_FALSE;
}
- RETURN_STRING(buf, 1);
+ RETURN_STRING(buf);
}
/* }}} */
#endif
@@ -170,7 +170,8 @@ PHP_FUNCTION(gethostbyaddr)
#endif
RETVAL_FALSE;
} else {
- RETVAL_STRING(hostname, 0);
+//??? RETVAL_STRING(hostname, 0);
+ RETVAL_STRING(hostname);
}
}
/* }}} */
@@ -224,7 +225,8 @@ PHP_FUNCTION(gethostbyname)
addr = php_gethostbyname(hostname);
- RETVAL_STRING(addr, 0);
+//??? RETVAL_STRING(addr, 0);
+ RETVAL_STRING(addr);
}
/* }}} */
@@ -413,7 +415,7 @@ PHP_FUNCTION(dns_check_record)
#if HAVE_FULL_DNS_FUNCS
/* {{{ php_parserr */
-static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int store, int raw, zval **subarray)
+static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int store, int raw, zval *subarray)
{
u_short type, class, dlen;
u_long ttl;
@@ -423,7 +425,7 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
char name[MAXHOSTNAMELEN];
int have_v6_break = 0, in_v6_break = 0;
- *subarray = NULL;
+ ZVAL_UNDEF(subarray);
n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, sizeof(name) - 2);
if (n < 0) {
@@ -445,113 +447,111 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
return cp;
}
- ALLOC_INIT_ZVAL(*subarray);
- array_init(*subarray);
+ array_init(subarray);
- add_assoc_string(*subarray, "host", name, 1);
- add_assoc_string(*subarray, "class", "IN", 1);
- add_assoc_long(*subarray, "ttl", ttl);
+ add_assoc_string(subarray, "host", name, 1);
+ add_assoc_string(subarray, "class", "IN", 1);
+ add_assoc_long(subarray, "ttl", ttl);
if (raw) {
- add_assoc_long(*subarray, "type", type);
- add_assoc_stringl(*subarray, "data", (char*) cp, (uint) dlen, 1);
+ add_assoc_long(subarray, "type", type);
+ add_assoc_stringl(subarray, "data", (char*) cp, (uint) dlen, 1);
cp += dlen;
return cp;
}
switch (type) {
case DNS_T_A:
- add_assoc_string(*subarray, "type", "A", 1);
+ add_assoc_string(subarray, "type", "A", 1);
snprintf(name, sizeof(name), "%d.%d.%d.%d", cp[0], cp[1], cp[2], cp[3]);
- add_assoc_string(*subarray, "ip", name, 1);
+ add_assoc_string(subarray, "ip", name, 1);
cp += dlen;
break;
case DNS_T_MX:
- add_assoc_string(*subarray, "type", "MX", 1);
+ add_assoc_string(subarray, "type", "MX", 1);
GETSHORT(n, cp);
- add_assoc_long(*subarray, "pri", n);
+ add_assoc_long(subarray, "pri", n);
/* no break; */
case DNS_T_CNAME:
if (type == DNS_T_CNAME) {
- add_assoc_string(*subarray, "type", "CNAME", 1);
+ add_assoc_string(subarray, "type", "CNAME", 1);
}
/* no break; */
case DNS_T_NS:
if (type == DNS_T_NS) {
- add_assoc_string(*subarray, "type", "NS", 1);
+ add_assoc_string(subarray, "type", "NS", 1);
}
/* no break; */
case DNS_T_PTR:
if (type == DNS_T_PTR) {
- add_assoc_string(*subarray, "type", "PTR", 1);
+ add_assoc_string(subarray, "type", "PTR", 1);
}
n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) - 2);
if (n < 0) {
return NULL;
}
cp += n;
- add_assoc_string(*subarray, "target", name, 1);
+ add_assoc_string(subarray, "target", name, 1);
break;
case DNS_T_HINFO:
/* See RFC 1010 for values */
- add_assoc_string(*subarray, "type", "HINFO", 1);
+ add_assoc_string(subarray, "type", "HINFO", 1);
n = *cp & 0xFF;
cp++;
- add_assoc_stringl(*subarray, "cpu", (char*)cp, n, 1);
+ add_assoc_stringl(subarray, "cpu", (char*)cp, n, 1);
cp += n;
n = *cp & 0xFF;
cp++;
- add_assoc_stringl(*subarray, "os", (char*)cp, n, 1);
+ add_assoc_stringl(subarray, "os", (char*)cp, n, 1);
cp += n;
break;
case DNS_T_TXT:
{
int ll = 0;
- zval *entries = NULL;
+ zval entries;
- add_assoc_string(*subarray, "type", "TXT", 1);
+ add_assoc_string(subarray, "type", "TXT", 1);
tp = emalloc(dlen + 1);
- MAKE_STD_ZVAL(entries);
- array_init(entries);
+ array_init(&entries);
while (ll < dlen) {
n = cp[ll];
memcpy(tp + ll , cp + ll + 1, n);
- add_next_index_stringl(entries, cp + ll + 1, n, 1);
+ add_next_index_stringl(&entries, (char*)cp + ll + 1, n, 1);
ll = ll + n + 1;
}
tp[dlen] = '\0';
cp += dlen;
- add_assoc_stringl(*subarray, "txt", tp, (dlen>0)?dlen - 1:0, 0);
- add_assoc_zval(*subarray, "entries", entries);
+ add_assoc_stringl(subarray, "txt", (char*)tp, (dlen>0)?dlen - 1:0, 0);
+ add_assoc_zval(subarray, "entries", &entries);
}
break;
case DNS_T_SOA:
- add_assoc_string(*subarray, "type", "SOA", 1);
+ add_assoc_string(subarray, "type", "SOA", 1);
n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) -2);
if (n < 0) {
return NULL;
}
cp += n;
- add_assoc_string(*subarray, "mname", name, 1);
+ add_assoc_string(subarray, "mname", name, 1);
n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) -2);
if (n < 0) {
return NULL;
}
cp += n;
- add_assoc_string(*subarray, "rname", name, 1);
+ add_assoc_string(subarray, "rname", name, 1);
GETLONG(n, cp);
- add_assoc_long(*subarray, "serial", n);
+ add_assoc_long(subarray, "serial", n);
GETLONG(n, cp);
- add_assoc_long(*subarray, "refresh", n);
+ add_assoc_long(subarray, "refresh", n);
GETLONG(n, cp);
- add_assoc_long(*subarray, "retry", n);
+ add_assoc_long(subarray, "retry", n);
GETLONG(n, cp);
- add_assoc_long(*subarray, "expire", n);
+ add_assoc_long(subarray, "expire", n);
GETLONG(n, cp);
- add_assoc_long(*subarray, "minimum-ttl", n);
+ add_assoc_long(subarray, "minimum-ttl", n);
break;
case DNS_T_AAAA:
tp = (u_char*)name;
@@ -583,15 +583,15 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
tp++;
}
tp[0] = '\0';
- add_assoc_string(*subarray, "type", "AAAA", 1);
- add_assoc_string(*subarray, "ipv6", name, 1);
+ add_assoc_string(subarray, "type", "AAAA", 1);
+ add_assoc_string(subarray, "ipv6", name, 1);
break;
case DNS_T_A6:
p = cp;
- add_assoc_string(*subarray, "type", "A6", 1);
+ add_assoc_string(subarray, "type", "A6", 1);
n = ((int)cp[0]) & 0xFF;
cp++;
- add_assoc_long(*subarray, "masklen", n);
+ add_assoc_long(subarray, "masklen", n);
tp = (u_char*)name;
if (n > 15) {
have_v6_break = 1;
@@ -651,56 +651,56 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
tp++;
}
tp[0] = '\0';
- add_assoc_string(*subarray, "ipv6", name, 1);
+ add_assoc_string(subarray, "ipv6", name, 1);
if (cp < p + dlen) {
n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) - 2);
if (n < 0) {
return NULL;
}
cp += n;
- add_assoc_string(*subarray, "chain", name, 1);
+ add_assoc_string(subarray, "chain", name, 1);
}
break;
case DNS_T_SRV:
- add_assoc_string(*subarray, "type", "SRV", 1);
+ add_assoc_string(subarray, "type", "SRV", 1);
GETSHORT(n, cp);
- add_assoc_long(*subarray, "pri", n);
+ add_assoc_long(subarray, "pri", n);
GETSHORT(n, cp);
- add_assoc_long(*subarray, "weight", n);
+ add_assoc_long(subarray, "weight", n);
GETSHORT(n, cp);
- add_assoc_long(*subarray, "port", n);
+ add_assoc_long(subarray, "port", n);
n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) - 2);
if (n < 0) {
return NULL;
}
cp += n;
- add_assoc_string(*subarray, "target", name, 1);
+ add_assoc_string(subarray, "target", name, 1);
break;
case DNS_T_NAPTR:
- add_assoc_string(*subarray, "type", "NAPTR", 1);
+ add_assoc_string(subarray, "type", "NAPTR", 1);
GETSHORT(n, cp);
- add_assoc_long(*subarray, "order", n);
+ add_assoc_long(subarray, "order", n);
GETSHORT(n, cp);
- add_assoc_long(*subarray, "pref", n);
+ add_assoc_long(subarray, "pref", n);
n = (cp[0] & 0xFF);
- add_assoc_stringl(*subarray, "flags", (char*)++cp, n, 1);
+ add_assoc_stringl(subarray, "flags", (char*)++cp, n, 1);
cp += n;
n = (cp[0] & 0xFF);
- add_assoc_stringl(*subarray, "services", (char*)++cp, n, 1);
+ add_assoc_stringl(subarray, "services", (char*)++cp, n, 1);
cp += n;
n = (cp[0] & 0xFF);
- add_assoc_stringl(*subarray, "regex", (char*)++cp, n, 1);
+ add_assoc_stringl(subarray, "regex", (char*)++cp, n, 1);
cp += n;
n = dn_expand(answer->qb2, answer->qb2+65536, cp, name, (sizeof name) - 2);
if (n < 0) {
return NULL;
}
cp += n;
- add_assoc_string(*subarray, "replacement", name, 1);
+ add_assoc_string(subarray, "replacement", name, 1);
break;
default:
zval_ptr_dtor(subarray);
- *subarray = NULL;
+ ZVAL_UNDEF(subarray);
cp += dlen;
break;
}
@@ -882,11 +882,11 @@ PHP_FUNCTION(dns_get_record)
/* YAY! Our real answers! */
while (an-- && cp && cp < end) {
- zval *retval;
+ zval retval;
cp = php_parserr(cp, &answer, type_to_fetch, store_results, raw, &retval);
- if (retval != NULL && store_results) {
- add_next_index_zval(return_value, retval);
+ if (Z_TYPE(retval) != IS_UNDEF && store_results) {
+ add_next_index_zval(return_value, &retval);
}
}
@@ -895,11 +895,11 @@ PHP_FUNCTION(dns_get_record)
* Process when only requesting addtl so that we can skip through the section
*/
while (ns-- > 0 && cp && cp < end) {
- zval *retval = NULL;
+ zval retval;
cp = php_parserr(cp, &answer, DNS_T_ANY, authns != NULL, raw, &retval);
- if (retval != NULL) {
- add_next_index_zval(authns, retval);
+ if (Z_TYPE(retval) != IS_UNDEF) {
+ add_next_index_zval(authns, &retval);
}
}
}
@@ -907,11 +907,11 @@ PHP_FUNCTION(dns_get_record)
if (addtl) {
/* Additional records associated with authoritative name servers */
while (ar-- > 0 && cp && cp < end) {
- zval *retval = NULL;
+ zval retval;
cp = php_parserr(cp, &answer, DNS_T_ANY, 1, raw, &retval);
- if (retval != NULL) {
- add_next_index_zval(addtl, retval);
+ if (Z_TYPE(retval) != IS_UNDEF) {
+ add_next_index_zval(addtl, &retval);
}
}
}
diff --git a/ext/standard/exec.c b/ext/standard/exec.c
index f8a22adf39..8bb8fefba5 100644
--- a/ext/standard/exec.c
+++ b/ext/standard/exec.c
@@ -139,7 +139,7 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_
}
/* Return last line from the shell command */
- RETVAL_STRINGL(buf, bufl, 1);
+ RETVAL_STRINGL(buf, bufl);
} else { /* should return NULL, but for BC we return "" */
RETVAL_EMPTY_STRING();
}
@@ -405,7 +405,8 @@ PHP_FUNCTION(escapeshellcmd)
if (command_len) {
cmd = php_escape_shell_cmd(command);
- RETVAL_STRING(cmd, 0);
+//??? RETVAL_STRING(cmd, 0);
+ RETVAL_STRING(cmd);
} else {
RETVAL_EMPTY_STRING();
}
@@ -426,7 +427,8 @@ PHP_FUNCTION(escapeshellarg)
if (argument) {
cmd = php_escape_shell_arg(argument);
- RETVAL_STRING(cmd, 0);
+//??? RETVAL_STRING(cmd, 0);
+ RETVAL_STRING(cmd);
}
}
/* }}} */
@@ -460,7 +462,8 @@ PHP_FUNCTION(shell_exec)
php_stream_close(stream);
if (total_readbytes > 0) {
- RETVAL_STRINGL(ret, total_readbytes, 0);
+//??? RETVAL_STRINGL(ret, total_readbytes, 0);
+ RETVAL_STRINGL(ret, total_readbytes);
}
}
/* }}} */
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 0dab6f284a..5cb33932bf 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -148,10 +148,10 @@ PHPAPI int php_le_stream_context(TSRMLS_D)
*/
static ZEND_RSRC_DTOR_FUNC(file_context_dtor)
{
- php_stream_context *context = (php_stream_context*)rsrc->ptr;
- if (context->options) {
+ php_stream_context *context = (php_stream_context*)res->ptr;
+ if (Z_TYPE(context->options) != IS_UNDEF) {
zval_ptr_dtor(&context->options);
- context->options = NULL;
+ ZVAL_UNDEF(&context->options);
}
php_stream_context_free(context);
}
@@ -344,7 +344,7 @@ PHP_FUNCTION(flock)
return;
}
- PHP_STREAM_TO_ZVAL(stream, &arg1);
+ PHP_STREAM_TO_ZVAL(stream, arg1);
act = operation & 3;
if (act < 1 || act > 3) {
@@ -352,16 +352,16 @@ PHP_FUNCTION(flock)
RETURN_FALSE;
}
- if (arg3 && PZVAL_IS_REF(arg3)) {
- convert_to_long_ex(&arg3);
- Z_LVAL_P(arg3) = 0;
+ if (arg3 && Z_ISREF_P(arg3)) {
+ convert_to_long_ex(Z_REFVAL_P(arg3));
+ Z_LVAL_P(Z_REFVAL_P(arg3)) = 0;
}
/* flock_values contains all possible actions if (operation & 4) we won't block on the lock */
act = flock_values[act - 1] | (operation & PHP_LOCK_NB ? LOCK_NB : 0);
if (php_stream_lock(stream, act)) {
- if (operation && errno == EWOULDBLOCK && arg3 && PZVAL_IS_REF(arg3)) {
- Z_LVAL_P(arg3) = 1;
+ if (operation && errno == EWOULDBLOCK && arg3 && Z_ISREF_P(arg3)) {
+ Z_LVAL_P(Z_REFVAL_P(arg3)) = 1;
}
RETURN_FALSE;
}
@@ -415,7 +415,7 @@ PHP_FUNCTION(get_meta_tags)
}
} else if (tok_last == TOK_EQUAL && looking_for_val) {
if (saw_name) {
- STR_FREE(name);
+ if (name) efree(name);
/* Get the NAME attr (Single word attr, non-quoted) */
temp = name = estrndup(md.token_data, md.token_len);
@@ -428,7 +428,7 @@ PHP_FUNCTION(get_meta_tags)
have_name = 1;
} else if (saw_content) {
- STR_FREE(value);
+ if (value) efree(value);
value = estrndup(md.token_data, md.token_len);
have_content = 1;
}
@@ -449,7 +449,7 @@ PHP_FUNCTION(get_meta_tags)
}
} else if (tok == TOK_STRING && tok_last == TOK_EQUAL && looking_for_val) {
if (saw_name) {
- STR_FREE(name);
+ if (name) efree(name);
/* Get the NAME attr (Quoted single/double) */
temp = name = estrndup(md.token_data, md.token_len);
@@ -462,7 +462,7 @@ PHP_FUNCTION(get_meta_tags)
have_name = 1;
} else if (saw_content) {
- STR_FREE(value);
+ if (value) efree(value);
value = estrndup(md.token_data, md.token_len);
have_content = 1;
}
@@ -486,7 +486,7 @@ PHP_FUNCTION(get_meta_tags)
}
efree(name);
- STR_FREE(value);
+ if (value) efree(value);
} else if (have_content) {
efree(value);
}
@@ -508,8 +508,8 @@ PHP_FUNCTION(get_meta_tags)
md.token_data = NULL;
}
- STR_FREE(value);
- STR_FREE(name);
+ if (value) efree(value);
+ if (name) efree(name);
php_stream_close(md.stream);
}
/* }}} */
@@ -555,7 +555,8 @@ PHP_FUNCTION(file_get_contents)
}
if ((len = php_stream_copy_to_mem(stream, &contents, maxlen, 0)) > 0) {
- RETVAL_STRINGL(contents, len, 0);
+//??? RETVAL_STRINGL(contents, len, 0);
+ RETVAL_STRINGL(contents, len);
} else if (len == 0) {
RETVAL_EMPTY_STRING();
} else {
@@ -586,7 +587,7 @@ PHP_FUNCTION(file_put_contents)
}
if (Z_TYPE_P(data) == IS_RESOURCE) {
- php_stream_from_zval(srcstream, &data);
+ php_stream_from_zval(srcstream, data);
}
context = php_stream_context_from_zval(zcontext, flags & PHP_FILE_NO_DEFAULT_CONTEXT);
@@ -635,7 +636,7 @@ PHP_FUNCTION(file_put_contents)
case IS_DOUBLE:
case IS_BOOL:
case IS_CONSTANT:
- convert_to_string_ex(&data);
+ convert_to_string_ex(data);
case IS_STRING:
if (Z_STRLEN_P(data)) {
@@ -650,23 +651,23 @@ PHP_FUNCTION(file_put_contents)
case IS_ARRAY:
if (zend_hash_num_elements(Z_ARRVAL_P(data))) {
int bytes_written;
- zval **tmp;
+ zval *tmp;
HashPosition pos;
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(data), &pos);
- while (zend_hash_get_current_data_ex(Z_ARRVAL_P(data), (void **) &tmp, &pos) == SUCCESS) {
- if (Z_TYPE_PP(tmp) != IS_STRING) {
+ while ((tmp = zend_hash_get_current_data_ex(Z_ARRVAL_P(data), &pos)) != NULL) {
+ if (Z_TYPE_P(tmp) != IS_STRING) {
SEPARATE_ZVAL(tmp);
- convert_to_string(*tmp);
+ convert_to_string(tmp);
}
- if (Z_STRLEN_PP(tmp)) {
- numbytes += Z_STRLEN_PP(tmp);
- bytes_written = php_stream_write(stream, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
- if (bytes_written < 0 || bytes_written != Z_STRLEN_PP(tmp)) {
+ if (Z_STRLEN_P(tmp)) {
+ numbytes += Z_STRLEN_P(tmp);
+ bytes_written = php_stream_write(stream, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
+ if (bytes_written < 0 || bytes_written != Z_STRLEN_P(tmp)) {
if (bytes_written < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write %d bytes to %s", Z_STRLEN_PP(tmp), filename);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to write %d bytes to %s", Z_STRLEN_P(tmp), filename);
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d bytes written, possibly out of free disk space", bytes_written, Z_STRLEN_PP(tmp));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d bytes written, possibly out of free disk space", bytes_written, Z_STRLEN_P(tmp));
}
numbytes = -1;
break;
@@ -752,7 +753,7 @@ PHP_FUNCTION(file)
s = target_buf;
e = target_buf + target_len;
- if (!(p = php_stream_locate_eol(stream, target_buf, target_len TSRMLS_CC))) {
+ if (!(p = (char*)php_stream_locate_eol(stream, target_buf, target_len TSRMLS_CC))) {
p = e;
goto parse_eol;
}
@@ -827,7 +828,8 @@ PHP_FUNCTION(tempnam)
if ((fd = php_open_temporary_fd_ex(dir, p, &opened_path, 1 TSRMLS_CC)) >= 0) {
close(fd);
- RETVAL_STRING(opened_path, 0);
+//??? RETVAL_STRING(opened_path, 0);
+ RETVAL_STRING(opened_path);
}
efree(p);
}
@@ -891,10 +893,10 @@ PHPAPI PHP_FUNCTION(fclose)
RETURN_FALSE;
}
- PHP_STREAM_TO_ZVAL(stream, &arg1);
+ PHP_STREAM_TO_ZVAL(stream, arg1);
if ((stream->flags & PHP_STREAM_FLAG_NO_FCLOSE) != 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid stream resource", stream->rsrc_id);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%ld is not a valid stream resource", stream->res->handle);
RETURN_FALSE;
}
@@ -963,10 +965,10 @@ PHP_FUNCTION(pclose)
RETURN_FALSE;
}
- PHP_STREAM_TO_ZVAL(stream, &arg1);
+ PHP_STREAM_TO_ZVAL(stream, arg1);
FG(pclose_wait) = 1;
- zend_list_delete(stream->rsrc_id);
+ zend_list_delete(stream->res);
FG(pclose_wait) = 0;
RETURN_LONG(FG(pclose_ret));
}
@@ -983,7 +985,7 @@ PHPAPI PHP_FUNCTION(feof)
RETURN_FALSE;
}
- PHP_STREAM_TO_ZVAL(stream, &arg1);
+ PHP_STREAM_TO_ZVAL(stream, arg1);
if (php_stream_eof(stream)) {
RETURN_TRUE;
@@ -1008,7 +1010,7 @@ PHPAPI PHP_FUNCTION(fgets)
RETURN_FALSE;
}
- PHP_STREAM_TO_ZVAL(stream, &arg1);
+ PHP_STREAM_TO_ZVAL(stream, arg1);
if (argc == 1) {
/* ask streams to give us a buffer of an appropriate size */
@@ -1028,11 +1030,17 @@ PHPAPI PHP_FUNCTION(fgets)
}
}
- ZVAL_STRINGL(return_value, buf, line_len, 0);
/* resize buffer if it's much larger than the result.
* Only needed if the user requested a buffer size. */
if (argc > 1 && Z_STRLEN_P(return_value) < len / 2) {
- Z_STRVAL_P(return_value) = erealloc(buf, line_len + 1);
+//???
+ ZVAL_STRINGL(return_value, buf, line_len + 1);
+ Z_STRLEN_P(return_value)--;
+ efree(buf);
+ } else {
+//???
+ ZVAL_STRINGL(return_value, buf, line_len);
+ efree(buf);
}
return;
@@ -1057,7 +1065,7 @@ PHPAPI PHP_FUNCTION(fgetc)
RETURN_FALSE;
}
- PHP_STREAM_TO_ZVAL(stream, &arg1);
+ PHP_STREAM_TO_ZVAL(stream, arg1);
result = php_stream_getc(stream);
@@ -1067,7 +1075,7 @@ PHPAPI PHP_FUNCTION(fgetc)
buf[0] = result;
buf[1] = '\0';
- RETURN_STRINGL(buf, 1, 1);
+ RETURN_STRINGL(buf, 1);
}
}
/* }}} */
@@ -1089,7 +1097,7 @@ PHPAPI PHP_FUNCTION(fgetss)
RETURN_FALSE;
}
- PHP_STREAM_TO_ZVAL(stream, &fd);
+ PHP_STREAM_TO_ZVAL(stream, fd);
if (ZEND_NUM_ARGS() >= 2) {
if (bytes <= 0) {
@@ -1112,7 +1120,8 @@ PHPAPI PHP_FUNCTION(fgetss)
retval_len = php_strip_tags(retval, actual_len, &stream->fgetss_state, allowed_tags, allowed_tags_len);
- RETURN_STRINGL(retval, retval_len, 0);
+//??? RETURN_STRINGL(retval, retval_len, 0);
+ RETURN_STRINGL(retval, retval_len);
}
/* }}} */
@@ -1121,7 +1130,7 @@ PHPAPI PHP_FUNCTION(fgetss)
PHP_FUNCTION(fscanf)
{
int result, format_len, type, argc = 0;
- zval ***args = NULL;
+ zval *args = NULL;
zval *file_handle;
char *buf, *format;
size_t len;
@@ -1131,7 +1140,7 @@ PHP_FUNCTION(fscanf)
return;
}
- what = zend_fetch_resource(&file_handle TSRMLS_CC, -1, "File-Handle", &type, 2, php_file_le_stream(), php_file_le_pstream());
+ what = zend_fetch_resource(file_handle TSRMLS_CC, -1, "File-Handle", &type, 2, php_file_le_stream(), php_file_le_pstream());
/* we can't do a ZEND_VERIFY_RESOURCE(what), otherwise we end up
* with a leak if we have an invalid filehandle. This needs changing
@@ -1151,7 +1160,7 @@ PHP_FUNCTION(fscanf)
RETURN_FALSE;
}
- result = php_sscanf_internal(buf, format, argc, args, 0, &return_value TSRMLS_CC);
+ result = php_sscanf_internal(buf, format, argc, args, 0, return_value TSRMLS_CC);
if (args) {
efree(args);
@@ -1191,7 +1200,7 @@ PHPAPI PHP_FUNCTION(fwrite)
RETURN_LONG(0);
}
- PHP_STREAM_TO_ZVAL(stream, &arg1);
+ PHP_STREAM_TO_ZVAL(stream, arg1);
ret = php_stream_write(stream, buffer ? buffer : arg2, num_bytes);
if (buffer) {
@@ -1214,7 +1223,7 @@ PHPAPI PHP_FUNCTION(fflush)
RETURN_FALSE;
}
- PHP_STREAM_TO_ZVAL(stream, &arg1);
+ PHP_STREAM_TO_ZVAL(stream, arg1);
ret = php_stream_flush(stream);
if (ret) {
@@ -1235,7 +1244,7 @@ PHPAPI PHP_FUNCTION(rewind)
RETURN_FALSE;
}
- PHP_STREAM_TO_ZVAL(stream, &arg1);
+ PHP_STREAM_TO_ZVAL(stream, arg1);
if (-1 == php_stream_rewind(stream)) {
RETURN_FALSE;
@@ -1256,7 +1265,7 @@ PHPAPI PHP_FUNCTION(ftell)
RETURN_FALSE;
}
- PHP_STREAM_TO_ZVAL(stream, &arg1);
+ PHP_STREAM_TO_ZVAL(stream, arg1);
ret = php_stream_tell(stream);
if (ret == -1) {
@@ -1278,7 +1287,7 @@ PHPAPI PHP_FUNCTION(fseek)
RETURN_FALSE;
}
- PHP_STREAM_TO_ZVAL(stream, &arg1);
+ PHP_STREAM_TO_ZVAL(stream, arg1);
RETURN_LONG(php_stream_seek(stream, arg2, whence));
}
@@ -1417,7 +1426,7 @@ PHPAPI PHP_FUNCTION(fpassthru)
RETURN_FALSE;
}
- PHP_STREAM_TO_ZVAL(stream, &arg1);
+ PHP_STREAM_TO_ZVAL(stream, arg1);
size = php_stream_passthru(stream);
RETURN_LONG(size);
@@ -1504,7 +1513,7 @@ PHP_NAMED_FUNCTION(php_if_ftruncate)
RETURN_FALSE;
}
- PHP_STREAM_TO_ZVAL(stream, &fp);
+ PHP_STREAM_TO_ZVAL(stream, fp);
if (!php_stream_truncate_supported(stream)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't truncate this stream!");
@@ -1520,8 +1529,8 @@ PHP_NAMED_FUNCTION(php_if_ftruncate)
PHP_NAMED_FUNCTION(php_if_fstat)
{
zval *fp;
- zval *stat_dev, *stat_ino, *stat_mode, *stat_nlink, *stat_uid, *stat_gid, *stat_rdev,
- *stat_size, *stat_atime, *stat_mtime, *stat_ctime, *stat_blksize, *stat_blocks;
+ zval stat_dev, stat_ino, stat_mode, stat_nlink, stat_uid, stat_gid, stat_rdev,
+ stat_size, stat_atime, stat_mtime, stat_ctime, stat_blksize, stat_blocks;
php_stream *stream;
php_stream_statbuf stat_ssb;
char *stat_sb_names[13] = {
@@ -1533,7 +1542,7 @@ PHP_NAMED_FUNCTION(php_if_fstat)
RETURN_FALSE;
}
- PHP_STREAM_TO_ZVAL(stream, &fp);
+ PHP_STREAM_TO_ZVAL(stream, fp);
if (php_stream_stat(stream, &stat_ssb)) {
RETURN_FALSE;
@@ -1541,60 +1550,60 @@ PHP_NAMED_FUNCTION(php_if_fstat)
array_init(return_value);
- MAKE_LONG_ZVAL_INCREF(stat_dev, stat_ssb.sb.st_dev);
- MAKE_LONG_ZVAL_INCREF(stat_ino, stat_ssb.sb.st_ino);
- MAKE_LONG_ZVAL_INCREF(stat_mode, stat_ssb.sb.st_mode);
- MAKE_LONG_ZVAL_INCREF(stat_nlink, stat_ssb.sb.st_nlink);
- MAKE_LONG_ZVAL_INCREF(stat_uid, stat_ssb.sb.st_uid);
- MAKE_LONG_ZVAL_INCREF(stat_gid, stat_ssb.sb.st_gid);
+ ZVAL_LONG(&stat_dev, stat_ssb.sb.st_dev);
+ ZVAL_LONG(&stat_ino, stat_ssb.sb.st_ino);
+ ZVAL_LONG(&stat_mode, stat_ssb.sb.st_mode);
+ ZVAL_LONG(&stat_nlink, stat_ssb.sb.st_nlink);
+ ZVAL_LONG(&stat_uid, stat_ssb.sb.st_uid);
+ ZVAL_LONG(&stat_gid, stat_ssb.sb.st_gid);
#ifdef HAVE_ST_RDEV
- MAKE_LONG_ZVAL_INCREF(stat_rdev, stat_ssb.sb.st_rdev);
+ ZVAL_LONG(&stat_rdev, stat_ssb.sb.st_rdev);
#else
- MAKE_LONG_ZVAL_INCREF(stat_rdev, -1);
+ ZVAL_LONG(&stat_rdev, -1);
#endif
- MAKE_LONG_ZVAL_INCREF(stat_size, stat_ssb.sb.st_size);
- MAKE_LONG_ZVAL_INCREF(stat_atime, stat_ssb.sb.st_atime);
- MAKE_LONG_ZVAL_INCREF(stat_mtime, stat_ssb.sb.st_mtime);
- MAKE_LONG_ZVAL_INCREF(stat_ctime, stat_ssb.sb.st_ctime);
+ ZVAL_LONG(&stat_size, stat_ssb.sb.st_size);
+ ZVAL_LONG(&stat_atime, stat_ssb.sb.st_atime);
+ ZVAL_LONG(&stat_mtime, stat_ssb.sb.st_mtime);
+ ZVAL_LONG(&stat_ctime, stat_ssb.sb.st_ctime);
#ifdef HAVE_ST_BLKSIZE
- MAKE_LONG_ZVAL_INCREF(stat_blksize, stat_ssb.sb.st_blksize);
+ ZVAL_LONG(&stat_blksize, stat_ssb.sb.st_blksize);
#else
- MAKE_LONG_ZVAL_INCREF(stat_blksize,-1);
+ ZVAL_LONG(&stat_blksize,-1);
#endif
#ifdef HAVE_ST_BLOCKS
- MAKE_LONG_ZVAL_INCREF(stat_blocks, stat_ssb.sb.st_blocks);
+ ZVAL_LONG(&stat_blocks, stat_ssb.sb.st_blocks);
#else
- MAKE_LONG_ZVAL_INCREF(stat_blocks,-1);
+ ZVAL_LONG(&stat_blocks,-1);
#endif
/* Store numeric indexes in propper order */
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_dev, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_ino, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_mode, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_nlink, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_uid, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_gid, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_rdev, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_size, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_atime, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_mtime, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_ctime, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_blksize, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_blocks, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_dev);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_ino);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_mode);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_nlink);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_uid);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_gid);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_rdev);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_size);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_atime);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_mtime);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_ctime);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_blksize);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_blocks);
/* Store string indexes referencing the same zval*/
- zend_hash_update(HASH_OF(return_value), stat_sb_names[0], strlen(stat_sb_names[0])+1, (void *)&stat_dev, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[1], strlen(stat_sb_names[1])+1, (void *)&stat_ino, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[2], strlen(stat_sb_names[2])+1, (void *)&stat_mode, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[3], strlen(stat_sb_names[3])+1, (void *)&stat_nlink, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[4], strlen(stat_sb_names[4])+1, (void *)&stat_uid, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[5], strlen(stat_sb_names[5])+1, (void *)&stat_gid, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[6], strlen(stat_sb_names[6])+1, (void *)&stat_rdev, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[7], strlen(stat_sb_names[7])+1, (void *)&stat_size, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[8], strlen(stat_sb_names[8])+1, (void *)&stat_atime, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[9], strlen(stat_sb_names[9])+1, (void *)&stat_mtime, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[10], strlen(stat_sb_names[10])+1, (void *)&stat_ctime, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[11], strlen(stat_sb_names[11])+1, (void *)&stat_blksize, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[12], strlen(stat_sb_names[12])+1, (void *)&stat_blocks, sizeof(zval *), NULL);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[0], strlen(stat_sb_names[0]), &stat_dev);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[1], strlen(stat_sb_names[1]), &stat_ino);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[2], strlen(stat_sb_names[2]), &stat_mode);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[3], strlen(stat_sb_names[3]), &stat_nlink);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[4], strlen(stat_sb_names[4]), &stat_uid);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[5], strlen(stat_sb_names[5]), &stat_gid);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[6], strlen(stat_sb_names[6]), &stat_rdev);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[7], strlen(stat_sb_names[7]), &stat_size);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[8], strlen(stat_sb_names[8]), &stat_atime);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[9], strlen(stat_sb_names[9]), &stat_mtime);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[10], strlen(stat_sb_names[10]), &stat_ctime);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[11], strlen(stat_sb_names[11]), &stat_blksize);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[12], strlen(stat_sb_names[12]), &stat_blocks);
}
/* }}} */
@@ -1747,19 +1756,18 @@ PHPAPI PHP_FUNCTION(fread)
RETURN_FALSE;
}
- PHP_STREAM_TO_ZVAL(stream, &arg1);
+ PHP_STREAM_TO_ZVAL(stream, arg1);
if (len <= 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be greater than 0");
RETURN_FALSE;
}
- Z_STRVAL_P(return_value) = emalloc(len + 1);
+ ZVAL_STR(return_value, STR_ALLOC(len, 0));
Z_STRLEN_P(return_value) = php_stream_read(stream, Z_STRVAL_P(return_value), len);
/* needed because recv/read/gzread doesnt put a null at the end*/
Z_STRVAL_P(return_value)[Z_STRLEN_P(return_value)] = 0;
- Z_TYPE_P(return_value) = IS_STRING;
}
/* }}} */
@@ -1858,7 +1866,7 @@ PHP_FUNCTION(fputcsv)
escape_char = *escape_str;
}
- PHP_STREAM_TO_ZVAL(stream, &fp);
+ PHP_STREAM_TO_ZVAL(stream, fp);
ret = php_fputcsv(stream, fields, delimiter, enclosure, escape_char TSRMLS_CC);
RETURN_LONG(ret);
@@ -1869,16 +1877,16 @@ PHP_FUNCTION(fputcsv)
PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char enclosure, char escape_char TSRMLS_DC)
{
int count, i = 0, ret;
- zval **field_tmp = NULL, field;
+ zval *field_tmp = NULL, field;
smart_str csvline = {0};
HashPosition pos;
count = zend_hash_num_elements(Z_ARRVAL_P(fields));
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(fields), &pos);
- while (zend_hash_get_current_data_ex(Z_ARRVAL_P(fields), (void **) &field_tmp, &pos) == SUCCESS) {
- field = **field_tmp;
+ while ((field_tmp = zend_hash_get_current_data_ex(Z_ARRVAL_P(fields), &pos)) != NULL) {
+ ZVAL_COPY_VALUE(&field, field_tmp);
- if (Z_TYPE_PP(field_tmp) != IS_STRING) {
+ if (Z_TYPE(field) != IS_STRING) {
zval_copy_ctor(&field);
convert_to_string(&field);
}
@@ -1918,7 +1926,7 @@ PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char en
}
zend_hash_move_forward_ex(Z_ARRVAL_P(fields), &pos);
- if (Z_TYPE_PP(field_tmp) != IS_STRING) {
+ if (Z_TYPE_P(field_tmp) != IS_STRING) {
zval_dtor(&field);
}
}
@@ -1950,7 +1958,7 @@ PHP_FUNCTION(fgetcsv)
php_stream *stream;
{
- zval *fd, **len_zv = NULL;
+ zval *fd, *len_zv = NULL;
char *delimiter_str = NULL;
int delimiter_str_len = 0;
char *enclosure_str = NULL;
@@ -1958,7 +1966,7 @@ PHP_FUNCTION(fgetcsv)
char *escape_str = NULL;
int escape_str_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|Zsss",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|zsss",
&fd, &len_zv, &delimiter_str, &delimiter_str_len,
&enclosure_str, &enclosure_str_len,
&escape_str, &escape_str_len) == FAILURE
@@ -2002,9 +2010,9 @@ PHP_FUNCTION(fgetcsv)
escape = escape_str[0];
}
- if (len_zv != NULL && Z_TYPE_PP(len_zv) != IS_NULL) {
+ if (len_zv != NULL && Z_TYPE_P(len_zv) != IS_NULL) {
convert_to_long_ex(len_zv);
- len = Z_LVAL_PP(len_zv);
+ len = Z_LVAL_P(len_zv);
if (len < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter may not be negative");
RETURN_FALSE;
@@ -2015,7 +2023,7 @@ PHP_FUNCTION(fgetcsv)
len = -1;
}
- PHP_STREAM_TO_ZVAL(stream, &fd);
+ PHP_STREAM_TO_ZVAL(stream, fd);
}
if (len < 0) {
@@ -2315,7 +2323,7 @@ PHP_FUNCTION(realpath)
RETURN_FALSE;
}
#endif
- RETURN_STRING(resolved_path_buff, 1);
+ RETURN_STRING(resolved_path_buff);
} else {
RETURN_FALSE;
}
@@ -2464,7 +2472,7 @@ PHP_FUNCTION(sys_get_temp_dir)
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- RETURN_STRING((char *)php_get_temporary_directory(TSRMLS_C), 1);
+ RETURN_STRING((char *)php_get_temporary_directory(TSRMLS_C));
}
/* }}} */
diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c
index 2ec4ec3808..311ca48f1c 100644
--- a/ext/standard/filestat.c
+++ b/ext/standard/filestat.c
@@ -848,8 +848,8 @@ PHP_FUNCTION(clearstatcache)
*/
PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int type, zval *return_value TSRMLS_DC)
{
- zval *stat_dev, *stat_ino, *stat_mode, *stat_nlink, *stat_uid, *stat_gid, *stat_rdev,
- *stat_size, *stat_atime, *stat_mtime, *stat_ctime, *stat_blksize, *stat_blocks;
+ zval stat_dev, stat_ino, stat_mode, stat_nlink, stat_uid, stat_gid, stat_rdev,
+ stat_size, stat_atime, stat_mtime, stat_ctime, stat_blksize, stat_blocks;
struct stat *stat_sb;
php_stream_statbuf ssb;
int flags = 0, rmask=S_IROTH, wmask=S_IWOTH, xmask=S_IXOTH; /* access rights defaults to other */
@@ -979,20 +979,20 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ
RETURN_LONG((long)ssb.sb.st_ctime);
case FS_TYPE:
if (S_ISLNK(ssb.sb.st_mode)) {
- RETURN_STRING("link", 1);
+ RETURN_STRING("link");
}
switch(ssb.sb.st_mode & S_IFMT) {
- case S_IFIFO: RETURN_STRING("fifo", 1);
- case S_IFCHR: RETURN_STRING("char", 1);
- case S_IFDIR: RETURN_STRING("dir", 1);
- case S_IFBLK: RETURN_STRING("block", 1);
- case S_IFREG: RETURN_STRING("file", 1);
+ case S_IFIFO: RETURN_STRING("fifo");
+ case S_IFCHR: RETURN_STRING("char");
+ case S_IFDIR: RETURN_STRING("dir");
+ case S_IFBLK: RETURN_STRING("block");
+ case S_IFREG: RETURN_STRING("file");
#if defined(S_IFSOCK) && !defined(ZEND_WIN32)&&!defined(__BEOS__)
- case S_IFSOCK: RETURN_STRING("socket", 1);
+ case S_IFSOCK: RETURN_STRING("socket");
#endif
}
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unknown file type (%d)", ssb.sb.st_mode&S_IFMT);
- RETURN_STRING("unknown", 1);
+ RETURN_STRING("unknown");
case FS_IS_W:
RETURN_BOOL((ssb.sb.st_mode & wmask) != 0);
case FS_IS_R:
@@ -1012,61 +1012,61 @@ PHPAPI void php_stat(const char *filename, php_stat_len filename_length, int typ
case FS_STAT:
array_init(return_value);
- MAKE_LONG_ZVAL_INCREF(stat_dev, stat_sb->st_dev);
- MAKE_LONG_ZVAL_INCREF(stat_ino, stat_sb->st_ino);
- MAKE_LONG_ZVAL_INCREF(stat_mode, stat_sb->st_mode);
- MAKE_LONG_ZVAL_INCREF(stat_nlink, stat_sb->st_nlink);
- MAKE_LONG_ZVAL_INCREF(stat_uid, stat_sb->st_uid);
- MAKE_LONG_ZVAL_INCREF(stat_gid, stat_sb->st_gid);
+ ZVAL_LONG(&stat_dev, stat_sb->st_dev);
+ ZVAL_LONG(&stat_ino, stat_sb->st_ino);
+ ZVAL_LONG(&stat_mode, stat_sb->st_mode);
+ ZVAL_LONG(&stat_nlink, stat_sb->st_nlink);
+ ZVAL_LONG(&stat_uid, stat_sb->st_uid);
+ ZVAL_LONG(&stat_gid, stat_sb->st_gid);
#ifdef HAVE_ST_RDEV
- MAKE_LONG_ZVAL_INCREF(stat_rdev, stat_sb->st_rdev);
+ ZVAL_LONG(&stat_rdev, stat_sb->st_rdev);
#else
- MAKE_LONG_ZVAL_INCREF(stat_rdev, -1);
+ ZVAL_LONG(&stat_rdev, -1);
#endif
- MAKE_LONG_ZVAL_INCREF(stat_size, stat_sb->st_size);
- MAKE_LONG_ZVAL_INCREF(stat_atime, stat_sb->st_atime);
- MAKE_LONG_ZVAL_INCREF(stat_mtime, stat_sb->st_mtime);
- MAKE_LONG_ZVAL_INCREF(stat_ctime, stat_sb->st_ctime);
+ ZVAL_LONG(&stat_size, stat_sb->st_size);
+ ZVAL_LONG(&stat_atime, stat_sb->st_atime);
+ ZVAL_LONG(&stat_mtime, stat_sb->st_mtime);
+ ZVAL_LONG(&stat_ctime, stat_sb->st_ctime);
#ifdef HAVE_ST_BLKSIZE
- MAKE_LONG_ZVAL_INCREF(stat_blksize, stat_sb->st_blksize);
+ ZVAL_LONG(&stat_blksize, stat_sb->st_blksize);
#else
- MAKE_LONG_ZVAL_INCREF(stat_blksize,-1);
+ ZVAL_LONG(&stat_blksize,-1);
#endif
#ifdef HAVE_ST_BLOCKS
- MAKE_LONG_ZVAL_INCREF(stat_blocks, stat_sb->st_blocks);
+ ZVAL_LONG(&stat_blocks, stat_sb->st_blocks);
#else
- MAKE_LONG_ZVAL_INCREF(stat_blocks,-1);
+ ZVAL_LONG(&stat_blocks,-1);
#endif
/* Store numeric indexes in propper order */
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_dev, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_ino, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_mode, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_nlink, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_uid, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_gid, sizeof(zval *), NULL);
-
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_rdev, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_size, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_atime, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_mtime, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_ctime, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_blksize, sizeof(zval *), NULL);
- zend_hash_next_index_insert(HASH_OF(return_value), (void *)&stat_blocks, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_dev);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_ino);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_mode);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_nlink);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_uid);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_gid);
+
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_rdev);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_size);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_atime);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_mtime);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_ctime);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_blksize);
+ zend_hash_next_index_insert(HASH_OF(return_value), &stat_blocks);
/* Store string indexes referencing the same zval*/
- zend_hash_update(HASH_OF(return_value), stat_sb_names[0], strlen(stat_sb_names[0])+1, (void *) &stat_dev, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[1], strlen(stat_sb_names[1])+1, (void *) &stat_ino, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[2], strlen(stat_sb_names[2])+1, (void *) &stat_mode, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[3], strlen(stat_sb_names[3])+1, (void *) &stat_nlink, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[4], strlen(stat_sb_names[4])+1, (void *) &stat_uid, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[5], strlen(stat_sb_names[5])+1, (void *) &stat_gid, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[6], strlen(stat_sb_names[6])+1, (void *) &stat_rdev, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[7], strlen(stat_sb_names[7])+1, (void *) &stat_size, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[8], strlen(stat_sb_names[8])+1, (void *) &stat_atime, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[9], strlen(stat_sb_names[9])+1, (void *) &stat_mtime, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[10], strlen(stat_sb_names[10])+1, (void *) &stat_ctime, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[11], strlen(stat_sb_names[11])+1, (void *) &stat_blksize, sizeof(zval *), NULL);
- zend_hash_update(HASH_OF(return_value), stat_sb_names[12], strlen(stat_sb_names[12])+1, (void *) &stat_blocks, sizeof(zval *), NULL);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[0], strlen(stat_sb_names[0]), &stat_dev);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[1], strlen(stat_sb_names[1]), &stat_ino);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[2], strlen(stat_sb_names[2]), &stat_mode);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[3], strlen(stat_sb_names[3]), &stat_nlink);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[4], strlen(stat_sb_names[4]), &stat_uid);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[5], strlen(stat_sb_names[5]), &stat_gid);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[6], strlen(stat_sb_names[6]), &stat_rdev);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[7], strlen(stat_sb_names[7]), &stat_size);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[8], strlen(stat_sb_names[8]), &stat_atime);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[9], strlen(stat_sb_names[9]), &stat_mtime);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[10], strlen(stat_sb_names[10]), &stat_ctime);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[11], strlen(stat_sb_names[11]), &stat_blksize);
+ zend_hash_str_update(HASH_OF(return_value), stat_sb_names[12], strlen(stat_sb_names[12]), &stat_blocks);
return;
}
@@ -1204,26 +1204,26 @@ PHP_FUNCTION(realpath_cache_get)
while(buckets < end) {
realpath_cache_bucket *bucket = *buckets;
while(bucket) {
- zval *entry;
- MAKE_STD_ZVAL(entry);
- array_init(entry);
+ zval entry;
+
+ array_init(&entry);
/* bucket->key is unsigned long */
if (LONG_MAX >= bucket->key) {
- add_assoc_long(entry, "key", bucket->key);
+ add_assoc_long(&entry, "key", bucket->key);
} else {
- add_assoc_double(entry, "key", (double)bucket->key);
+ add_assoc_double(&entry, "key", (double)bucket->key);
}
- add_assoc_bool(entry, "is_dir", bucket->is_dir);
- add_assoc_stringl(entry, "realpath", bucket->realpath, bucket->realpath_len, 1);
- add_assoc_long(entry, "expires", bucket->expires);
+ add_assoc_bool(&entry, "is_dir", bucket->is_dir);
+ add_assoc_stringl(&entry, "realpath", bucket->realpath, bucket->realpath_len, 1);
+ add_assoc_long(&entry, "expires", bucket->expires);
#ifdef PHP_WIN32
- add_assoc_bool(entry, "is_rvalid", bucket->is_rvalid);
- add_assoc_bool(entry, "is_wvalid", bucket->is_wvalid);
- add_assoc_bool(entry, "is_readable", bucket->is_readable);
- add_assoc_bool(entry, "is_writable", bucket->is_writable);
+ add_assoc_bool(&entry, "is_rvalid", bucket->is_rvalid);
+ add_assoc_bool(&entry, "is_wvalid", bucket->is_wvalid);
+ add_assoc_bool(&entry, "is_readable", bucket->is_readable);
+ add_assoc_bool(&entry, "is_writable", bucket->is_writable);
#endif
- zend_hash_update(Z_ARRVAL_P(return_value), bucket->path, bucket->path_len+1, &entry, sizeof(zval *), NULL);
+ zend_hash_str_update(Z_ARRVAL_P(return_value), bucket->path, bucket->path_len, &entry);
bucket = bucket->next;
}
buckets++;
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c
index 3cd5839313..00ecfb2892 100644
--- a/ext/standard/formatted_print.c
+++ b/ext/standard/formatted_print.c
@@ -52,21 +52,20 @@ static char HEXCHARS[] = "0123456789ABCDEF";
/* php_spintf_appendchar() {{{ */
inline static void
-php_sprintf_appendchar(char **buffer, int *pos, int *size, char add TSRMLS_DC)
+php_sprintf_appendchar(zend_string **buffer, int *pos, char add TSRMLS_DC)
{
- if ((*pos + 1) >= *size) {
- *size <<= 1;
- PRINTF_DEBUG(("%s(): ereallocing buffer to %d bytes\n", get_active_function_name(TSRMLS_C), *size));
- *buffer = erealloc(*buffer, *size);
+ if (!*buffer || (*pos + 1) >= (*buffer)->len) {
+ PRINTF_DEBUG(("%s(): ereallocing buffer to %d bytes\n", get_active_function_name(TSRMLS_C), (*buffer)->len));
+ *buffer = STR_EREALLOC(*buffer, (*buffer)->len << 1);
}
PRINTF_DEBUG(("sprintf: appending '%c', pos=\n", add, *pos));
- (*buffer)[(*pos)++] = add;
+ (*buffer)->val[(*pos)++] = add;
}
/* }}} */
/* php_spintf_appendstring() {{{ */
inline static void
-php_sprintf_appendstring(char **buffer, int *pos, int *size, char *add,
+php_sprintf_appendstring(zend_string **buffer, int *pos, char *add,
int min_width, int max_width, char padding,
int alignment, int len, int neg, int expprec, int always_sign)
{
@@ -83,7 +82,7 @@ php_sprintf_appendstring(char **buffer, int *pos, int *size, char *add,
}
PRINTF_DEBUG(("sprintf: appendstring(%x, %d, %d, \"%s\", %d, '%c', %d)\n",
- *buffer, *pos, *size, add, min_width, padding, alignment));
+ *buffer, *pos, (*buffer)->len, add, min_width, padding, alignment));
m_width = MAX(min_width, copy_len);
if(m_width > INT_MAX - *pos - 1) {
@@ -92,33 +91,34 @@ php_sprintf_appendstring(char **buffer, int *pos, int *size, char *add,
req_size = *pos + m_width + 1;
- if (req_size > *size) {
- while (req_size > *size) {
- if(*size > INT_MAX/2) {
+ if (!*buffer || req_size > (*buffer)->len) {
+ int size = (*buffer)->len;
+ while (req_size > size) {
+ if (size > INT_MAX/2) {
zend_error_noreturn(E_ERROR, "Field width %d is too long", req_size);
}
- *size <<= 1;
+ size <<= 1;
}
- PRINTF_DEBUG(("sprintf ereallocing buffer to %d bytes\n", *size));
- *buffer = erealloc(*buffer, *size);
+ PRINTF_DEBUG(("sprintf ereallocing buffer to %d bytes\n", size));
+ *buffer = STR_EREALLOC(*buffer, size);
}
if (alignment == ALIGN_RIGHT) {
if ((neg || always_sign) && padding=='0') {
- (*buffer)[(*pos)++] = (neg) ? '-' : '+';
+ (*buffer)->val[(*pos)++] = (neg) ? '-' : '+';
add++;
len--;
copy_len--;
}
while (npad-- > 0) {
- (*buffer)[(*pos)++] = padding;
+ (*buffer)->val[(*pos)++] = padding;
}
}
PRINTF_DEBUG(("sprintf: appending \"%s\"\n", add));
- memcpy(&(*buffer)[*pos], add, copy_len + 1);
+ memcpy(&(*buffer)->val[*pos], add, copy_len + 1);
*pos += copy_len;
if (alignment == ALIGN_LEFT) {
while (npad--) {
- (*buffer)[(*pos)++] = padding;
+ (*buffer)->val[(*pos)++] = padding;
}
}
}
@@ -126,7 +126,7 @@ php_sprintf_appendstring(char **buffer, int *pos, int *size, char *add,
/* php_spintf_appendint() {{{ */
inline static void
-php_sprintf_appendint(char **buffer, int *pos, int *size, long number,
+php_sprintf_appendint(zend_string **buffer, int *pos, long number,
int width, char padding, int alignment,
int always_sign)
{
@@ -135,7 +135,7 @@ php_sprintf_appendint(char **buffer, int *pos, int *size, long number,
register unsigned int i = NUM_BUF_SIZE - 1, neg = 0;
PRINTF_DEBUG(("sprintf: appendint(%x, %x, %x, %d, %d, '%c', %d)\n",
- *buffer, pos, size, number, width, padding, alignment));
+ *buffer, pos, &(*buffer)->len, number, width, padding, alignment));
if (number < 0) {
neg = 1;
magn = ((unsigned long) -(number + 1)) + 1;
@@ -162,7 +162,7 @@ php_sprintf_appendint(char **buffer, int *pos, int *size, long number,
}
PRINTF_DEBUG(("sprintf: appending %d as \"%s\", i=%d\n",
number, &numbuf[i], i));
- php_sprintf_appendstring(buffer, pos, size, &numbuf[i], width, 0,
+ php_sprintf_appendstring(buffer, pos, &numbuf[i], width, 0,
padding, alignment, (NUM_BUF_SIZE - 1) - i,
neg, 0, always_sign);
}
@@ -170,7 +170,7 @@ php_sprintf_appendint(char **buffer, int *pos, int *size, long number,
/* php_spintf_appenduint() {{{ */
inline static void
-php_sprintf_appenduint(char **buffer, int *pos, int *size,
+php_sprintf_appenduint(zend_string **buffer, int *pos,
unsigned long number,
int width, char padding, int alignment)
{
@@ -179,7 +179,7 @@ php_sprintf_appenduint(char **buffer, int *pos, int *size,
register unsigned int i = NUM_BUF_SIZE - 1;
PRINTF_DEBUG(("sprintf: appenduint(%x, %x, %x, %d, %d, '%c', %d)\n",
- *buffer, pos, size, number, width, padding, alignment));
+ *buffer, pos, &(*buffer)->len, number, width, padding, alignment));
magn = (unsigned long) number;
/* Can't right-pad 0's on integers */
@@ -195,15 +195,15 @@ php_sprintf_appenduint(char **buffer, int *pos, int *size,
} while (magn > 0 && i > 0);
PRINTF_DEBUG(("sprintf: appending %d as \"%s\", i=%d\n", number, &numbuf[i], i));
- php_sprintf_appendstring(buffer, pos, size, &numbuf[i], width, 0,
+ php_sprintf_appendstring(buffer, pos, &numbuf[i], width, 0,
padding, alignment, (NUM_BUF_SIZE - 1) - i, 0, 0, 0);
}
/* }}} */
/* php_spintf_appenddouble() {{{ */
inline static void
-php_sprintf_appenddouble(char **buffer, int *pos,
- int *size, double number,
+php_sprintf_appenddouble(zend_string **buffer, int *pos,
+ double number,
int width, char padding,
int alignment, int precision,
int adjust, char fmt,
@@ -218,7 +218,7 @@ php_sprintf_appenddouble(char **buffer, int *pos,
#endif
PRINTF_DEBUG(("sprintf: appenddouble(%x, %x, %x, %f, %d, '%c', %d, %c)\n",
- *buffer, pos, size, number, width, padding, alignment, fmt));
+ *buffer, pos, &(*buffer)->len, number, width, padding, alignment, fmt));
if ((adjust & ADJ_PRECISION) == 0) {
precision = FLOAT_PRECISION;
} else if (precision > MAX_FLOAT_PRECISION) {
@@ -228,14 +228,14 @@ php_sprintf_appenddouble(char **buffer, int *pos,
if (zend_isnan(number)) {
is_negative = (number<0);
- php_sprintf_appendstring(buffer, pos, size, "NaN", 3, 0, padding,
+ php_sprintf_appendstring(buffer, pos, "NaN", 3, 0, padding,
alignment, 3, is_negative, 0, always_sign);
return;
}
if (zend_isinf(number)) {
is_negative = (number<0);
- php_sprintf_appendstring(buffer, pos, size, "INF", 3, 0, padding,
+ php_sprintf_appendstring(buffer, pos, "INF", 3, 0, padding,
alignment, 3, is_negative, 0, always_sign);
return;
}
@@ -286,14 +286,14 @@ php_sprintf_appenddouble(char **buffer, int *pos,
break;
}
- php_sprintf_appendstring(buffer, pos, size, s, width, 0, padding,
+ php_sprintf_appendstring(buffer, pos, s, width, 0, padding,
alignment, s_len, is_negative, 0, always_sign);
}
/* }}} */
/* php_spintf_appendd2n() {{{ */
inline static void
-php_sprintf_append2n(char **buffer, int *pos, int *size, long number,
+php_sprintf_append2n(zend_string **buffer, int *pos, long number,
int width, char padding, int alignment, int n,
char *chartable, int expprec)
{
@@ -303,7 +303,7 @@ php_sprintf_append2n(char **buffer, int *pos, int *size, long number,
register int andbits = (1 << n) - 1;
PRINTF_DEBUG(("sprintf: append2n(%x, %x, %x, %d, %d, '%c', %d, %d, %x)\n",
- *buffer, pos, size, number, width, padding, alignment, n,
+ *buffer, pos, &(*buffer)->len, number, width, padding, alignment, n,
chartable));
PRINTF_DEBUG(("sprintf: append2n 2^%d andbits=%x\n", n, andbits));
@@ -316,7 +316,7 @@ php_sprintf_append2n(char **buffer, int *pos, int *size, long number,
}
while (num > 0);
- php_sprintf_appendstring(buffer, pos, size, &numbuf[i], width, 0,
+ php_sprintf_appendstring(buffer, pos, &numbuf[i], width, 0,
padding, alignment, (NUM_BUF_SIZE - 1) - i,
0, expprec, 0);
}
@@ -368,13 +368,14 @@ php_sprintf_getnumber(char *buffer, int *pos)
* "X" integer argument is printed as uppercase hexadecimal
*
*/
-static char *
-php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC)
+static zend_string *
+php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC)
{
- zval ***args, **z_format;
+ zval *args, *z_format;
int argc, size = 240, inpos = 0, outpos = 0, temppos;
int alignment, currarg, adjusting, argnum, width, precision;
- char *format, *result, padding;
+ char *format, padding;
+ zend_string *result;
int always_sign;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &args, &argc) == FAILURE) {
@@ -390,44 +391,46 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC
if (use_array) {
int i = 1;
- zval ***newargs;
- zval **array;
+ zval *newargs, *zv;
+ zval array;
- z_format = args[format_offset];
- array = args[1 + format_offset];
+ z_format = &args[format_offset];
+ ZVAL_COPY_VALUE(&array, &args[1 + format_offset]);
- SEPARATE_ZVAL(array);
- convert_to_array_ex(array);
+ SEPARATE_ZVAL(&array);
+ convert_to_array_ex(&array);
- argc = 1 + zend_hash_num_elements(Z_ARRVAL_PP(array));
- newargs = (zval ***)safe_emalloc(argc, sizeof(zval *), 0);
- newargs[0] = z_format;
+ argc = 1 + zend_hash_num_elements(Z_ARRVAL(array));
+ newargs = (zval *)safe_emalloc(argc, sizeof(zval), 0);
+ ZVAL_COPY_VALUE(&newargs[0], z_format);
- for (zend_hash_internal_pointer_reset(Z_ARRVAL_PP(array));
- zend_hash_get_current_data(Z_ARRVAL_PP(array), (void **)&newargs[i++]) == SUCCESS;
- zend_hash_move_forward(Z_ARRVAL_PP(array)));
-
+ for (zend_hash_internal_pointer_reset(Z_ARRVAL(array));
+ (zv = zend_hash_get_current_data(Z_ARRVAL(array))) != NULL;
+ zend_hash_move_forward(Z_ARRVAL(array))) {
+ ZVAL_COPY_VALUE(&newargs[i], zv);
+ i++;
+ }
efree(args);
args = newargs;
format_offset = 0;
}
- convert_to_string_ex(args[format_offset]);
- format = Z_STRVAL_PP(args[format_offset]);
- result = emalloc(size);
+ convert_to_string_ex(&args[format_offset]);
+ format = Z_STRVAL(args[format_offset]);
+ result = STR_ALLOC(size, 0);
currarg = 1;
- while (inpos<Z_STRLEN_PP(args[format_offset])) {
+ while (inpos<Z_STRLEN(args[format_offset])) {
int expprec = 0, multiuse = 0;
- zval *tmp;
+ zval tmp;
PRINTF_DEBUG(("sprintf: format[%d]='%c'\n", inpos, format[inpos]));
PRINTF_DEBUG(("sprintf: outpos=%d\n", outpos));
if (format[inpos] != '%') {
- php_sprintf_appendchar(&result, &outpos, &size, format[inpos++] TSRMLS_CC);
+ php_sprintf_appendchar(&result, &outpos, format[inpos++] TSRMLS_CC);
} else if (format[inpos + 1] == '%') {
- php_sprintf_appendchar(&result, &outpos, &size, '%' TSRMLS_CC);
+ php_sprintf_appendchar(&result, &outpos, '%' TSRMLS_CC);
inpos += 2;
} else {
/* starting a new format specifier, reset variables */
@@ -538,13 +541,10 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC
PRINTF_DEBUG(("sprintf: format character='%c'\n", format[inpos]));
/* now we expect to find a type specifier */
if (multiuse) {
- MAKE_STD_ZVAL(tmp);
- *tmp = **(args[argnum]);
- INIT_PZVAL(tmp);
- zval_copy_ctor(tmp);
+ ZVAL_DUP(&tmp, &args[argnum]);
} else {
- SEPARATE_ZVAL(args[argnum]);
- tmp = *(args[argnum]);
+ SEPARATE_ZVAL(&args[argnum]);
+ ZVAL_COPY_VALUE(&tmp, &args[argnum]);
}
switch (format[inpos]) {
@@ -552,13 +552,13 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC
zval *var, var_copy;
int use_copy;
- zend_make_printable_zval(tmp, &var_copy, &use_copy);
+ zend_make_printable_zval(&tmp, &var_copy, &use_copy);
if (use_copy) {
var = &var_copy;
} else {
- var = tmp;
+ var = &tmp;
}
- php_sprintf_appendstring(&result, &outpos, &size,
+ php_sprintf_appendstring(&result, &outpos,
Z_STRVAL_P(var),
width, precision, padding,
alignment,
@@ -571,17 +571,17 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC
}
case 'd':
- convert_to_long(tmp);
- php_sprintf_appendint(&result, &outpos, &size,
- Z_LVAL_P(tmp),
+ convert_to_long(&tmp);
+ php_sprintf_appendint(&result, &outpos,
+ Z_LVAL(tmp),
width, padding, alignment,
always_sign);
break;
case 'u':
- convert_to_long(tmp);
- php_sprintf_appenduint(&result, &outpos, &size,
- Z_LVAL_P(tmp),
+ convert_to_long(&tmp);
+ php_sprintf_appenduint(&result, &outpos,
+ Z_LVAL(tmp),
width, padding, alignment);
break;
@@ -591,9 +591,9 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC
case 'E':
case 'f':
case 'F':
- convert_to_double(tmp);
- php_sprintf_appenddouble(&result, &outpos, &size,
- Z_DVAL_P(tmp),
+ convert_to_double(&tmp);
+ php_sprintf_appenddouble(&result, &outpos,
+ Z_DVAL(tmp),
width, padding, alignment,
precision, adjusting,
format[inpos], always_sign
@@ -601,45 +601,45 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC
break;
case 'c':
- convert_to_long(tmp);
- php_sprintf_appendchar(&result, &outpos, &size,
- (char) Z_LVAL_P(tmp) TSRMLS_CC);
+ convert_to_long(&tmp);
+ php_sprintf_appendchar(&result, &outpos,
+ (char) Z_LVAL(tmp) TSRMLS_CC);
break;
case 'o':
- convert_to_long(tmp);
- php_sprintf_append2n(&result, &outpos, &size,
- Z_LVAL_P(tmp),
+ convert_to_long(&tmp);
+ php_sprintf_append2n(&result, &outpos,
+ Z_LVAL(tmp),
width, padding, alignment, 3,
hexchars, expprec);
break;
case 'x':
- convert_to_long(tmp);
- php_sprintf_append2n(&result, &outpos, &size,
- Z_LVAL_P(tmp),
+ convert_to_long(&tmp);
+ php_sprintf_append2n(&result, &outpos,
+ Z_LVAL(tmp),
width, padding, alignment, 4,
hexchars, expprec);
break;
case 'X':
- convert_to_long(tmp);
- php_sprintf_append2n(&result, &outpos, &size,
- Z_LVAL_P(tmp),
+ convert_to_long(&tmp);
+ php_sprintf_append2n(&result, &outpos,
+ Z_LVAL(tmp),
width, padding, alignment, 4,
HEXCHARS, expprec);
break;
case 'b':
- convert_to_long(tmp);
- php_sprintf_append2n(&result, &outpos, &size,
- Z_LVAL_P(tmp),
+ convert_to_long(&tmp);
+ php_sprintf_append2n(&result, &outpos,
+ Z_LVAL(tmp),
width, padding, alignment, 1,
hexchars, expprec);
break;
case '%':
- php_sprintf_appendchar(&result, &outpos, &size, '%' TSRMLS_CC);
+ php_sprintf_appendchar(&result, &outpos, '%' TSRMLS_CC);
break;
default:
@@ -655,8 +655,8 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC
efree(args);
/* possibly, we have to make sure we have room for the terminating null? */
- result[outpos]=0;
- *len = outpos;
+ result->val[outpos]=0;
+ result->len = outpos;
return result;
}
/* }}} */
@@ -665,13 +665,12 @@ php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC
Return a formatted string */
PHP_FUNCTION(user_sprintf)
{
- char *result;
- int len;
+ zend_string *result;
- if ((result=php_formatted_print(ht, &len, 0, 0 TSRMLS_CC))==NULL) {
+ if ((result=php_formatted_print(ZEND_NUM_ARGS(), 0, 0 TSRMLS_CC))==NULL) {
RETURN_FALSE;
}
- RETVAL_STRINGL(result, len, 0);
+ RETVAL_STR(result);
}
/* }}} */
@@ -679,13 +678,12 @@ PHP_FUNCTION(user_sprintf)
Return a formatted string */
PHP_FUNCTION(vsprintf)
{
- char *result;
- int len;
+ zend_string *result;
- if ((result=php_formatted_print(ht, &len, 1, 0 TSRMLS_CC))==NULL) {
+ if ((result=php_formatted_print(ZEND_NUM_ARGS(), 1, 0 TSRMLS_CC))==NULL) {
RETURN_FALSE;
}
- RETVAL_STRINGL(result, len, 0);
+ RETVAL_STR(result);
}
/* }}} */
@@ -693,14 +691,14 @@ PHP_FUNCTION(vsprintf)
Output a formatted string */
PHP_FUNCTION(user_printf)
{
- char *result;
- int len, rlen;
+ zend_string *result;
+ int rlen;
- if ((result=php_formatted_print(ht, &len, 0, 0 TSRMLS_CC))==NULL) {
+ if ((result=php_formatted_print(ZEND_NUM_ARGS(), 0, 0 TSRMLS_CC))==NULL) {
RETURN_FALSE;
}
- rlen = PHPWRITE(result, len);
- efree(result);
+ rlen = PHPWRITE(result->val, result->len);
+ STR_FREE(result);
RETURN_LONG(rlen);
}
/* }}} */
@@ -709,14 +707,14 @@ PHP_FUNCTION(user_printf)
Output a formatted string */
PHP_FUNCTION(vprintf)
{
- char *result;
- int len, rlen;
+ zend_string *result;
+ int rlen;
- if ((result=php_formatted_print(ht, &len, 1, 0 TSRMLS_CC))==NULL) {
+ if ((result=php_formatted_print(ZEND_NUM_ARGS(), 1, 0 TSRMLS_CC))==NULL) {
RETURN_FALSE;
}
- rlen = PHPWRITE(result, len);
- efree(result);
+ rlen = PHPWRITE(result->val, result->len);
+ STR_FREE(result);
RETURN_LONG(rlen);
}
/* }}} */
@@ -727,8 +725,7 @@ PHP_FUNCTION(fprintf)
{
php_stream *stream;
zval *arg1;
- char *result;
- int len;
+ zend_string *result;
if (ZEND_NUM_ARGS() < 2) {
WRONG_PARAM_COUNT;
@@ -738,17 +735,16 @@ PHP_FUNCTION(fprintf)
RETURN_FALSE;
}
- php_stream_from_zval(stream, &arg1);
+ php_stream_from_zval(stream, arg1);
- if ((result=php_formatted_print(ht, &len, 0, 1 TSRMLS_CC))==NULL) {
+ if ((result=php_formatted_print(ZEND_NUM_ARGS(), 0, 1 TSRMLS_CC))==NULL) {
RETURN_FALSE;
}
- php_stream_write(stream, result, len);
+ php_stream_write(stream, result->val, result->len);
- efree(result);
-
- RETURN_LONG(len);
+ RETVAL_LONG(result->len);
+ STR_FREE(result);
}
/* }}} */
@@ -758,8 +754,7 @@ PHP_FUNCTION(vfprintf)
{
php_stream *stream;
zval *arg1;
- char *result;
- int len;
+ zend_string *result;
if (ZEND_NUM_ARGS() != 3) {
WRONG_PARAM_COUNT;
@@ -769,17 +764,16 @@ PHP_FUNCTION(vfprintf)
RETURN_FALSE;
}
- php_stream_from_zval(stream, &arg1);
+ php_stream_from_zval(stream, arg1);
- if ((result=php_formatted_print(ht, &len, 1, 1 TSRMLS_CC))==NULL) {
+ if ((result=php_formatted_print(ZEND_NUM_ARGS(), 1, 1 TSRMLS_CC))==NULL) {
RETURN_FALSE;
}
- php_stream_write(stream, result, len);
-
- efree(result);
+ php_stream_write(stream, result->val, result->len);
- RETURN_LONG(len);
+ RETVAL_LONG(result->len);
+ STR_FREE(result);
}
/* }}} */
diff --git a/ext/standard/fsock.c b/ext/standard/fsock.c
index d5a554725a..d1446555a5 100644
--- a/ext/standard/fsock.c
+++ b/ext/standard/fsock.c
@@ -73,7 +73,7 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
}
if (zerrstr) {
zval_dtor(zerrstr);
- ZVAL_STRING(zerrstr, "", 1);
+ ZVAL_EMPTY_STRING(zerrstr);
}
stream = php_stream_xport_create(hostname, hostname_len, REPORT_ERRORS,
@@ -98,7 +98,8 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
if (zerrstr && errstr) {
/* no need to dup; we need to efree buf anyway */
zval_dtor(zerrstr);
- ZVAL_STRING(zerrstr, errstr, 0);
+//??? ZVAL_STRING(zerrstr, errstr, 0);
+ ZVAL_STRING(zerrstr, errstr);
}
else if (!zerrstr && errstr) {
efree(errstr);
diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c
index df03772c39..b0b2c6ba8c 100644
--- a/ext/standard/ftp_fopen_wrapper.c
+++ b/ext/standard/ftp_fopen_wrapper.c
@@ -423,7 +423,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *pa
int result = 0, use_ssl, use_ssl_on_data=0;
php_stream *reuseid=NULL;
size_t file_size = 0;
- zval **tmpzval;
+ zval *tmpzval;
int allow_overwrite = 0;
int read_write = 0;
char *transport;
@@ -452,7 +452,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *pa
}
if (context &&
- php_stream_context_get_option(context, "ftp", "proxy", &tmpzval) == SUCCESS) {
+ (tmpzval = php_stream_context_get_option(context, "ftp", "proxy")) != NULL) {
if (read_write == 1) {
/* Use http wrapper to proxy ftp request */
return php_stream_url_wrap_http(wrapper, path, mode, options, opened_path, context STREAMS_CC TSRMLS_CC);
@@ -497,8 +497,8 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *pa
}
} else if (read_write == 2) {
/* when writing file (but not appending), it must NOT exist, unless a context option exists which allows it */
- if (context && php_stream_context_get_option(context, "ftp", "overwrite", &tmpzval) == SUCCESS) {
- allow_overwrite = Z_LVAL_PP(tmpzval);
+ if (context && (tmpzval = php_stream_context_get_option(context, "ftp", "overwrite")) != NULL) {
+ allow_overwrite = Z_LVAL_P(tmpzval);
}
if (result <= 299 && result >= 200) {
if (allow_overwrite) {
@@ -528,13 +528,13 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *pa
if (read_write == 1) {
/* set resume position if applicable */
if (context &&
- php_stream_context_get_option(context, "ftp", "resume_pos", &tmpzval) == SUCCESS &&
- Z_TYPE_PP(tmpzval) == IS_LONG &&
- Z_LVAL_PP(tmpzval) > 0) {
- php_stream_printf(stream TSRMLS_CC, "REST %ld\r\n", Z_LVAL_PP(tmpzval));
+ (tmpzval = php_stream_context_get_option(context, "ftp", "resume_pos")) != NULL &&
+ Z_TYPE_P(tmpzval) == IS_LONG &&
+ Z_LVAL_P(tmpzval) > 0) {
+ php_stream_printf(stream TSRMLS_CC, "REST %ld\r\n", Z_LVAL_P(tmpzval));
result = GET_FTP_RESULT(stream);
if (result < 300 || result > 399) {
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Unable to resume from offset %ld", Z_LVAL_PP(tmpzval));
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Unable to resume from offset %ld", Z_LVAL_P(tmpzval));
goto errexit;
}
}
diff --git a/ext/standard/head.c b/ext/standard/head.c
index eca032a97b..d63f937623 100644
--- a/ext/standard/head.c
+++ b/ext/standard/head.c
@@ -243,9 +243,9 @@ PHP_FUNCTION(headers_sent)
case 1:
zval_dtor(arg1);
if (file) {
- ZVAL_STRING(arg1, file, 1);
+ ZVAL_STRING(arg1, file);
} else {
- ZVAL_STRING(arg1, "", 1);
+ ZVAL_EMPTY_STRING(arg1);
}
break;
}
diff --git a/ext/standard/html.c b/ext/standard/html.c
index 91fc050add..402b3aaac5 100644
--- a/ext/standard/html.c
+++ b/ext/standard/html.c
@@ -924,8 +924,7 @@ static inline size_t write_octet_sequence(unsigned char *buf, enum entity_charse
static void traverse_for_entities(
const char *old,
size_t oldlen,
- char *ret, /* should have allocated TRAVERSE_FOR_ENTITIES_EXPAND_SIZE(olden) */
- size_t *retlen,
+ zend_string *ret, /* should have allocated TRAVERSE_FOR_ENTITIES_EXPAND_SIZE(olden) */
int all,
int flags,
const entity_ht *inv_map,
@@ -939,7 +938,7 @@ static void traverse_for_entities(
lim = old + oldlen; /* terminator address */
assert(*lim == '\0');
- for (p = old, q = ret; p < lim;) {
+ for (p = old, q = ret->val; p < lim;) {
unsigned code, code2 = 0;
const char *next = NULL; /* when set, next > p, otherwise possible inf loop */
@@ -1012,9 +1011,9 @@ static void traverse_for_entities(
goto invalid_code; /* not representable in target charset */
}
- q += write_octet_sequence(q, charset, code);
+ q += write_octet_sequence((unsigned char*)q, charset, code);
if (code2) {
- q += write_octet_sequence(q, charset, code2);
+ q += write_octet_sequence((unsigned char*)q, charset, code2);
}
/* jump over the valid entity; may go beyond size of buffer; np */
@@ -1028,7 +1027,7 @@ invalid_code:
}
*q = '\0';
- *retlen = (size_t)(q - ret);
+ ret->len = (size_t)(q - ret->val);
}
/* }}} */
@@ -1083,10 +1082,10 @@ static entity_table_opt determine_entity_table(int all, int doctype)
* only the basic ones, i.e., those in basic_entities_ex + the numeric entities
* that correspond to quotes.
*/
-PHPAPI char *php_unescape_html_entities(unsigned char *old, size_t oldlen, size_t *newlen, int all, int flags, char *hint_charset TSRMLS_DC)
+PHPAPI zend_string *php_unescape_html_entities(unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset TSRMLS_DC)
{
size_t retlen;
- char *ret;
+ zend_string *ret;
enum entity_charset charset;
const entity_ht *inverse_map = NULL;
size_t new_size = TRAVERSE_FOR_ENTITIES_EXPAND_SIZE(oldlen);
@@ -1101,12 +1100,13 @@ PHPAPI char *php_unescape_html_entities(unsigned char *old, size_t oldlen, size_
if (oldlen > new_size) {
/* overflow, refuse to do anything */
- ret = estrndup((char*)old, oldlen);
+ ret = STR_INIT((char*)old, oldlen, 0);
retlen = oldlen;
goto empty_source;
}
- ret = emalloc(new_size);
- *ret = '\0';
+ ret = STR_ALLOC(new_size, 0);
+ ret->val[0] = '\0';
+ ret->len = oldlen;
retlen = oldlen;
if (retlen == 0) {
goto empty_source;
@@ -1115,17 +1115,16 @@ PHPAPI char *php_unescape_html_entities(unsigned char *old, size_t oldlen, size_
inverse_map = unescape_inverse_map(all, flags);
/* replace numeric entities */
- traverse_for_entities(old, oldlen, ret, &retlen, all, flags, inverse_map, charset);
+ traverse_for_entities((char*)old, oldlen, ret, all, flags, inverse_map, charset);
empty_source:
- *newlen = retlen;
return ret;
}
/* }}} */
-PHPAPI char *php_escape_html_entities(unsigned char *old, size_t oldlen, size_t *newlen, int all, int flags, char *hint_charset TSRMLS_DC)
+PHPAPI zend_string *php_escape_html_entities(unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset TSRMLS_DC)
{
- return php_escape_html_entities_ex(old, oldlen, newlen, all, flags, hint_charset, 1 TSRMLS_CC);
+ return php_escape_html_entities_ex(old, oldlen, all, flags, hint_charset, 1 TSRMLS_CC);
}
/* {{{ find_entity_for_char */
@@ -1211,10 +1210,10 @@ static inline void find_entity_for_char_basic(
/* {{{ php_escape_html_entities
*/
-PHPAPI char *php_escape_html_entities_ex(unsigned char *old, size_t oldlen, size_t *newlen, int all, int flags, char *hint_charset, zend_bool double_encode TSRMLS_DC)
+PHPAPI zend_string *php_escape_html_entities_ex(unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset, zend_bool double_encode TSRMLS_DC)
{
size_t cursor, maxlen, len;
- char *replaced;
+ zend_string *replaced;
enum entity_charset charset = determine_charset(hint_charset TSRMLS_CC);
int doctype = flags & ENT_HTML_DOC_TYPE_MASK;
entity_table_opt entity_table;
@@ -1264,7 +1263,7 @@ PHPAPI char *php_escape_html_entities_ex(unsigned char *old, size_t oldlen, size
}
}
- replaced = emalloc(maxlen + 1); /* adding 1 is safe: maxlen is even */
+ replaced = STR_ALLOC(maxlen, 0);
len = 0;
cursor = 0;
while (cursor < oldlen) {
@@ -1277,7 +1276,8 @@ PHPAPI char *php_escape_html_entities_ex(unsigned char *old, size_t oldlen, size
/* guarantee we have at least 40 bytes to write.
* In HTML5, entities may take up to 33 bytes */
if (len > maxlen - 40) { /* maxlen can never be smaller than 128 */
- replaced = safe_erealloc(replaced, maxlen , 1, 128 + 1);
+//??? replaced = safe_erealloc(replaced, maxlen , 1, 128 + 1);
+ replaced = STR_EREALLOC(replaced, maxlen + 128);
maxlen += 128;
}
@@ -1286,12 +1286,11 @@ PHPAPI char *php_escape_html_entities_ex(unsigned char *old, size_t oldlen, size
if (flags & ENT_HTML_IGNORE_ERRORS) {
continue;
} else if (flags & ENT_HTML_SUBSTITUTE_ERRORS) {
- memcpy(&replaced[len], replacement, replacement_len);
+ memcpy(&replaced->val[len], replacement, replacement_len);
len += replacement_len;
continue;
} else {
- efree(replaced);
- *newlen = 0;
+ STR_FREE(replaced);
return STR_EMPTY_ALLOC();
}
} else { /* SUCCESS */
@@ -1324,10 +1323,10 @@ PHPAPI char *php_escape_html_entities_ex(unsigned char *old, size_t oldlen, size
}
if (rep != NULL) {
- replaced[len++] = '&';
- memcpy(&replaced[len], rep, rep_len);
+ replaced->val[len++] = '&';
+ memcpy(&replaced->val[len], rep, rep_len);
len += rep_len;
- replaced[len++] = ';';
+ replaced->val[len++] = ';';
} else {
/* we did not find an entity for this char.
* check for its validity, if its valid pass it unchanged */
@@ -1361,16 +1360,16 @@ PHPAPI char *php_escape_html_entities_ex(unsigned char *old, size_t oldlen, size
}
pass_char_through:
if (mbseqlen > 1) {
- memcpy(replaced + len, mbsequence, mbseqlen);
+ memcpy(replaced->val + len, mbsequence, mbseqlen);
len += mbseqlen;
} else {
- replaced[len++] = mbsequence[0];
+ replaced->val[len++] = mbsequence[0];
}
}
} else { /* this_char == '&' */
if (double_encode) {
encode_amp:
- memcpy(&replaced[len], "&amp;", sizeof("&amp;") - 1);
+ memcpy(&replaced->val[len], "&amp;", sizeof("&amp;") - 1);
len += sizeof("&amp;") - 1;
} else { /* no double encode */
/* check if entity is valid */
@@ -1410,19 +1409,20 @@ encode_amp:
/* at this point maxlen - len >= 40 */
if (maxlen - len < ent_len + 2 /* & and ; */) {
/* ent_len < oldlen, which is certainly <= SIZE_MAX/2 */
- replaced = safe_erealloc(replaced, maxlen, 1, ent_len + 128 + 1);
+//??? replaced = safe_erealloc(replaced, maxlen, 1, ent_len + 128 + 1);
+ replaced = STR_EREALLOC(replaced, maxlen + ent_len + 128);
maxlen += ent_len + 128;
}
- replaced[len++] = '&';
- memcpy(&replaced[len], &old[cursor], ent_len);
+ replaced->val[len++] = '&';
+ memcpy(&replaced->val[len], &old[cursor], ent_len);
len += ent_len;
- replaced[len++] = ';';
+ replaced->val[len++] = ';';
cursor += ent_len + 1;
}
}
}
- replaced[len] = '\0';
- *newlen = len;
+ replaced->val[len] = '\0';
+ replaced->len = len;
return replaced;
}
@@ -1434,17 +1434,16 @@ static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
{
char *str, *hint_charset = NULL;
int str_len, hint_charset_len = 0;
- size_t new_len;
long flags = ENT_COMPAT;
- char *replaced;
+ zend_string *replaced;
zend_bool double_encode = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls!b", &str, &str_len, &flags, &hint_charset, &hint_charset_len, &double_encode) == FAILURE) {
return;
}
- replaced = php_escape_html_entities_ex(str, str_len, &new_len, all, (int) flags, hint_charset, double_encode TSRMLS_CC);
- RETVAL_STRINGL(replaced, (int)new_len, 0);
+ replaced = php_escape_html_entities_ex((unsigned char*)str, str_len, all, (int) flags, hint_charset, double_encode TSRMLS_CC);
+ RETVAL_STR(replaced);
}
/* }}} */
@@ -1484,17 +1483,16 @@ PHP_FUNCTION(htmlspecialchars_decode)
{
char *str;
int str_len;
- size_t new_len = 0;
long quote_style = ENT_COMPAT;
- char *replaced;
+ zend_string *replaced;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &str, &str_len, &quote_style) == FAILURE) {
return;
}
- replaced = php_unescape_html_entities(str, str_len, &new_len, 0 /*!all*/, quote_style, NULL TSRMLS_CC);
+ replaced = php_unescape_html_entities((unsigned char*)str, str_len, 0 /*!all*/, quote_style, NULL TSRMLS_CC);
if (replaced) {
- RETURN_STRINGL(replaced, (int)new_len, 0);
+ RETURN_STR(replaced);
}
RETURN_FALSE;
}
@@ -1506,18 +1504,17 @@ PHP_FUNCTION(html_entity_decode)
{
char *str, *hint_charset = NULL;
int str_len, hint_charset_len = 0;
- size_t new_len = 0;
long quote_style = ENT_COMPAT;
- char *replaced;
+ zend_string *replaced;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls", &str, &str_len,
&quote_style, &hint_charset, &hint_charset_len) == FAILURE) {
return;
}
- replaced = php_unescape_html_entities(str, str_len, &new_len, 1 /*all*/, quote_style, hint_charset TSRMLS_CC);
+ replaced = php_unescape_html_entities((unsigned char*)str, str_len, 1 /*all*/, quote_style, hint_charset TSRMLS_CC);
if (replaced) {
- RETURN_STRINGL(replaced, (int)new_len, 0);
+ RETURN_STR(replaced);
}
RETURN_FALSE;
}
@@ -1543,7 +1540,7 @@ static inline void write_s3row_data(
char entity[LONGEST_ENTITY_LENGTH + 2] = {'&'};
size_t written_k1;
- written_k1 = write_octet_sequence(key, charset, orig_cp);
+ written_k1 = write_octet_sequence((unsigned char*)key, charset, orig_cp);
if (!r->ambiguous) {
size_t l = r->data.ent.entity_len;
@@ -1578,7 +1575,7 @@ static inline void write_s3row_data(
spe_cp = uni_cp;
}
- written_k2 = write_octet_sequence(&key[written_k1], charset, spe_cp);
+ written_k2 = write_octet_sequence((unsigned char*)&key[written_k1], charset, spe_cp);
memcpy(&entity[1], mcpr[i].normal_entry.entity, l);
entity[l + 1] = ';';
entity[l + 1] = '\0';
diff --git a/ext/standard/html.h b/ext/standard/html.h
index b3da83f307..0777130e0f 100644
--- a/ext/standard/html.h
+++ b/ext/standard/html.h
@@ -54,9 +54,9 @@ PHP_FUNCTION(htmlspecialchars_decode);
PHP_FUNCTION(html_entity_decode);
PHP_FUNCTION(get_html_translation_table);
-PHPAPI char *php_escape_html_entities(unsigned char *old, size_t oldlen, size_t *newlen, int all, int flags, char *hint_charset TSRMLS_DC);
-PHPAPI char *php_escape_html_entities_ex(unsigned char *old, size_t oldlen, size_t *newlen, int all, int flags, char *hint_charset, zend_bool double_encode TSRMLS_DC);
-PHPAPI char *php_unescape_html_entities(unsigned char *old, size_t oldlen, size_t *newlen, int all, int flags, char *hint_charset TSRMLS_DC);
+PHPAPI zend_string *php_escape_html_entities(unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset TSRMLS_DC);
+PHPAPI zend_string *php_escape_html_entities_ex(unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset, zend_bool double_encode TSRMLS_DC);
+PHPAPI zend_string *php_unescape_html_entities(unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset TSRMLS_DC);
PHPAPI unsigned int php_next_utf8_char(const unsigned char *str, size_t str_len, size_t *cursor, int *status);
#endif /* HTML_H */
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index 3ef722bde0..84fc2a72ae 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -120,7 +120,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
char *scratch = NULL;
char *tmp = NULL;
char *ua_str = NULL;
- zval **ua_zval = NULL, **tmpzval = NULL;
+ zval *ua_zval = NULL, *tmpzval = NULL;
int scratch_len = 0;
int body = 0;
char location[HTTP_HEADER_BLOCK_SIZE];
@@ -156,9 +156,9 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
if (strncasecmp(resource->scheme, "http", sizeof("http")) && strncasecmp(resource->scheme, "https", sizeof("https"))) {
if (!context ||
- php_stream_context_get_option(context, wrapper->wops->label, "proxy", &tmpzval) == FAILURE ||
- Z_TYPE_PP(tmpzval) != IS_STRING ||
- Z_STRLEN_PP(tmpzval) <= 0) {
+ (tmpzval = php_stream_context_get_option(context, wrapper->wops->label, "proxy")) == NULL ||
+ Z_TYPE_P(tmpzval) != IS_STRING ||
+ Z_STRLEN_P(tmpzval) <= 0) {
php_url_free(resource);
return php_stream_open_wrapper_ex(path, mode, REPORT_ERRORS, NULL, context);
}
@@ -167,8 +167,8 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
use_ssl = 0;
use_proxy = 1;
- transport_len = Z_STRLEN_PP(tmpzval);
- transport_string = estrndup(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval));
+ transport_len = Z_STRLEN_P(tmpzval);
+ transport_string = estrndup(Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval));
} else {
/* Normal http request (possibly with proxy) */
@@ -186,22 +186,22 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
resource->port = 80;
if (context &&
- php_stream_context_get_option(context, wrapper->wops->label, "proxy", &tmpzval) == SUCCESS &&
- Z_TYPE_PP(tmpzval) == IS_STRING &&
- Z_STRLEN_PP(tmpzval) > 0) {
+ (tmpzval = php_stream_context_get_option(context, wrapper->wops->label, "proxy")) != NULL &&
+ Z_TYPE_P(tmpzval) == IS_STRING &&
+ Z_STRLEN_P(tmpzval) > 0) {
use_proxy = 1;
- transport_len = Z_STRLEN_PP(tmpzval);
- transport_string = estrndup(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval));
+ transport_len = Z_STRLEN_P(tmpzval);
+ transport_string = estrndup(Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval));
} else {
transport_len = spprintf(&transport_string, 0, "%s://%s:%d", use_ssl ? "ssl" : "tcp", resource->host, resource->port);
}
}
- if (context && php_stream_context_get_option(context, wrapper->wops->label, "timeout", &tmpzval) == SUCCESS) {
+ if (context && (tmpzval = php_stream_context_get_option(context, wrapper->wops->label, "timeout")) != NULL) {
SEPARATE_ZVAL(tmpzval);
convert_to_double_ex(tmpzval);
- timeout.tv_sec = (time_t) Z_DVAL_PP(tmpzval);
- timeout.tv_usec = (size_t) ((Z_DVAL_PP(tmpzval) - timeout.tv_sec) * 1000000);
+ timeout.tv_sec = (time_t) Z_DVAL_P(tmpzval);
+ timeout.tv_usec = (size_t) ((Z_DVAL_P(tmpzval) - timeout.tv_sec) * 1000000);
} else {
timeout.tv_sec = FG(default_socket_timeout);
timeout.tv_usec = 0;
@@ -233,18 +233,18 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
smart_str_appendl(&header, " HTTP/1.0\r\n", sizeof(" HTTP/1.0\r\n")-1);
/* check if we have Proxy-Authorization header */
- if (context && php_stream_context_get_option(context, "http", "header", &tmpzval) == SUCCESS) {
+ if (context && (tmpzval = php_stream_context_get_option(context, "http", "header")) != NULL) {
char *s, *p;
- if (Z_TYPE_PP(tmpzval) == IS_ARRAY) {
+ if (Z_TYPE_P(tmpzval) == IS_ARRAY) {
HashPosition pos;
- zval **tmpheader = NULL;
+ zval *tmpheader = NULL;
- for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(tmpzval), &pos);
- SUCCESS == zend_hash_get_current_data_ex(Z_ARRVAL_PP(tmpzval), (void *)&tmpheader, &pos);
- zend_hash_move_forward_ex(Z_ARRVAL_PP(tmpzval), &pos)) {
- if (Z_TYPE_PP(tmpheader) == IS_STRING) {
- s = Z_STRVAL_PP(tmpheader);
+ for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(tmpzval), &pos);
+ NULL != (tmpheader = zend_hash_get_current_data_ex(Z_ARRVAL_P(tmpzval), &pos));
+ zend_hash_move_forward_ex(Z_ARRVAL_P(tmpzval), &pos)) {
+ if (Z_TYPE_P(tmpheader) == IS_STRING) {
+ s = Z_STRVAL_P(tmpheader);
do {
while (*s == ' ' || *s == '\t') s++;
p = s;
@@ -267,8 +267,8 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
} while (*s != 0);
}
}
- } else if (Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval)) {
- s = Z_STRVAL_PP(tmpzval);
+ } else if (Z_TYPE_P(tmpzval) == IS_STRING && Z_STRLEN_P(tmpzval)) {
+ s = Z_STRVAL_P(tmpzval);
do {
while (*s == ' ' || *s == '\t') s++;
p = s;
@@ -341,32 +341,32 @@ finish:
php_stream_notify_info(context, PHP_STREAM_NOTIFY_CONNECT, NULL, 0);
- if (header_init && context && php_stream_context_get_option(context, "http", "max_redirects", &tmpzval) == SUCCESS) {
+ if (header_init && context && (tmpzval = php_stream_context_get_option(context, "http", "max_redirects")) != NULL) {
SEPARATE_ZVAL(tmpzval);
convert_to_long_ex(tmpzval);
- redirect_max = Z_LVAL_PP(tmpzval);
+ redirect_max = Z_LVAL_P(tmpzval);
}
- if (context && php_stream_context_get_option(context, "http", "method", &tmpzval) == SUCCESS) {
- if (Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) {
+ if (context && (tmpzval = php_stream_context_get_option(context, "http", "method")) != NULL) {
+ if (Z_TYPE_P(tmpzval) == IS_STRING && Z_STRLEN_P(tmpzval) > 0) {
/* As per the RFC, automatically redirected requests MUST NOT use other methods than
* GET and HEAD unless it can be confirmed by the user */
if (!redirected
- || (Z_STRLEN_PP(tmpzval) == 3 && memcmp("GET", Z_STRVAL_PP(tmpzval), 3) == 0)
- || (Z_STRLEN_PP(tmpzval) == 4 && memcmp("HEAD",Z_STRVAL_PP(tmpzval), 4) == 0)
+ || (Z_STRLEN_P(tmpzval) == 3 && memcmp("GET", Z_STRVAL_P(tmpzval), 3) == 0)
+ || (Z_STRLEN_P(tmpzval) == 4 && memcmp("HEAD",Z_STRVAL_P(tmpzval), 4) == 0)
) {
- scratch_len = strlen(path) + 29 + Z_STRLEN_PP(tmpzval);
+ scratch_len = strlen(path) + 29 + Z_STRLEN_P(tmpzval);
scratch = emalloc(scratch_len);
- strlcpy(scratch, Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval) + 1);
+ strlcpy(scratch, Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval) + 1);
strncat(scratch, " ", 1);
}
}
}
- if (context && php_stream_context_get_option(context, "http", "protocol_version", &tmpzval) == SUCCESS) {
+ if (context && (tmpzval = php_stream_context_get_option(context, "http", "protocol_version")) != NULL) {
SEPARATE_ZVAL(tmpzval);
convert_to_double_ex(tmpzval);
- protocol_version_len = spprintf(&protocol_version, 0, "%.1F", Z_DVAL_PP(tmpzval));
+ protocol_version_len = spprintf(&protocol_version, 0, "%.1F", Z_DVAL_P(tmpzval));
}
if (!scratch) {
@@ -378,10 +378,10 @@ finish:
/* Should we send the entire path in the request line, default to no. */
if (!request_fulluri &&
context &&
- php_stream_context_get_option(context, "http", "request_fulluri", &tmpzval) == SUCCESS) {
- zval ztmp = **tmpzval;
-
- zval_copy_ctor(&ztmp);
+ (tmpzval = php_stream_context_get_option(context, "http", "request_fulluri")) != NULL) {
+ zval ztmp;
+
+ ZVAL_DUP(&ztmp, tmpzval);
convert_to_boolean(&ztmp);
request_fulluri = Z_BVAL(ztmp) ? 1 : 0;
zval_dtor(&ztmp);
@@ -419,20 +419,20 @@ finish:
/* send it */
php_stream_write(stream, scratch, strlen(scratch));
- if (context && php_stream_context_get_option(context, "http", "header", &tmpzval) == SUCCESS) {
+ if (context && (tmpzval = php_stream_context_get_option(context, "http", "header")) != NULL) {
tmp = NULL;
- if (Z_TYPE_PP(tmpzval) == IS_ARRAY) {
+ if (Z_TYPE_P(tmpzval) == IS_ARRAY) {
HashPosition pos;
- zval **tmpheader = NULL;
+ zval *tmpheader = NULL;
smart_str tmpstr = {0};
- for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(tmpzval), &pos);
- SUCCESS == zend_hash_get_current_data_ex(Z_ARRVAL_PP(tmpzval), (void *)&tmpheader, &pos);
- zend_hash_move_forward_ex(Z_ARRVAL_PP(tmpzval), &pos)
+ for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(tmpzval), &pos);
+ NULL != (tmpheader = zend_hash_get_current_data_ex(Z_ARRVAL_P(tmpzval), &pos));
+ zend_hash_move_forward_ex(Z_ARRVAL_P(tmpzval), &pos)
) {
- if (Z_TYPE_PP(tmpheader) == IS_STRING) {
- smart_str_appendl(&tmpstr, Z_STRVAL_PP(tmpheader), Z_STRLEN_PP(tmpheader));
+ if (Z_TYPE_P(tmpheader) == IS_STRING) {
+ smart_str_appendl(&tmpstr, Z_STRVAL_P(tmpheader), Z_STRLEN_P(tmpheader));
smart_str_appendl(&tmpstr, "\r\n", sizeof("\r\n") - 1);
}
}
@@ -443,9 +443,9 @@ finish:
smart_str_free(&tmpstr);
}
}
- if (Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval)) {
+ if (Z_TYPE_P(tmpzval) == IS_STRING && Z_STRLEN_P(tmpzval)) {
/* Remove newlines and spaces from start and end php_trim will estrndup() */
- tmp = php_trim(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval), NULL, 0, NULL, 3 TSRMLS_CC);
+ tmp = php_trim(Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval), NULL, 0, NULL, 3 TSRMLS_CC);
}
if (tmp && strlen(tmp) > 0) {
char *s;
@@ -580,9 +580,9 @@ finish:
}
if (context &&
- php_stream_context_get_option(context, "http", "user_agent", &ua_zval) == SUCCESS &&
- Z_TYPE_PP(ua_zval) == IS_STRING) {
- ua_str = Z_STRVAL_PP(ua_zval);
+ (ua_zval = php_stream_context_get_option(context, "http", "user_agent")) != NULL &&
+ Z_TYPE_P(ua_zval) == IS_STRING) {
+ ua_str = Z_STRVAL_P(ua_zval);
} else if (FG(user_agent)) {
ua_str = FG(user_agent);
}
@@ -618,10 +618,10 @@ finish:
header_init &&
context &&
!(have_header & HTTP_HEADER_CONTENT_LENGTH) &&
- php_stream_context_get_option(context, "http", "content", &tmpzval) == SUCCESS &&
- Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0
+ (tmpzval = php_stream_context_get_option(context, "http", "content")) != NULL &&
+ Z_TYPE_P(tmpzval) == IS_STRING && Z_STRLEN_P(tmpzval) > 0
) {
- scratch_len = slprintf(scratch, scratch_len, "Content-Length: %d\r\n", Z_STRLEN_PP(tmpzval));
+ scratch_len = slprintf(scratch, scratch_len, "Content-Length: %d\r\n", Z_STRLEN_P(tmpzval));
php_stream_write(stream, scratch, scratch_len);
have_header |= HTTP_HEADER_CONTENT_LENGTH;
}
@@ -633,10 +633,10 @@ finish:
/* Request content, such as for POST requests */
if (header_init && context &&
- php_stream_context_get_option(context, "http", "content", &tmpzval) == SUCCESS &&
- Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval) > 0) {
+ (tmpzval = php_stream_context_get_option(context, "http", "content")) != NULL &&
+ Z_TYPE_P(tmpzval) == IS_STRING && Z_STRLEN_P(tmpzval) > 0) {
if (!(have_header & HTTP_HEADER_CONTENT_LENGTH)) {
- scratch_len = slprintf(scratch, scratch_len, "Content-Length: %d\r\n", Z_STRLEN_PP(tmpzval));
+ scratch_len = slprintf(scratch, scratch_len, "Content-Length: %d\r\n", Z_STRLEN_P(tmpzval));
php_stream_write(stream, scratch, scratch_len);
}
if (!(have_header & HTTP_HEADER_TYPE)) {
@@ -645,7 +645,7 @@ finish:
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Content-type not specified assuming application/x-www-form-urlencoded");
}
php_stream_write(stream, "\r\n", sizeof("\r\n")-1);
- php_stream_write(stream, Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval));
+ php_stream_write(stream, Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval));
} else {
php_stream_write(stream, "\r\n", sizeof("\r\n")-1);
}
@@ -657,32 +657,27 @@ finish:
}
if (header_init) {
- zval *ztmp;
- MAKE_STD_ZVAL(ztmp);
- array_init(ztmp);
- ZEND_SET_SYMBOL(EG(active_symbol_table), "http_response_header", ztmp);
+ zval ztmp;
+ array_init(&ztmp);
+ ZEND_SET_SYMBOL(EG(active_symbol_table), "http_response_header", &ztmp);
}
- {
- zval **rh;
- zend_hash_find(EG(active_symbol_table), "http_response_header", sizeof("http_response_header"), (void **) &rh);
- response_header = *rh;
- }
+ response_header = zend_hash_str_find(EG(active_symbol_table), "http_response_header", sizeof("http_response_header")-1);
if (!php_stream_eof(stream)) {
size_t tmp_line_len;
/* get response header */
if (php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len) != NULL) {
- zval *http_response;
+ zval http_response;
if (tmp_line_len > 9) {
response_code = atoi(tmp_line + 9);
} else {
response_code = 0;
}
- if (context && SUCCESS==php_stream_context_get_option(context, "http", "ignore_errors", &tmpzval)) {
- ignore_errors = zend_is_true(*tmpzval TSRMLS_CC);
+ if (context && NULL != (tmpzval = php_stream_context_get_option(context, "http", "ignore_errors"))) {
+ ignore_errors = zend_is_true(tmpzval TSRMLS_CC);
}
/* when we request only the header, don't fail even on error codes */
if ((options & STREAM_ONLY_GET_HEADERS) || ignore_errors) {
@@ -714,9 +709,8 @@ finish:
--tmp_line_len;
}
}
- MAKE_STD_ZVAL(http_response);
- ZVAL_STRINGL(http_response, tmp_line, tmp_line_len, 1);
- zend_hash_next_index_insert(Z_ARRVAL_P(response_header), &http_response, sizeof(zval *), NULL);
+ ZVAL_STRINGL(&http_response, tmp_line, tmp_line_len);
+ zend_hash_next_index_insert(Z_ARRVAL_P(response_header), &http_response);
}
} else {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "HTTP request failed, unexpected end of socket!");
@@ -748,11 +742,11 @@ finish:
http_header_line[http_header_line_length] = '\0';
if (!strncasecmp(http_header_line, "Location: ", 10)) {
- if (context && php_stream_context_get_option(context, "http", "follow_location", &tmpzval) == SUCCESS) {
+ if (context && (tmpzval = php_stream_context_get_option(context, "http", "follow_location")) != NULL) {
SEPARATE_ZVAL(tmpzval);
convert_to_long_ex(tmpzval);
- follow_location = Z_LVAL_PP(tmpzval);
- } else if (!(response_code >= 300 && response_code < 304 || 307 == response_code)) {
+ follow_location = Z_LVAL_P(tmpzval);
+ } else if (!((response_code >= 300 && response_code < 304) || 307 == response_code)) {
/* we shouldn't redirect automatically
if follow_location isn't set and response_code not in (300, 301, 302, 303 and 307)
see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.1 */
@@ -770,10 +764,10 @@ finish:
if (!(options & STREAM_ONLY_GET_HEADERS)) {
long decode = 1;
- if (context && php_stream_context_get_option(context, "http", "auto_decode", &tmpzval) == SUCCESS) {
+ if (context && (tmpzval = php_stream_context_get_option(context, "http", "auto_decode")) != NULL) {
SEPARATE_ZVAL(tmpzval);
- convert_to_boolean(*tmpzval);
- decode = Z_LVAL_PP(tmpzval);
+ convert_to_boolean(tmpzval);
+ decode = Z_LVAL_P( tmpzval);
}
if (decode) {
transfer_encoding = php_stream_filter_create("dechunk", NULL, php_stream_is_persistent(stream) TSRMLS_CC);
@@ -788,13 +782,11 @@ finish:
if (http_header_line[0] == '\0') {
body = 1;
} else {
- zval *http_header;
-
- MAKE_STD_ZVAL(http_header);
+ zval http_header;
- ZVAL_STRINGL(http_header, http_header_line, http_header_line_length, 1);
+ ZVAL_STRINGL(&http_header, http_header_line, http_header_line_length);
- zend_hash_next_index_insert(Z_ARRVAL_P(response_header), &http_header, sizeof(zval *), NULL);
+ zend_hash_next_index_insert(Z_ARRVAL_P(response_header), &http_header);
}
} else {
break;
@@ -908,8 +900,7 @@ out:
if (stream) {
if (header_init) {
- zval_add_ref(&response_header);
- stream->wrapperdata = response_header;
+ ZVAL_COPY(&stream->wrapperdata, response_header);
}
php_stream_notify_progress_init(context, 0, file_size);
diff --git a/ext/standard/image.c b/ext/standard/image.c
index 27f60c95a7..ce48b961f4 100644
--- a/ext/standard/image.c
+++ b/ext/standard/image.c
@@ -105,7 +105,7 @@ static struct gfxinfo *php_handle_gif (php_stream * stream TSRMLS_DC)
if (php_stream_seek(stream, 3, SEEK_CUR))
return NULL;
- if (php_stream_read(stream, dim, sizeof(dim)) != sizeof(dim))
+ if (php_stream_read(stream, (char*)dim, sizeof(dim)) != sizeof(dim))
return NULL;
result = (struct gfxinfo *) ecalloc(1, sizeof(struct gfxinfo));
@@ -128,7 +128,7 @@ static struct gfxinfo *php_handle_psd (php_stream * stream TSRMLS_DC)
if (php_stream_seek(stream, 11, SEEK_CUR))
return NULL;
- if (php_stream_read(stream, dim, sizeof(dim)) != sizeof(dim))
+ if (php_stream_read(stream, (char*)dim, sizeof(dim)) != sizeof(dim))
return NULL;
result = (struct gfxinfo *) ecalloc(1, sizeof(struct gfxinfo));
@@ -150,7 +150,7 @@ static struct gfxinfo *php_handle_bmp (php_stream * stream TSRMLS_DC)
if (php_stream_seek(stream, 11, SEEK_CUR))
return NULL;
- if (php_stream_read(stream, dim, sizeof(dim)) != sizeof(dim))
+ if (php_stream_read(stream, (char*)dim, sizeof(dim)) != sizeof(dim))
return NULL;
size = (((unsigned int)dim[ 3]) << 24) + (((unsigned int)dim[ 2]) << 16) + (((unsigned int)dim[ 1]) << 8) + ((unsigned int) dim[ 0]);
@@ -272,7 +272,7 @@ static struct gfxinfo *php_handle_swf (php_stream * stream TSRMLS_DC)
if (php_stream_seek(stream, 5, SEEK_CUR))
return NULL;
- if (php_stream_read(stream, a, sizeof(a)) != sizeof(a))
+ if (php_stream_read(stream, (char*)a, sizeof(a)) != sizeof(a))
return NULL;
result = (struct gfxinfo *) ecalloc (1, sizeof (struct gfxinfo));
@@ -305,7 +305,7 @@ static struct gfxinfo *php_handle_png (php_stream * stream TSRMLS_DC)
if (php_stream_seek(stream, 8, SEEK_CUR))
return NULL;
- if((php_stream_read(stream, dim, sizeof(dim))) < sizeof(dim))
+ if((php_stream_read(stream, (char*)dim, sizeof(dim))) < sizeof(dim))
return NULL;
result = (struct gfxinfo *) ecalloc(1, sizeof(struct gfxinfo));
@@ -362,7 +362,7 @@ static unsigned short php_read2(php_stream * stream TSRMLS_DC)
unsigned char a[2];
/* just return 0 if we hit the end-of-file */
- if((php_stream_read(stream, a, sizeof(a))) <= 0) return 0;
+ if((php_stream_read(stream, (char*)a, sizeof(a))) <= 0) return 0;
return (((unsigned short)a[0]) << 8) + ((unsigned short)a[1]);
}
@@ -436,8 +436,8 @@ static int php_skip_variable(php_stream * stream TSRMLS_DC)
static int php_read_APP(php_stream * stream, unsigned int marker, zval *info TSRMLS_DC)
{
unsigned short length;
- unsigned char *buffer;
- unsigned char markername[16];
+ char *buffer;
+ char markername[16];
zval *tmp;
length = php_read2(stream TSRMLS_CC);
@@ -455,7 +455,7 @@ static int php_read_APP(php_stream * stream, unsigned int marker, zval *info TSR
snprintf(markername, sizeof(markername), "APP%d", marker - M_APP0);
- if (zend_hash_find(Z_ARRVAL_P(info), markername, strlen(markername)+1, (void **) &tmp) == FAILURE) {
+ if ((tmp = zend_hash_str_find(Z_ARRVAL_P(info), markername, strlen(markername))) == NULL) {
/* XXX we onyl catch the 1st tag of it's kind! */
add_assoc_stringl(info, markername, buffer, length, 1);
}
@@ -561,7 +561,7 @@ static unsigned int php_read4(php_stream * stream TSRMLS_DC)
unsigned char a[4];
/* just return 0 if we hit the end-of-file */
- if ((php_stream_read(stream, a, sizeof(a))) != sizeof(a)) return 0;
+ if ((php_stream_read(stream, (char*)a, sizeof(a))) != sizeof(a)) return 0;
return (((unsigned int)a[0]) << 24)
+ (((unsigned int)a[1]) << 16)
@@ -893,7 +893,7 @@ static struct gfxinfo *php_handle_iff(php_stream * stream TSRMLS_DC)
/* loop chunks to find BMHD chunk */
do {
- if (php_stream_read(stream, a, 8) != 8) {
+ if (php_stream_read(stream, (char*)a, 8) != 8) {
return NULL;
}
chunkId = php_ifd_get32s(a+0, 1);
@@ -905,7 +905,7 @@ static struct gfxinfo *php_handle_iff(php_stream * stream TSRMLS_DC)
size++;
}
if (chunkId == 0x424d4844) { /* BMHD chunk */
- if (size < 9 || php_stream_read(stream, a, 9) != 9) {
+ if (size < 9 || php_stream_read(stream, (char*)a, 9) != 9) {
return NULL;
}
width = php_ifd_get16s(a+0, 1);
@@ -1161,7 +1161,7 @@ PHP_FUNCTION(image_type_to_mime_type)
return;
}
- ZVAL_STRING(return_value, (char*)php_image_type_to_mime_type(p_image_type), 1);
+ ZVAL_STRING(return_value, (char*)php_image_type_to_mime_type(p_image_type));
}
/* }}} */
@@ -1178,36 +1178,36 @@ PHP_FUNCTION(image_type_to_extension)
switch (image_type) {
case IMAGE_FILETYPE_GIF:
- RETURN_STRING(".gif" + !inc_dot, 1);
+ RETURN_STRING(".gif" + !inc_dot);
case IMAGE_FILETYPE_JPEG:
- RETURN_STRING(".jpeg" + !inc_dot, 1);
+ RETURN_STRING(".jpeg" + !inc_dot);
case IMAGE_FILETYPE_PNG:
- RETURN_STRING(".png" + !inc_dot, 1);
+ RETURN_STRING(".png" + !inc_dot);
case IMAGE_FILETYPE_SWF:
case IMAGE_FILETYPE_SWC:
- RETURN_STRING(".swf" + !inc_dot, 1);
+ RETURN_STRING(".swf" + !inc_dot);
case IMAGE_FILETYPE_PSD:
- RETURN_STRING(".psd" + !inc_dot, 1);
+ RETURN_STRING(".psd" + !inc_dot);
case IMAGE_FILETYPE_BMP:
case IMAGE_FILETYPE_WBMP:
- RETURN_STRING(".bmp" + !inc_dot, 1);
+ RETURN_STRING(".bmp" + !inc_dot);
case IMAGE_FILETYPE_TIFF_II:
case IMAGE_FILETYPE_TIFF_MM:
- RETURN_STRING(".tiff" + !inc_dot, 1);
+ RETURN_STRING(".tiff" + !inc_dot);
case IMAGE_FILETYPE_IFF:
- RETURN_STRING(".iff" + !inc_dot, 1);
+ RETURN_STRING(".iff" + !inc_dot);
case IMAGE_FILETYPE_JPC:
- RETURN_STRING(".jpc" + !inc_dot, 1);
+ RETURN_STRING(".jpc" + !inc_dot);
case IMAGE_FILETYPE_JP2:
- RETURN_STRING(".jp2" + !inc_dot, 1);
+ RETURN_STRING(".jp2" + !inc_dot);
case IMAGE_FILETYPE_JPX:
- RETURN_STRING(".jpx" + !inc_dot, 1);
+ RETURN_STRING(".jpx" + !inc_dot);
case IMAGE_FILETYPE_JB2:
- RETURN_STRING(".jb2" + !inc_dot, 1);
+ RETURN_STRING(".jb2" + !inc_dot);
case IMAGE_FILETYPE_XBM:
- RETURN_STRING(".xbm" + !inc_dot, 1);
+ RETURN_STRING(".xbm" + !inc_dot);
case IMAGE_FILETYPE_ICO:
- RETURN_STRING(".ico" + !inc_dot, 1);
+ RETURN_STRING(".ico" + !inc_dot);
}
RETURN_FALSE;
diff --git a/ext/standard/incomplete_class.c b/ext/standard/incomplete_class.c
index 968a5e2ebd..d8aa461b05 100644
--- a/ext/standard/incomplete_class.c
+++ b/ext/standard/incomplete_class.c
@@ -36,20 +36,15 @@ static zend_object_handlers php_incomplete_object_handlers;
*/
static void incomplete_class_message(zval *object, int error_type TSRMLS_DC)
{
- char *class_name;
- zend_bool class_name_alloced = 1;
+ zend_string *class_name;
- class_name = php_lookup_class_name(object, NULL);
+ class_name = php_lookup_class_name(object);
- if (!class_name) {
- class_name_alloced = 0;
- class_name = "unknown";
- }
-
- php_error_docref(NULL TSRMLS_CC, error_type, INCOMPLETE_CLASS_MSG, class_name);
-
- if (class_name_alloced) {
- efree(class_name);
+ if (class_name) {
+ php_error_docref(NULL TSRMLS_CC, error_type, INCOMPLETE_CLASS_MSG, "unknown");
+ } else {
+ php_error_docref(NULL TSRMLS_CC, error_type, INCOMPLETE_CLASS_MSG, class_name->val);
+ STR_RELEASE(class_name);
}
}
/* }}} */
@@ -59,9 +54,9 @@ static zval *incomplete_class_get_property(zval *object, zval *member, int type,
incomplete_class_message(object, E_NOTICE TSRMLS_CC);
if (type == BP_VAR_W || type == BP_VAR_RW) {
- return EG(error_zval_ptr);
+ return &EG(error_zval);
} else {
- return EG(uninitialized_zval_ptr);
+ return &EG(uninitialized_zval);
}
}
/* }}} */
@@ -72,10 +67,10 @@ static void incomplete_class_write_property(zval *object, zval *member, zval *va
}
/* }}} */
-static zval **incomplete_class_get_property_ptr_ptr(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) /* {{{ */
+static zval *incomplete_class_get_property_ptr_ptr(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) /* {{{ */
{
incomplete_class_message(object, E_NOTICE TSRMLS_CC);
- return &EG(error_zval_ptr);
+ return &EG(error_zval);
}
/* }}} */
@@ -92,26 +87,25 @@ static int incomplete_class_has_property(zval *object, zval *member, int check_e
}
/* }}} */
-static union _zend_function *incomplete_class_get_method(zval **object, char *method, int method_len, const zend_literal *key TSRMLS_DC) /* {{{ */
+static union _zend_function *incomplete_class_get_method(zval *object, zend_string *method, const zend_literal *key TSRMLS_DC) /* {{{ */
{
- incomplete_class_message(*object, E_ERROR TSRMLS_CC);
+ incomplete_class_message(object, E_ERROR TSRMLS_CC);
return NULL;
}
/* }}} */
/* {{{ php_create_incomplete_class
*/
-static zend_object_value php_create_incomplete_object(zend_class_entry *class_type TSRMLS_DC)
+static zend_object *php_create_incomplete_object(zend_class_entry *class_type TSRMLS_DC)
{
zend_object *object;
- zend_object_value value;
- value = zend_objects_new(&object, class_type TSRMLS_CC);
- value.handlers = &php_incomplete_object_handlers;
+ object = zend_objects_new( class_type TSRMLS_CC);
+ object->handlers = &php_incomplete_object_handlers;
object_properties_init(object, class_type);
- return value;
+ return object;
}
PHPAPI zend_class_entry *php_create_incomplete_class(TSRMLS_D)
@@ -135,24 +129,19 @@ PHPAPI zend_class_entry *php_create_incomplete_class(TSRMLS_D)
/* {{{ php_lookup_class_name
*/
-PHPAPI char *php_lookup_class_name(zval *object, zend_uint *nlen)
+PHPAPI zend_string *php_lookup_class_name(zval *object)
{
- zval **val;
- char *retval = NULL;
+ zval *val;
HashTable *object_properties;
TSRMLS_FETCH();
object_properties = Z_OBJPROP_P(object);
- if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS) {
- retval = estrndup(Z_STRVAL_PP(val), Z_STRLEN_PP(val));
-
- if (nlen) {
- *nlen = Z_STRLEN_PP(val);
- }
+ if ((val = zend_hash_str_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER)-1)) != NULL) {
+ return STR_COPY(Z_STR_P(val));
}
- return retval;
+ return NULL;
}
/* }}} */
@@ -160,16 +149,12 @@ PHPAPI char *php_lookup_class_name(zval *object, zend_uint *nlen)
*/
PHPAPI void php_store_class_name(zval *object, const char *name, zend_uint len)
{
- zval *val;
+ zval val;
TSRMLS_FETCH();
- MAKE_STD_ZVAL(val);
-
- Z_TYPE_P(val) = IS_STRING;
- Z_STRVAL_P(val) = estrndup(name, len);
- Z_STRLEN_P(val) = len;
- zend_hash_update(Z_OBJPROP_P(object), MAGIC_MEMBER, sizeof(MAGIC_MEMBER), &val, sizeof(val), NULL);
+ ZVAL_STRINGL(&val, name, len);
+ zend_hash_str_update(Z_OBJPROP_P(object), MAGIC_MEMBER, sizeof(MAGIC_MEMBER)-1, &val);
}
/* }}} */
diff --git a/ext/standard/info.c b/ext/standard/info.c
index 0acf4c75b8..682af53798 100644
--- a/ext/standard/info.c
+++ b/ext/standard/info.c
@@ -63,14 +63,13 @@ PHPAPI extern char *php_ini_scanned_files;
static int php_info_print_html_esc(const char *str, int len) /* {{{ */
{
- size_t new_len;
int written;
- char *new_str;
+ zend_string *new_str;
TSRMLS_FETCH();
- new_str = php_escape_html_entities((unsigned char *) str, len, &new_len, 0, ENT_QUOTES, "utf-8" TSRMLS_CC);
- written = php_output_write(new_str, new_len TSRMLS_CC);
- str_efree(new_str);
+ new_str = php_escape_html_entities((unsigned char *) str, len, 0, ENT_QUOTES, "utf-8" TSRMLS_CC);
+ written = php_output_write(new_str->val, new_str->len TSRMLS_CC);
+ STR_FREE(new_str);
return written;
}
/* }}} */
@@ -101,8 +100,7 @@ static int php_info_print(const char *str) /* {{{ */
static void php_info_print_stream_hash(const char *name, HashTable *ht TSRMLS_DC) /* {{{ */
{
- char *key;
- uint len;
+ zend_string *key;
if (ht) {
if (zend_hash_num_elements(ht)) {
@@ -115,15 +113,15 @@ static void php_info_print_stream_hash(const char *name, HashTable *ht TSRMLS_DC
}
zend_hash_internal_pointer_reset_ex(ht, &pos);
- while (zend_hash_get_current_key_ex(ht, &key, &len, NULL, 0, &pos) == HASH_KEY_IS_STRING)
+ while (zend_hash_get_current_key_ex(ht, &key, NULL, 0, &pos) == HASH_KEY_IS_STRING)
{
if (!sapi_module.phpinfo_as_text) {
- php_info_print_html_esc(key, len-1);
+ php_info_print_html_esc(key->val, key->len);
} else {
- php_info_print(key);
+ php_info_print(key->val);
}
zend_hash_move_forward_ex(ht, &pos);
- if (zend_hash_get_current_key_ex(ht, &key, &len, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
+ if (zend_hash_get_current_key_ex(ht, &key, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
php_info_print(", ");
} else {
break;
@@ -194,17 +192,18 @@ static int _display_module_info_def(zend_module_entry *module TSRMLS_DC) /* {{{
*/
static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
{
- zval **data, **tmp, tmp2;
- char *string_key;
- uint string_len;
+ zval *data, *tmp, tmp2;
+ zend_string *string_key;
ulong num_key;
-
- zend_is_auto_global(name, name_length TSRMLS_CC);
-
- if (zend_hash_find(&EG(symbol_table), name, name_length+1, (void **) &data)!=FAILURE
- && (Z_TYPE_PP(data)==IS_ARRAY)) {
- zend_hash_internal_pointer_reset(Z_ARRVAL_PP(data));
- while (zend_hash_get_current_data(Z_ARRVAL_PP(data), (void **) &tmp) == SUCCESS) {
+ zend_string *key;
+
+ key = STR_INIT(name, name_length, 0);
+ zend_is_auto_global(key TSRMLS_CC);
+
+ if ((data = zend_hash_find(&EG(symbol_table).ht, key)) != NULL
+ && (Z_TYPE_P(data)==IS_ARRAY)) {
+ zend_hash_internal_pointer_reset(Z_ARRVAL_P(data));
+ while ((tmp = zend_hash_get_current_data(Z_ARRVAL_P(data))) != NULL) {
if (!sapi_module.phpinfo_as_text) {
php_info_print("<tr>");
php_info_print("<td class=\"e\">");
@@ -213,12 +212,12 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
php_info_print(name);
php_info_print("[\"");
- switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(data), &string_key, &string_len, &num_key, 0, NULL)) {
+ switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(data), &string_key, &num_key, 0, NULL)) {
case HASH_KEY_IS_STRING:
if (!sapi_module.phpinfo_as_text) {
- php_info_print_html_esc(string_key, string_len-1);
+ php_info_print_html_esc(string_key->val, string_key->len);
} else {
- php_info_print(string_key);
+ php_info_print(string_key->val);
}
break;
case HASH_KEY_IS_LONG:
@@ -231,17 +230,17 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
} else {
php_info_print(" => ");
}
- if (Z_TYPE_PP(tmp) == IS_ARRAY) {
+ if (Z_TYPE_P(tmp) == IS_ARRAY) {
if (!sapi_module.phpinfo_as_text) {
php_info_print("<pre>");
- zend_print_zval_r_ex((zend_write_func_t) php_info_print_html_esc, *tmp, 0 TSRMLS_CC);
+ zend_print_zval_r_ex((zend_write_func_t) php_info_print_html_esc, tmp, 0 TSRMLS_CC);
php_info_print("</pre>");
} else {
- zend_print_zval_r(*tmp, 0 TSRMLS_CC);
+ zend_print_zval_r(tmp, 0 TSRMLS_CC);
}
} else {
- tmp2 = **tmp;
- if (Z_TYPE_PP(tmp) != IS_STRING) {
+ ZVAL_COPY_VALUE(&tmp2, tmp);
+ if (Z_TYPE(tmp2) != IS_STRING) {
tmp = NULL;
zval_copy_ctor(&tmp2);
convert_to_string(&tmp2);
@@ -266,7 +265,7 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
} else {
php_info_print("\n");
}
- zend_hash_move_forward(Z_ARRVAL_PP(data));
+ zend_hash_move_forward(Z_ARRVAL_P(data));
}
}
}
@@ -284,10 +283,9 @@ void php_info_print_style(TSRMLS_D)
/* {{{ php_info_html_esc
*/
-PHPAPI char *php_info_html_esc(char *string TSRMLS_DC)
+PHPAPI zend_string *php_info_html_esc(char *string TSRMLS_DC)
{
- size_t new_len;
- return php_escape_html_entities((unsigned char *) string, strlen(string), &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
+ return php_escape_html_entities((unsigned char *) string, strlen(string), 0, ENT_QUOTES, NULL TSRMLS_CC);
}
/* }}} */
@@ -651,8 +649,8 @@ static int module_name_cmp(const void *a, const void *b TSRMLS_DC)
Bucket *f = (Bucket *) a;
Bucket *s = (Bucket *) b;
- return strcasecmp(((zend_module_entry *)f->xData)->name,
- ((zend_module_entry *)s->xData)->name);
+ return strcasecmp(((zend_module_entry *)Z_PTR(f->val))->name,
+ ((zend_module_entry *)Z_PTR(s->val))->name);
}
/* }}} */
@@ -824,10 +822,10 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
if (flag & PHP_INFO_MODULES) {
HashTable sorted_registry;
- zend_module_entry tmp;
zend_hash_init(&sorted_registry, zend_hash_num_elements(&module_registry), NULL, NULL, 1);
- zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry));
+//??? zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry));
+ zend_hash_copy(&sorted_registry, &module_registry, NULL);
zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC);
zend_hash_apply(&sorted_registry, (apply_func_t) _display_module_info_func TSRMLS_CC);
@@ -860,23 +858,23 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
}
if (flag & PHP_INFO_VARIABLES) {
- zval **data;
+ zval *data;
SECTION("PHP Variables");
php_info_print_table_start();
php_info_print_table_header(2, "Variable", "Value");
- if (zend_hash_find(&EG(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void **) &data) != FAILURE) {
- php_info_print_table_row(2, "PHP_SELF", Z_STRVAL_PP(data));
+ if ((data = zend_hash_str_find(&EG(symbol_table).ht, "PHP_SELF", sizeof("PHP_SELF")-1)) != NULL) {
+ php_info_print_table_row(2, "PHP_SELF", Z_STRVAL_P(data));
}
- if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_TYPE", sizeof("PHP_AUTH_TYPE"), (void **) &data) != FAILURE) {
- php_info_print_table_row(2, "PHP_AUTH_TYPE", Z_STRVAL_PP(data));
+ if ((data = zend_hash_str_find(&EG(symbol_table).ht, "PHP_AUTH_TYPE", sizeof("PHP_AUTH_TYPE")-1)) != NULL) {
+ php_info_print_table_row(2, "PHP_AUTH_TYPE", Z_STRVAL_P(data));
}
- if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_USER", sizeof("PHP_AUTH_USER"), (void **) &data) != FAILURE) {
- php_info_print_table_row(2, "PHP_AUTH_USER", Z_STRVAL_PP(data));
+ if ((data = zend_hash_str_find(&EG(symbol_table).ht, "PHP_AUTH_USER", sizeof("PHP_AUTH_USER")-1)) != NULL) {
+ php_info_print_table_row(2, "PHP_AUTH_USER", Z_STRVAL_P(data));
}
- if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_PW", sizeof("PHP_AUTH_PW"), (void **) &data) != FAILURE) {
- php_info_print_table_row(2, "PHP_AUTH_PW", Z_STRVAL_PP(data));
+ if ((data = zend_hash_str_find(&EG(symbol_table).ht, "PHP_AUTH_PW", sizeof("PHP_AUTH_PW")-1)) != NULL) {
+ php_info_print_table_row(2, "PHP_AUTH_PW", Z_STRVAL_P(data));
}
php_print_gpcse_array(ZEND_STRL("_REQUEST") TSRMLS_CC);
php_print_gpcse_array(ZEND_STRL("_GET") TSRMLS_CC);
@@ -1166,14 +1164,14 @@ PHP_FUNCTION(phpversion)
}
if (!ext_name) {
- RETURN_STRING(PHP_VERSION, 1);
+ RETURN_STRING(PHP_VERSION);
} else {
const char *version;
version = zend_get_module_version(ext_name);
if (version == NULL) {
RETURN_FALSE;
}
- RETURN_STRING(version, 1);
+ RETURN_STRING(version);
}
}
/* }}} */
@@ -1202,7 +1200,7 @@ PHP_FUNCTION(php_sapi_name)
}
if (sapi_module.name) {
- RETURN_STRING(sapi_module.name, 1);
+ RETURN_STRING(sapi_module.name);
} else {
RETURN_FALSE;
}
@@ -1220,7 +1218,8 @@ PHP_FUNCTION(php_uname)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &mode, &modelen) == FAILURE) {
return;
}
- RETURN_STRING(php_get_uname(*mode), 0);
+//??? RETURN_STRING(php_get_uname(*mode), 0);
+ RETURN_STRING(php_get_uname(*mode));
}
/* }}} */
@@ -1234,7 +1233,7 @@ PHP_FUNCTION(php_ini_scanned_files)
}
if (strlen(PHP_CONFIG_FILE_SCAN_DIR) && php_ini_scanned_files) {
- RETURN_STRING(php_ini_scanned_files, 1);
+ RETURN_STRING(php_ini_scanned_files);
} else {
RETURN_FALSE;
}
@@ -1250,7 +1249,7 @@ PHP_FUNCTION(php_ini_loaded_file)
}
if (php_ini_opened_path) {
- RETURN_STRING(php_ini_opened_path, 1);
+ RETURN_STRING(php_ini_opened_path);
} else {
RETURN_FALSE;
}
diff --git a/ext/standard/info.h b/ext/standard/info.h
index 03c652822f..6775a2660c 100644
--- a/ext/standard/info.h
+++ b/ext/standard/info.h
@@ -63,7 +63,7 @@ PHP_FUNCTION(php_sapi_name);
PHP_FUNCTION(php_uname);
PHP_FUNCTION(php_ini_scanned_files);
PHP_FUNCTION(php_ini_loaded_file);
-PHPAPI char *php_info_html_esc(char *string TSRMLS_DC);
+PHPAPI zend_string *php_info_html_esc(char *string TSRMLS_DC);
PHPAPI void php_info_html_esc_write(char *string, int str_len TSRMLS_DC);
PHPAPI void php_print_info_htmlhead(TSRMLS_D);
PHPAPI void php_print_info(int flag TSRMLS_DC);
diff --git a/ext/standard/iptc.c b/ext/standard/iptc.c
index 3257339106..e5a17456d4 100644
--- a/ext/standard/iptc.c
+++ b/ext/standard/iptc.c
@@ -285,7 +285,8 @@ PHP_FUNCTION(iptcembed)
fclose(fp);
if (spool < 2) {
- RETVAL_STRINGL(spoolbuf, poi - spoolbuf, 0);
+//??? RETVAL_STRINGL(spoolbuf, poi - spoolbuf, 0);
+ RETVAL_STRINGL(spoolbuf, poi - spoolbuf);
} else {
RETURN_TRUE;
}
@@ -301,7 +302,7 @@ PHP_FUNCTION(iptcparse)
unsigned char *buffer, recnum, dataset, key[ 16 ];
char *str;
int str_len;
- zval *values, **element;
+ zval values, *element;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) != SUCCESS) {
return;
@@ -347,14 +348,13 @@ PHP_FUNCTION(iptcparse)
array_init(return_value);
}
- if (zend_hash_find(Z_ARRVAL_P(return_value), key, strlen(key) + 1, (void **) &element) == FAILURE) {
- MAKE_STD_ZVAL(values);
- array_init(values);
+ if ((element = zend_hash_str_find(Z_ARRVAL_P(return_value), key, strlen(key))) == NULL) {
+ array_init(&values);
- zend_hash_update(Z_ARRVAL_P(return_value), key, strlen(key) + 1, (void *) &values, sizeof(zval*), (void **) &element);
+ element = zend_hash_str_update(Z_ARRVAL_P(return_value), key, strlen(key), &values);
}
- add_next_index_stringl(*element, buffer+inx, len, 1);
+ add_next_index_stringl(element, buffer+inx, len, 1);
inx += len;
tagsfound++;
}
diff --git a/ext/standard/link.c b/ext/standard/link.c
index c57484e766..0f889a9e6a 100644
--- a/ext/standard/link.c
+++ b/ext/standard/link.c
@@ -76,7 +76,7 @@ PHP_FUNCTION(readlink)
/* Append NULL to the end of the string */
buff[ret] = '\0';
- RETURN_STRING(buff, 1);
+ RETURN_STRING(buff);
}
/* }}} */
diff --git a/ext/standard/math.c b/ext/standard/math.c
index 2be049f200..c12764c29b 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -276,20 +276,20 @@ static double php_expm1(double x)
Return the absolute value of the number */
PHP_FUNCTION(abs)
{
- zval **value;
+ zval *value;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &value) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
return;
}
convert_scalar_to_number_ex(value);
- if (Z_TYPE_PP(value) == IS_DOUBLE) {
- RETURN_DOUBLE(fabs(Z_DVAL_PP(value)));
- } else if (Z_TYPE_PP(value) == IS_LONG) {
- if (Z_LVAL_PP(value) == LONG_MIN) {
+ if (Z_TYPE_P(value) == IS_DOUBLE) {
+ RETURN_DOUBLE(fabs(Z_DVAL_P(value)));
+ } else if (Z_TYPE_P(value) == IS_LONG) {
+ if (Z_LVAL_P(value) == LONG_MIN) {
RETURN_DOUBLE(-(double)LONG_MIN);
} else {
- RETURN_LONG(Z_LVAL_PP(value) < 0 ? -Z_LVAL_PP(value) : Z_LVAL_PP(value));
+ RETURN_LONG(Z_LVAL_P(value) < 0 ? -Z_LVAL_P(value) : Z_LVAL_P(value));
}
}
RETURN_FALSE;
@@ -300,18 +300,18 @@ PHP_FUNCTION(abs)
Returns the next highest integer value of the number */
PHP_FUNCTION(ceil)
{
- zval **value;
+ zval *value;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &value) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
return;
}
convert_scalar_to_number_ex(value);
- if (Z_TYPE_PP(value) == IS_DOUBLE) {
- RETURN_DOUBLE(ceil(Z_DVAL_PP(value)));
- } else if (Z_TYPE_PP(value) == IS_LONG) {
+ if (Z_TYPE_P(value) == IS_DOUBLE) {
+ RETURN_DOUBLE(ceil(Z_DVAL_P(value)));
+ } else if (Z_TYPE_P(value) == IS_LONG) {
convert_to_double_ex(value);
- RETURN_DOUBLE(Z_DVAL_PP(value));
+ RETURN_DOUBLE(Z_DVAL_P(value));
}
RETURN_FALSE;
}
@@ -321,18 +321,18 @@ PHP_FUNCTION(ceil)
Returns the next lowest integer value from the number */
PHP_FUNCTION(floor)
{
- zval **value;
+ zval *value;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &value) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
return;
}
convert_scalar_to_number_ex(value);
- if (Z_TYPE_PP(value) == IS_DOUBLE) {
- RETURN_DOUBLE(floor(Z_DVAL_PP(value)));
- } else if (Z_TYPE_PP(value) == IS_LONG) {
+ if (Z_TYPE_P(value) == IS_DOUBLE) {
+ RETURN_DOUBLE(floor(Z_DVAL_P(value)));
+ } else if (Z_TYPE_P(value) == IS_LONG) {
convert_to_double_ex(value);
- RETURN_DOUBLE(Z_DVAL_PP(value));
+ RETURN_DOUBLE(Z_DVAL_P(value));
}
RETURN_FALSE;
}
@@ -342,13 +342,13 @@ PHP_FUNCTION(floor)
Returns the number rounded to specified precision */
PHP_FUNCTION(round)
{
- zval **value;
+ zval *value;
int places = 0;
long precision = 0;
long mode = PHP_ROUND_HALF_UP;
double return_val;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|ll", &value, &precision, &mode) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ll", &value, &precision, &mode) == FAILURE) {
return;
}
@@ -357,16 +357,16 @@ PHP_FUNCTION(round)
}
convert_scalar_to_number_ex(value);
- switch (Z_TYPE_PP(value)) {
+ switch (Z_TYPE_P(value)) {
case IS_LONG:
/* Simple case - long that doesn't need to be rounded. */
if (places >= 0) {
- RETURN_DOUBLE((double) Z_LVAL_PP(value));
+ RETURN_DOUBLE((double) Z_LVAL_P(value));
}
/* break omitted intentionally */
case IS_DOUBLE:
- return_val = (Z_TYPE_PP(value) == IS_LONG) ? (double)Z_LVAL_PP(value) : Z_DVAL_PP(value);
+ return_val = (Z_TYPE_P(value) == IS_LONG) ? (double)Z_LVAL_P(value) : Z_DVAL_P(value);
return_val = _php_math_round(return_val, places, mode);
RETURN_DOUBLE(return_val);
break;
@@ -900,7 +900,7 @@ PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret)
* Convert a long to a string containing a base(2-36) representation of
* the number.
*/
-PHPAPI char * _php_math_longtobase(zval *arg, int base)
+PHPAPI zend_string * _php_math_longtobase(zval *arg, int base)
{
static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
char buf[(sizeof(unsigned long) << 3) + 1];
@@ -921,7 +921,7 @@ PHPAPI char * _php_math_longtobase(zval *arg, int base)
value /= base;
} while (ptr > buf && value);
- return estrndup(ptr, end - ptr);
+ return STR_INIT(ptr, end - ptr, 0);
}
/* }}} */
@@ -930,7 +930,7 @@ PHPAPI char * _php_math_longtobase(zval *arg, int base)
* Convert a zval to a string containing a base(2-36) representation of
* the number.
*/
-PHPAPI char * _php_math_zvaltobase(zval *arg, int base TSRMLS_DC)
+PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base TSRMLS_DC)
{
static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
@@ -957,7 +957,7 @@ PHPAPI char * _php_math_zvaltobase(zval *arg, int base TSRMLS_DC)
fvalue /= base;
} while (ptr > buf && fabs(fvalue) >= 1);
- return estrndup(ptr, end - ptr);
+ return STR_INIT(ptr, end - ptr, 0);
}
return _php_math_longtobase(arg, base);
@@ -968,13 +968,13 @@ PHPAPI char * _php_math_zvaltobase(zval *arg, int base TSRMLS_DC)
Returns the decimal equivalent of the binary number */
PHP_FUNCTION(bindec)
{
- zval **arg;
+ zval *arg;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
return;
}
convert_to_string_ex(arg);
- if (_php_math_basetozval(*arg, 2, return_value) == FAILURE) {
+ if (_php_math_basetozval(arg, 2, return_value) == FAILURE) {
RETURN_FALSE;
}
}
@@ -984,13 +984,13 @@ PHP_FUNCTION(bindec)
Returns the decimal equivalent of the hexadecimal number */
PHP_FUNCTION(hexdec)
{
- zval **arg;
+ zval *arg;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
return;
}
convert_to_string_ex(arg);
- if (_php_math_basetozval(*arg, 16, return_value) == FAILURE) {
+ if (_php_math_basetozval(arg, 16, return_value) == FAILURE) {
RETURN_FALSE;
}
}
@@ -1000,13 +1000,13 @@ PHP_FUNCTION(hexdec)
Returns the decimal equivalent of an octal string */
PHP_FUNCTION(octdec)
{
- zval **arg;
+ zval *arg;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
return;
}
convert_to_string_ex(arg);
- if (_php_math_basetozval(*arg, 8, return_value) == FAILURE) {
+ if (_php_math_basetozval(arg, 8, return_value) == FAILURE) {
RETURN_FALSE;
}
}
@@ -1016,15 +1016,15 @@ PHP_FUNCTION(octdec)
Returns a string containing a binary representation of the number */
PHP_FUNCTION(decbin)
{
- zval **arg;
- char *result;
+ zval *arg;
+ zend_string *result;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
return;
}
convert_to_long_ex(arg);
- result = _php_math_longtobase(*arg, 2);
- RETURN_STRING(result, 0);
+ result = _php_math_longtobase(arg, 2);
+ RETURN_STR(result);
}
/* }}} */
@@ -1032,15 +1032,15 @@ PHP_FUNCTION(decbin)
Returns a string containing an octal representation of the given number */
PHP_FUNCTION(decoct)
{
- zval **arg;
- char *result;
+ zval *arg;
+ zend_string *result;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
return;
}
convert_to_long_ex(arg);
- result = _php_math_longtobase(*arg, 8);
- RETURN_STRING(result, 0);
+ result = _php_math_longtobase(arg, 8);
+ RETURN_STR(result);
}
/* }}} */
@@ -1048,15 +1048,15 @@ PHP_FUNCTION(decoct)
Returns a string containing a hexadecimal representation of the given number */
PHP_FUNCTION(dechex)
{
- zval **arg;
- char *result;
+ zval *arg;
+ zend_string *result;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
return;
}
convert_to_long_ex(arg);
- result = _php_math_longtobase(*arg, 16);
- RETURN_STRING(result, 0);
+ result = _php_math_longtobase(arg, 16);
+ RETURN_STR(result);
}
/* }}} */
@@ -1064,11 +1064,11 @@ PHP_FUNCTION(dechex)
Converts a number in a string from any base <= 36 to any base <= 36 */
PHP_FUNCTION(base_convert)
{
- zval **number, temp;
+ zval *number, temp;
long frombase, tobase;
- char *result;
+ zend_string *result;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zll", &number, &frombase, &tobase) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zll", &number, &frombase, &tobase) == FAILURE) {
return;
}
convert_to_string_ex(number);
@@ -1082,26 +1082,26 @@ PHP_FUNCTION(base_convert)
RETURN_FALSE;
}
- if(_php_math_basetozval(*number, frombase, &temp) == FAILURE) {
+ if(_php_math_basetozval(number, frombase, &temp) == FAILURE) {
RETURN_FALSE;
}
result = _php_math_zvaltobase(&temp, tobase TSRMLS_CC);
- RETVAL_STRING(result, 0);
+ RETVAL_STR(result);
}
/* }}} */
/* {{{ _php_math_number_format
*/
-PHPAPI char *_php_math_number_format(double d, int dec, char dec_point, char thousand_sep)
+PHPAPI zend_string *_php_math_number_format(double d, int dec, char dec_point, char thousand_sep)
{
return _php_math_number_format_ex(d, dec, &dec_point, 1, &thousand_sep, 1);
}
-static char *_php_math_number_format_ex_len(double d, int dec, char *dec_point,
- size_t dec_point_len, char *thousand_sep, size_t thousand_sep_len,
- int *result_len)
+PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, char *dec_point,
+ size_t dec_point_len, char *thousand_sep, size_t thousand_sep_len)
{
- char *tmpbuf = NULL, *resbuf;
+ zend_string *res;
+ char *tmpbuf = NULL;
char *s, *t; /* source, target */
char *dp;
int integral;
@@ -1120,11 +1120,8 @@ static char *_php_math_number_format_ex_len(double d, int dec, char *dec_point,
tmplen = spprintf(&tmpbuf, 0, "%.*F", dec, d);
if (tmpbuf == NULL || !isdigit((int)tmpbuf[0])) {
- if (result_len) {
- *result_len = tmplen;
- }
-
- return tmpbuf;
+//??? return tmpbuf;
+ return STR_INIT(tmpbuf, tmplen, 0);
}
/* find decimal point, if expected */
@@ -1161,10 +1158,10 @@ static char *_php_math_number_format_ex_len(double d, int dec, char *dec_point,
if (is_negative) {
reslen++;
}
- resbuf = (char *) emalloc(reslen+1); /* +1 for NUL terminator */
+ res = STR_ALLOC(reslen, 0);
s = tmpbuf+tmplen-1;
- t = resbuf+reslen;
+ t = res->val+reslen;
*t-- = '\0';
/* copy the decimal places.
@@ -1211,21 +1208,10 @@ static char *_php_math_number_format_ex_len(double d, int dec, char *dec_point,
efree(tmpbuf);
- if (result_len) {
- *result_len = reslen;
- }
-
- return resbuf;
+ res->len = reslen;
+ return res;
}
-PHPAPI char *_php_math_number_format_ex(double d, int dec, char *dec_point,
- size_t dec_point_len, char *thousand_sep, size_t thousand_sep_len)
-{
- return _php_math_number_format_ex_len(d, dec, dec_point, dec_point_len,
- thousand_sep, thousand_sep_len, NULL);
-}
-/* }}} */
-
/* {{{ proto string number_format(float number [, int num_decimal_places [, string dec_separator, string thousands_separator]])
Formats a number with grouped thousands */
PHP_FUNCTION(number_format)
@@ -1242,10 +1228,10 @@ PHP_FUNCTION(number_format)
switch(ZEND_NUM_ARGS()) {
case 1:
- RETURN_STRING(_php_math_number_format(num, 0, dec_point_chr, thousand_sep_chr), 0);
+ RETURN_STR(_php_math_number_format(num, 0, dec_point_chr, thousand_sep_chr));
break;
case 2:
- RETURN_STRING(_php_math_number_format(num, dec, dec_point_chr, thousand_sep_chr), 0);
+ RETURN_STR(_php_math_number_format(num, dec, dec_point_chr, thousand_sep_chr));
break;
case 4:
if (dec_point == NULL) {
@@ -1258,10 +1244,8 @@ PHP_FUNCTION(number_format)
thousand_sep_len = 1;
}
- Z_TYPE_P(return_value) = IS_STRING;
- Z_STRVAL_P(return_value) = _php_math_number_format_ex_len(num, dec,
- dec_point, dec_point_len, thousand_sep, thousand_sep_len,
- &Z_STRLEN_P(return_value));
+ RETVAL_STR(_php_math_number_format_ex(num, dec,
+ dec_point, dec_point_len, thousand_sep, thousand_sep_len));
break;
default:
WRONG_PARAM_COUNT;
diff --git a/ext/standard/md5.c b/ext/standard/md5.c
index 134b650212..d2545e913a 100644
--- a/ext/standard/md5.c
+++ b/ext/standard/md5.c
@@ -62,10 +62,10 @@ PHP_NAMED_FUNCTION(php_if_md5)
PHP_MD5Update(&context, arg, arg_len);
PHP_MD5Final(digest, &context);
if (raw_output) {
- RETURN_STRINGL(digest, 16, 1);
+ RETURN_STRINGL(digest, 16);
} else {
make_digest_ex(md5str, digest, 16);
- RETVAL_STRING(md5str, 1);
+ RETVAL_STRING(md5str);
}
}
@@ -96,7 +96,7 @@ PHP_NAMED_FUNCTION(php_if_md5_file)
PHP_MD5Init(&context);
- while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
+ while ((n = php_stream_read(stream, (char*)buf, sizeof(buf))) > 0) {
PHP_MD5Update(&context, buf, n);
}
@@ -109,10 +109,10 @@ PHP_NAMED_FUNCTION(php_if_md5_file)
}
if (raw_output) {
- RETURN_STRINGL(digest, 16, 1);
+ RETURN_STRINGL(digest, 16);
} else {
make_digest_ex(md5str, digest, 16);
- RETVAL_STRING(md5str, 1);
+ RETVAL_STRING(md5str);
}
}
/* }}} */
diff --git a/ext/standard/metaphone.c b/ext/standard/metaphone.c
index 07143dfa7d..98f5d299ed 100644
--- a/ext/standard/metaphone.c
+++ b/ext/standard/metaphone.c
@@ -25,14 +25,14 @@
#include "php.h"
#include "php_metaphone.h"
-static int metaphone(unsigned char *word, int word_len, long max_phonemes, char **phoned_word, int traditional);
+static int metaphone(unsigned char *word, int word_len, long max_phonemes, zend_string **phoned_word, int traditional);
/* {{{ proto string metaphone(string text[, int phones])
Break english phrases down into their phonemes */
PHP_FUNCTION(metaphone)
{
char *str;
- char *result = 0;
+ zend_string *result = NULL;
int str_len;
long phones = 0;
@@ -42,10 +42,10 @@ PHP_FUNCTION(metaphone)
}
if (metaphone((unsigned char *)str, str_len, phones, &result, 1) == 0) {
- RETVAL_STRING(result, 0);
+ RETVAL_STR(result);
} else {
if (result) {
- efree(result);
+ STR_FREE(result);
}
RETURN_FALSE;
}
@@ -144,17 +144,19 @@ static char Lookahead(char *word, int how_far)
* could be one though; or more too). */
#define Phonize(c) { \
if (p_idx >= max_buffer_len) { \
- *phoned_word = safe_erealloc(*phoned_word, 2, sizeof(char), max_buffer_len); \
+ *phoned_word = STR_EREALLOC(*phoned_word, 1 + max_buffer_len); \
max_buffer_len += 2; \
} \
- (*phoned_word)[p_idx++] = c; \
+ (*phoned_word)->val[p_idx++] = c; \
+ (*phoned_word)->len = p_idx; \
}
/* Slap a null character on the end of the phoned word */
#define End_Phoned_Word { \
if (p_idx == max_buffer_len) { \
- *phoned_word = safe_erealloc(*phoned_word, 1, sizeof(char), max_buffer_len); \
+ *phoned_word = STR_EREALLOC(*phoned_word, max_buffer_len); \
} \
- (*phoned_word)[p_idx] = '\0'; \
+ (*phoned_word)->val[p_idx] = '\0'; \
+ (*phoned_word)->len = p_idx; \
}
/* How long is the phoned word? */
#define Phone_Len (p_idx)
@@ -164,7 +166,7 @@ static char Lookahead(char *word, int how_far)
/* {{{ metaphone
*/
-static int metaphone(unsigned char *word, int word_len, long max_phonemes, char **phoned_word, int traditional)
+static int metaphone(unsigned char *word, int word_len, long max_phonemes, zend_string **phoned_word, int traditional)
{
int w_idx = 0; /* point in the phonization we're at. */
int p_idx = 0; /* end of the phoned phrase */
diff --git a/ext/standard/microtime.c b/ext/standard/microtime.c
index fe2236683a..f8e19c74ca 100644
--- a/ext/standard/microtime.c
+++ b/ext/standard/microtime.c
@@ -84,7 +84,7 @@ static void _php_gettimeofday(INTERNAL_FUNCTION_PARAMETERS, int mode)
char ret[100];
snprintf(ret, 100, "%.8F %ld", tp.tv_usec / MICRO_IN_SEC, tp.tv_sec);
- RETURN_STRING(ret, 1);
+ RETURN_STRING(ret);
}
}
diff --git a/ext/standard/pack.c b/ext/standard/pack.c
index 16a30668dc..d4208e7ac6 100644
--- a/ext/standard/pack.c
+++ b/ext/standard/pack.c
@@ -84,13 +84,13 @@ static int little_endian_long_map[4];
/* {{{ php_pack
*/
-static void php_pack(zval **val, int size, int *map, char *output)
+static void php_pack(zval *val, int size, int *map, char *output)
{
int i;
char *v;
convert_to_long_ex(val);
- v = (char *) &Z_LVAL_PP(val);
+ v = (char *) &Z_LVAL_P(val);
for (i = 0; i < size; i++) {
*output++ = v[map[i]];
@@ -105,7 +105,7 @@ static void php_pack(zval **val, int size, int *map, char *output)
Takes one or more arguments and packs them into a binary string according to the format argument */
PHP_FUNCTION(pack)
{
- zval ***argv = NULL;
+ zval *argv = NULL;
int num_args, i;
int currentarg;
char *format;
@@ -120,13 +120,13 @@ PHP_FUNCTION(pack)
return;
}
- if (Z_ISREF_PP(argv[0])) {
- SEPARATE_ZVAL(argv[0]);
+ if (Z_ISREF(argv[0])) {
+ SEPARATE_ZVAL(&argv[0]);
}
- convert_to_string_ex(argv[0]);
+ convert_to_string_ex(&argv[0]);
- format = Z_STRVAL_PP(argv[0]);
- formatlen = Z_STRLEN_PP(argv[0]);
+ format = Z_STRVAL(argv[0]);
+ formatlen = Z_STRLEN(argv[0]);
/* We have a maximum of <formatlen> format codes to deal with */
formatcodes = safe_emalloc(formatlen, sizeof(*formatcodes), 0);
@@ -182,11 +182,11 @@ PHP_FUNCTION(pack)
}
if (arg < 0) {
- if (Z_ISREF_PP(argv[currentarg])) {
- SEPARATE_ZVAL(argv[currentarg]);
+ if (Z_ISREF(argv[currentarg])) {
+ SEPARATE_ZVAL(&argv[currentarg]);
}
- convert_to_string_ex(argv[currentarg]);
- arg = Z_STRLEN_PP(argv[currentarg]);
+ convert_to_string_ex(&argv[currentarg]);
+ arg = Z_STRLEN(argv[currentarg]);
if (code == 'Z') {
/* add one because Z is always NUL-terminated:
* pack("Z*", "aa") === "aa\0"
@@ -318,7 +318,7 @@ PHP_FUNCTION(pack)
for (i = 0; i < formatcount; i++) {
int code = (int) formatcodes[i];
int arg = formatargs[i];
- zval **val;
+ zval *val;
switch ((int) code) {
case 'a':
@@ -326,13 +326,13 @@ PHP_FUNCTION(pack)
case 'Z': {
int arg_cp = (code != 'Z') ? arg : MAX(0, arg - 1);
memset(&output[outputpos], (code == 'a' || code == 'Z') ? '\0' : ' ', arg);
- val = argv[currentarg++];
- if (Z_ISREF_PP(val)) {
+ val = &argv[currentarg++];
+ if (Z_ISREF_P(val)) {
SEPARATE_ZVAL(val);
}
convert_to_string_ex(val);
- memcpy(&output[outputpos], Z_STRVAL_PP(val),
- (Z_STRLEN_PP(val) < arg_cp) ? Z_STRLEN_PP(val) : arg_cp);
+ memcpy(&output[outputpos], Z_STRVAL_P(val),
+ (Z_STRLEN_P(val) < arg_cp) ? Z_STRLEN_P(val) : arg_cp);
outputpos += arg;
break;
}
@@ -343,16 +343,16 @@ PHP_FUNCTION(pack)
int first = 1;
char *v;
- val = argv[currentarg++];
- if (Z_ISREF_PP(val)) {
+ val = &argv[currentarg++];
+ if (Z_ISREF_P(val)) {
SEPARATE_ZVAL(val);
}
convert_to_string_ex(val);
- v = Z_STRVAL_PP(val);
+ v = Z_STRVAL_P(val);
outputpos--;
- if(arg > Z_STRLEN_PP(val)) {
+ if(arg > Z_STRLEN_P(val)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type %c: not enough characters in string", code);
- arg = Z_STRLEN_PP(val);
+ arg = Z_STRLEN_P(val);
}
while (arg-- > 0) {
@@ -386,7 +386,7 @@ PHP_FUNCTION(pack)
case 'c':
case 'C':
while (arg-- > 0) {
- php_pack(argv[currentarg++], 1, byte_map, &output[outputpos]);
+ php_pack(&argv[currentarg++], 1, byte_map, &output[outputpos]);
outputpos++;
}
break;
@@ -404,7 +404,7 @@ PHP_FUNCTION(pack)
}
while (arg-- > 0) {
- php_pack(argv[currentarg++], 2, map, &output[outputpos]);
+ php_pack(&argv[currentarg++], 2, map, &output[outputpos]);
outputpos += 2;
}
break;
@@ -413,7 +413,7 @@ PHP_FUNCTION(pack)
case 'i':
case 'I':
while (arg-- > 0) {
- php_pack(argv[currentarg++], sizeof(int), int_map, &output[outputpos]);
+ php_pack(&argv[currentarg++], sizeof(int), int_map, &output[outputpos]);
outputpos += sizeof(int);
}
break;
@@ -431,7 +431,7 @@ PHP_FUNCTION(pack)
}
while (arg-- > 0) {
- php_pack(argv[currentarg++], 4, map, &output[outputpos]);
+ php_pack(&argv[currentarg++], 4, map, &output[outputpos]);
outputpos += 4;
}
break;
@@ -441,9 +441,9 @@ PHP_FUNCTION(pack)
float v;
while (arg-- > 0) {
- val = argv[currentarg++];
+ val = &argv[currentarg++];
convert_to_double_ex(val);
- v = (float) Z_DVAL_PP(val);
+ v = (float) Z_DVAL_P(val);
memcpy(&output[outputpos], &v, sizeof(v));
outputpos += sizeof(v);
}
@@ -454,9 +454,9 @@ PHP_FUNCTION(pack)
double v;
while (arg-- > 0) {
- val = argv[currentarg++];
+ val = &argv[currentarg++];
convert_to_double_ex(val);
- v = (double) Z_DVAL_PP(val);
+ v = (double) Z_DVAL_P(val);
memcpy(&output[outputpos], &v, sizeof(v));
outputpos += sizeof(v);
}
@@ -489,7 +489,7 @@ PHP_FUNCTION(pack)
efree(formatcodes);
efree(formatargs);
output[outputpos] = '\0';
- RETVAL_STRINGL(output, outputpos, 1);
+ RETVAL_STRINGL(output, outputpos);
efree(output);
}
/* }}} */
diff --git a/ext/standard/php_filestat.h b/ext/standard/php_filestat.h
index ef72e584f1..4f29553aea 100644
--- a/ext/standard/php_filestat.h
+++ b/ext/standard/php_filestat.h
@@ -61,11 +61,6 @@ PHP_FUNCTION(touch);
#endif
PHP_FUNCTION(clearstatcache);
-#define MAKE_LONG_ZVAL_INCREF(name, val)\
- MAKE_STD_ZVAL(name); \
- ZVAL_LONG(name, val); \
- Z_ADDREF_P(name);
-
#ifdef PHP_WIN32
#define S_IRUSR S_IREAD
#define S_IWUSR S_IWRITE
diff --git a/ext/standard/php_incomplete_class.h b/ext/standard/php_incomplete_class.h
index b5a2a322f7..9afc5d7d5b 100644
--- a/ext/standard/php_incomplete_class.h
+++ b/ext/standard/php_incomplete_class.h
@@ -30,24 +30,20 @@
/* OBJECTS_FIXME: Fix for new object model */ \
if (Z_OBJ_HT_P(struc)->get_class_entry && \
Z_OBJCE_P(struc) == BG(incomplete_class)) { \
- class_name = php_lookup_class_name(struc, &name_len); \
+ class_name = php_lookup_class_name(struc); \
if (!class_name) { \
- name_len = sizeof(INCOMPLETE_CLASS) - 1; \
- class_name = estrndup(INCOMPLETE_CLASS, name_len); \
+ class_name = STR_INIT(INCOMPLETE_CLASS, sizeof(INCOMPLETE_CLASS) - 1, 0); \
} \
- free_class_name = 1; \
incomplete_class = 1; \
} else { \
- free_class_name = !zend_get_object_classname(struc, (const char **)&class_name, &name_len TSRMLS_CC);\
+ class_name = zend_get_object_classname(struc TSRMLS_CC); \
}
#define PHP_CLEANUP_CLASS_ATTRIBUTES() \
- if (free_class_name) efree(class_name)
+ STR_RELEASE(class_name)
#define PHP_CLASS_ATTRIBUTES \
- char *class_name; \
- zend_uint name_len; \
- zend_bool free_class_name = 0; \
+ zend_string *class_name; \
zend_bool incomplete_class = 0
#define INCOMPLETE_CLASS "__PHP_Incomplete_Class"
@@ -58,7 +54,7 @@ extern "C" {
#endif
PHPAPI zend_class_entry *php_create_incomplete_class(TSRMLS_D);
-PHPAPI char *php_lookup_class_name(zval *object, zend_uint *nlen);
+PHPAPI zend_string *php_lookup_class_name(zval *object);
PHPAPI void php_store_class_name(zval *object, const char *name, zend_uint len);
#ifdef __cplusplus
diff --git a/ext/standard/php_math.h b/ext/standard/php_math.h
index 8dec21acf3..01d2152ccc 100644
--- a/ext/standard/php_math.h
+++ b/ext/standard/php_math.h
@@ -22,12 +22,12 @@
#ifndef PHP_MATH_H
#define PHP_MATH_H
-PHPAPI char *_php_math_number_format(double, int, char, char);
-PHPAPI char *_php_math_number_format_ex(double, int, char *, size_t, char *, size_t);
-PHPAPI char * _php_math_longtobase(zval *arg, int base);
+PHPAPI zend_string *_php_math_number_format(double, int, char, char);
+PHPAPI zend_string *_php_math_number_format_ex(double, int, char *, size_t, char *, size_t);
+PHPAPI zend_string * _php_math_longtobase(zval *arg, int base);
PHPAPI long _php_math_basetolong(zval *arg, int base);
PHPAPI int _php_math_basetozval(zval *arg, int base, zval *ret);
-PHPAPI char * _php_math_zvaltobase(zval *arg, int base TSRMLS_DC);
+PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base TSRMLS_DC);
PHP_FUNCTION(sin);
PHP_FUNCTION(cos);
diff --git a/ext/standard/php_var.h b/ext/standard/php_var.h
index 48692e57c3..0af644d49a 100644
--- a/ext/standard/php_var.h
+++ b/ext/standard/php_var.h
@@ -32,11 +32,11 @@ PHP_FUNCTION(unserialize);
PHP_FUNCTION(memory_get_usage);
PHP_FUNCTION(memory_get_peak_usage);
-PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC);
-PHPAPI void php_var_export(zval **struc, int level TSRMLS_DC);
-PHPAPI void php_var_export_ex(zval **struc, int level, smart_str *buf TSRMLS_DC);
+PHPAPI void php_var_dump(zval *struc, int level TSRMLS_DC);
+PHPAPI void php_var_export(zval *struc, int level TSRMLS_DC);
+PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf TSRMLS_DC);
-PHPAPI void php_debug_zval_dump(zval **struc, int level TSRMLS_DC);
+PHPAPI void php_debug_zval_dump(zval *struc, int level TSRMLS_DC);
typedef HashTable* php_serialize_data_t;
diff --git a/ext/standard/quot_print.c b/ext/standard/quot_print.c
index 7f54ce4d21..0738ead2fd 100644
--- a/ext/standard/quot_print.c
+++ b/ext/standard/quot_print.c
@@ -51,7 +51,7 @@ static char php_hex2int(int c) /* {{{ */
}
/* }}} */
-PHPAPI unsigned char *php_quot_print_decode(const unsigned char *str, size_t length, size_t *ret_length, int replace_us_by_ws) /* {{{ */
+PHPAPI zend_string *php_quot_print_decode(const unsigned char *str, size_t length, int replace_us_by_ws) /* {{{ */
{
register unsigned int i;
register unsigned const char *p1;
@@ -59,7 +59,7 @@ PHPAPI unsigned char *php_quot_print_decode(const unsigned char *str, size_t len
register unsigned int h_nbl, l_nbl;
size_t decoded_len, buf_size;
- unsigned char *retval;
+ zend_string *retval;
static unsigned int hexval_tbl[256] = {
64, 64, 64, 64, 64, 64, 64, 64, 64, 32, 16, 64, 64, 16, 64, 64,
@@ -96,8 +96,8 @@ PHPAPI unsigned char *php_quot_print_decode(const unsigned char *str, size_t len
i--;
}
- retval = emalloc(buf_size + 1);
- i = length; p1 = str; p2 = retval;
+ retval = STR_ALLOC(buf_size, 0);
+ i = length; p1 = str; p2 = (unsigned char*)retval->val;
decoded_len = 0;
while (i > 0 && *p1 != '\0') {
@@ -138,21 +138,23 @@ PHPAPI unsigned char *php_quot_print_decode(const unsigned char *str, size_t len
}
*p2 = '\0';
- *ret_length = decoded_len;
+ retval->len = decoded_len;
return retval;
}
/* }}} */
#define PHP_QPRINT_MAXL 75
-PHPAPI unsigned char *php_quot_print_encode(const unsigned char *str, size_t length, size_t *ret_length) /* {{{ */
+PHPAPI zend_string *php_quot_print_encode(const unsigned char *str, size_t length) /* {{{ */
{
unsigned long lp = 0;
- unsigned char c, *ret, *d;
+ unsigned char c, *d;
char *hex = "0123456789ABCDEF";
+ zend_string *ret;
- ret = safe_emalloc(3, length + (((3 * length)/(PHP_QPRINT_MAXL-9)) + 1), 1);
- d = ret;
+//??? ret = safe_emalloc(3, length + (((3 * length)/(PHP_QPRINT_MAXL-9)) + 1), 1);
+ ret = STR_ALLOC(3 * (length + (((3 * length)/(PHP_QPRINT_MAXL-9)) + 1)), 0);
+ d = (unsigned char*)ret->val;
while (length--) {
if (((c = *str++) == '\015') && (*str == '\012') && length > 0) {
@@ -186,9 +188,7 @@ PHPAPI unsigned char *php_quot_print_encode(const unsigned char *str, size_t len
}
}
*d = '\0';
- *ret_length = d - ret;
-
- ret = erealloc(ret, *ret_length + 1);
+ ret = STR_EREALLOC(ret, d - (unsigned char*)ret->val);
return ret;
}
/* }}} */
@@ -202,7 +202,8 @@ PHPAPI unsigned char *php_quot_print_encode(const unsigned char *str, size_t len
Convert a quoted-printable string to an 8 bit string */
PHP_FUNCTION(quoted_printable_decode)
{
- char *arg1, *str_in, *str_out;
+ char *arg1, *str_in;
+ zend_string *str_out;
int arg1_len, i = 0, j = 0, k;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg1, &arg1_len) == FAILURE) {
@@ -215,7 +216,7 @@ PHP_FUNCTION(quoted_printable_decode)
}
str_in = arg1;
- str_out = emalloc(arg1_len + 1);
+ str_out = STR_ALLOC(arg1_len, 0);
while (str_in[i]) {
switch (str_in[i]) {
case '=':
@@ -223,7 +224,7 @@ PHP_FUNCTION(quoted_printable_decode)
isxdigit((int) str_in[i + 1]) &&
isxdigit((int) str_in[i + 2]))
{
- str_out[j++] = (php_hex2int((int) str_in[i + 1]) << 4)
+ str_out->val[j++] = (php_hex2int((int) str_in[i + 1]) << 4)
+ php_hex2int((int) str_in[i + 2]);
i += 3;
} else /* check for soft line break according to RFC 2045*/ {
@@ -245,26 +246,27 @@ PHP_FUNCTION(quoted_printable_decode)
i += k + 1;
}
else {
- str_out[j++] = str_in[i++];
+ str_out->val[j++] = str_in[i++];
}
}
break;
default:
- str_out[j++] = str_in[i++];
+ str_out->val[j++] = str_in[i++];
}
}
- str_out[j] = '\0';
+ str_out->val[j] = '\0';
+ str_out->len = j;
- RETVAL_STRINGL(str_out, j, 0);
+ RETVAL_STR(str_out);
}
/* }}} */
/* {{{ proto string quoted_printable_encode(string str) */
PHP_FUNCTION(quoted_printable_encode)
{
- char *str, *new_str;
+ char *str;
+ zend_string *new_str;
int str_len;
- size_t new_str_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) != SUCCESS) {
return;
@@ -274,8 +276,8 @@ PHP_FUNCTION(quoted_printable_encode)
RETURN_EMPTY_STRING();
}
- new_str = (char *)php_quot_print_encode((unsigned char *)str, (size_t)str_len, &new_str_len);
- RETURN_STRINGL(new_str, new_str_len, 0);
+ new_str = php_quot_print_encode((unsigned char *)str, (size_t)str_len);
+ RETURN_STR(new_str);
}
/* }}} */
diff --git a/ext/standard/quot_print.h b/ext/standard/quot_print.h
index 8be7faa388..7055d05717 100644
--- a/ext/standard/quot_print.h
+++ b/ext/standard/quot_print.h
@@ -21,8 +21,8 @@
#ifndef QUOT_PRINT_H
#define QUOT_PRINT_H
-PHPAPI unsigned char *php_quot_print_decode(const unsigned char *str, size_t length, size_t *ret_length, int replace_us_by_ws);
-PHPAPI unsigned char *php_quot_print_encode(const unsigned char *str, size_t length, size_t *ret_length);
+PHPAPI zend_string *php_quot_print_decode(const unsigned char *str, size_t length, int replace_us_by_ws);
+PHPAPI zend_string *php_quot_print_encode(const unsigned char *str, size_t length);
PHP_FUNCTION(quoted_printable_decode);
PHP_FUNCTION(quoted_printable_encode);
diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c
index d092bbcfcf..6ecc163a4b 100644
--- a/ext/standard/scanf.c
+++ b/ext/standard/scanf.c
@@ -118,7 +118,7 @@ typedef struct CharSet {
static char *BuildCharSet(CharSet *cset, char *format);
static int CharInSet(CharSet *cset, int ch);
static void ReleaseCharSet(CharSet *cset);
-static inline void scan_set_error_return(int numVars, zval **return_value);
+static inline void scan_set_error_return(int numVars, zval *return_value);
/* {{{ BuildCharSet
@@ -577,15 +577,15 @@ error:
*/
PHPAPI int php_sscanf_internal( char *string, char *format,
- int argCount, zval ***args,
- int varStart, zval **return_value TSRMLS_DC)
+ int argCount, zval *args,
+ int varStart, zval *return_value TSRMLS_DC)
{
int numVars, nconversions, totalVars = -1;
int i, result;
long value;
int objIndex;
char *end, *baseString;
- zval **current;
+ zval *current;
char op = 0;
int base = 0;
int underflow = 0;
@@ -624,7 +624,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
*/
if (numVars) {
for (i = varStart;i < argCount;i++){
- if ( ! PZVAL_IS_REF( *args[ i ] ) ) {
+ if ( ! Z_ISREF(args[ i ] ) ) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Parameter %d must be passed by reference", i);
scan_set_error_return(numVars, return_value);
return SCAN_ERROR_VAR_PASSED_BYVAL;
@@ -637,15 +637,14 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
* are specified
*/
if (!numVars) {
- zval *tmp;
+ zval tmp;
/* allocate an array for return */
- array_init(*return_value);
+ array_init(return_value);
for (i = 0; i < totalVars; i++) {
- MAKE_STD_ZVAL(tmp);
- ZVAL_NULL(tmp);
- if (add_next_index_zval(*return_value, tmp) == FAILURE) {
+ ZVAL_NULL(&tmp);
+ if (add_next_index_zval(return_value, &tmp) == FAILURE) {
scan_set_error_return(0, return_value);
return FAILURE;
}
@@ -745,14 +744,15 @@ literal:
} else if (numVars) {
zend_uint refcount;
- current = args[objIndex++];
- refcount = Z_REFCOUNT_PP(current);
- zval_dtor( *current );
- ZVAL_LONG( *current, (long)(string - baseString) );
- Z_SET_REFCOUNT_PP(current, refcount);
- Z_SET_ISREF_PP(current);
+ current = &args[objIndex++];
+ refcount = Z_REFCOUNT_P(current);
+ zval_dtor(current);
+ ZVAL_LONG(current, (long)(string - baseString) );
+ Z_SET_REFCOUNT_P(current, refcount);
+//??? Z_SET_ISREF_P(current);
+ ZVAL_NEW_REF(current, current);
} else {
- add_index_long(*return_value, objIndex++, string - baseString);
+ add_index_long(return_value, objIndex++, string - baseString);
}
}
nconversions++;
@@ -869,14 +869,15 @@ literal:
} else if (numVars) {
zend_uint refcount;
- current = args[objIndex++];
- refcount = Z_REFCOUNT_PP(current);
- zval_dtor( *current );
- ZVAL_STRINGL( *current, string, end-string, 1);
- Z_SET_REFCOUNT_PP(current, refcount);
- Z_SET_ISREF_PP(current);
+ current = &args[objIndex++];
+ refcount = Z_REFCOUNT_P(current);
+ zval_dtor( current );
+ ZVAL_STRINGL( current, string, end-string);
+ Z_SET_REFCOUNT_P(current, refcount);
+//??? Z_SET_ISREF_PP(current);
+ ZVAL_NEW_REF(current, current);
} else {
- add_index_stringl( *return_value, objIndex++, string, end-string, 1);
+ add_index_stringl(return_value, objIndex++, string, end-string, 1);
}
}
string = end;
@@ -913,11 +914,11 @@ literal:
if (numVars && objIndex >= argCount) {
break;
} else if (numVars) {
- current = args[objIndex++];
- zval_dtor( *current );
- ZVAL_STRINGL( *current, string, end-string, 1);
+ current = &args[objIndex++];
+ zval_dtor( current );
+ ZVAL_STRINGL( current, string, end-string);
} else {
- add_index_stringl(*return_value, objIndex++, string, end-string, 1);
+ add_index_stringl(return_value, objIndex++, string, end-string, 1);
}
}
string = end;
@@ -938,7 +939,7 @@ literal:
zval_dtor(*current);
ZVAL_STRINGL( *current, __buf, 1, 1);
} else {
- add_index_stringl(*return_value, objIndex++, &sch, 1, 1);
+ add_index_stringl(return_value, objIndex++, &sch, 1, 1);
}
}
break;
@@ -1067,21 +1068,21 @@ addToInt:
break;
} else if (numVars) {
/* change passed value type to string */
- current = args[objIndex++];
- zval_dtor(*current);
- ZVAL_STRING( *current, buf, 1 );
+ current = &args[objIndex++];
+ zval_dtor(current);
+ ZVAL_STRING(current, buf);
} else {
- add_index_string(*return_value, objIndex++, buf, 1);
+ add_index_string(return_value, objIndex++, buf, 1);
}
} else {
if (numVars && objIndex >= argCount) {
break;
} else if (numVars) {
- current = args[objIndex++];
- zval_dtor(*current);
- ZVAL_LONG(*current, value);
+ current = &args[objIndex++];
+ zval_dtor(current);
+ ZVAL_LONG(current, value);
} else {
- add_index_long(*return_value, objIndex++, value);
+ add_index_long(return_value, objIndex++, value);
}
}
}
@@ -1182,11 +1183,11 @@ addToFloat:
if (numVars && objIndex >= argCount) {
break;
} else if (numVars) {
- current = args[objIndex++];
- zval_dtor(*current);
- ZVAL_DOUBLE(*current, dvalue);
+ current = &args[objIndex++];
+ zval_dtor(current);
+ ZVAL_DOUBLE(current, dvalue);
} else {
- add_index_double( *return_value, objIndex++, dvalue );
+ add_index_double(return_value, objIndex++, dvalue );
}
}
break;
@@ -1201,8 +1202,8 @@ done:
scan_set_error_return( numVars, return_value );
result = SCAN_ERROR_EOF;
} else if (numVars) {
- convert_to_long( *return_value );
- Z_LVAL_PP(return_value) = nconversions;
+ convert_to_long(return_value );
+ Z_LVAL_P(return_value) = nconversions;
} else if (nconversions < totalVars) {
/* TODO: not all elements converted. we need to prune the list - cc */
}
@@ -1211,14 +1212,14 @@ done:
/* }}} */
/* the compiler choked when i tried to make this a macro */
-static inline void scan_set_error_return(int numVars, zval **return_value) /* {{{ */
+static inline void scan_set_error_return(int numVars, zval *return_value) /* {{{ */
{
if (numVars) {
- Z_TYPE_PP(return_value) = IS_LONG;
- Z_LVAL_PP(return_value) = SCAN_ERROR_EOF; /* EOF marker */
+ Z_TYPE_P(return_value) = IS_LONG;
+ Z_LVAL_P(return_value) = SCAN_ERROR_EOF; /* EOF marker */
} else {
/* convert_to_null calls destructor */
- convert_to_null( *return_value );
+ convert_to_null(return_value);
}
}
/* }}} */
diff --git a/ext/standard/scanf.h b/ext/standard/scanf.h
index 9d4acd4a8f..8d5fee22e1 100644
--- a/ext/standard/scanf.h
+++ b/ext/standard/scanf.h
@@ -42,8 +42,8 @@
* e.g. fscanf
*/
PHPAPI int ValidateFormat(char *format, int numVars, int *totalVars);
-PHPAPI int php_sscanf_internal(char *string,char *format,int argCount,zval ***args,
- int varStart, zval **return_value TSRMLS_DC);
+PHPAPI int php_sscanf_internal(char *string,char *format,int argCount,zval *args,
+ int varStart, zval *return_value TSRMLS_DC);
#endif /* SCANF_H */
diff --git a/ext/standard/sha1.c b/ext/standard/sha1.c
index 67e5d520f4..84a7d258c1 100644
--- a/ext/standard/sha1.c
+++ b/ext/standard/sha1.c
@@ -50,10 +50,10 @@ PHP_FUNCTION(sha1)
PHP_SHA1Update(&context, arg, arg_len);
PHP_SHA1Final(digest, &context);
if (raw_output) {
- RETURN_STRINGL(digest, 20, 1);
+ RETURN_STRINGL(digest, 20);
} else {
make_digest_ex(sha1str, digest, 20);
- RETVAL_STRING(sha1str, 1);
+ RETVAL_STRING(sha1str);
}
}
@@ -99,10 +99,10 @@ PHP_FUNCTION(sha1_file)
}
if (raw_output) {
- RETURN_STRINGL(digest, 20, 1);
+ RETURN_STRINGL(digest, 20);
} else {
make_digest_ex(sha1str, digest, 20);
- RETVAL_STRING(sha1str, 1);
+ RETVAL_STRING(sha1str);
}
}
/* }}} */
diff --git a/ext/standard/soundex.c b/ext/standard/soundex.c
index cf915d4c1d..af9a719d39 100644
--- a/ext/standard/soundex.c
+++ b/ext/standard/soundex.c
@@ -101,7 +101,7 @@ PHP_FUNCTION(soundex)
}
soundex[_small] = '\0';
- RETURN_STRINGL(soundex, _small, 1);
+ RETURN_STRINGL(soundex, _small);
}
/* }}} */
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 891bad3085..76815def26 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -5283,7 +5283,7 @@ PHP_FUNCTION(str_pad)
Implements an ANSI C compatible sscanf */
PHP_FUNCTION(sscanf)
{
- zval ***args = NULL;
+ zval *args = NULL;
char *str, *format;
int str_len, format_len, result, num_args = 0;
@@ -5292,7 +5292,7 @@ PHP_FUNCTION(sscanf)
return;
}
- result = php_sscanf_internal(str, format, num_args, args, 0, &return_value TSRMLS_CC);
+ result = php_sscanf_internal(str, format, num_args, args, 0, return_value TSRMLS_CC);
if (args) {
efree(args);
diff --git a/ext/standard/type.c b/ext/standard/type.c
index 15bdbb06c2..3fe312644b 100644
--- a/ext/standard/type.c
+++ b/ext/standard/type.c
@@ -25,39 +25,39 @@
Returns the type of the variable */
PHP_FUNCTION(gettype)
{
- zval **arg;
+ zval *arg;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
return;
}
- switch (Z_TYPE_PP(arg)) {
+ switch (Z_TYPE_P(arg)) {
case IS_NULL:
- RETVAL_STRING("NULL", 1);
+ RETVAL_STRING("NULL");
break;
case IS_BOOL:
- RETVAL_STRING("boolean", 1);
+ RETVAL_STRING("boolean");
break;
case IS_LONG:
- RETVAL_STRING("integer", 1);
+ RETVAL_STRING("integer");
break;
case IS_DOUBLE:
- RETVAL_STRING("double", 1);
+ RETVAL_STRING("double");
break;
case IS_STRING:
- RETVAL_STRING("string", 1);
+ RETVAL_STRING("string");
break;
case IS_ARRAY:
- RETVAL_STRING("array", 1);
+ RETVAL_STRING("array");
break;
case IS_OBJECT:
- RETVAL_STRING("object", 1);
+ RETVAL_STRING("object");
/*
{
char *result;
@@ -72,16 +72,16 @@ PHP_FUNCTION(gettype)
case IS_RESOURCE:
{
- const char *type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(arg) TSRMLS_CC);
+ const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(arg) TSRMLS_CC);
if (type_name) {
- RETVAL_STRING("resource", 1);
+ RETVAL_STRING("resource");
break;
}
}
default:
- RETVAL_STRING("unknown type", 1);
+ RETVAL_STRING("unknown type");
}
}
/* }}} */
@@ -214,26 +214,26 @@ PHP_FUNCTION(strval)
static void php_is_type(INTERNAL_FUNCTION_PARAMETERS, int type)
{
- zval **arg;
+ zval *arg;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
RETURN_FALSE;
}
- if (Z_TYPE_PP(arg) == type) {
+ if (Z_TYPE_P(arg) == type) {
if (type == IS_OBJECT) {
zend_class_entry *ce;
- if(Z_OBJ_HT_PP(arg)->get_class_entry == NULL) {
+ if(Z_OBJ_HT_P(arg)->get_class_entry == NULL) {
/* if there's no get_class_entry it's not a PHP object, so it can't be INCOMPLETE_CLASS */
RETURN_TRUE;
}
- ce = Z_OBJCE_PP(arg);
- if (!strcmp(ce->name, INCOMPLETE_CLASS)) {
+ ce = Z_OBJCE_P(arg);
+ if (!strcmp(ce->name->val, INCOMPLETE_CLASS)) {
RETURN_FALSE;
}
}
if (type == IS_RESOURCE) {
- const char *type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(arg) TSRMLS_CC);
+ const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(arg) TSRMLS_CC);
if (!type_name) {
RETURN_FALSE;
}
@@ -313,20 +313,20 @@ PHP_FUNCTION(is_object)
Returns true if value is a number or a numeric string */
PHP_FUNCTION(is_numeric)
{
- zval **arg;
+ zval *arg;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
return;
}
- switch (Z_TYPE_PP(arg)) {
+ switch (Z_TYPE_P(arg)) {
case IS_LONG:
case IS_DOUBLE:
RETURN_TRUE;
break;
case IS_STRING:
- if (is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), NULL, NULL, 0)) {
+ if (is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), NULL, NULL, 0)) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -344,13 +344,13 @@ PHP_FUNCTION(is_numeric)
Returns true if value is a scalar */
PHP_FUNCTION(is_scalar)
{
- zval **arg;
+ zval *arg;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
return;
}
- switch (Z_TYPE_PP(arg)) {
+ switch (Z_TYPE_P(arg)) {
case IS_BOOL:
case IS_DOUBLE:
case IS_LONG:
@@ -369,14 +369,14 @@ PHP_FUNCTION(is_scalar)
Returns true if var is callable. */
PHP_FUNCTION(is_callable)
{
- zval *var, **callable_name = NULL;
+ zval *var, *callable_name = NULL;
char *name;
char *error;
zend_bool retval;
zend_bool syntax_only = 0;
int check_flags = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|bZ", &var,
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|bz", &var,
&syntax_only, &callable_name) == FAILURE) {
return;
}
@@ -386,8 +386,9 @@ PHP_FUNCTION(is_callable)
}
if (ZEND_NUM_ARGS() > 2) {
retval = zend_is_callable_ex(var, NULL, check_flags, &name, NULL, NULL, &error TSRMLS_CC);
- zval_dtor(*callable_name);
- ZVAL_STRING(*callable_name, name, 0);
+ zval_dtor(callable_name);
+//??? ZVAL_STRING(callable_name, name, 0);
+ ZVAL_STRING(callable_name, name);
} else {
retval = zend_is_callable_ex(var, NULL, check_flags, NULL, NULL, NULL, &error TSRMLS_CC);
}
diff --git a/ext/standard/uniqid.c b/ext/standard/uniqid.c
index a87bdb9c52..815dde774b 100644
--- a/ext/standard/uniqid.c
+++ b/ext/standard/uniqid.c
@@ -81,7 +81,8 @@ PHP_FUNCTION(uniqid)
spprintf(&uniqid, 0, "%s%08x%05x", prefix, sec, usec);
}
- RETURN_STRING(uniqid, 0);
+//??? RETURN_STRING(uniqid, 0);
+ RETURN_STRING(uniqid);
}
#endif
/* }}} */
diff --git a/ext/standard/url.c b/ext/standard/url.c
index e4eb9c48b9..1c02a1c437 100644
--- a/ext/standard/url.c
+++ b/ext/standard/url.c
@@ -193,12 +193,12 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
if (port > 0 && port <= 65535) {
ret->port = (unsigned short) port;
} else {
- STR_FREE(ret->scheme);
+ if (ret->scheme) efree(ret->scheme);
efree(ret);
return NULL;
}
} else if (p == pp && *pp == '\0') {
- STR_FREE(ret->scheme);
+ if (ret->scheme) efree(ret->scheme);
efree(ret);
return NULL;
} else if (*s == '/' && *(s+1) == '/') { /* relative-scheme URL */
@@ -274,9 +274,9 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
if (!ret->port) {
p++;
if (e-p > 5) { /* port cannot be longer then 5 characters */
- STR_FREE(ret->scheme);
- STR_FREE(ret->user);
- STR_FREE(ret->pass);
+ if (ret->scheme) efree(ret->scheme);
+ if (ret->user) efree(ret->user);
+ if (ret->pass) efree(ret->pass);
efree(ret);
return NULL;
} else if (e - p > 0) {
@@ -287,9 +287,9 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
if (port > 0 && port <= 65535) {
ret->port = (unsigned short)port;
} else {
- STR_FREE(ret->scheme);
- STR_FREE(ret->user);
- STR_FREE(ret->pass);
+ if (ret->scheme) efree(ret->scheme);
+ if (ret->user) efree(ret->user);
+ if (ret->pass) efree(ret->pass);
efree(ret);
return NULL;
}
@@ -302,9 +302,9 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
/* check if we have a valid host, if we don't reject the string as url */
if ((p-s) < 1) {
- STR_FREE(ret->scheme);
- STR_FREE(ret->user);
- STR_FREE(ret->pass);
+ if (ret->scheme) efree(ret->scheme);
+ if (ret->user) efree(ret->user);
+ if (ret->pass) efree(ret->pass);
efree(ret);
return NULL;
}
@@ -392,28 +392,28 @@ PHP_FUNCTION(parse_url)
if (key > -1) {
switch (key) {
case PHP_URL_SCHEME:
- if (resource->scheme != NULL) RETVAL_STRING(resource->scheme, 1);
+ if (resource->scheme != NULL) RETVAL_STRING(resource->scheme);
break;
case PHP_URL_HOST:
- if (resource->host != NULL) RETVAL_STRING(resource->host, 1);
+ if (resource->host != NULL) RETVAL_STRING(resource->host);
break;
case PHP_URL_PORT:
if (resource->port != 0) RETVAL_LONG(resource->port);
break;
case PHP_URL_USER:
- if (resource->user != NULL) RETVAL_STRING(resource->user, 1);
+ if (resource->user != NULL) RETVAL_STRING(resource->user);
break;
case PHP_URL_PASS:
- if (resource->pass != NULL) RETVAL_STRING(resource->pass, 1);
+ if (resource->pass != NULL) RETVAL_STRING(resource->pass);
break;
case PHP_URL_PATH:
- if (resource->path != NULL) RETVAL_STRING(resource->path, 1);
+ if (resource->path != NULL) RETVAL_STRING(resource->path);
break;
case PHP_URL_QUERY:
- if (resource->query != NULL) RETVAL_STRING(resource->query, 1);
+ if (resource->query != NULL) RETVAL_STRING(resource->query);
break;
case PHP_URL_FRAGMENT:
- if (resource->fragment != NULL) RETVAL_STRING(resource->fragment, 1);
+ if (resource->fragment != NULL) RETVAL_STRING(resource->fragment);
break;
default:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid URL component identifier %ld", key);
@@ -542,7 +542,8 @@ PHP_FUNCTION(urlencode)
}
out_str = php_url_encode(in_str, in_str_len, &out_str_len);
- RETURN_STRINGL(out_str, out_str_len, 0);
+//??? RETURN_STRINGL(out_str, out_str_len, 0);
+ RETURN_STRINGL(out_str, out_str_len);
}
/* }}} */
@@ -561,7 +562,8 @@ PHP_FUNCTION(urldecode)
out_str = estrndup(in_str, in_str_len);
out_str_len = php_url_decode(out_str, in_str_len);
- RETURN_STRINGL(out_str, out_str_len, 0);
+//??? RETURN_STRINGL(out_str, out_str_len, 0);
+ RETURN_STRINGL(out_str, out_str_len);
}
/* }}} */
@@ -643,7 +645,8 @@ PHP_FUNCTION(rawurlencode)
}
out_str = php_raw_url_encode(in_str, in_str_len, &out_str_len);
- RETURN_STRINGL(out_str, out_str_len, 0);
+//??? RETURN_STRINGL(out_str, out_str_len, 0);
+ RETURN_STRINGL(out_str, out_str_len);
}
/* }}} */
@@ -662,7 +665,8 @@ PHP_FUNCTION(rawurldecode)
out_str = estrndup(in_str, in_str_len);
out_str_len = php_raw_url_decode(out_str, in_str_len);
- RETURN_STRINGL(out_str, out_str_len, 0);
+//??? RETURN_STRINGL(out_str, out_str_len, 0);
+ RETURN_STRINGL(out_str, out_str_len);
}
/* }}} */
@@ -702,7 +706,7 @@ PHP_FUNCTION(get_headers)
int url_len;
php_stream_context *context;
php_stream *stream;
- zval **prev_val, **hdr = NULL, **h;
+ zval *prev_val, *hdr = NULL, *h;
HashPosition pos;
HashTable *hashT;
long format = 0;
@@ -716,7 +720,7 @@ PHP_FUNCTION(get_headers)
RETURN_FALSE;
}
- if (!stream->wrapperdata || Z_TYPE_P(stream->wrapperdata) != IS_ARRAY) {
+ if (Z_TYPE(stream->wrapperdata) != IS_ARRAY) {
php_stream_close(stream);
RETURN_FALSE;
}
@@ -724,31 +728,31 @@ PHP_FUNCTION(get_headers)
array_init(return_value);
/* check for curl-wrappers that provide headers via a special "headers" element */
- if (zend_hash_find(HASH_OF(stream->wrapperdata), "headers", sizeof("headers"), (void **)&h) != FAILURE && Z_TYPE_PP(h) == IS_ARRAY) {
+ if ((h = zend_hash_str_find(HASH_OF(&stream->wrapperdata), "headers", sizeof("headers")-1)) != NULL && Z_TYPE_P(h) == IS_ARRAY) {
/* curl-wrappers don't load data until the 1st read */
- if (!Z_ARRVAL_PP(h)->nNumOfElements) {
+ if (!Z_ARRVAL_P(h)->nNumOfElements) {
php_stream_getc(stream);
}
- zend_hash_find(HASH_OF(stream->wrapperdata), "headers", sizeof("headers"), (void **)&h);
- hashT = Z_ARRVAL_PP(h);
+ h = zend_hash_str_find(HASH_OF(&stream->wrapperdata), "headers", sizeof("headers")-1);
+ hashT = Z_ARRVAL_P(h);
} else {
- hashT = HASH_OF(stream->wrapperdata);
+ hashT = HASH_OF(&stream->wrapperdata);
}
zend_hash_internal_pointer_reset_ex(hashT, &pos);
- while (zend_hash_get_current_data_ex(hashT, (void**)&hdr, &pos) != FAILURE) {
- if (!hdr || Z_TYPE_PP(hdr) != IS_STRING) {
+ while ((hdr = zend_hash_get_current_data_ex(hashT, &pos)) != NULL) {
+ if (!hdr || Z_TYPE_P(hdr) != IS_STRING) {
zend_hash_move_forward_ex(hashT, &pos);
continue;
}
if (!format) {
no_name_header:
- add_next_index_stringl(return_value, Z_STRVAL_PP(hdr), Z_STRLEN_PP(hdr), 1);
+ add_next_index_str(return_value, STR_COPY(Z_STR_P(hdr)));
} else {
char c;
char *s, *p;
- if ((p = strchr(Z_STRVAL_PP(hdr), ':'))) {
+ if ((p = strchr(Z_STRVAL_P(hdr), ':'))) {
c = *p;
*p = '\0';
s = p + 1;
@@ -756,11 +760,11 @@ no_name_header:
s++;
}
- if (zend_hash_find(HASH_OF(return_value), Z_STRVAL_PP(hdr), (p - Z_STRVAL_PP(hdr) + 1), (void **) &prev_val) == FAILURE) {
- add_assoc_stringl_ex(return_value, Z_STRVAL_PP(hdr), (p - Z_STRVAL_PP(hdr) + 1), s, (Z_STRLEN_PP(hdr) - (s - Z_STRVAL_PP(hdr))), 1);
+ if ((prev_val = zend_hash_str_find(HASH_OF(return_value), Z_STRVAL_P(hdr), (p - Z_STRVAL_P(hdr)))) == NULL) {
+ add_assoc_stringl_ex(return_value, Z_STRVAL_P(hdr), (p - Z_STRVAL_P(hdr) + 1), s, (Z_STRLEN_P(hdr) - (s - Z_STRVAL_P(hdr))), 1);
} else { /* some headers may occur more then once, therefor we need to remake the string into an array */
- convert_to_array(*prev_val);
- add_next_index_stringl(*prev_val, s, (Z_STRLEN_PP(hdr) - (s - Z_STRVAL_PP(hdr))), 1);
+ convert_to_array(prev_val);
+ add_next_index_stringl(prev_val, s, (Z_STRLEN_P(hdr) - (s - Z_STRVAL_P(hdr))), 1);
}
*p = c;
diff --git a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c
index 8c9098a182..b48a52661a 100644
--- a/ext/standard/url_scanner_ex.c
+++ b/ext/standard/url_scanner_ex.c
@@ -4,7 +4,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2014 The PHP Group |
+ | Copyright (c) 1997-2013 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -65,7 +65,6 @@ static PHP_INI_MH(OnUpdateTags)
}
zend_hash_init(ctx->tags, 0, NULL, NULL, 1);
- ctx->tags->flags |= HASH_FLAG_BIG_DATA;
for (key = php_strtok_r(tmp, ",", &lasts);
key;
@@ -83,7 +82,7 @@ static PHP_INI_MH(OnUpdateTags)
keylen = q - key;
/* key is stored withOUT NUL
val is stored WITH NUL */
- zend_hash_add(ctx->tags, key, keylen, val, strlen(val)+1, NULL);
+ zend_hash_str_add_mem(ctx->tags, key, keylen, val, strlen(val)+1);
}
}
@@ -320,7 +319,7 @@ static inline void handle_tag(STD_PARA)
smart_str_appendl(&ctx->tag, start, YYCURSOR - start);
for (i = 0; i < ctx->tag.len; i++)
ctx->tag.c[i] = tolower((int)(unsigned char)ctx->tag.c[i]);
- if (zend_hash_find(ctx->tags, ctx->tag.c, ctx->tag.len, (void **) &ctx->lookup_data) == SUCCESS)
+ if ((ctx->lookup_data = zend_hash_str_find_ptr(ctx->tags, ctx->tag.c, ctx->tag.len)) != NULL)
ok = 1;
STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN;
}
diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re
index 56e74f7957..fa4220897c 100644
--- a/ext/standard/url_scanner_ex.re
+++ b/ext/standard/url_scanner_ex.re
@@ -63,7 +63,6 @@ static PHP_INI_MH(OnUpdateTags)
}
zend_hash_init(ctx->tags, 0, NULL, NULL, 1);
- ctx->tags->flags |= ZEND_FLAG_BIG_DATA;
for (key = php_strtok_r(tmp, ",", &lasts);
key;
@@ -81,7 +80,7 @@ static PHP_INI_MH(OnUpdateTags)
keylen = q - key;
/* key is stored withOUT NUL
val is stored WITH NUL */
- zend_hash_add(ctx->tags, key, keylen, val, strlen(val)+1, NULL);
+ zend_hash_str_add_mem(ctx->tags, key, keylen, val, strlen(val)+1);
}
}
@@ -256,7 +255,7 @@ static inline void handle_tag(STD_PARA)
smart_str_appendl(&ctx->tag, start, YYCURSOR - start);
for (i = 0; i < ctx->tag.len; i++)
ctx->tag.c[i] = tolower((int)(unsigned char)ctx->tag.c[i]);
- if (zend_hash_find(ctx->tags, ctx->tag.c, ctx->tag.len, (void **) &ctx->lookup_data) == SUCCESS)
+ if ((ctx->lookup_data = zend_hash_str_find_ptr(ctx->tags, ctx->tag.c, ctx->tag.len)) != NULL)
ok = 1;
STATE = ok ? STATE_NEXT_ARG : STATE_PLAIN;
}
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 930edd6877..c289aa178e 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -32,20 +32,20 @@
#include "basic_functions.h"
#include "php_incomplete_class.h"
-#define COMMON (Z_ISREF_PP(struc) ? "&" : "")
+#define COMMON (Z_ISREF_P(struc) ? "&" : "")
/* }}} */
-static int php_array_element_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
+static int php_array_element_dump(zval *zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
{
int level;
level = va_arg(args, int);
- if (hash_key->nKeyLength == 0) { /* numeric key */
+ if (hash_key->key == NULL) { /* numeric key */
php_printf("%*c[%ld]=>\n", level + 1, ' ', hash_key->h);
} else { /* string key */
php_printf("%*c[\"", level + 1, ' ');
- PHPWRITE(hash_key->arKey, hash_key->nKeyLength - 1);
+ PHPWRITE(hash_key->key->val, hash_key->key->len);
php_printf("\"]=>\n");
}
php_var_dump(zv, level + 2 TSRMLS_CC);
@@ -53,17 +53,17 @@ static int php_array_element_dump(zval **zv TSRMLS_DC, int num_args, va_list arg
}
/* }}} */
-static int php_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
+static int php_object_property_dump(zval *zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
{
int level;
const char *prop_name, *class_name;
level = va_arg(args, int);
- if (hash_key->nKeyLength == 0) { /* numeric key */
+ if (hash_key->key == NULL) { /* numeric key */
php_printf("%*c[%ld]=>\n", level + 1, ' ', hash_key->h);
} else { /* string key */
- int unmangle = zend_unmangle_property_name(hash_key->arKey, hash_key->nKeyLength - 1, &class_name, &prop_name);
+ int unmangle = zend_unmangle_property_name(hash_key->key->val, hash_key->key->len, &class_name, &prop_name);
php_printf("%*c[", level + 1, ' ');
if (class_name && unmangle == SUCCESS) {
@@ -74,7 +74,7 @@ static int php_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list a
}
} else {
php_printf("\"");
- PHPWRITE(hash_key->arKey, hash_key->nKeyLength - 1);
+ PHPWRITE(hash_key->key->val, hash_key->key->len);
php_printf("\"");
}
ZEND_PUTS("]=>\n");
@@ -84,38 +84,37 @@ static int php_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list a
}
/* }}} */
-PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC) /* {{{ */
+PHPAPI void php_var_dump(zval *struc, int level TSRMLS_DC) /* {{{ */
{
HashTable *myht;
- const char *class_name;
- zend_uint class_name_len;
- int (*php_element_dump_func)(zval** TSRMLS_DC, int, va_list, zend_hash_key*);
+ zend_string *class_name;
+ int (*php_element_dump_func)(zval* TSRMLS_DC, int, va_list, zend_hash_key*);
int is_temp;
if (level > 1) {
php_printf("%*c", level - 1, ' ');
}
- switch (Z_TYPE_PP(struc)) {
+ switch (Z_TYPE_P(struc)) {
case IS_BOOL:
- php_printf("%sbool(%s)\n", COMMON, Z_LVAL_PP(struc) ? "true" : "false");
+ php_printf("%sbool(%s)\n", COMMON, Z_LVAL_P(struc) ? "true" : "false");
break;
case IS_NULL:
php_printf("%sNULL\n", COMMON);
break;
case IS_LONG:
- php_printf("%sint(%ld)\n", COMMON, Z_LVAL_PP(struc));
+ php_printf("%sint(%ld)\n", COMMON, Z_LVAL_P(struc));
break;
case IS_DOUBLE:
- php_printf("%sfloat(%.*G)\n", COMMON, (int) EG(precision), Z_DVAL_PP(struc));
+ php_printf("%sfloat(%.*G)\n", COMMON, (int) EG(precision), Z_DVAL_P(struc));
break;
case IS_STRING:
- php_printf("%sstring(%d) \"", COMMON, Z_STRLEN_PP(struc));
- PHPWRITE(Z_STRVAL_PP(struc), Z_STRLEN_PP(struc));
+ php_printf("%sstring(%d) \"", COMMON, Z_STRLEN_P(struc));
+ PHPWRITE(Z_STRVAL_P(struc), Z_STRLEN_P(struc));
PUTS("\"\n");
break;
case IS_ARRAY:
- myht = Z_ARRVAL_PP(struc);
+ myht = Z_ARRVAL_P(struc);
if (++myht->nApplyCount > 1) {
PUTS("*RECURSION*\n");
--myht->nApplyCount;
@@ -126,19 +125,19 @@ PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC) /* {{{ */
is_temp = 0;
goto head_done;
case IS_OBJECT:
- myht = Z_OBJDEBUG_PP(struc, is_temp);
+ myht = Z_OBJDEBUG_P(struc, is_temp);
if (myht && ++myht->nApplyCount > 1) {
PUTS("*RECURSION*\n");
--myht->nApplyCount;
return;
}
- if (Z_OBJ_HANDLER(**struc, get_class_name)) {
- Z_OBJ_HANDLER(**struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC);
- php_printf("%sobject(%s)#%d (%d) {\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0);
- efree((char*)class_name);
+ if (Z_OBJ_HANDLER_P(struc, get_class_name)) {
+ class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(struc, 0 TSRMLS_CC);
+ php_printf("%sobject(%s)#%d (%d) {\n", COMMON, class_name->val, Z_OBJ_HANDLE_P(struc), myht ? zend_hash_num_elements(myht) : 0);
+ STR_RELEASE(class_name);
} else {
- php_printf("%sobject(unknown class)#%d (%d) {\n", COMMON, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0);
+ php_printf("%sobject(unknown class)#%d (%d) {\n", COMMON, Z_OBJ_HANDLE_P(struc), myht ? zend_hash_num_elements(myht) : 0);
}
php_element_dump_func = php_object_property_dump;
head_done:
@@ -156,8 +155,8 @@ head_done:
PUTS("}\n");
break;
case IS_RESOURCE: {
- const char *type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC);
- php_printf("%sresource(%ld) of type (%s)\n", COMMON, Z_LVAL_PP(struc), type_name ? type_name : "Unknown");
+ const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(struc) TSRMLS_CC);
+ php_printf("%sresource(%ld) of type (%s)\n", COMMON, Z_RES_P(struc)->handle, type_name ? type_name : "Unknown");
break;
}
default:
@@ -171,7 +170,7 @@ head_done:
Dumps a string representation of variable to output */
PHP_FUNCTION(var_dump)
{
- zval ***args;
+ zval *args;
int argc;
int i;
@@ -180,29 +179,29 @@ PHP_FUNCTION(var_dump)
}
for (i = 0; i < argc; i++) {
- php_var_dump(args[i], 1 TSRMLS_CC);
+ php_var_dump(&args[i], 1 TSRMLS_CC);
}
efree(args);
}
/* }}} */
-static int zval_array_element_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
+static int zval_array_element_dump(zval *zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
{
int level;
level = va_arg(args, int);
- if (hash_key->nKeyLength == 0) { /* numeric key */
+ if (hash_key->key == NULL) { /* numeric key */
php_printf("%*c[%ld]=>\n", level + 1, ' ', hash_key->h);
} else { /* string key */
/* XXX: perphaps when we are inside the class we should permit access to
* private & protected values
*/
- if (va_arg(args, int) && hash_key->arKey[0] == '\0') {
+ if (va_arg(args, int) && hash_key->key->val[0] == '\0') {
return 0;
}
php_printf("%*c[\"", level + 1, ' ');
- PHPWRITE(hash_key->arKey, hash_key->nKeyLength - 1);
+ PHPWRITE(hash_key->key->val, hash_key->key->len);
php_printf("\"]=>\n");
}
php_debug_zval_dump(zv, level + 2 TSRMLS_CC);
@@ -210,17 +209,17 @@ static int zval_array_element_dump(zval **zv TSRMLS_DC, int num_args, va_list ar
}
/* }}} */
-static int zval_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
+static int zval_object_property_dump(zval *zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
{
int level;
const char *prop_name, *class_name;
level = va_arg(args, int);
- if (hash_key->nKeyLength == 0) { /* numeric key */
+ if (hash_key->key == NULL) { /* numeric key */
php_printf("%*c[%ld]=>\n", level + 1, ' ', hash_key->h);
} else { /* string key */
- zend_unmangle_property_name(hash_key->arKey, hash_key->nKeyLength - 1, &class_name, &prop_name);
+ zend_unmangle_property_name(hash_key->key->val, hash_key->key->len, &class_name, &prop_name);
php_printf("%*c[", level + 1, ' ');
if (class_name) {
@@ -239,58 +238,57 @@ static int zval_object_property_dump(zval **zv TSRMLS_DC, int num_args, va_list
}
/* }}} */
-PHPAPI void php_debug_zval_dump(zval **struc, int level TSRMLS_DC) /* {{{ */
+PHPAPI void php_debug_zval_dump(zval *struc, int level TSRMLS_DC) /* {{{ */
{
HashTable *myht = NULL;
- const char *class_name;
- zend_uint class_name_len;
- int (*zval_element_dump_func)(zval** TSRMLS_DC, int, va_list, zend_hash_key*);
+ zend_string *class_name;
+ int (*zval_element_dump_func)(zval* TSRMLS_DC, int, va_list, zend_hash_key*);
int is_temp = 0;
if (level > 1) {
php_printf("%*c", level - 1, ' ');
}
- switch (Z_TYPE_PP(struc)) {
+ switch (Z_TYPE_P(struc)) {
case IS_BOOL:
- php_printf("%sbool(%s) refcount(%u)\n", COMMON, Z_LVAL_PP(struc)?"true":"false", Z_REFCOUNT_PP(struc));
+ php_printf("%sbool(%s) refcount(%u)\n", COMMON, Z_LVAL_P(struc)?"true":"false", Z_REFCOUNT_P(struc));
break;
case IS_NULL:
- php_printf("%sNULL refcount(%u)\n", COMMON, Z_REFCOUNT_PP(struc));
+ php_printf("%sNULL refcount(%u)\n", COMMON, Z_REFCOUNT_P(struc));
break;
case IS_LONG:
- php_printf("%slong(%ld) refcount(%u)\n", COMMON, Z_LVAL_PP(struc), Z_REFCOUNT_PP(struc));
+ php_printf("%slong(%ld) refcount(%u)\n", COMMON, Z_LVAL_P(struc), Z_REFCOUNT_P(struc));
break;
case IS_DOUBLE:
- php_printf("%sdouble(%.*G) refcount(%u)\n", COMMON, (int) EG(precision), Z_DVAL_PP(struc), Z_REFCOUNT_PP(struc));
+ php_printf("%sdouble(%.*G) refcount(%u)\n", COMMON, (int) EG(precision), Z_DVAL_P(struc), Z_REFCOUNT_P(struc));
break;
case IS_STRING:
- php_printf("%sstring(%d) \"", COMMON, Z_STRLEN_PP(struc));
- PHPWRITE(Z_STRVAL_PP(struc), Z_STRLEN_PP(struc));
- php_printf("\" refcount(%u)\n", Z_REFCOUNT_PP(struc));
+ php_printf("%sstring(%d) \"", COMMON, Z_STRLEN_P(struc));
+ PHPWRITE(Z_STRVAL_P(struc), Z_STRLEN_P(struc));
+ php_printf("\" refcount(%u)\n", Z_REFCOUNT_P(struc));
break;
case IS_ARRAY:
- myht = Z_ARRVAL_PP(struc);
+ myht = Z_ARRVAL_P(struc);
if (myht->nApplyCount > 1) {
PUTS("*RECURSION*\n");
return;
}
- php_printf("%sarray(%d) refcount(%u){\n", COMMON, zend_hash_num_elements(myht), Z_REFCOUNT_PP(struc));
+ php_printf("%sarray(%d) refcount(%u){\n", COMMON, zend_hash_num_elements(myht), Z_REFCOUNT_P(struc));
zval_element_dump_func = zval_array_element_dump;
goto head_done;
case IS_OBJECT:
- myht = Z_OBJDEBUG_PP(struc, is_temp);
+ myht = Z_OBJDEBUG_P(struc, is_temp);
if (myht && myht->nApplyCount > 1) {
PUTS("*RECURSION*\n");
return;
}
- Z_OBJ_HANDLER_PP(struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC);
- php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0, Z_REFCOUNT_PP(struc));
- efree((char*)class_name);
+ class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(struc, 0 TSRMLS_CC);
+ php_printf("%sobject(%s)#%d (%d) refcount(%u){\n", COMMON, class_name->val, Z_OBJ_HANDLE_P(struc), myht ? zend_hash_num_elements(myht) : 0, Z_REFCOUNT_P(struc));
+ STR_RELEASE(class_name);
zval_element_dump_func = zval_object_property_dump;
head_done:
if (myht) {
- zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) zval_element_dump_func, 1, level, (Z_TYPE_PP(struc) == IS_ARRAY ? 0 : 1));
+ zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) zval_element_dump_func, 1, level, (Z_TYPE_P(struc) == IS_ARRAY ? 0 : 1));
if (is_temp) {
zend_hash_destroy(myht);
efree(myht);
@@ -302,8 +300,8 @@ head_done:
PUTS("}\n");
break;
case IS_RESOURCE: {
- const char *type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC);
- php_printf("%sresource(%ld) of type (%s) refcount(%u)\n", COMMON, Z_LVAL_PP(struc), type_name ? type_name : "Unknown", Z_REFCOUNT_PP(struc));
+ const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(struc) TSRMLS_CC);
+ php_printf("%sresource(%ld) of type (%s) refcount(%u)\n", COMMON, Z_RES_P(struc)->handle, type_name ? type_name : "Unknown", Z_REFCOUNT_P(struc));
break;
}
default:
@@ -317,7 +315,7 @@ head_done:
Dumps a string representation of an internal zend value to output. */
PHP_FUNCTION(debug_zval_dump)
{
- zval ***args;
+ zval *args;
int argc;
int i;
@@ -326,7 +324,7 @@ PHP_FUNCTION(debug_zval_dump)
}
for (i = 0; i < argc; i++) {
- php_debug_zval_dump(args[i], 1 TSRMLS_CC);
+ php_debug_zval_dump(&args[i], 1 TSRMLS_CC);
}
efree(args);
}
@@ -341,7 +339,7 @@ PHP_FUNCTION(debug_zval_dump)
efree(tmp_spaces); \
} while(0);
-static int php_array_element_export(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
+static int php_array_element_export(zval *zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
{
int level;
smart_str *buf;
@@ -349,7 +347,7 @@ static int php_array_element_export(zval **zv TSRMLS_DC, int num_args, va_list a
level = va_arg(args, int);
buf = va_arg(args, smart_str *);
- if (hash_key->nKeyLength == 0) { /* numeric key */
+ if (hash_key->key == NULL) { /* numeric key */
buffer_append_spaces(buf, level+1);
smart_str_append_long(buf, (long) hash_key->h);
smart_str_appendl(buf, " => ", 4);
@@ -357,7 +355,7 @@ static int php_array_element_export(zval **zv TSRMLS_DC, int num_args, va_list a
} else { /* string key */
char *key, *tmp_str;
int key_len, tmp_len;
- key = php_addcslashes(hash_key->arKey, hash_key->nKeyLength - 1, &key_len, 0, "'\\", 2 TSRMLS_CC);
+ key = php_addcslashes(hash_key->key->val, hash_key->key->len, &key_len, 0, "'\\", 2 TSRMLS_CC);
tmp_str = php_str_to_str_ex(key, key_len, "\0", 1, "' . \"\\0\" . '", 12, &tmp_len, 0, NULL);
buffer_append_spaces(buf, level + 1);
@@ -378,7 +376,7 @@ static int php_array_element_export(zval **zv TSRMLS_DC, int num_args, va_list a
}
/* }}} */
-static int php_object_element_export(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
+static int php_object_element_export(zval *zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
{
int level;
smart_str *buf;
@@ -387,13 +385,13 @@ static int php_object_element_export(zval **zv TSRMLS_DC, int num_args, va_list
buf = va_arg(args, smart_str *);
buffer_append_spaces(buf, level + 2);
- if (hash_key->nKeyLength != 0) {
+ if (hash_key->key != NULL) {
const char *class_name; /* ignored, but must be passed to unmangle */
const char *pname;
char *pname_esc;
int pname_esc_len;
- zend_unmangle_property_name(hash_key->arKey, hash_key->nKeyLength - 1,
+ zend_unmangle_property_name(hash_key->key->val, hash_key->key->len,
&class_name, &pname);
pname_esc = php_addcslashes(pname, strlen(pname), &pname_esc_len, 0,
"'\\", 2 TSRMLS_CC);
@@ -413,17 +411,16 @@ static int php_object_element_export(zval **zv TSRMLS_DC, int num_args, va_list
}
/* }}} */
-PHPAPI void php_var_export_ex(zval **struc, int level, smart_str *buf TSRMLS_DC) /* {{{ */
+PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf TSRMLS_DC) /* {{{ */
{
HashTable *myht;
char *tmp_str, *tmp_str2;
int tmp_len, tmp_len2;
- const char *class_name;
- zend_uint class_name_len;
+ zend_string *class_name;
- switch (Z_TYPE_PP(struc)) {
+ switch (Z_TYPE_P(struc)) {
case IS_BOOL:
- if (Z_LVAL_PP(struc)) {
+ if (Z_LVAL_P(struc)) {
smart_str_appendl(buf, "true", 4);
} else {
smart_str_appendl(buf, "false", 5);
@@ -433,15 +430,15 @@ PHPAPI void php_var_export_ex(zval **struc, int level, smart_str *buf TSRMLS_DC)
smart_str_appendl(buf, "NULL", 4);
break;
case IS_LONG:
- smart_str_append_long(buf, Z_LVAL_PP(struc));
+ smart_str_append_long(buf, Z_LVAL_P(struc));
break;
case IS_DOUBLE:
- tmp_len = spprintf(&tmp_str, 0,"%.*H", PG(serialize_precision), Z_DVAL_PP(struc));
+ tmp_len = spprintf(&tmp_str, 0,"%.*H", PG(serialize_precision), Z_DVAL_P(struc));
smart_str_appendl(buf, tmp_str, tmp_len);
efree(tmp_str);
break;
case IS_STRING:
- tmp_str = php_addcslashes(Z_STRVAL_PP(struc), Z_STRLEN_PP(struc), &tmp_len, 0, "'\\", 2 TSRMLS_CC);
+ tmp_str = php_addcslashes(Z_STRVAL_P(struc), Z_STRLEN_P(struc), &tmp_len, 0, "'\\", 2 TSRMLS_CC);
tmp_str2 = php_str_to_str_ex(tmp_str, tmp_len, "\0", 1, "' . \"\\0\" . '", 12, &tmp_len2, 0, NULL);
smart_str_appendc(buf, '\'');
@@ -452,7 +449,7 @@ PHPAPI void php_var_export_ex(zval **struc, int level, smart_str *buf TSRMLS_DC)
efree(tmp_str);
break;
case IS_ARRAY:
- myht = Z_ARRVAL_PP(struc);
+ myht = Z_ARRVAL_P(struc);
if (myht->nApplyCount > 0){
smart_str_appendl(buf, "NULL", 4);
zend_error(E_WARNING, "var_export does not handle circular references");
@@ -473,7 +470,7 @@ PHPAPI void php_var_export_ex(zval **struc, int level, smart_str *buf TSRMLS_DC)
break;
case IS_OBJECT:
- myht = Z_OBJPROP_PP(struc);
+ myht = Z_OBJPROP_P(struc);
if(myht && myht->nApplyCount > 0){
smart_str_appendl(buf, "NULL", 4);
zend_error(E_WARNING, "var_export does not handle circular references");
@@ -483,12 +480,12 @@ PHPAPI void php_var_export_ex(zval **struc, int level, smart_str *buf TSRMLS_DC)
smart_str_appendc(buf, '\n');
buffer_append_spaces(buf, level - 1);
}
- Z_OBJ_HANDLER(**struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC);
+ class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(struc, 0 TSRMLS_CC);
- smart_str_appendl(buf, class_name, class_name_len);
+ smart_str_appendl(buf, class_name->val, class_name->len);
smart_str_appendl(buf, "::__set_state(array(\n", 21);
- efree((char*)class_name);
+ STR_RELEASE(class_name);
if (myht) {
zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) php_object_element_export, 1, level, buf);
}
@@ -506,7 +503,7 @@ PHPAPI void php_var_export_ex(zval **struc, int level, smart_str *buf TSRMLS_DC)
/* }}} */
/* FOR BC reasons, this will always perform and then print */
-PHPAPI void php_var_export(zval **struc, int level TSRMLS_DC) /* {{{ */
+PHPAPI void php_var_export(zval *struc, int level TSRMLS_DC) /* {{{ */
{
smart_str buf = {0};
php_var_export_ex(struc, level, &buf TSRMLS_CC);
@@ -529,11 +526,11 @@ PHP_FUNCTION(var_export)
return;
}
- php_var_export_ex(&var, 1, &buf TSRMLS_CC);
+ php_var_export_ex(var, 1, &buf TSRMLS_CC);
smart_str_0 (&buf);
if (return_output) {
- RETVAL_STRINGL(buf.c, buf.len, 1);
+ RETVAL_STRINGL(buf.c, buf.len);
} else {
PHPWRITE(buf.c, buf.len);
}
@@ -543,15 +540,15 @@ PHP_FUNCTION(var_export)
static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var_hash TSRMLS_DC);
-static inline int php_add_var_hash(HashTable *var_hash, zval *var, void *var_old TSRMLS_DC) /* {{{ */
+static inline int php_add_var_hash(HashTable *var_hash, zval *var, zval *var_old TSRMLS_DC) /* {{{ */
{
- ulong var_no;
+ zval var_no, *zv;
char id[32], *p;
register int len;
if ((Z_TYPE_P(var) == IS_OBJECT) && Z_OBJ_HT_P(var)->get_class_entry) {
p = smart_str_print_long(id + sizeof(id) - 1,
- (long) zend_objects_get_address(var TSRMLS_CC));
+ (long) Z_OBJ_P(var));
*(--p) = 'O';
len = id + sizeof(id) - 1 - p;
} else {
@@ -559,12 +556,13 @@ static inline int php_add_var_hash(HashTable *var_hash, zval *var, void *var_old
len = id + sizeof(id) - 1 - p;
}
- if (var_old && zend_hash_find(var_hash, p, len, var_old) == SUCCESS) {
+ if ((zv = zend_hash_str_find(var_hash, p, len)) != NULL) {
+ ZVAL_COPY_VALUE(var_old, zv);
if (!Z_ISREF_P(var)) {
/* we still need to bump up the counter, since non-refs will
* be counted separately by unserializer */
- var_no = -1;
- zend_hash_next_index_insert(var_hash, &var_no, sizeof(var_no), NULL);
+ ZVAL_LONG(&var_no, -1);
+ zend_hash_next_index_insert(var_hash, &var_no);
}
#if 0
fprintf(stderr, "- had var (%d): %lu\n", Z_TYPE_P(var), **(ulong**)var_old);
@@ -573,10 +571,10 @@ static inline int php_add_var_hash(HashTable *var_hash, zval *var, void *var_old
}
/* +1 because otherwise hash will think we are trying to store NULL pointer */
- var_no = zend_hash_num_elements(var_hash) + 1;
- zend_hash_add(var_hash, p, len, &var_no, sizeof(var_no), NULL);
+ ZVAL_LONG(&var_no, zend_hash_num_elements(var_hash) + 1);
+ zend_hash_str_add(var_hash, p, len, &var_no);
#if 0
- fprintf(stderr, "+ add var (%d): %lu\n", Z_TYPE_P(var), var_no);
+ fprintf(stderr, "+ add var (%d): %lu\n", Z_TYPE_P(var), Z_LVAL(var_no));
#endif
return SUCCESS;
}
@@ -606,9 +604,9 @@ static inline zend_bool php_var_serialize_class_name(smart_str *buf, zval *struc
PHP_SET_CLASS_ATTRIBUTES(struc);
smart_str_appendl(buf, "O:", 2);
- smart_str_append_long(buf, (int)name_len);
+ smart_str_append_long(buf, (int)class_name->len);
smart_str_appendl(buf, ":\"", 2);
- smart_str_appendl(buf, class_name, name_len);
+ smart_str_appendl(buf, class_name->val, class_name->len);
smart_str_appendl(buf, "\":", 2);
PHP_CLEANUP_CLASS_ATTRIBUTES();
return incomplete_class;
@@ -631,8 +629,8 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt
smart_str_appendl(buf, ":{", 2);
if (count > 0) {
- char *key;
- zval **d, **name;
+ zend_string *key;
+ zval *d, *name;
ulong index;
HashPosition pos;
int i;
@@ -645,18 +643,18 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt
zend_hash_internal_pointer_reset_ex(HASH_OF(retval_ptr), &pos);
for (;; zend_hash_move_forward_ex(HASH_OF(retval_ptr), &pos)) {
- i = zend_hash_get_current_key_ex(HASH_OF(retval_ptr), &key, NULL, &index, 0, &pos);
+ i = zend_hash_get_current_key_ex(HASH_OF(retval_ptr), &key, &index, 0, &pos);
if (i == HASH_KEY_NON_EXISTENT) {
break;
}
- if (incomplete_class && strcmp(key, MAGIC_MEMBER) == 0) {
+ if (incomplete_class && strcmp(key->val, MAGIC_MEMBER) == 0) {
continue;
}
- zend_hash_get_current_data_ex(HASH_OF(retval_ptr), (void **) &name, &pos);
+ name = zend_hash_get_current_data_ex(HASH_OF(retval_ptr), &pos);
- if (Z_TYPE_PP(name) != IS_STRING) {
+ if (Z_TYPE_P(name) != IS_STRING) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "__sleep should return an array only containing the names of instance-variables to serialize.");
/* we should still add element even if it's not OK,
* since we already wrote the length of the array before */
@@ -664,9 +662,9 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt
continue;
}
propers = Z_OBJPROP_P(struc);
- if (zend_hash_find(propers, Z_STRVAL_PP(name), Z_STRLEN_PP(name) + 1, (void *) &d) == SUCCESS) {
- php_var_serialize_string(buf, Z_STRVAL_PP(name), Z_STRLEN_PP(name));
- php_var_serialize_intern(buf, *d, var_hash TSRMLS_CC);
+ if ((d = zend_hash_find(propers, Z_STR_P(name))) != NULL) {
+ php_var_serialize_string(buf, Z_STRVAL_P(name), Z_STRLEN_P(name));
+ php_var_serialize_intern(buf, d, var_hash TSRMLS_CC);
} else {
zend_class_entry *ce;
ce = zend_get_class_entry(struc TSRMLS_CC);
@@ -675,28 +673,28 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt
int prop_name_length;
do {
- zend_mangle_property_name(&priv_name, &prop_name_length, ce->name, ce->name_length, Z_STRVAL_PP(name), Z_STRLEN_PP(name), ce->type & ZEND_INTERNAL_CLASS);
- if (zend_hash_find(propers, priv_name, prop_name_length + 1, (void *) &d) == SUCCESS) {
+ zend_mangle_property_name(&priv_name, &prop_name_length, ce->name->val, ce->name->len, Z_STRVAL_P(name), Z_STRLEN_P(name), ce->type & ZEND_INTERNAL_CLASS);
+ if ((d = zend_hash_str_find(propers, priv_name, prop_name_length)) != NULL) {
php_var_serialize_string(buf, priv_name, prop_name_length);
pefree(priv_name, ce->type & ZEND_INTERNAL_CLASS);
- php_var_serialize_intern(buf, *d, var_hash TSRMLS_CC);
+ php_var_serialize_intern(buf, d, var_hash TSRMLS_CC);
break;
}
pefree(priv_name, ce->type & ZEND_INTERNAL_CLASS);
- zend_mangle_property_name(&prot_name, &prop_name_length, "*", 1, Z_STRVAL_PP(name), Z_STRLEN_PP(name), ce->type & ZEND_INTERNAL_CLASS);
- if (zend_hash_find(propers, prot_name, prop_name_length + 1, (void *) &d) == SUCCESS) {
+ zend_mangle_property_name(&prot_name, &prop_name_length, "*", 1, Z_STRVAL_P(name), Z_STRLEN_P(name), ce->type & ZEND_INTERNAL_CLASS);
+ if ((d = zend_hash_str_find(propers, prot_name, prop_name_length)) != NULL) {
php_var_serialize_string(buf, prot_name, prop_name_length);
pefree(prot_name, ce->type & ZEND_INTERNAL_CLASS);
- php_var_serialize_intern(buf, *d, var_hash TSRMLS_CC);
+ php_var_serialize_intern(buf, d, var_hash TSRMLS_CC);
break;
}
pefree(prot_name, ce->type & ZEND_INTERNAL_CLASS);
- php_var_serialize_string(buf, Z_STRVAL_PP(name), Z_STRLEN_PP(name));
+ php_var_serialize_string(buf, Z_STRVAL_P(name), Z_STRLEN_P(name));
php_var_serialize_intern(buf, nvalp, var_hash TSRMLS_CC);
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "\"%s\" returned as member variable from __sleep() but does not exist", Z_STRVAL_PP(name));
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "\"%s\" returned as member variable from __sleep() but does not exist", Z_STRVAL_P(name));
} while (0);
} else {
- php_var_serialize_string(buf, Z_STRVAL_PP(name), Z_STRLEN_PP(name));
+ php_var_serialize_string(buf, Z_STRVAL_P(name), Z_STRLEN_P(name));
php_var_serialize_intern(buf, nvalp, var_hash TSRMLS_CC);
}
}
@@ -709,22 +707,23 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt
static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var_hash TSRMLS_DC) /* {{{ */
{
int i;
- ulong *var_already;
+ zval var_already;
HashTable *myht;
if (EG(exception)) {
return;
}
- if (var_hash && php_add_var_hash(var_hash, struc, (void *) &var_already TSRMLS_CC) == FAILURE) {
+ ZVAL_UNDEF(&var_already);
+ if (var_hash && php_add_var_hash(var_hash, struc, &var_already TSRMLS_CC) == FAILURE) {
if (Z_ISREF_P(struc)) {
smart_str_appendl(buf, "R:", 2);
- smart_str_append_long(buf, (long)*var_already);
+ smart_str_append_long(buf, Z_LVAL(var_already));
smart_str_appendc(buf, ';');
return;
} else if (Z_TYPE_P(struc) == IS_OBJECT) {
smart_str_appendl(buf, "r:", 2);
- smart_str_append_long(buf, (long)*var_already);
+ smart_str_append_long(buf, Z_LVAL(var_already));
smart_str_appendc(buf, ';');
return;
}
@@ -762,7 +761,7 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var
return;
case IS_OBJECT: {
- zval *retval_ptr = NULL;
+ zval retval;
zval fname;
int res;
zend_class_entry *ce = NULL;
@@ -778,9 +777,9 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var
if (ce->serialize(struc, &serialized_data, &serialized_length, (zend_serialize_data *)var_hash TSRMLS_CC) == SUCCESS) {
smart_str_appendl(buf, "C:", 2);
- smart_str_append_long(buf, (int)Z_OBJCE_P(struc)->name_length);
+ smart_str_append_long(buf, (int)Z_OBJCE_P(struc)->name->len);
smart_str_appendl(buf, ":\"", 2);
- smart_str_appendl(buf, Z_OBJCE_P(struc)->name, Z_OBJCE_P(struc)->name_length);
+ smart_str_appendl(buf, Z_OBJCE_P(struc)->name->val, Z_OBJCE_P(struc)->name->len);
smart_str_appendl(buf, "\":", 2);
smart_str_append_long(buf, (int)serialized_length);
@@ -796,39 +795,35 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var
return;
}
- if (ce && ce != PHP_IC_ENTRY && zend_hash_exists(&ce->function_table, "__sleep", sizeof("__sleep"))) {
- INIT_PZVAL(&fname);
- ZVAL_STRINGL(&fname, "__sleep", sizeof("__sleep") - 1, 0);
+ if (ce && ce != PHP_IC_ENTRY && zend_hash_str_exists(&ce->function_table, "__sleep", sizeof("__sleep")-1)) {
+//??? ZVAL_STRINGL(&fname, "__sleep", sizeof("__sleep") - 1, 0);
+ ZVAL_STRINGL(&fname, "__sleep", sizeof("__sleep") - 1);
BG(serialize_lock)++;
- res = call_user_function_ex(CG(function_table), &struc, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC);
+ res = call_user_function_ex(CG(function_table), struc, &fname, &retval, 0, 0, 1, NULL TSRMLS_CC);
BG(serialize_lock)--;
if (EG(exception)) {
- if (retval_ptr) {
- zval_ptr_dtor(&retval_ptr);
- }
+ zval_ptr_dtor(&retval);
return;
}
if (res == SUCCESS) {
- if (retval_ptr) {
- if (HASH_OF(retval_ptr)) {
- php_var_serialize_class(buf, struc, retval_ptr, var_hash TSRMLS_CC);
+ if (Z_TYPE(retval) != IS_UNDEF) {
+ if (HASH_OF(&retval)) {
+ php_var_serialize_class(buf, struc, &retval, var_hash TSRMLS_CC);
} else {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "__sleep should return an array only containing the names of instance-variables to serialize");
/* we should still add element even if it's not OK,
* since we already wrote the length of the array before */
smart_str_appendl(buf,"N;", 2);
}
- zval_ptr_dtor(&retval_ptr);
+ zval_ptr_dtor(&retval);
}
return;
}
}
- if (retval_ptr) {
- zval_ptr_dtor(&retval_ptr);
- }
+ zval_ptr_dtor(&retval);
/* fall-through */
}
case IS_ARRAY: {
@@ -849,19 +844,18 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var
smart_str_append_long(buf, i);
smart_str_appendl(buf, ":{", 2);
if (i > 0) {
- char *key;
- zval **data;
+ zend_string *key;
+ zval *data;
ulong index;
- uint key_len;
HashPosition pos;
zend_hash_internal_pointer_reset_ex(myht, &pos);
for (;; zend_hash_move_forward_ex(myht, &pos)) {
- i = zend_hash_get_current_key_ex(myht, &key, &key_len, &index, 0, &pos);
+ i = zend_hash_get_current_key_ex(myht, &key, &index, 0, &pos);
if (i == HASH_KEY_NON_EXISTENT) {
break;
}
- if (incomplete_class && strcmp(key, MAGIC_MEMBER) == 0) {
+ if (incomplete_class && strcmp(key->val, MAGIC_MEMBER) == 0) {
continue;
}
@@ -870,25 +864,24 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var
php_var_serialize_long(buf, index);
break;
case HASH_KEY_IS_STRING:
- php_var_serialize_string(buf, key, key_len - 1);
+ php_var_serialize_string(buf, key->val, key->len);
break;
}
/* we should still add element even if it's not OK,
* since we already wrote the length of the array before */
- if (zend_hash_get_current_data_ex(myht, (void **) &data, &pos) != SUCCESS
- || !data
- || data == &struc
- || (Z_TYPE_PP(data) == IS_ARRAY && Z_ARRVAL_PP(data)->nApplyCount > 1)
+ if ((data = zend_hash_get_current_data_ex(myht, &pos)) == NULL
+ || Z_ARR_P(data) == Z_ARR_P(struc)
+ || (Z_TYPE_P(data) == IS_ARRAY && Z_ARRVAL_P(data)->nApplyCount > 1)
) {
smart_str_appendl(buf, "N;", 2);
} else {
- if (Z_TYPE_PP(data) == IS_ARRAY) {
- Z_ARRVAL_PP(data)->nApplyCount++;
+ if (Z_TYPE_P(data) == IS_ARRAY) {
+ Z_ARRVAL_P(data)->nApplyCount++;
}
- php_var_serialize_intern(buf, *data, var_hash TSRMLS_CC);
- if (Z_TYPE_PP(data) == IS_ARRAY) {
- Z_ARRVAL_PP(data)->nApplyCount--;
+ php_var_serialize_intern(buf, data, var_hash TSRMLS_CC);
+ if (Z_TYPE_P(data) == IS_ARRAY) {
+ Z_ARRVAL_P(data)->nApplyCount--;
}
}
}
@@ -922,10 +915,6 @@ PHP_FUNCTION(serialize)
return;
}
- Z_TYPE_P(return_value) = IS_STRING;
- Z_STRVAL_P(return_value) = NULL;
- Z_STRLEN_P(return_value) = 0;
-
PHP_VAR_SERIALIZE_INIT(var_hash);
php_var_serialize(&buf, struc, &var_hash TSRMLS_CC);
PHP_VAR_SERIALIZE_DESTROY(var_hash);
@@ -936,7 +925,8 @@ PHP_FUNCTION(serialize)
}
if (buf.c) {
- RETURN_STRINGL(buf.c, buf.len, 0);
+//??? RETURN_STRINGL(buf.c, buf.len, 0);
+ RETURN_STRINGL(buf.c, buf.len);
} else {
RETURN_NULL();
}
diff --git a/main/main.c b/main/main.c
index 12587d9162..2d12c2060b 100644
--- a/main/main.c
+++ b/main/main.c
@@ -699,6 +699,7 @@ PHPAPI int php_printf(const char *format, ...)
*/
PHPAPI void php_verror(const char *docref, const char *params, int type, const char *format, va_list args TSRMLS_DC)
{
+ zend_string *replace_buffer = NULL, *replace_origin = NULL;
char *buffer = NULL, *docref_buf = NULL, *target = NULL;
char *docref_target = "", *docref_root = "";
char *p;
@@ -715,11 +716,10 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
buffer_len = vspprintf(&buffer, 0, format, args);
if (PG(html_errors)) {
- size_t len;
- char *replace = php_escape_html_entities(buffer, buffer_len, &len, 0, ENT_COMPAT, NULL TSRMLS_CC);
+ replace_buffer = php_escape_html_entities(buffer, buffer_len, 0, ENT_COMPAT, NULL TSRMLS_CC);
efree(buffer);
- buffer = replace;
- buffer_len = len;
+ buffer = replace_buffer->val;
+ buffer_len = replace_buffer->len;
}
/* which function caused the problem if any at all */
@@ -773,10 +773,9 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
}
if (PG(html_errors)) {
- size_t len;
- char *replace = php_escape_html_entities(origin, origin_len, &len, 0, ENT_COMPAT, NULL TSRMLS_CC);
+ replace_origin = php_escape_html_entities(origin, origin_len, 0, ENT_COMPAT, NULL TSRMLS_CC);
efree(origin);
- origin = replace;
+ origin = replace_origin->val;
}
/* origin and buffer available, so lets come up with the error message */
@@ -847,7 +846,11 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
} else {
spprintf(&message, 0, "%s: %s", origin, buffer);
}
- efree(origin);
+ if (replace_origin) {
+ STR_FREE(replace_origin);
+ } else {
+ efree(origin);
+ }
if (docref_buf) {
efree(docref_buf);
}
@@ -863,7 +866,11 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
zend_hash_str_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg")-1, &tmp);
}
}
- efree(buffer);
+ if (replace_buffer) {
+ STR_FREE(replace_buffer);
+ } else {
+ efree(buffer);
+ }
php_error(type, "%s", message);
efree(message);
@@ -1082,10 +1089,9 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
if (PG(html_errors)) {
if (type == E_ERROR || type == E_PARSE) {
- size_t len;
- char *buf = php_escape_html_entities(buffer, buffer_len, &len, 0, ENT_COMPAT, NULL TSRMLS_CC);
+ zend_string *buf = php_escape_html_entities(buffer, buffer_len, 0, ENT_COMPAT, NULL TSRMLS_CC);
php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buf, error_filename, error_lineno, STR_PRINT(append_string));
- efree(buf);
+ STR_FREE(buf);
} else {
php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string));
}
diff --git a/main/php_streams.h b/main/php_streams.h
index f3e887fade..f434e6db75 100644
--- a/main/php_streams.h
+++ b/main/php_streams.h
@@ -249,10 +249,10 @@ END_EXTERN_C()
/* use this to assign the stream to a zval and tell the stream that is
* has been exported to the engine; it will expect to be closed automatically
* when the resources are auto-destructed */
-# define php_stream_to_zval(stream, zval) { ZVAL_RESOURCE(zval, (stream)->res); (stream)->__exposed++; }
+# define php_stream_to_zval(stream, zval) { ZVAL_RES(zval, (stream)->res); (stream)->__exposed++; }
#else
# define php_stream_auto_cleanup(stream) /* nothing */
-# define php_stream_to_zval(stream, zval) { ZVAL_RESOURCE(zval, (stream)->res); }
+# define php_stream_to_zval(stream, zval) { ZVAL_RES(zval, (stream)->res); }
#endif
#define php_stream_from_zval(xstr, ppzval) ZEND_FETCH_RESOURCE2((xstr), php_stream *, (ppzval), -1, "stream", php_file_le_stream(), php_file_le_pstream())
diff --git a/main/streams/php_stream_context.h b/main/streams/php_stream_context.h
index 2c0a33aab7..6740124f5a 100644
--- a/main/streams/php_stream_context.h
+++ b/main/streams/php_stream_context.h
@@ -33,7 +33,7 @@ typedef void (*php_stream_notification_func)(php_stream_context *context,
If no context was passed, use the default context
The default context has not yet been created, do it now. */
#define php_stream_context_from_zval(zcontext, nocontext) ( \
- (zcontext) ? zend_fetch_resource(&(zcontext) TSRMLS_CC, -1, "Stream-Context", NULL, 1, php_le_stream_context(TSRMLS_C)) : \
+ (zcontext) ? zend_fetch_resource(zcontext TSRMLS_CC, -1, "Stream-Context", NULL, 1, php_le_stream_context(TSRMLS_C)) : \
(nocontext) ? NULL : \
FG(default_context) ? FG(default_context) : \
(FG(default_context) = php_stream_context_alloc(TSRMLS_C)) )