[PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/general_functions bug47027.phpt
derick Wed Jan 7 14:35:50 2009 UTC Added files: /php-src/ext/standard/tests/general_functions bug47027.phpt Modified files: /php-src/ext/standard var.c Log: - Fixed bug #47027 (var_export doesn't show numeric indices on ArrayObject). http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.279r2=1.280diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.279 php-src/ext/standard/var.c:1.280 --- php-src/ext/standard/var.c:1.279Wed Dec 31 11:12:37 2008 +++ php-src/ext/standard/var.c Wed Jan 7 14:35:50 2009 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.279 2008/12/31 11:12:37 sebastian Exp $ */ +/* $Id: var.c,v 1.280 2009/01/07 14:35:50 derick Exp $ */ /* {{{ includes */ @@ -486,13 +486,15 @@ level = va_arg(args, int); + php_printf(%*c, level + 1, ' '); if (hash_key-nKeyLength != 0) { - php_printf(%*c, level + 1, ' '); zend_u_unmangle_property_name(hash_key-type, hash_key-arKey, hash_key-nKeyLength - 1, class_name, prop_name); php_printf( '%R' = , hash_key-type, prop_name); - php_var_export(zv, level + 2 TSRMLS_CC); - PUTS (,\n); + } else { + php_printf( %ld = , hash_key-h); } + php_var_export(zv, level + 2 TSRMLS_CC); + PUTS (,\n); return 0; } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/bug47027.phpt?view=markuprev=1.1 Index: php-src/ext/standard/tests/general_functions/bug47027.phpt +++ php-src/ext/standard/tests/general_functions/bug47027.phpt --TEST-- Bug #47027 (var_export doesn't show numeric indices on ArrayObject) --FILE-- ?php $ao = new ArrayObject(array (2 = foo, bar = baz)); var_export ($ao); ? --EXPECT-- ArrayObject::__set_state(array( 2 = 'foo', 'bar' = 'baz', )) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
felipe Fri Oct 24 10:27:54 2008 UTC Modified files: /php-src/ext/standard var.c Log: - Removed unnecessary check for array (#46273, noticed by serovov at gmail dot com) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.277r2=1.278diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.277 php-src/ext/standard/var.c:1.278 --- php-src/ext/standard/var.c:1.277Tue Aug 19 02:51:27 2008 +++ php-src/ext/standard/var.c Fri Oct 24 10:27:54 2008 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.277 2008/08/19 02:51:27 felipe Exp $ */ +/* $Id: var.c,v 1.278 2008/10/24 10:27:54 felipe Exp $ */ /* {{{ includes */ @@ -604,7 +604,7 @@ php_printf(\n%*c, level - 1, ' '); } PUTS (array (\n); - zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) php_array_element_export, 1, level, (Z_TYPE_PP(struc) == IS_ARRAY ? 0 : 1)); + zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) php_array_element_export, 1, level, 0); if (level 1) { php_printf(%*c, level - 1, ' '); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
janiSun Aug 3 12:03:03 2008 UTC Modified files: /php-src/ext/standard var.c Log: - Fix comment http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.275r2=1.276diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.275 php-src/ext/standard/var.c:1.276 --- php-src/ext/standard/var.c:1.275Thu Jul 24 19:50:23 2008 +++ php-src/ext/standard/var.c Sun Aug 3 12:03:02 2008 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.275 2008/07/24 19:50:23 felipe Exp $ */ +/* $Id: var.c,v 1.276 2008/08/03 12:03:02 jani Exp $ */ /* {{{ includes */ @@ -569,7 +569,7 @@ break; } } - if (state == 1) { // if we are in double quotes, go back to single */ + if (state == 1) { /* if we are in double quotes, go back to single */ PHPWRITE(\ . ', 5); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/array bug26458.phpt var_export2.phpt /ext/standard/tests/strings explode.phpt
derick Tue Dec 18 10:53:26 2007 UTC Modified files: /php-src/ext/standard var.c /php-src/ext/standard/tests/array bug26458.phpt var_export2.phpt /php-src/ext/standard/tests/strings explode.phpt Log: - Fixed var_export() for array keys - Fixed broken explode() test http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.272r2=1.273diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.272 php-src/ext/standard/var.c:1.273 --- php-src/ext/standard/var.c:1.272Sun Dec 9 16:54:30 2007 +++ php-src/ext/standard/var.c Tue Dec 18 10:53:25 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.272 2007/12/09 16:54:30 derick Exp $ */ +/* $Id: var.c,v 1.273 2007/12/18 10:53:25 derick Exp $ */ /* {{{ includes */ @@ -480,12 +480,13 @@ if (hash_key-type == IS_UNICODE) { php_var_dump_unicode(hash_key-arKey.u, hash_key-nKeyLength-1, 0, , 1 TSRMLS_CC); } else { - char *key; - int key_len; - + char *key, *tmp_str; + int key_len, tmp_len; key = php_addcslashes(hash_key-arKey.s, hash_key-nKeyLength - 1, key_len, 0, '\\, 2 TSRMLS_CC); - PHPWRITE(key, key_len); + tmp_str = php_str_to_str_ex(key, key_len, \0, 1, ' . \\\0\ . ', 12, tmp_len, 0, NULL); + PHPWRITE(tmp_str, tmp_len); efree(key); + efree(tmp_str); } php_printf(' = ); } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/bug26458.phpt?r1=1.2r2=1.3diff_format=u Index: php-src/ext/standard/tests/array/bug26458.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/var_export2.phpt?r1=1.2r2=1.3diff_format=u Index: php-src/ext/standard/tests/array/var_export2.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/explode.phpt?r1=1.7r2=1.8diff_format=u Index: php-src/ext/standard/tests/strings/explode.phpt diff -u php-src/ext/standard/tests/strings/explode.phpt:1.7 php-src/ext/standard/tests/strings/explode.phpt:1.8 --- php-src/ext/standard/tests/strings/explode.phpt:1.7 Tue Mar 6 20:45:15 2007 +++ php-src/ext/standard/tests/strings/explode.phpt Tue Dec 18 10:53:25 2007 @@ -6,6 +6,7 @@ ?php /* From http://bugs.php.net/19865 */ $s = (binary) var_export(explode(b\1, (binary)a. chr(1). b. chr(0). d . chr(1) . f . chr(1). 1 . chr(1) . d), TRUE); +echo $s; echo md5($s); echo \n; var_dump(@explode(, )); @@ -30,7 +31,13 @@ var_dump(explode(:^:,a lazy dog:^:jumps::over:^:,-2)); ? --EXPECTF-- -6e5d59d5afd6693547a733219d079658 +array ( + 0 = 'a', + 1 = 'b' . \0 . 'd', + 2 = 'f', + 3 = '1', + 4 = 'd', +)d6bee42a771449205344c0938ad4f035 bool(false) bool(false) bool(false) @@ -154,7 +161,13 @@ string(10) a lazy dog } --UEXPECTF-- -6e5d59d5afd6693547a733219d079658 +array ( + 0 = 'a', + 1 = 'b' . \0 . 'd', + 2 = 'f', + 3 = '1', + 4 = 'd', +)d6bee42a771449205344c0938ad4f035 bool(false) bool(false) bool(false) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/general_functions bug42272.phpt var_export-locale.phpt var_export.phpt /ext/standard/tests/strings bug37262.phpt
derick Sun Dec 9 16:54:30 2007 UTC Added files: /php-src/ext/standard/tests/general_functions bug42272.phpt Modified files: /php-src/ext/standard var.c /php-src/ext/standard/tests/general_functions var_export-locale.phpt var_export.phpt /php-src/ext/standard/tests/strings bug37262.phpt Log: - Fixed Bug #42272 (var_export() incorrectly escapes char(0)). - Also fixed var_export() in unicode mode, as the function would actually generate non-parsable strings which defeats the purpose of var_export(). http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.271r2=1.272diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.271 php-src/ext/standard/var.c:1.272 --- php-src/ext/standard/var.c:1.271Fri Nov 2 09:43:04 2007 +++ php-src/ext/standard/var.c Sun Dec 9 16:54:30 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.271 2007/11/02 09:43:04 jani Exp $ */ +/* $Id: var.c,v 1.272 2007/12/09 16:54:30 derick Exp $ */ /* {{{ includes */ @@ -520,6 +520,7 @@ int i = 0; char buf[10]; int buf_len; + int state = 0; /* 0 = in single quotes, 1 = in double quotes */ /* * We export all codepoints 128 in escaped form to avoid encoding issues @@ -529,10 +530,18 @@ U16_NEXT(ustr, i, ustr_len, cp); switch (cp) { case 0x0: /* '\0' */ - PHPWRITE(\\000, 4); + if (state == 0) { + PHPWRITE(' . \, 5); + state = 1; + } + PHPWRITE(\\0, 2); break; case 0x27: /* '\'' */ + if (state == 1) { + PHPWRITE(\ . ', 5); + state = 0; + } PHPWRITE(\\', 2); break; @@ -542,25 +551,40 @@ default: if ((uint32_t)cp 128) { + if (state == 1) { + PHPWRITE(\ . ', 5); + state = 0; + } buf[0] = (char) (short) cp; buf_len = 1; } else if (U_IS_BMP(cp)) { + if (state == 0) { + PHPWRITE(' . \, 5); + state = 1; + } buf_len = snprintf(buf, sizeof(buf), \\u%04X, cp); } else { + if (state == 0) { + PHPWRITE(' . \, 5); + state = 1; + } buf_len = snprintf(buf, sizeof(buf), \\u%06X, cp); } PHPWRITE(buf, buf_len); break; } } + if (state == 1) { // if we are in double quotes, go back to single */ + PHPWRITE(\ . ', 5); + } } /* }}} */ PHPAPI void php_var_export(zval **struc, int level TSRMLS_DC) /* {{{ */ { HashTable *myht; - char* tmp_str; - int tmp_len; + char *tmp_str, *tmp_str2; + int tmp_len, tmp_len2; zstr class_name; zend_uint class_name_len; @@ -578,11 +602,13 @@ php_printf(%.*H, (int) EG(precision), Z_DVAL_PP(struc)); break; case IS_STRING: - tmp_str = php_addcslashes(Z_STRVAL_PP(struc), Z_STRLEN_PP(struc), tmp_len, 0, '\\\0, 3 TSRMLS_CC); + tmp_str = php_addcslashes(Z_STRVAL_PP(struc), Z_STRLEN_PP(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); PUTS ('); - PHPWRITE(tmp_str, tmp_len); + PHPWRITE(tmp_str2, tmp_len2); PUTS ('); - efree (tmp_str); + efree(tmp_str2); + efree(tmp_str); break; case IS_UNICODE: PUTS (');
[PHP-CVS] cvs: php-src /ext/standard var.c
janiFri Nov 2 09:15:55 2007 UTC Modified files: /php-src/ext/standard var.c Log: ws http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.269r2=1.270diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.269 php-src/ext/standard/var.c:1.270 --- php-src/ext/standard/var.c:1.269Fri Nov 2 09:01:39 2007 +++ php-src/ext/standard/var.c Fri Nov 2 09:15:55 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.269 2007/11/02 09:01:39 jani Exp $ */ +/* $Id: var.c,v 1.270 2007/11/02 09:15:55 jani Exp $ */ /* {{{ includes */ @@ -59,7 +59,7 @@ ZEND_PUTS(quote); if (escape) { char *str; - int str_len; + int str_len; str = php_addcslashes(out, clen, str_len, 0, '\\, 2 TSRMLS_CC); PHPWRITE(str, str_len); @@ -305,8 +305,9 @@ * private protected values */ if (va_arg(args, int) - ((hash_key-type == IS_STRING hash_key-arKey.s[0] == 0) || -(hash_key-type == IS_UNICODE hash_key-arKey.u[0] == 0))) { + ((hash_key-type == IS_STRING hash_key-arKey.s[0] == 0) || + (hash_key-type == IS_UNICODE hash_key-arKey.u[0] == 0)) + ) { return 0; } php_printf(%*c[, level + 1, ' '); @@ -558,9 +559,9 @@ PHPAPI void php_var_export(zval **struc, int level TSRMLS_DC) /* {{{ */ { HashTable *myht; - char* tmp_str; - int tmp_len; - zstr class_name; + char* tmp_str; + int tmp_len; + zstr class_name; zend_uint class_name_len; switch (Z_TYPE_PP(struc)) { @@ -663,8 +664,8 @@ register int len; /* relies on (long) being a perfect hash function for data pointers, - however the actual identity of an object has had to be determined - by its object handle and the class entry since 5.0. */ +* however the actual identity of an object has had to be determined +* by its object handle and the class entry since 5.0. */ if ((Z_TYPE_P(var) == IS_OBJECT) Z_OBJ_HT_P(var)-get_class_entry) { p = smart_str_print_long(id + sizeof(id) - 1, (((size_t)Z_OBJCE_P(var) 5) @@ -680,7 +681,7 @@ if (var_old zend_hash_find(var_hash, p, len, var_old) == SUCCESS) { if (!Z_ISREF_P(var)) { /* we still need to bump up the counter, since non-refs will - be counted separately by unserializer */ +* be counted separately by unserializer */ var_no = -1; zend_hash_next_index_insert(var_hash, var_no, sizeof(var_no), NULL); } @@ -780,14 +781,14 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_ptr, HashTable *var_hash TSRMLS_DC) /* {{{ */ { int count; - zend_bool incomplete_class; + zend_bool incomplete_class; zstr star; star.s = *; incomplete_class = php_var_serialize_class_name(buf, struc TSRMLS_CC); /* count after serializing name, since php_var_serialize_class_name - changes the count if the variable is incomplete class */ +* changes the count if the variable is incomplete class */ count = zend_hash_num_elements(HASH_OF(retval_ptr)); if (incomplete_class) { --count; @@ -817,8 +818,8 @@ } if (incomplete_class - key_len == sizeof(MAGIC_MEMBER) - ZEND_U_EQUAL(i, key, key_len-1, MAGIC_MEMBER, sizeof(MAGIC_MEMBER)-1) + key_len == sizeof(MAGIC_MEMBER) + ZEND_U_EQUAL(i, key, key_len-1, MAGIC_MEMBER, sizeof(MAGIC_MEMBER)-1) ) { continue; } @@ -858,7 +859,7 @@ break; } efree(priv_name.v); - zend_u_mangle_property_name(prot_name, prop_name_length, Z_TYPE_PP(name), star, 1, Z_UNIVAL_PP(name), Z_UNILEN_PP(name), ce-type ZEND_INTERNAL_CLASS); + zend_u_mangle_property_name(prot_name, prop_name_length, Z_TYPE_PP(name), star, 1, Z_UNIVAL_PP(name), Z_UNILEN_PP(name), ce-type ZEND_INTERNAL_CLASS); if (zend_u_hash_find(Z_OBJPROP_P(struc), Z_TYPE_PP(name), prot_name, prop_name_length+1, (void *) d)
[PHP-CVS] cvs: php-src /ext/standard var.c
janiFri Nov 2 09:43:04 2007 UTC Modified files: /php-src/ext/standard var.c Log: more ws http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.270r2=1.271diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.270 php-src/ext/standard/var.c:1.271 --- php-src/ext/standard/var.c:1.270Fri Nov 2 09:15:55 2007 +++ php-src/ext/standard/var.c Fri Nov 2 09:43:04 2007 @@ -18,9 +18,9 @@ +--+ */ -/* $Id: var.c,v 1.270 2007/11/02 09:15:55 jani Exp $ */ +/* $Id: var.c,v 1.271 2007/11/02 09:43:04 jani Exp $ */ -/* {{{ includes +/* {{{ includes */ #include stdio.h #include stdlib.h @@ -252,18 +252,18 @@ zval ***args; int argc; int i; - + argc = ZEND_NUM_ARGS(); - + args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0); if (ZEND_NUM_ARGS() == 0 || zend_get_parameters_array_ex(argc, args) == FAILURE) { efree(args); WRONG_PARAM_COUNT; } - - for (i=0; iargc; i++) + + for (i = 0; i argc; i++) { php_var_dump(args[i], 1, 0 TSRMLS_CC); - + } efree(args); } /* }}} */ @@ -275,18 +275,18 @@ zval ***args; int argc; int i; - + argc = ZEND_NUM_ARGS(); - + args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0); if (ZEND_NUM_ARGS() == 0 || zend_get_parameters_array_ex(argc, args) == FAILURE) { efree(args); WRONG_PARAM_COUNT; } - - for (i=0; iargc; i++) + + for (i = 0; i argc; i++) { php_var_dump(args[i], 1, 1 TSRMLS_CC); - + } efree(args); } /* }}} */ @@ -301,13 +301,13 @@ if (hash_key-nKeyLength == 0) { /* 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 + /* XXX: perphaps when we are inside the class we should permit access to * private protected values */ - if (va_arg(args, int) + if (va_arg(args, int) ((hash_key-type == IS_STRING hash_key-arKey.s[0] == 0) || (hash_key-type == IS_UNICODE hash_key-arKey.u[0] == 0)) - ) { + ) { return 0; } php_printf(%*c[, level + 1, ' '); @@ -450,16 +450,16 @@ zval ***args; int argc; int i; - + argc = ZEND_NUM_ARGS(); - + args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0); if (ZEND_NUM_ARGS() == 0 || zend_get_parameters_array_ex(argc, args) == FAILURE) { efree(args); WRONG_PARAM_COUNT; } - - for (i = 0; iargc; i++) { + + for (i = 0; i argc; i++) { php_debug_zval_dump(args[i], 1, 1 TSRMLS_CC); } efree(args); @@ -473,7 +473,7 @@ level = va_arg(args, int); - if (hash_key-nKeyLength==0) { /* numeric key */ + if (hash_key-nKeyLength == 0) { /* numeric key */ php_printf(%*c%ld = , level + 1, ' ', hash_key-h); } else { /* string key */ php_printf(%*c', level + 1, ' '); @@ -622,7 +622,6 @@ break; } } - /* }}} */ /* {{{ proto mixed var_export(mixed var [, bool return]) U @@ -631,15 +630,15 @@ { zval *var; zend_bool return_output = 0; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, z|b, var, return_output) == FAILURE) { return; } - + if (return_output) { php_output_start_default(TSRMLS_C); } - + /* UTODO * We need to escape non-ASCII chars with \u format. php_var_export() * currently uses output_encoding to export Unicode strings. Suppose it's @@ -687,7 +686,7 @@ } return FAILURE; } - + /* +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); @@ -809,14 +808,14 @@ nvalp = nval; 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, key_len, index, 0, pos); - + if (i == HASH_KEY_NON_EXISTANT) { break; } -
[PHP-CVS] cvs: php-src /ext/standard var.c
janiFri Nov 2 09:01:39 2007 UTC Modified files: /php-src/ext/standard var.c Log: ws + cs + missing folding tags http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.268r2=1.269diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.268 php-src/ext/standard/var.c:1.269 --- php-src/ext/standard/var.c:1.268Sun Oct 7 05:15:06 2007 +++ php-src/ext/standard/var.c Fri Nov 2 09:01:39 2007 @@ -18,11 +18,10 @@ +--+ */ -/* $Id: var.c,v 1.268 2007/10/07 05:15:06 davidw Exp $ */ +/* $Id: var.c,v 1.269 2007/11/02 09:01:39 jani Exp $ */ /* {{{ includes */ - #include stdio.h #include stdlib.h #include errno.h @@ -34,7 +33,6 @@ #include php_incomplete_class.h #define COMMON (Z_ISREF_PP(struc) ? : ) - /* }}} */ static void php_var_dump_unicode(UChar *ustr, int length, int verbose, char *quote, int escape TSRMLS_DC) /* {{{ */ @@ -52,7 +50,7 @@ } zend_unicode_to_string_ex(ZEND_U_CONVERTER(UG(output_encoding_conv)), out, clen, ustr, length, status); - if(U_FAILURE(status)) { + if (U_FAILURE(status)) { php_printf(problem converting string from Unicode: %s\n, u_errorName(status)); efree(out); return; @@ -73,17 +71,17 @@ if (verbose) { ZEND_PUTS( {); /* output the code points (not code units) */ - if(length=0) { + if (length=0) { /* s is not NUL-terminated */ - for(i=0; ilength; /* U16_NEXT post-increments */) { + for (i = 0; i length; /* U16_NEXT post-increments */) { U16_NEXT(ustr, i, length, c); php_printf( %04x, c); } } else { /* s is NUL-terminated */ - for(i=0; /* condition in loop body */; /* U16_NEXT post-increments */) { + for (i = 0; /* condition in loop body */; /* U16_NEXT post-increments */) { U16_NEXT(ustr, i, length, c); - if(c==0) { + if (c == 0) { break; } php_printf( %04x, c); @@ -93,8 +91,9 @@ } efree(out); } +/* }}} */ -static int php_array_element_dump(zval **zv, int num_args, va_list args, zend_hash_key *hash_key) +static int php_array_element_dump(zval **zv, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { int level; int verbose; @@ -103,7 +102,7 @@ level = va_arg(args, int); verbose = va_arg(args, int); - if (hash_key-nKeyLength==0) { /* numeric key */ + if (hash_key-nKeyLength == 0) { /* numeric key */ php_printf(%*c[%ld]=\n, level + 1, ' ', hash_key-h); } else { /* string key */ php_printf(%*c[, level + 1, ' '); @@ -120,8 +119,9 @@ php_var_dump(zv, level + 2, verbose TSRMLS_CC); return 0; } +/* }}} */ -static int php_object_property_dump(zval **zv, int num_args, va_list args, zend_hash_key *hash_key) +static int php_object_property_dump(zval **zv, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { int level; zstr prop_name, class_name; @@ -131,7 +131,7 @@ level = va_arg(args, int); verbose = va_arg(args, int); - if (hash_key-nKeyLength ==0 ) { /* numeric key */ + if (hash_key-nKeyLength == 0) { /* numeric key */ php_printf(%*c[%ld]=\n, level + 1, ' ', hash_key-h); } else { /* string key */ int is_unicode = hash_key-type == IS_UNICODE; @@ -140,7 +140,7 @@ php_printf(%*c[, level + 1, ' '); if (class_name.s unmangle == SUCCESS) { - if (class_name.s[0]=='*') { + if (class_name.s[0] == '*') { php_printf(%s\%R\:protected, is_unicode ? u : , hash_key-type, prop_name); } else { php_printf(%s\%R\:%s\%R\:private, is_unicode ? u : , hash_key-type, prop_name, is_unicode ? u : , hash_key-type, class_name); @@ -160,9 +160,9 @@ php_var_dump(zv, level + 2, verbose TSRMLS_CC); return 0; } +/* }}} */ - -PHPAPI void php_var_dump(zval **struc, int level, int verbose TSRMLS_DC) +PHPAPI void php_var_dump(zval **struc, int level, int verbose TSRMLS_DC) /* {{{ */ { HashTable *myht; zstr class_name; @@ -176,7 +176,7 @@ switch (Z_TYPE_PP(struc)) { case IS_BOOL: - php_printf(%sbool(%s)\n, COMMON, Z_LVAL_PP(struc)?true:false); + php_printf(%sbool(%s)\n, COMMON, Z_LVAL_PP(struc) ?
[PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/general_functions var_export-locale.phpt /main snprintf.c spprintf.c
derick Tue Jun 19 12:19:27 2007 UTC Added files: /php-src/ext/standard/tests/general_functions var_export-locale.phpt Modified files: /php-src/ext/standard var.c /php-src/main snprintf.c spprintf.c Log: - Added the H modifier to create non-locale-aware non-fixed-precision float representations. - Fixed var_export() to use the new H modifier so that it can generate parsable PHP code for floats again, independent of the locale. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.265r2=1.266diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.265 php-src/ext/standard/var.c:1.266 --- php-src/ext/standard/var.c:1.265Mon Apr 23 10:21:43 2007 +++ php-src/ext/standard/var.c Tue Jun 19 12:19:27 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.265 2007/04/23 10:21:43 dmitry Exp $ */ +/* $Id: var.c,v 1.266 2007/06/19 12:19:27 derick Exp $ */ @@ -584,7 +584,7 @@ php_printf(%ld, Z_LVAL_PP(struc)); break; case IS_DOUBLE: - php_printf(%.*G, (int) EG(precision), Z_DVAL_PP(struc)); + php_printf(%.*H, (int) EG(precision), Z_DVAL_PP(struc)); break; case IS_STRING: tmp_str = php_addcslashes(Z_STRVAL_PP(struc), Z_STRLEN_PP(struc), tmp_len, 0, '\\\0, 3 TSRMLS_CC); http://cvs.php.net/viewvc.cgi/php-src/main/snprintf.c?r1=1.55r2=1.56diff_format=u Index: php-src/main/snprintf.c diff -u php-src/main/snprintf.c:1.55 php-src/main/snprintf.c:1.56 --- php-src/main/snprintf.c:1.55Thu Apr 12 22:00:56 2007 +++ php-src/main/snprintf.c Tue Jun 19 12:19:27 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: snprintf.c,v 1.55 2007/04/12 22:00:56 tony2001 Exp $ */ +/* $Id: snprintf.c,v 1.56 2007/06/19 12:19:27 derick Exp $ */ #include php.h @@ -1043,6 +1043,7 @@ case 'g': case 'G': + case 'H': switch(modifier) { case LM_LONG_DOUBLE: fp_num = (double) va_arg(ap, long double); @@ -1081,7 +1082,7 @@ lconv = localeconv(); } #endif - s = php_gcvt(fp_num, precision, LCONV_DECIMAL_POINT, (*fmt == 'G')?'E':'e', num_buf[1]); + s = php_gcvt(fp_num, precision, *fmt=='H' ? '.' : LCONV_DECIMAL_POINT, (*fmt == 'G')?'E':'e', num_buf[1]); if (*s == '-') prefix_char = *s++; else if (print_sign) http://cvs.php.net/viewvc.cgi/php-src/main/spprintf.c?r1=1.44r2=1.45diff_format=u Index: php-src/main/spprintf.c diff -u php-src/main/spprintf.c:1.44 php-src/main/spprintf.c:1.45 --- php-src/main/spprintf.c:1.44Fri Jan 19 09:12:08 2007 +++ php-src/main/spprintf.c Tue Jun 19 12:19:27 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: spprintf.c,v 1.44 2007/01/19 09:12:08 helly Exp $ */ +/* $Id: spprintf.c,v 1.45 2007/06/19 12:19:27 derick Exp $ */ /* This is the spprintf implementation. * It has emerged from apache snprintf. See original header: @@ -670,6 +670,7 @@ case 'g': case 'G': + case 'H': switch(modifier) { case LM_LONG_DOUBLE: fp_num = (double) va_arg(ap, long double); @@ -708,7 +709,7 @@ lconv = localeconv(); } #endif - s = php_gcvt(fp_num, precision, LCONV_DECIMAL_POINT, (*fmt == 'G')?'E':'e', num_buf[1]); + s = php_gcvt(fp_num, precision, *fmt=='H' ? '.' : LCONV_DECIMAL_POINT, (*fmt == 'G')?'E':'e', num_buf[1]); if (*s == '-') prefix_char = *s++; else if (print_sign) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/var_export-locale.phpt?view=markuprev=1.1 Index: php-src/ext/standard/tests/general_functions/var_export-locale.phpt +++ php-src/ext/standard/tests/general_functions/var_export-locale.phpt --TEST-- Test var_export() function
[PHP-CVS] cvs: php-src /ext/standard var.c
helly Mon Feb 19 17:28:11 2007 UTC Modified files: /php-src/ext/standard var.c Log: - MFH Fixed bug #40465 (Ensure that all PHP elements are printed by var_dump) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.261r2=1.262diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.261 php-src/ext/standard/var.c:1.262 --- php-src/ext/standard/var.c:1.261Fri Jan 19 22:19:39 2007 +++ php-src/ext/standard/var.c Mon Feb 19 17:28:11 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.261 2007/01/19 22:19:39 helly Exp $ */ +/* $Id: var.c,v 1.262 2007/02/19 17:28:11 helly Exp $ */ @@ -111,14 +111,6 @@ if (hash_key-nKeyLength==0) { /* numeric key */ php_printf(%*c[%ld]=\n, level + 1, ' ', hash_key-h); } else { /* string key */ - if (va_arg(args, int) - ((hash_key-type == IS_STRING hash_key-arKey.s[0] == 0) || -(hash_key-type == IS_UNICODE hash_key-arKey.u[0] == 0))) { - /* XXX: perhaps when we are inside the class we should permit access to -* private protected values -*/ - return 0; - } php_printf(%*c[, level + 1, ' '); if (hash_key-type == IS_STRING) { php_printf(\); @@ -233,7 +225,7 @@ php_element_dump_func = php_object_property_dump; head_done: if (myht) { - zend_hash_apply_with_arguments(myht, (apply_func_args_t) php_element_dump_func, 3, level, verbose, (Z_TYPE_PP(struc) == IS_ARRAY ? 0 : 1)); + zend_hash_apply_with_arguments(myht, (apply_func_args_t) php_element_dump_func, 2, level, verbose); if (is_temp) { zend_hash_destroy(myht); efree(myht); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
helly Fri Jan 19 22:19:39 2007 UTC Modified files: /php-src/ext/standard var.c Log: - Use Z_OBJDEBUG_PP() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.260r2=1.261diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.260 php-src/ext/standard/var.c:1.261 --- php-src/ext/standard/var.c:1.260Thu Jan 18 23:23:13 2007 +++ php-src/ext/standard/var.c Fri Jan 19 22:19:39 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.260 2007/01/18 23:23:13 helly Exp $ */ +/* $Id: var.c,v 1.261 2007/01/19 22:19:39 helly Exp $ */ @@ -221,15 +221,7 @@ is_temp = 0; goto head_done; case IS_OBJECT: - if (Z_OBJ_HANDLER_PP(struc, get_debug_info)) { - myht = Z_OBJ_HANDLER_PP(struc, get_debug_info)(*struc, is_temp TSRMLS_CC); - } else if (Z_OBJ_HANDLER_PP(struc, get_properties)) { - myht = Z_OBJPROP_PP(struc); - is_temp = 0; - } else { - myht = NULL; - is_temp = 0; - } + myht = Z_OBJDEBUG_PP(struc, is_temp); if (myht myht-nApplyCount 1) { PUTS(*RECURSION*\n); return; @@ -430,15 +422,7 @@ zval_element_dump_func = zval_array_element_dump; goto head_done; case IS_OBJECT: - if (Z_OBJ_HANDLER_PP(struc, get_debug_info)) { - myht = Z_OBJ_HANDLER_PP(struc, get_debug_info)(*struc, is_temp TSRMLS_CC); - } else if (Z_OBJ_HANDLER_PP(struc, get_properties)) { - myht = Z_OBJPROP_PP(struc); - is_temp = 0; - } else { - myht = NULL; - is_temp = 0; - } + myht = Z_OBJDEBUG_PP(struc, is_temp); if (myht myht-nApplyCount 1) { PUTS(*RECURSION*\n); return; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c var_unserializer.c var_unserializer.re /ext/standard/tests/serialize 005.phpt
helly Fri Dec 22 00:47:27 2006 UTC Modified files: /php-src/ext/standard var.c var_unserializer.c var_unserializer.re /php-src/ext/standard/tests/serialize 005.phpt Log: - Make custom serializing work with zstr (as discussed with andrei) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.256r2=1.257diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.256 php-src/ext/standard/var.c:1.257 --- php-src/ext/standard/var.c:1.256Thu Dec 21 23:19:48 2006 +++ php-src/ext/standard/var.c Fri Dec 22 00:47:27 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.256 2006/12/21 23:19:48 helly Exp $ */ +/* $Id: var.c,v 1.257 2006/12/22 00:47:27 helly Exp $ */ @@ -972,10 +972,12 @@ if(ce ce-serialize != NULL) { /* has custom handler */ - unsigned char *serialized_data = NULL; + int serialized_type; + zstr serialized_data; zend_uint serialized_length; - if(ce-serialize(struc, serialized_data, serialized_length, (zend_serialize_data *)var_hash TSRMLS_CC) == SUCCESS) { + serialized_data.v = NULL; + if(ce-serialize(struc, serialized_type, serialized_data, serialized_length, (zend_serialize_data *)var_hash TSRMLS_CC) == SUCCESS) { smart_str_appendl(buf, C:, 2); smart_str_append_long(buf, Z_OBJCE_P(struc)-name_length); smart_str_appendl(buf, :\, 2); @@ -989,15 +991,21 @@ smart_str_appendl(buf, \:, 2); smart_str_append_long(buf, serialized_length); - smart_str_appendl(buf, :{, 2); - /* we need binary or ascii at least not unicode */ - smart_str_appendl(buf, serialized_data, serialized_length); + if (serialized_type == IS_UNICODE) { + smart_str_appendl(buf, :U:{, 4); + php_var_serialize_ustr(buf, serialized_data.u, serialized_length); + } else if (serialized_type == IS_STRING) { + smart_str_appendl(buf, :{, 2); + smart_str_appendl(buf, serialized_data.s, serialized_length); + } else { + smart_str_appendc(buf, 'N'); + } smart_str_appendc(buf, '}'); } else { smart_str_appendl(buf, N;, 2); } - if(serialized_data) { - efree(serialized_data); + if(serialized_data.v) { + efree(serialized_data.v); } return; } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var_unserializer.c?r1=1.82r2=1.83diff_format=u Index: php-src/ext/standard/var_unserializer.c diff -u php-src/ext/standard/var_unserializer.c:1.82 php-src/ext/standard/var_unserializer.c:1.83 --- php-src/ext/standard/var_unserializer.c:1.82Thu Dec 14 23:41:57 2006 +++ php-src/ext/standard/var_unserializer.c Fri Dec 22 00:47:27 2006 @@ -1,4 +1,4 @@ -/* Generated by re2c 0.9.12 on Thu Dec 14 15:32:34 2006 */ +/* Generated by re2c 0.10.2 on Thu Dec 21 19:19:25 2006 */ #line 1 ext/standard/var_unserializer.re /* +--+ @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var_unserializer.c,v 1.82 2006/12/14 23:41:57 andrei Exp $ */ +/* $Id: var_unserializer.c,v 1.83 2006/12/22 00:47:27 helly Exp $ */ #include php.h #include ext/standard/php_var.h @@ -347,6 +347,7 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) { long datalen; + int type;
[PHP-CVS] cvs: php-src /ext/standard var.c
tony2001Tue Dec 19 12:44:26 2006 UTC Modified files: /php-src/ext/standard var.c Log: MFB: serialize() should use '.' as decimal point irrespectively to locale http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.252r2=1.253diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.252 php-src/ext/standard/var.c:1.253 --- php-src/ext/standard/var.c:1.252Thu Dec 14 23:41:57 2006 +++ php-src/ext/standard/var.c Tue Dec 19 12:44:26 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.252 2006/12/14 23:41:57 andrei Exp $ */ +/* $Id: var.c,v 1.253 2006/12/19 12:44:26 tony2001 Exp $ */ @@ -942,10 +942,12 @@ case IS_DOUBLE: { char *s; - ulong slen; - slen = spprintf(s, 0, d:%.*G;, (int) PG(serialize_precision), Z_DVAL_P(struc)); - smart_str_appendl(buf, s, slen); + smart_str_appendl(buf, d:, 2); + s = (char *) emalloc(MAX_LENGTH_OF_DOUBLE + PG(serialize_precision) + 1); + php_gcvt(Z_DVAL_P(struc), PG(serialize_precision), '.', 'E', s); + smart_str_appends(buf, s); + smart_str_appendc(buf, ';'); efree(s); return; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c var_unserializer.c var_unserializer.re
andrei Thu Dec 14 23:41:57 2006 UTC Modified files: /php-src/ext/standard var.c var_unserializer.c var_unserializer.re Log: Use 'S' for escaped binary strings and 's' for non-escaped. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.251r2=1.252diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.251 php-src/ext/standard/var.c:1.252 --- php-src/ext/standard/var.c:1.251Fri Dec 8 21:18:16 2006 +++ php-src/ext/standard/var.c Thu Dec 14 23:41:57 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.251 2006/12/08 21:18:16 tony2001 Exp $ */ +/* $Id: var.c,v 1.252 2006/12/14 23:41:57 andrei Exp $ */ @@ -718,7 +718,7 @@ unsigned char c; int i; - smart_str_appendl(buf, s:, 2); + smart_str_appendl(buf, S:, 2); smart_str_append_long(buf, len); smart_str_appendl(buf, :\, 2); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var_unserializer.c?r1=1.81r2=1.82diff_format=u Index: php-src/ext/standard/var_unserializer.c diff -u php-src/ext/standard/var_unserializer.c:1.81 php-src/ext/standard/var_unserializer.c:1.82 --- php-src/ext/standard/var_unserializer.c:1.81Fri Dec 1 19:25:11 2006 +++ php-src/ext/standard/var_unserializer.c Thu Dec 14 23:41:57 2006 @@ -1,4 +1,4 @@ -/* Generated by re2c 0.9.12 on Fri Dec 1 11:18:14 2006 */ +/* Generated by re2c 0.9.12 on Thu Dec 14 15:32:34 2006 */ #line 1 ext/standard/var_unserializer.re /* +--+ @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var_unserializer.c,v 1.81 2006/12/01 19:25:11 andrei Exp $ */ +/* $Id: var_unserializer.c,v 1.82 2006/12/14 23:41:57 andrei Exp $ */ #include php.h #include ext/standard/php_var.h @@ -468,110 +468,115 @@ if((YYLIMIT - YYCURSOR) 7) YYFILL(7); yych = *YYCURSOR; switch(yych){ - case 'C': case 'O': goto yy13; + case 'C': case 'O': goto yy14; case 'N': goto yy5; case 'R': goto yy2; - case 'U': goto yy10; - case 'a': goto yy11; + case 'S': goto yy10; + case 'U': goto yy11; + case 'a': goto yy12; case 'b': goto yy6; case 'd': goto yy8; case 'i': goto yy7; - case 'o': goto yy12; + case 'o': goto yy13; case 'r': goto yy4; case 's': goto yy9; - case '}': goto yy14; - default:goto yy16; + case '}': goto yy15; + default:goto yy17; } yy2: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy95; + if(yych == ':') goto yy103; goto yy3; yy3: -#line 725 ext/standard/var_unserializer.re +#line 753 ext/standard/var_unserializer.re { return 0; } -#line 493 ext/standard/var_unserializer.c +#line 494 ext/standard/var_unserializer.c yy4: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy89; + if(yych == ':') goto yy97; goto yy3; yy5: yych = *++YYCURSOR; - if(yych == ';') goto yy87; + if(yych == ';') goto yy95; goto yy3; yy6: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy83; + if(yych == ':') goto yy91; goto yy3; yy7: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy77; + if(yych == ':') goto yy85; goto yy3; yy8: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy53; + if(yych == ':') goto yy61; goto yy3; yy9: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy46; + if(yych == ':') goto yy54; goto yy3; yy10: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy39; + if(yych == ':') goto yy47; goto yy3; yy11: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy32; + if(yych == ':') goto yy40; goto yy3; yy12: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy25; + if(yych == ':') goto yy33; goto yy3; yy13: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if(yych == ':') goto yy17; + if(yych == ':') goto yy26; goto yy3; -yy14: ++YYCURSOR; - goto yy15; -yy15: -#line 719 ext/standard/var_unserializer.re +yy14: yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if(yych == ':') goto yy18; + goto yy3; +yy15: ++YYCURSOR; + goto yy16; +yy16: +#line 747 ext/standard/var_unserializer.re { /* this is the case where we have less data than planned */
[PHP-CVS] cvs: php-src /ext/standard var.c var_unserializer.c var_unserializer.re
andrei Fri Dec 1 19:25:11 2006 UTC Modified files: /php-src/ext/standard var.c var_unserializer.c var_unserializer.re Log: Finalize Unicode support in serialize() and unserialize(). http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.247r2=1.248diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.247 php-src/ext/standard/var.c:1.248 --- php-src/ext/standard/var.c:1.247Mon Oct 9 18:09:42 2006 +++ php-src/ext/standard/var.c Fri Dec 1 19:25:10 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.247 2006/10/09 18:09:42 iliaa Exp $ */ +/* $Id: var.c,v 1.248 2006/12/01 19:25:10 andrei Exp $ */ @@ -671,25 +671,40 @@ static inline void php_var_serialize_string(smart_str *buf, char *str, int len) { + static const char hex[] = 0123456789abcdef; + unsigned char c; + int i; + smart_str_appendl(buf, s:, 2); smart_str_append_long(buf, len); smart_str_appendl(buf, :\, 2); - smart_str_appendl(buf, str, len); + + for (i = 0; i len; i++) { + c = (unsigned char) str[i]; + if (c 128 c != 0x5c /*'\\'*/) { + smart_str_appendc(buf, c 0xff); + } else { + smart_str_appendc(buf, 0x5c /*'\\'*/); + smart_str_appendc(buf, hex[(c 4) 0xf]); + smart_str_appendc(buf, hex[(c 0) 0xf]); + } + } + smart_str_appendl(buf, \;, 2); } static inline void php_var_serialize_ustr(smart_str *buf, UChar *ustr, int len) { static const char hex[] = 0123456789abcdef; - UChar32 c; - int32_t i; + UChar c; + int i; - for(i=0; ilen; /* U16_NEXT post-increments */) { - U16_NEXT(ustr, i, len, c); - if (c 128 c != '\\') { + for (i = 0; i len; i++) { + c = ustr[i]; + if (c 128 c != 0x5c /*'\\'*/) { smart_str_appendc(buf, c 0xff); } else { - smart_str_appendc(buf, '\\'); + smart_str_appendc(buf, 0x5c /*'\\'*/); smart_str_appendc(buf, hex[(c 12) 0xf]); smart_str_appendc(buf, hex[(c 8) 0xf]); smart_str_appendc(buf, hex[(c 4) 0xf]); @@ -1062,7 +1077,7 @@ /* }}} */ -/* {{{ proto string serialize(mixed variable) +/* {{{ proto string serialize(mixed variable) U Returns a string representation of variable (which can later be unserialized) */ PHP_FUNCTION(serialize) { @@ -1093,22 +1108,20 @@ } /* }}} */ -/* {{{ proto mixed unserialize(string variable_representation) +/* {{{ proto mixed unserialize(string variable_representation) U Takes a string representation of variable and recreates it */ PHP_FUNCTION(unserialize) { - zstr buf; - char *str = NULL; + char *buf = NULL; int buf_len; - zend_uchar buf_type; const unsigned char *p; php_unserialize_data_t var_hash; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, T, - buf, buf_len, buf_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, + buf, buf_len, UG(ascii_conv)) == FAILURE) { RETURN_FALSE; } @@ -1116,34 +1129,15 @@ RETURN_FALSE; } - if (buf_type == IS_UNICODE) { - /* ASCII unicode string to binary string conversion */ - int i; - - str = emalloc(buf_len+1); - for (i = 0; i buf_len; i++) { - if (buf.u[i] 128) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Error at offset %d of %d bytes, i, buf_len); - STR_FREE(str); - RETURN_FALSE; - } - str[i] = buf.u[i]; - } - str[i] = '\0'; - buf.s = str; - } - - p = (const unsigned char*)buf.s; + p = (const unsigned char*) buf; PHP_VAR_UNSERIALIZE_INIT(var_hash); if (!php_var_unserialize(return_value, p, p + buf_len, var_hash TSRMLS_CC)) { PHP_VAR_UNSERIALIZE_DESTROY(var_hash); zval_dtor(return_value); - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Error at offset %ld of %d bytes, (long)((char*)p - buf.s), buf_len); - STR_FREE(str); + php_error_docref(NULL TSRMLS_CC, E_NOTICE, Error at offset %ld of %d bytes, (long)((char*)p - buf), buf_len); RETURN_FALSE; } PHP_VAR_UNSERIALIZE_DESTROY(var_hash); - STR_FREE(str); }
[PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/strings bug37262.phpt explode.phpt
iliaa Mon Oct 9 18:09:43 2006 UTC Modified files: /php-src/ext/standard/tests/strings bug37262.phpt explode.phpt /php-src/ext/standard var.c Log: MFB: Fixed bug #37262 (var_export() does not escape \0 character). http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug37262.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/standard/tests/strings/bug37262.phpt diff -u /dev/null php-src/ext/standard/tests/strings/bug37262.phpt:1.2 --- /dev/null Mon Oct 9 18:09:43 2006 +++ php-src/ext/standard/tests/strings/bug37262.phptMon Oct 9 18:09:42 2006 @@ -0,0 +1,9 @@ +--TEST-- +Bug #37262 (var_export() does not escape \0 character) +--FILE-- +?php +$func = create_function('$a', 'return $a;'); +var_export($func); +? +--EXPECT-- +'\000lambda_1' http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/explode.phpt?r1=1.5r2=1.6diff_format=u Index: php-src/ext/standard/tests/strings/explode.phpt diff -u php-src/ext/standard/tests/strings/explode.phpt:1.5 php-src/ext/standard/tests/strings/explode.phpt:1.6 --- php-src/ext/standard/tests/strings/explode.phpt:1.5 Tue Aug 16 10:18:43 2005 +++ php-src/ext/standard/tests/strings/explode.phpt Mon Oct 9 18:09:42 2006 @@ -29,7 +29,7 @@ var_dump(explode(:^:,a lazy dog:^:jumps::over:^:,-2)); ? --EXPECTF-- -26d4e18734cb2582df5055e2175223df +6e5d59d5afd6693547a733219d079658 bool(false) bool(false) bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.246r2=1.247diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.246 php-src/ext/standard/var.c:1.247 --- php-src/ext/standard/var.c:1.246Sun Oct 8 13:34:24 2006 +++ php-src/ext/standard/var.c Mon Oct 9 18:09:42 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.246 2006/10/08 13:34:24 bjori Exp $ */ +/* $Id: var.c,v 1.247 2006/10/09 18:09:42 iliaa Exp $ */ @@ -543,7 +543,7 @@ php_printf(%.*G, (int) EG(precision), Z_DVAL_PP(struc)); 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_PP(struc), Z_STRLEN_PP(struc), tmp_len, 0, '\\\0, 3 TSRMLS_CC); PUTS ('); PHPWRITE(tmp_str, tmp_len); PUTS ('); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
andrei Fri Oct 6 18:03:41 2006 UTC Modified files: /php-src/ext/standard var.c Log: Mark memory funcs with U. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.244r2=1.245diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.244 php-src/ext/standard/var.c:1.245 --- php-src/ext/standard/var.c:1.244Tue Aug 8 16:59:11 2006 +++ php-src/ext/standard/var.c Fri Oct 6 18:03:41 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.244 2006/08/08 16:59:11 tony2001 Exp $ */ +/* $Id: var.c,v 1.245 2006/10/06 18:03:41 andrei Exp $ */ @@ -1149,7 +1149,7 @@ /* }}} */ #if MEMORY_LIMIT -/* {{{ proto int memory_get_usage([real_usage]) +/* {{{ proto int memory_get_usage([real_usage]) U Returns the allocated by PHP memory */ PHP_FUNCTION(memory_get_usage) { zend_bool real_usage = 0; @@ -1161,7 +1161,7 @@ RETURN_LONG(zend_memory_usage(real_usage TSRMLS_CC)); } /* }}} */ -/* {{{ proto int memory_get_peak_usage([real_usage]) +/* {{{ proto int memory_get_peak_usage([real_usage]) U Returns the peak allocated by PHP memory */ PHP_FUNCTION(memory_get_peak_usage) { zend_bool real_usage = 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c /sapi/apache mod_php5.c /sapi/apache2filter sapi_apache2.c /sapi/apache2handler sapi_apache2.c /sapi/apache_hooks mod_php5.c ZendEngine2 zend_alloc.c ze
dmitry Tue Jul 25 13:41:08 2006 UTC Modified files: /ZendEngine2zend_alloc.c zend_alloc.h /php-src/ext/standard var.c /php-src/sapi/apachemod_php5.c /php-src/sapi/apache2filter sapi_apache2.c /php-src/sapi/apache2handlersapi_apache2.c /php-src/sapi/apache_hooks mod_php5.c Log: Changed memory_get_usage() and memory_get_peak_usage(). Optional boolean argument allows get memory size allocated by emalloc() (by default) or real size of memory allocated from system. http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_alloc.c?r1=1.154r2=1.155diff_format=u Index: ZendEngine2/zend_alloc.c diff -u ZendEngine2/zend_alloc.c:1.154 ZendEngine2/zend_alloc.c:1.155 --- ZendEngine2/zend_alloc.c:1.154 Mon Jul 24 08:15:42 2006 +++ ZendEngine2/zend_alloc.cTue Jul 25 13:41:08 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: zend_alloc.c,v 1.154 2006/07/24 08:15:42 dmitry Exp $ */ +/* $Id: zend_alloc.c,v 1.155 2006/07/25 13:41:08 dmitry Exp $ */ #include zend.h #include zend_alloc.h @@ -312,10 +312,12 @@ size_t block_size; zend_mm_segment*segments_list; zend_mm_storage*storage; - size_t size; + size_t real_size; #if MEMORY_LIMIT - size_t peak; + size_t real_peak; size_t limit; + size_t size; + size_t peak; #endif #if ZEND_USE_MALLOC_MM int use_zend_alloc; @@ -514,7 +516,7 @@ p = p-next_segment; } } - heap-size -= segment-size; + heap-real_size -= segment-size; ZEND_MM_STORAGE_FREE(segment); } @@ -595,10 +597,12 @@ heap-use_zend_alloc = 1; #endif - heap-size = 0; + heap-real_size = 0; #if MEMORY_LIMIT - heap-peak = 0; + heap-real_peak = 0; heap-limit = 130; + heap-size = 0; + heap-peak = 0; #endif heap-overflow = 0; @@ -996,8 +1000,10 @@ } else { heap-segments_list = NULL; zend_mm_init(heap); - heap-size = 0; + heap-real_size = 0; #if MEMORY_LIMIT + heap-real_peak = 0; + heap-size = 0; heap-peak = 0; #endif heap-overflow = 0; @@ -1175,7 +1181,7 @@ #if MEMORY_LIMIT - if (heap-size + segment_size heap-limit) { + if (heap-real_size + segment_size heap-limit) { /* Memory limit overflow */ #if ZEND_DEBUG zend_mm_safe_error(heap, Allowed memory size of %d bytes exhausted at %s:%d (tried to allocate %d bytes), heap-limit, __zend_filename, __zend_lineno, size); @@ -1196,17 +1202,17 @@ #endif HANDLE_UNBLOCK_INTERRUPTIONS(); #if ZEND_DEBUG - zend_mm_safe_error(heap, Out of memory (allocated %d) at %s:%d (tried to allocate %d bytes), heap-size, __zend_filename, __zend_lineno, size); + zend_mm_safe_error(heap, Out of memory (allocated %d) at %s:%d (tried to allocate %d bytes), heap-real_size, __zend_filename, __zend_lineno, size); #else - zend_mm_safe_error(heap, Out of memory (allocated %d) (tried to allocate %d bytes), heap-size, size); + zend_mm_safe_error(heap, Out of memory (allocated %d) (tried to allocate %d bytes), heap-real_size, size); #endif return NULL; } - heap-size += segment_size; + heap-real_size += segment_size; #if MEMORY_LIMIT - if (heap-size heap-peak) { - heap-peak = heap-size; + if (heap-real_size heap-real_peak) { + heap-real_peak = heap-real_size; } #endif @@ -1242,6 +1248,14 @@ # endif ZEND_MM_SET_END_MAGIC(best_fit); #endif + +#if MEMORY_LIMIT + heap-size += true_size; + if (heap-peak heap-size) { + heap-peak = heap-size; + } +#endif + HANDLE_UNBLOCK_INTERRUPTIONS(); return ZEND_MM_DATA_OF(best_fit); @@ -1278,6 +1292,11 @@ #endif HANDLE_BLOCK_INTERRUPTIONS(); + +#if MEMORY_LIMIT + heap-size -= size; +#endif + if (ZEND_MM_PREV_BLOCK_IS_FREE(mm_block)) { next_block = ZEND_MM_NEXT_BLOCK(mm_block); if (ZEND_MM_IS_FREE_BLOCK(next_block)) { @@ -1349,6 +1368,14 @@ } mm_block = ZEND_MM_HEADER_OF(p); true_size = ZEND_MM_TRUE_SIZE(size); + +#if MEMORY_LIMIT + heap-size = heap-size + true_size - ZEND_MM_BLOCK_SIZE(mm_block); + if (heap-peak heap-size) { + heap-peak = heap-size; + } +#endif +
[PHP-CVS] cvs: php-src /ext/standard var.c
helly Mon Jul 24 23:28:00 2006 UTC Modified files: /php-src/ext/standard var.c Log: - Correctly handle binary proeprty names which are not mangled http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.240r2=1.241diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.240 php-src/ext/standard/var.c:1.241 --- php-src/ext/standard/var.c:1.240Mon Jul 24 17:55:41 2006 +++ php-src/ext/standard/var.c Mon Jul 24 23:28:00 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.240 2006/07/24 17:55:41 helly Exp $ */ +/* $Id: var.c,v 1.241 2006/07/24 23:28:00 helly Exp $ */ @@ -149,17 +149,24 @@ } else { /* string key */ int is_unicode = hash_key-type == IS_UNICODE; - zend_u_unmangle_property_name(hash_key-type, hash_key-arKey, hash_key-nKeyLength-1, class_name, prop_name); + int unmangle = zend_u_unmangle_property_name(hash_key-type, hash_key-arKey, hash_key-nKeyLength-1, class_name, prop_name); php_printf(%*c[, level + 1, ' '); - if (class_name.s) { + if (class_name.s unmangle == SUCCESS) { if (class_name.s[0]=='*') { php_printf(%s\%R\:protected, is_unicode ? u : , hash_key-type, prop_name); } else { php_printf(%s\%R\:%s\%R\:private, is_unicode ? u : , hash_key-type, prop_name, is_unicode ? u : , hash_key-type, class_name); } } else { - php_printf(%s\%R\, is_unicode ? u : , hash_key-type, prop_name); + if (is_unicode) { + php_printf(u); + php_var_dump_unicode(hash_key-arKey.u, hash_key-nKeyLength-1, verbose, \, 0 TSRMLS_CC); + } else { + php_printf(\); + PHPWRITE(hash_key-arKey.s, hash_key-nKeyLength - 1); + php_printf(\); + } } ZEND_PUTS(]=\n); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
dmitry Fri Jul 14 08:29:07 2006 UTC Modified files: /php-src/ext/standard var.c Log: Fixed unserialize() in unicode mode http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.236r2=1.237diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.236 php-src/ext/standard/var.c:1.237 --- php-src/ext/standard/var.c:1.236Wed Jul 12 17:23:53 2006 +++ php-src/ext/standard/var.c Fri Jul 14 08:29:06 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.236 2006/07/12 17:23:53 andrei Exp $ */ +/* $Id: var.c,v 1.237 2006/07/14 08:29:06 dmitry Exp $ */ @@ -1092,7 +1092,7 @@ PHP_FUNCTION(unserialize) { - unsigned char *buf; + zstr buf; char *str = NULL; int buf_len; zend_uchar buf_type; @@ -1115,24 +1115,34 @@ str = emalloc(buf_len+1); for (i = 0; i buf_len; i++) { - if (buf[i] 128) { + if (buf.u[i] 128) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, Error at offset %d of %d bytes, i, buf_len); + if (str) { + efree(str); + } + RETURN_FALSE; } - str[i] = buf[i]; + str[i] = buf.u[i]; } str[i] = '\0'; - buf = str; + buf.s = str; } - p = (const unsigned char*)buf; + p = (const unsigned char*)buf.s; PHP_VAR_UNSERIALIZE_INIT(var_hash); if (!php_var_unserialize(return_value, p, p + buf_len, var_hash TSRMLS_CC)) { PHP_VAR_UNSERIALIZE_DESTROY(var_hash); zval_dtor(return_value); - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Error at offset %ld of %d bytes, (long)((unsigned char*)p - buf), buf_len); + php_error_docref(NULL TSRMLS_CC, E_NOTICE, Error at offset %ld of %d bytes, (long)((char*)p - buf.s), buf_len); + if (str) { + efree(str); + } RETURN_FALSE; } PHP_VAR_UNSERIALIZE_DESTROY(var_hash); + if (str) { + efree(str); + } } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
tony2001Fri Jul 14 08:38:31 2006 UTC Modified files: /php-src/ext/standard var.c Log: WS and CS fixes I suppose STR_FREE() is better than if(..) {efree (..);} http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.237r2=1.238diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.237 php-src/ext/standard/var.c:1.238 --- php-src/ext/standard/var.c:1.237Fri Jul 14 08:29:06 2006 +++ php-src/ext/standard/var.c Fri Jul 14 08:38:30 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.237 2006/07/14 08:29:06 dmitry Exp $ */ +/* $Id: var.c,v 1.238 2006/07/14 08:38:30 tony2001 Exp $ */ @@ -1116,10 +1116,8 @@ str = emalloc(buf_len+1); for (i = 0; i buf_len; i++) { if (buf.u[i] 128) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Error at offset %d of %d bytes, i, buf_len); - if (str) { - efree(str); - } + php_error_docref(NULL TSRMLS_CC, E_NOTICE, Error at offset %d of %d bytes, i, buf_len); + STR_FREE(str); RETURN_FALSE; } str[i] = buf.u[i]; @@ -1134,15 +1132,11 @@ PHP_VAR_UNSERIALIZE_DESTROY(var_hash); zval_dtor(return_value); php_error_docref(NULL TSRMLS_CC, E_NOTICE, Error at offset %ld of %d bytes, (long)((char*)p - buf.s), buf_len); - if (str) { - efree(str); - } + STR_FREE(str); RETURN_FALSE; } PHP_VAR_UNSERIALIZE_DESTROY(var_hash); - if (str) { - efree(str); - } + STR_FREE(str); } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
andrei Wed Jul 12 17:23:53 2006 UTC Modified files: /php-src/ext/standard var.c Log: Use zend_convert_from_unicode() in var_dump(). http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.235r2=1.236diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.235 php-src/ext/standard/var.c:1.236 --- php-src/ext/standard/var.c:1.235Mon Jul 10 14:02:54 2006 +++ php-src/ext/standard/var.c Wed Jul 12 17:23:53 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.235 2006/07/10 14:02:54 dmitry Exp $ */ +/* $Id: var.c,v 1.236 2006/07/12 17:23:53 andrei Exp $ */ @@ -45,9 +45,9 @@ static void php_var_dump_unicode(UChar *ustr, int length, int verbose, char *quote, int escape TSRMLS_DC) { UChar32 c; - int32_t i; + int i; UErrorCode status = U_ZERO_ERROR; - int32_t clen; + int clen; char *out = NULL; if (length == 0) { @@ -56,16 +56,8 @@ return; } - clen = length * ucnv_getMaxCharSize(ZEND_U_CONVERTER(UG(output_encoding_conv))) + 1; - while (1) { - status = U_ZERO_ERROR; - out = erealloc(out, clen+1); - clen = ucnv_fromUChars(ZEND_U_CONVERTER(UG(output_encoding_conv)), out, clen+1, ustr, length, status); - if (status != U_BUFFER_OVERFLOW_ERROR) { - break; - } - } - if(U_FAILURE(status) || status==U_STRING_NOT_TERMINATED_WARNING) { + zend_convert_from_unicode(ZEND_U_CONVERTER(UG(output_encoding_conv)), out, clen, ustr, length, status); + if(U_FAILURE(status)) { php_printf(problem converting string from Unicode: %s\n, u_errorName(status)); efree(out); return; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/serialize bug37947.phpt
dmitry Mon Jul 10 14:02:54 2006 UTC Modified files: /php-src/ext/standard var.c /php-src/ext/standard/tests/serialize bug37947.phpt Log: Fixed bug #37947 (zend_ptr_stack reallocation problem) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/var.c?r1=1.234r2=1.235diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.234 php-src/ext/standard/var.c:1.235 --- php-src/ext/standard/var.c:1.234Sat Jun 3 11:19:43 2006 +++ php-src/ext/standard/var.c Mon Jul 10 14:02:54 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.234 2006/06/03 11:19:43 mike Exp $ */ +/* $Id: var.c,v 1.235 2006/07/10 14:02:54 dmitry Exp $ */ @@ -1100,49 +1100,47 @@ PHP_FUNCTION(unserialize) { - zval **buf; + unsigned char *buf; + char *str = NULL; + int buf_len; + zend_uchar buf_type; + const unsigned char *p; + php_unserialize_data_t var_hash; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, buf) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, T, + buf, buf_len, buf_type) == FAILURE) { + RETURN_FALSE; } - if (Z_TYPE_PP(buf) == IS_UNICODE) { + if (buf_len == 0) { + RETURN_FALSE; + } + + if (buf_type == IS_UNICODE) { /* ASCII unicode string to binary string conversion */ - char *str = emalloc(Z_USTRLEN_PP(buf)+1); int i; - for (i = 0; i Z_UNILEN_PP(buf); i++) { - if (Z_USTRVAL_PP(buf)[i] 128) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Error at offset %d of %d bytes, i, Z_USTRLEN_PP(buf)); + str = emalloc(buf_len+1); + for (i = 0; i buf_len; i++) { + if (buf[i] 128) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, Error at offset %d of %d bytes, i, buf_len); } - str[i] = Z_USTRVAL_PP(buf)[i]; + str[i] = buf[i]; } str[i] = '\0'; - efree(Z_USTRVAL_PP(buf)); - Z_STRVAL_PP(buf) = str; - Z_TYPE_PP(buf) = IS_STRING; + buf = str; } - - if (Z_TYPE_PP(buf) == IS_STRING) { - const unsigned char *p = (unsigned char*)Z_STRVAL_PP(buf); - - if (Z_STRLEN_PP(buf) == 0) { - RETURN_FALSE; - } - - PHP_VAR_UNSERIALIZE_INIT(var_hash); - if (!php_var_unserialize(return_value, p, p + Z_STRLEN_PP(buf), var_hash TSRMLS_CC)) { - PHP_VAR_UNSERIALIZE_DESTROY(var_hash); - zval_dtor(return_value); - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Error at offset %ld of %d bytes, (long)((char*)p - Z_STRVAL_PP(buf)), Z_STRLEN_PP(buf)); - RETURN_FALSE; - } + + p = (const unsigned char*)buf; + PHP_VAR_UNSERIALIZE_INIT(var_hash); + if (!php_var_unserialize(return_value, p, p + buf_len, var_hash TSRMLS_CC)) { PHP_VAR_UNSERIALIZE_DESTROY(var_hash); - } else { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Argument is not a string); + zval_dtor(return_value); + php_error_docref(NULL TSRMLS_CC, E_NOTICE, Error at offset %ld of %d bytes, (long)((unsigned char*)p - buf), buf_len); RETURN_FALSE; } + PHP_VAR_UNSERIALIZE_DESTROY(var_hash); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/serialize/bug37947.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/standard/tests/serialize/bug37947.phpt diff -u /dev/null php-src/ext/standard/tests/serialize/bug37947.phpt:1.2 --- /dev/null Mon Jul 10 14:02:54 2006 +++ php-src/ext/standard/tests/serialize/bug37947.phpt Mon Jul 10 14:02:54 2006 @@ -0,0 +1,21 @@ +--TEST-- +Bug #37947 (zend_ptr_stack reallocation problem) +--INI-- +error_reporting=0 +--FILE-- +? +class test { +function extend_zend_ptr_stack($count,$a,$b,$c,$d,$e) { +if ($count0) $this-extend_zend_ptr_stack($count - +1,$a,$b,$c,$d,$e); +} + +function __wakeup() { +$this-extend_zend_ptr_stack(10,'a','b','c','d','e'); +} +} + +$str='a:2:{i:0;O:4:test:0:{}junk'; +var_dump(unserialize($str)); +--EXPECT-- +bool(false) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c /ext/zlib php_zlib.h zlib.c
mikeFri Jun 2 20:09:22 2006 UTC Modified files: /php-src/ext/standard var.c /php-src/ext/zlib php_zlib.h zlib.c Log: - fix encoding http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/var.c?r1=1.232r2=1.233diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.232 php-src/ext/standard/var.c:1.233 --- php-src/ext/standard/var.c:1.232Fri Jun 2 19:51:42 2006 +++ php-src/ext/standard/var.c Fri Jun 2 20:09:22 2006 @@ -12,13 +12,13 @@ | obtain it through the world-wide-web, please send a note to | | [EMAIL PROTECTED] so we can mail you a copy immediately. | +--+ - | Authors: Jani Lehtim�i [EMAIL PROTECTED] | + | Authors: Jani Lehtimäki [EMAIL PROTECTED] | | Thies C. Arntzen [EMAIL PROTECTED] | | Sascha Schumann [EMAIL PROTECTED]| +--+ */ -/* $Id: var.c,v 1.232 2006/06/02 19:51:42 mike Exp $ */ +/* $Id: var.c,v 1.233 2006/06/02 20:09:22 mike Exp $ */ http://cvs.php.net/viewcvs.cgi/php-src/ext/zlib/php_zlib.h?r1=1.44r2=1.45diff_format=u Index: php-src/ext/zlib/php_zlib.h diff -u php-src/ext/zlib/php_zlib.h:1.44 php-src/ext/zlib/php_zlib.h:1.45 --- php-src/ext/zlib/php_zlib.h:1.44Fri Jun 2 19:51:42 2006 +++ php-src/ext/zlib/php_zlib.h Fri Jun 2 20:09:22 2006 @@ -13,11 +13,11 @@ | [EMAIL PROTECTED] so we can mail you a copy immediately. | +--+ | Authors: Rasmus Lerdorf [EMAIL PROTECTED] | - | Stefan R�rich [EMAIL PROTECTED] | + | Stefan Röhrich [EMAIL PROTECTED] | +--+ */ -/* $Id: php_zlib.h,v 1.44 2006/06/02 19:51:42 mike Exp $ */ +/* $Id: php_zlib.h,v 1.45 2006/06/02 20:09:22 mike Exp $ */ #ifndef PHP_ZLIB_H #define PHP_ZLIB_H http://cvs.php.net/viewcvs.cgi/php-src/ext/zlib/zlib.c?r1=1.194r2=1.195diff_format=u Index: php-src/ext/zlib/zlib.c diff -u php-src/ext/zlib/zlib.c:1.194 php-src/ext/zlib/zlib.c:1.195 --- php-src/ext/zlib/zlib.c:1.194 Fri Jun 2 19:51:42 2006 +++ php-src/ext/zlib/zlib.c Fri Jun 2 20:09:22 2006 @@ -13,13 +13,13 @@ | [EMAIL PROTECTED] so we can mail you a copy immediately. | +--+ | Authors: Rasmus Lerdorf [EMAIL PROTECTED] | - | Stefan R�rich [EMAIL PROTECTED] | + | Stefan Röhrich [EMAIL PROTECTED] | | Zeev Suraski [EMAIL PROTECTED]| | Jade Nicoletti [EMAIL PROTECTED] | +--+ */ -/* $Id: zlib.c,v 1.194 2006/06/02 19:51:42 mike Exp $ */ +/* $Id: zlib.c,v 1.195 2006/06/02 20:09:22 mike Exp $ */ #ifdef HAVE_CONFIG_H #include config.h -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
iliaa Wed Apr 5 02:28:39 2006 UTC Modified files: /php-src/ext/standard var.c Log: Fixed bug #36957 (serialize() does not handle recursion). http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/var.c?r1=1.229r2=1.230diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.229 php-src/ext/standard/var.c:1.230 --- php-src/ext/standard/var.c:1.229Mon Mar 27 22:16:53 2006 +++ php-src/ext/standard/var.c Wed Apr 5 02:28:39 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.229 2006/03/27 22:16:53 andrei Exp $ */ +/* $Id: var.c,v 1.230 2006/04/05 02:28:39 iliaa Exp $ */ @@ -1031,10 +1031,18 @@ if (zend_hash_get_current_data_ex(myht, (void **) data, pos) != SUCCESS || !data - || data == struc) { + || data == struc + || (Z_TYPE_PP(data) == IS_ARRAY Z_ARRVAL_PP(data)-nApplyCount 1) + ) { smart_str_appendl(buf, N;, 2); } else { + 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_PP(data) == IS_ARRAY) { + Z_ARRVAL_PP(data)-nApplyCount--; + } } } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
andrei Mon Mar 27 19:24:18 2006 UTC Modified files: /php-src/ext/standard var.c Log: Proto updates. http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/var.c?r1=1.226r2=1.227diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.226 php-src/ext/standard/var.c:1.227 --- php-src/ext/standard/var.c:1.226Mon Mar 27 13:37:46 2006 +++ php-src/ext/standard/var.c Mon Mar 27 19:24:18 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.226 2006/03/27 13:37:46 dmitry Exp $ */ +/* $Id: var.c,v 1.227 2006/03/27 19:24:18 andrei Exp $ */ @@ -256,7 +256,7 @@ -/* {{{ proto void var_dump(mixed var) +/* {{{ proto void var_dump(mixed var) U Dumps a string representation of variable to output */ PHP_FUNCTION(var_dump) { @@ -280,7 +280,7 @@ /* }}} */ -/* {{{ proto void var_inspect(mixed var) +/* {{{ proto void var_inspect(mixed var) U Dumps a string representation of variable to output (verbose form) */ PHP_FUNCTION(var_inspect) { @@ -450,7 +450,7 @@ /* }}} */ -/* {{{ proto void debug_zval_dump(mixed var) +/* {{{ proto void debug_zval_dump(mixed var) U Dumps a string representation of an internal zend value to output. */ PHP_FUNCTION(debug_zval_dump) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
andrei Mon Mar 27 21:19:12 2006 UTC Modified files: /php-src/ext/standard var.c Log: Make a UTODO note. http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/var.c?r1=1.227r2=1.228diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.227 php-src/ext/standard/var.c:1.228 --- php-src/ext/standard/var.c:1.227Mon Mar 27 19:24:18 2006 +++ php-src/ext/standard/var.c Mon Mar 27 21:19:12 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.227 2006/03/27 19:24:18 andrei Exp $ */ +/* $Id: var.c,v 1.228 2006/03/27 21:19:12 andrei Exp $ */ @@ -605,6 +605,12 @@ php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC); } + /* UTODO +* We need to escape non-ASCII chars with \u format. php_var_export() +* currently uses output_encoding to export Unicode strings. Support it's +* set to utf-8. If you use the result of var_export() in non-utf-8 context, +* there may be trouble. +*/ php_var_export(var, 1 TSRMLS_CC); if (return_output) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
andrei Mon Mar 27 22:16:53 2006 UTC Modified files: /php-src/ext/standard var.c Log: Typo. http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/var.c?r1=1.228r2=1.229diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.228 php-src/ext/standard/var.c:1.229 --- php-src/ext/standard/var.c:1.228Mon Mar 27 21:19:12 2006 +++ php-src/ext/standard/var.c Mon Mar 27 22:16:53 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.228 2006/03/27 21:19:12 andrei Exp $ */ +/* $Id: var.c,v 1.229 2006/03/27 22:16:53 andrei Exp $ */ @@ -607,7 +607,7 @@ /* UTODO * We need to escape non-ASCII chars with \u format. php_var_export() -* currently uses output_encoding to export Unicode strings. Support it's +* currently uses output_encoding to export Unicode strings. Suppose it's * set to utf-8. If you use the result of var_export() in non-utf-8 context, * there may be trouble. */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
derick Wed Mar 15 09:50:47 2006 UTC Modified files: /php-src/ext/standard var.c Log: - Reduce space in serialization. The first 128 bytes will now use just the character and everything above will use \u. It seems that unserialize doesn't work at all yet on the U: element so that I added to my to-do list. http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/var.c?r1=1.224r2=1.225diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.224 php-src/ext/standard/var.c:1.225 --- php-src/ext/standard/var.c:1.224Fri Mar 10 08:43:14 2006 +++ php-src/ext/standard/var.c Wed Mar 15 09:50:47 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.224 2006/03/10 08:43:14 dmitry Exp $ */ +/* $Id: var.c,v 1.225 2006/03/15 09:50:47 derick Exp $ */ @@ -681,11 +681,15 @@ for(i=0; ilen; /* U16_NEXT post-increments */) { U16_NEXT(ustr, i, len, c); - smart_str_appendl(buf, \\u, 2); - smart_str_appendc(buf, hex[(c 12) 0xf]); - smart_str_appendc(buf, hex[(c 8) 0xf]); - smart_str_appendc(buf, hex[(c 4) 0xf]); - smart_str_appendc(buf, hex[(c 0) 0xf]); + if (c 128) { + smart_str_appendc(buf, c 0xff); + } else { + smart_str_appendl(buf, \\u, 2); + smart_str_appendc(buf, hex[(c 12) 0xf]); + smart_str_appendc(buf, hex[(c 8) 0xf]); + smart_str_appendc(buf, hex[(c 4) 0xf]); + smart_str_appendc(buf, hex[(c 0) 0xf]); + } } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
dmitry Fri Mar 10 08:43:14 2006 UTC Modified files: /php-src/ext/standard var.c Log: Fixed debug_zval_dump() to support private and protected members http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/var.c?r1=1.223r2=1.224diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.223 php-src/ext/standard/var.c:1.224 --- php-src/ext/standard/var.c:1.223Thu Mar 2 13:12:45 2006 +++ php-src/ext/standard/var.c Fri Mar 10 08:43:14 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.223 2006/03/02 13:12:45 dmitry Exp $ */ +/* $Id: var.c,v 1.224 2006/03/10 08:43:14 dmitry Exp $ */ @@ -338,12 +338,46 @@ return 0; } +static int zval_object_property_dump(zval **zv, int num_args, va_list args, zend_hash_key *hash_key) +{ + int level; + zstr prop_name, class_name; + int verbose; + TSRMLS_FETCH(); + + level = va_arg(args, int); + verbose = va_arg(args, int); + + if (hash_key-nKeyLength ==0 ) { /* numeric key */ + php_printf(%*c[%ld]=\n, level + 1, ' ', hash_key-h); + } else { /* string key */ + int is_unicode = hash_key-type == IS_UNICODE; + + zend_u_unmangle_property_name(hash_key-type, hash_key-arKey, class_name, prop_name); + php_printf(%*c[, level + 1, ' '); + + if (class_name.s) { + if (class_name.s[0]=='*') { + php_printf(%s\%R\:protected, is_unicode ? u : , hash_key-type, prop_name); + } else { + php_printf(%s\%R\:%s\%R\:private, is_unicode ? u : , hash_key-type, prop_name, is_unicode ? u : , hash_key-type, class_name); + } + } else { + php_printf(%s\%R\, is_unicode ? u : , hash_key-type, prop_name); + } + ZEND_PUTS(]=\n); + } + php_debug_zval_dump(zv, level + 2, 1 TSRMLS_CC); + return 0; +} + PHPAPI void php_debug_zval_dump(zval **struc, int level, int verbose TSRMLS_DC) { HashTable *myht = NULL; zstr class_name; zend_uint class_name_len; zend_class_entry *ce; + int (*zval_element_dump_func)(zval**, int, va_list, zend_hash_key*); if (level 1) { php_printf(%*c, level - 1, ' '); @@ -379,6 +413,7 @@ return; } php_printf(%sarray(%d) refcount(%u){\n, COMMON, zend_hash_num_elements(myht), Z_REFCOUNT_PP(struc)); + zval_element_dump_func = zval_array_element_dump; goto head_done; case IS_OBJECT: myht = Z_OBJPROP_PP(struc); @@ -390,9 +425,10 @@ Z_OBJ_HANDLER(**struc, get_class_name)(*struc, class_name, class_name_len, 0 TSRMLS_CC); php_printf(%sobject(%v)#%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(class_name.v); + zval_element_dump_func = zval_object_property_dump; head_done: if (myht) { - zend_hash_apply_with_arguments(myht, (apply_func_args_t) zval_array_element_dump, 1, level, (Z_TYPE_PP(struc) == IS_ARRAY ? 0 : 1)); + zend_hash_apply_with_arguments(myht, (apply_func_args_t) zval_element_dump_func, 1, level, (Z_TYPE_PP(struc) == IS_ARRAY ? 0 : 1)); } if (level 1) { php_printf(%*c, level-1, ' '); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
dmitry Wed Feb 22 13:47:40 2006 UTC Modified files: /php-src/ext/standard var.c Log: Unicode support: fixed serealization of Serializable and IncompleteClass http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/var.c?r1=1.219r2=1.220diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.219 php-src/ext/standard/var.c:1.220 --- php-src/ext/standard/var.c:1.219Tue Feb 21 20:12:42 2006 +++ php-src/ext/standard/var.c Wed Feb 22 13:47:40 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.219 2006/02/21 20:12:42 dmitry Exp $ */ +/* $Id: var.c,v 1.220 2006/02/22 13:47:40 dmitry Exp $ */ @@ -697,6 +697,7 @@ if (count 0) { zstr key; + unsigned int key_len; zval **d, **name; ulong index; HashPosition pos; @@ -709,14 +710,15 @@ 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, + i = zend_hash_get_current_key_ex(HASH_OF(retval_ptr), key, key_len, index, 0, pos); if (i == HASH_KEY_NON_EXISTANT) break; - /* FIXME: Unicode support??? */ - if (incomplete_class strcmp(key.s, MAGIC_MEMBER) == 0) { + if (incomplete_class + key_len == sizeof(MAGIC_MEMBER) + ZEND_U_EQUAL(i, key, key_len-1, MAGIC_MEMBER, sizeof(MAGIC_MEMBER)-1)) { continue; } zend_hash_get_current_data_ex(HASH_OF(retval_ptr), @@ -869,8 +871,13 @@ smart_str_appendl(buf, C:, 2); smart_str_append_long(buf, Z_OBJCE_PP(struc)-name_length); smart_str_appendl(buf, :\, 2); - /* FIXME: Unicode support??? */ - smart_str_appendl(buf, Z_OBJCE_PP(struc)-name.s, Z_OBJCE_PP(struc)-name_length); + + if (UG(unicode)) { + php_var_serialize_ustr(buf, Z_OBJCE_PP(struc)-name.u, Z_OBJCE_PP(struc)-name_length); + } else { + smart_str_appendl(buf, Z_OBJCE_PP(struc)-name.s, Z_OBJCE_PP(struc)-name_length); + } + smart_str_appendl(buf, \:, 2); smart_str_append_long(buf, serialized_length); @@ -948,8 +955,9 @@ if (i == HASH_KEY_NON_EXISTANT) break; - /* FIXME: Unicode support??? */ - if (incomplete_class strcmp(key.s, MAGIC_MEMBER) == 0) { + if (incomplete_class + key_len == sizeof(MAGIC_MEMBER) + ZEND_U_EQUAL(i, key, key_len-1, MAGIC_MEMBER, sizeof(MAGIC_MEMBER)-1)) { continue; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
dmitry Wed Feb 22 14:20:54 2006 UTC Modified files: /php-src/ext/standard var.c Log: Unicode support: fixed serialization of Serializable http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/var.c?r1=1.220r2=1.221diff_format=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.220 php-src/ext/standard/var.c:1.221 --- php-src/ext/standard/var.c:1.220Wed Feb 22 13:47:40 2006 +++ php-src/ext/standard/var.c Wed Feb 22 14:20:54 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.220 2006/02/22 13:47:40 dmitry Exp $ */ +/* $Id: var.c,v 1.221 2006/02/22 14:20:54 dmitry Exp $ */ @@ -882,7 +882,11 @@ smart_str_append_long(buf, serialized_length); smart_str_appendl(buf, :{, 2); - smart_str_appendl(buf, serialized_data, serialized_length); + if (UG(unicode)) { + php_var_serialize_ustr(buf, (UChar*)serialized_data, serialized_length); + } else { + smart_str_appendl(buf, serialized_data, serialized_length); + } smart_str_appendc(buf, '}'); } else { smart_str_appendl(buf, N;, 2); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
dmitry Wed Dec 7 04:41:27 2005 EDT Modified files: /php-src/ext/standard var.c Log: Fixed sleep() magic method with private and protected members http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.215r2=1.216ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.215 php-src/ext/standard/var.c:1.216 --- php-src/ext/standard/var.c:1.215Mon Oct 17 11:03:04 2005 +++ php-src/ext/standard/var.c Wed Dec 7 04:41:22 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.215 2005/10/17 15:03:04 derick Exp $ */ +/* $Id: var.c,v 1.216 2005/12/07 09:41:22 dmitry Exp $ */ @@ -777,11 +777,11 @@ do { zend_u_mangle_property_name(priv_name, prop_name_length, Z_TYPE_PP(name), ce-name, ce-name_length, Z_STRVAL_PP(name), Z_STRLEN_PP(name), ce-type ZEND_INTERNAL_CLASS); - if (zend_u_hash_find(Z_OBJPROP_PP(struc), Z_TYPE_PP(name), priv_name, prop_name_length, (void *) d) == SUCCESS) { + if (zend_u_hash_find(Z_OBJPROP_PP(struc), Z_TYPE_PP(name), priv_name, prop_name_length+1, (void *) d) == SUCCESS) { if (Z_TYPE_PP(name) == IS_UNICODE) { - php_var_serialize_unicode(buf, (UChar *)priv_name, prop_name_length-1); + php_var_serialize_unicode(buf, (UChar *)priv_name, prop_name_length); } else { - php_var_serialize_string(buf, priv_name, prop_name_length-1); + php_var_serialize_string(buf, priv_name, prop_name_length); } efree(priv_name); php_var_serialize_intern(buf, d, var_hash TSRMLS_CC); @@ -790,11 +790,11 @@ efree(priv_name); zend_u_mangle_property_name(prot_name, prop_name_length, Z_TYPE_PP(name), *, 1, Z_STRVAL_PP(name), Z_STRLEN_PP(name), ce-type ZEND_INTERNAL_CLASS); - if (zend_u_hash_find(Z_OBJPROP_PP(struc), Z_TYPE_PP(name), prot_name, prop_name_length, (void *) d) == SUCCESS) { + if (zend_u_hash_find(Z_OBJPROP_PP(struc), Z_TYPE_PP(name), prot_name, prop_name_length+1, (void *) d) == SUCCESS) { if (Z_TYPE_PP(name) == IS_UNICODE) { - php_var_serialize_unicode(buf, (UChar *)prot_name, prop_name_length-1); + php_var_serialize_unicode(buf, (UChar *)prot_name, prop_name_length); } else { - php_var_serialize_string(buf, prot_name, prop_name_length-1); + php_var_serialize_string(buf, prot_name, prop_name_length); } efree(prot_name); php_var_serialize_intern(buf, d, var_hash TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/array 007.phpt array_intersect_1.phpt var_export.phpt var_export3.phpt
derick Mon Oct 17 11:03:12 2005 EDT Modified files: /php-src/ext/standard var.c /php-src/ext/standard/tests/array var_export3.phpt 007.phpt array_intersect_1.phpt var_export.phpt Log: - MF51: Fixed bug #29361 (var_export() producing invalid code). http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.214r2=1.215ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.214 php-src/ext/standard/var.c:1.215 --- php-src/ext/standard/var.c:1.214Mon Sep 12 03:14:54 2005 +++ php-src/ext/standard/var.c Mon Oct 17 11:03:04 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.214 2005/09/12 07:14:54 dmitry Exp $ */ +/* $Id: var.c,v 1.215 2005/10/17 15:03:04 derick Exp $ */ @@ -497,18 +497,9 @@ if (hash_key-nKeyLength != 0) { php_printf(%*c, level + 1, ' '); zend_u_unmangle_property_name(hash_key-type, hash_key-u.string, class_name, prop_name); - if (class_name) { - if (class_name[0] == '*') { - php_printf(protected); - } else { - php_printf(private); - } - } else { - php_printf(public); - } - php_printf( $%R = , hash_key-type, prop_name); + php_printf( '%R' = , hash_key-type, prop_name); php_var_export(zv, level + 2 TSRMLS_CC); - PUTS (;\n); + PUTS (,\n); } return 0; } @@ -564,7 +555,7 @@ php_printf(\n%*c, level - 1, ' '); } Z_OBJ_HANDLER(**struc, get_class_name)(*struc, class_name, class_name_len, 0 TSRMLS_CC); - php_printf (class %v {\n, class_name); + php_printf (%v::__set_state(array(\n, class_name); efree(class_name); if (myht) { zend_hash_apply_with_arguments(myht, (apply_func_args_t) php_object_element_export, 1, level); @@ -572,7 +563,7 @@ if (level 1) { php_printf(%*c, level - 1, ' '); } - PUTS(}); + php_printf ())); break; default: PUTS (NULL); http://cvs.php.net/diff.php/php-src/ext/standard/tests/array/var_export3.phpt?r1=1.1r2=1.2ty=u Index: php-src/ext/standard/tests/array/var_export3.phpt diff -u /dev/null php-src/ext/standard/tests/array/var_export3.phpt:1.2 --- /dev/null Mon Oct 17 11:03:12 2005 +++ php-src/ext/standard/tests/array/var_export3.phpt Mon Oct 17 11:03:12 2005 @@ -0,0 +1,24 @@ +--TEST-- +var_export() and classes +--FILE-- +?php +class kake { + public $mann; + protected $kvinne; + + function __construct() + { + $this-mann = 42; + $this-kvinne = 43; + } +} + +$kake = new kake; + +var_export($kake); +? +--EXPECT-- +kake::__set_state(array( + 'mann' = 42, + 'kvinne' = 43, +)) http://cvs.php.net/diff.php/php-src/ext/standard/tests/array/007.phpt?r1=1.11r2=1.12ty=u Index: php-src/ext/standard/tests/array/007.phpt diff -u php-src/ext/standard/tests/array/007.phpt:1.11 php-src/ext/standard/tests/array/007.phpt:1.12 --- php-src/ext/standard/tests/array/007.phpt:1.11 Mon Aug 15 10:37:55 2005 +++ php-src/ext/standard/tests/array/007.phpt Mon Oct 17 11:03:12 2005 @@ -111,7 +111,7 @@ echo '$a='.var_export($a,TRUE).;\n; echo '$b='.var_export($b,TRUE).;\n; echo 'var_dump(array_diff_assoc($a, $b));'.\n; -var_dump(@array_diff_assoc($a, $b)); +var_dump(array_diff_assoc($a, $b)); echo '$a='.var_export($a,TRUE).;\n; @@ -254,57 +254,57 @@ -=-=-=-=-=-=-=-=- New functionality from 5.0.0 -=-=-=-=-=-=-=- $a=array ( '0.1' = - class cr { -private $priv_member = 9; -public $public_member = 9; - }, + cr::__set_state(array( + 'priv_member' = 9, + 'public_member' = 9, + )), '0.5' = - class cr { -private $priv_member = 12; -public $public_member = 12; - }, + cr::__set_state(array( + 'priv_member' = 12, + 'public_member' = 12, + )), 0 = - class cr { -private $priv_member = 23; -public $public_member = 23; - }, + cr::__set_state(array( + 'priv_member' = 23, + 'public_member' = 23, + )), 1 = - class cr { -private $priv_member = 4; -public $public_member = 4; - }, + cr::__set_state(array( + 'priv_member' = 4, + 'public_member' = 4, + )), 2 = - class cr { -private $priv_member = -15; -public $public_member = -15; - }, + cr::__set_state(array( + 'priv_member' = -15, + 'public_member' = -15, + )), ); $b=array ( '0.2' = - class cr { -private $priv_member = 9; -public $public_member = 9; - }, +
[PHP-CVS] cvs: php-src /ext/standard var.c
andrei Tue Aug 23 13:22:54 2005 EDT Modified files: /php-src/ext/standard var.c Log: Fix verbosity for var_inspect(). http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.212r2=1.213ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.212 php-src/ext/standard/var.c:1.213 --- php-src/ext/standard/var.c:1.212Thu Aug 18 07:13:50 2005 +++ php-src/ext/standard/var.c Tue Aug 23 13:22:54 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.212 2005/08/18 11:13:50 dmitry Exp $ */ +/* $Id: var.c,v 1.213 2005/08/23 17:22:54 andrei Exp $ */ @@ -142,7 +142,7 @@ } php_printf(]=\n); } - php_var_dump(zv, level + 2, 0 TSRMLS_CC); + php_var_dump(zv, level + 2, verbose TSRMLS_CC); return 0; } @@ -216,7 +216,7 @@ break; case IS_UNICODE: php_printf(%sunicode(%d) , COMMON, u_countChar32((*struc)-value.ustr.val, (*struc)-value.ustr.len)); - php_var_dump_unicode((*struc)-value.ustr.val, (*struc)-value.ustr.len, 0, \, 0 TSRMLS_CC); + php_var_dump_unicode((*struc)-value.ustr.val, (*struc)-value.ustr.len, verbose, \, 0 TSRMLS_CC); PUTS(\n); break; case IS_ARRAY: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
dmitry Thu Aug 18 07:13:53 2005 EDT Modified files: /php-src/ext/standard var.c Log: var_export() should escape \ and ' characters. http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.211r2=1.212ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.211 php-src/ext/standard/var.c:1.212 --- php-src/ext/standard/var.c:1.211Wed Aug 17 11:11:41 2005 +++ php-src/ext/standard/var.c Thu Aug 18 07:13:50 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.211 2005/08/17 15:11:41 dmitry Exp $ */ +/* $Id: var.c,v 1.212 2005/08/18 11:13:50 dmitry Exp $ */ @@ -42,7 +42,7 @@ /* {{{ php_var_dump */ /* temporary, for debugging */ -static void php_var_dump_unicode(UChar *ustr, int32_t length, int verbose, char *quote TSRMLS_DC) +static void php_var_dump_unicode(UChar *ustr, int32_t length, int verbose, char *quote, int escape TSRMLS_DC) { UChar32 c; int32_t i; @@ -72,7 +72,16 @@ } ZEND_PUTS(quote); - PHPWRITE(out, clen); + if (escape) { + char *str; + int str_len; + + str = php_addcslashes(out, clen, str_len, 0, '\\, 2 TSRMLS_CC); + PHPWRITE(str, str_len); + efree(str); + } else { + PHPWRITE(out, clen); + } ZEND_PUTS(quote); if (verbose) { ZEND_PUTS( {); @@ -129,7 +138,7 @@ php_printf(\); } else if (hash_key-type == IS_UNICODE) { php_printf(u); - php_var_dump_unicode(hash_key-u.unicode, hash_key-nKeyLength-1, verbose, \ TSRMLS_CC); + php_var_dump_unicode(hash_key-u.unicode, hash_key-nKeyLength-1, verbose, \, 0 TSRMLS_CC); } php_printf(]=\n); } @@ -207,7 +216,7 @@ break; case IS_UNICODE: php_printf(%sunicode(%d) , COMMON, u_countChar32((*struc)-value.ustr.val, (*struc)-value.ustr.len)); - php_var_dump_unicode((*struc)-value.ustr.val, (*struc)-value.ustr.len, 0, \ TSRMLS_CC); + php_var_dump_unicode((*struc)-value.ustr.val, (*struc)-value.ustr.len, 0, \, 0 TSRMLS_CC); PUTS(\n); break; case IS_ARRAY: @@ -334,7 +343,7 @@ php_printf(\); } else if (hash_key-type == IS_UNICODE) { php_printf(u); - php_var_dump_unicode(hash_key-u.unicode, hash_key-nKeyLength-1, 1, \ TSRMLS_CC); + php_var_dump_unicode(hash_key-u.unicode, hash_key-nKeyLength-1, 1, \, 0 TSRMLS_CC); } php_printf(]=\n); } @@ -378,7 +387,7 @@ break; case IS_UNICODE: php_printf(%sunicode(%d) , COMMON, u_countChar32((*struc)-value.ustr.val, (*struc)-value.ustr.len)); - php_var_dump_unicode((*struc)-value.ustr.val, (*struc)-value.ustr.len, verbose, \ TSRMLS_CC); + php_var_dump_unicode((*struc)-value.ustr.val, (*struc)-value.ustr.len, verbose, \, 0 TSRMLS_CC); php_printf( refcount(%u)\n, Z_REFCOUNT_PP(struc)); break; case IS_ARRAY: @@ -461,7 +470,7 @@ } else { /* string key */ php_printf(%*c', level + 1, ' '); if (hash_key-type == IS_UNICODE) { - php_var_dump_unicode(hash_key-u.unicode, hash_key-nKeyLength-1, 0, TSRMLS_CC); + php_var_dump_unicode(hash_key-u.unicode, hash_key-nKeyLength-1, 0, , 1 TSRMLS_CC); } else { char *key; int key_len; @@ -535,10 +544,7 @@ efree (tmp_str); break; case IS_UNICODE: -/* TODO - tmp_str = php_addcslashes(Z_STRVAL_PP(struc), Z_STRLEN_PP(struc), tmp_len, 0, '\\, 2 TSRMLS_CC); -*/ - php_var_dump_unicode(Z_USTRVAL_PP(struc), Z_USTRLEN_PP(struc), 0, ' TSRMLS_CC); + php_var_dump_unicode(Z_USTRVAL_PP(struc), Z_USTRLEN_PP(struc), 0, ', 1 TSRMLS_CC); break; case IS_ARRAY: myht = Z_ARRVAL_PP(struc); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c /tests/reflection 006.phpt ZendEngine2 zend_interfaces.c zend_object_handlers.c zend_object_handlers.h zend_reflection_api.c zend_vm_def.h zend_vm_execute.
dmitry Wed Aug 17 09:10:05 2005 EDT Modified files: /ZendEngine2zend_interfaces.c zend_object_handlers.c zend_object_handlers.h zend_reflection_api.c zend_vm_def.h zend_vm_execute.h zend_vm_opcodes.h /php-src/ext/standard var.c /php-src/tests/reflection 006.phpt Log: Unicode support http://cvs.php.net/diff.php/ZendEngine2/zend_interfaces.c?r1=1.35r2=1.36ty=u Index: ZendEngine2/zend_interfaces.c diff -u ZendEngine2/zend_interfaces.c:1.35 ZendEngine2/zend_interfaces.c:1.36 --- ZendEngine2/zend_interfaces.c:1.35 Fri Aug 12 07:29:26 2005 +++ ZendEngine2/zend_interfaces.c Wed Aug 17 09:10:02 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: zend_interfaces.c,v 1.35 2005/08/12 11:29:26 dmitry Exp $ */ +/* $Id: zend_interfaces.c,v 1.36 2005/08/17 13:10:02 dmitry Exp $ */ #include zend.h #include zend_API.h @@ -431,6 +431,11 @@ *buf_len = Z_STRLEN_P(retval); result = SUCCESS; break; + case IS_UNICODE: + *buffer = eustrndup(Z_USTRVAL_P(retval), Z_USTRLEN_P(retval)); + *buf_len = Z_USTRLEN_P(retval); + result = SUCCESS; + break; default: /* failure */ result = FAILURE; break; @@ -439,7 +444,7 @@ } if (result == FAILURE) { - zend_throw_exception_ex(NULL, 0 TSRMLS_CC, %s::serialize() must return a string or NULL, ce-name); + zend_throw_exception_ex(NULL, 0 TSRMLS_CC, %v::serialize() must return a string or NULL, ce-name); } return result; } http://cvs.php.net/diff.php/ZendEngine2/zend_object_handlers.c?r1=1.139r2=1.140ty=u Index: ZendEngine2/zend_object_handlers.c diff -u ZendEngine2/zend_object_handlers.c:1.139 ZendEngine2/zend_object_handlers.c:1.140 --- ZendEngine2/zend_object_handlers.c:1.139Mon Aug 15 10:39:18 2005 +++ ZendEngine2/zend_object_handlers.c Wed Aug 17 09:10:02 2005 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: zend_object_handlers.c,v 1.139 2005/08/15 14:39:18 dmitry Exp $ */ +/* $Id: zend_object_handlers.c,v 1.140 2005/08/17 13:10:02 dmitry Exp $ */ #include zend.h #include zend_globals.h @@ -816,13 +816,12 @@ } -ZEND_API zval **zend_std_get_static_property(zend_class_entry *ce, char *property_name, int property_name_len, zend_bool silent TSRMLS_DC) +ZEND_API zval **zend_std_get_static_property(zend_class_entry *ce, zend_uchar type, void *property_name, int property_name_len, zend_bool silent TSRMLS_DC) { zval **retval = NULL; zend_class_entry *tmp_ce = ce; zend_property_info *property_info; zend_property_info std_property_info; - zend_uchar type = UG(unicode)?IS_UNICODE:IS_STRING; if (zend_u_hash_find(ce-properties_info, type, property_name, property_name_len+1, (void **) property_info)==FAILURE) { std_property_info.flags = ZEND_ACC_PUBLIC; http://cvs.php.net/diff.php/ZendEngine2/zend_object_handlers.h?r1=1.47r2=1.48ty=u Index: ZendEngine2/zend_object_handlers.h diff -u ZendEngine2/zend_object_handlers.h:1.47 ZendEngine2/zend_object_handlers.h:1.48 --- ZendEngine2/zend_object_handlers.h:1.47 Wed Aug 3 09:30:55 2005 +++ ZendEngine2/zend_object_handlers.h Wed Aug 17 09:10:02 2005 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: zend_object_handlers.h,v 1.47 2005/08/03 13:30:55 sniper Exp $ */ +/* $Id: zend_object_handlers.h,v 1.48 2005/08/17 13:10:02 dmitry Exp $ */ #ifndef ZEND_OBJECT_HANDLERS_H #define ZEND_OBJECT_HANDLERS_H @@ -134,7 +134,7 @@ extern ZEND_API zend_object_handlers std_object_handlers; BEGIN_EXTERN_C() ZEND_API union _zend_function *zend_std_get_static_method(zend_class_entry *ce, char *function_name_strval, int function_name_strlen TSRMLS_DC); -ZEND_API zval **zend_std_get_static_property(zend_class_entry *ce, char *property_name, int property_name_len, zend_bool silent TSRMLS_DC); +ZEND_API zval **zend_std_get_static_property(zend_class_entry *ce, zend_uchar type, void *property_name, int property_name_len, zend_bool silent TSRMLS_DC); ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, char *property_name, int property_name_len TSRMLS_DC); ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zval *member, int silent TSRMLS_DC); http://cvs.php.net/diff.php/ZendEngine2/zend_reflection_api.c?r1=1.169r2=1.170ty=u Index: ZendEngine2/zend_reflection_api.c diff -u ZendEngine2/zend_reflection_api.c:1.169 ZendEngine2/zend_reflection_api.c:1.170 --- ZendEngine2/zend_reflection_api.c:1.169 Wed Aug 17 07:57:10 2005 +++
[PHP-CVS] cvs: php-src /ext/standard var.c
dmitry Wed Aug 17 11:11:41 2005 EDT Modified files: /php-src/ext/standard var.c Log: Proper handling of unicode strings with \0 in the middle http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.210r2=1.211ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.210 php-src/ext/standard/var.c:1.211 --- php-src/ext/standard/var.c:1.210Wed Aug 17 09:10:04 2005 +++ php-src/ext/standard/var.c Wed Aug 17 11:11:41 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.210 2005/08/17 13:10:04 dmitry Exp $ */ +/* $Id: var.c,v 1.211 2005/08/17 15:11:41 dmitry Exp $ */ @@ -42,7 +42,7 @@ /* {{{ php_var_dump */ /* temporary, for debugging */ -static void php_var_dump_unicode(UChar *ustr, int32_t length, int verbose TSRMLS_DC) +static void php_var_dump_unicode(UChar *ustr, int32_t length, int verbose, char *quote TSRMLS_DC) { UChar32 c; int32_t i; @@ -51,7 +51,8 @@ char *out = NULL; if (length == 0) { - php_printf(\\); + ZEND_PUTS(quote); + ZEND_PUTS(quote); return; } @@ -70,9 +71,11 @@ return; } + ZEND_PUTS(quote); + PHPWRITE(out, clen); + ZEND_PUTS(quote); if (verbose) { - php_printf(\%s\ {, out); - + ZEND_PUTS( {); /* output the code points (not code units) */ if(length=0) { /* s is not NUL-terminated */ @@ -91,8 +94,6 @@ } } php_printf( }); - } else { - php_printf(\%s\, out); } efree(out); } @@ -128,7 +129,7 @@ php_printf(\); } else if (hash_key-type == IS_UNICODE) { php_printf(u); - php_var_dump_unicode(hash_key-u.unicode, hash_key-nKeyLength-1, verbose TSRMLS_CC); + php_var_dump_unicode(hash_key-u.unicode, hash_key-nKeyLength-1, verbose, \ TSRMLS_CC); } php_printf(]=\n); } @@ -205,9 +206,8 @@ PUTS(\\n); break; case IS_UNICODE: - /* temporary, for debugging */ php_printf(%sunicode(%d) , COMMON, u_countChar32((*struc)-value.ustr.val, (*struc)-value.ustr.len)); - php_var_dump_unicode((*struc)-value.ustr.val, (*struc)-value.ustr.len, verbose TSRMLS_CC); + php_var_dump_unicode((*struc)-value.ustr.val, (*struc)-value.ustr.len, 0, \ TSRMLS_CC); PUTS(\n); break; case IS_ARRAY: @@ -334,7 +334,7 @@ php_printf(\); } else if (hash_key-type == IS_UNICODE) { php_printf(u); - php_var_dump_unicode(hash_key-u.unicode, hash_key-nKeyLength-1, 1 TSRMLS_CC); + php_var_dump_unicode(hash_key-u.unicode, hash_key-nKeyLength-1, 1, \ TSRMLS_CC); } php_printf(]=\n); } @@ -377,9 +377,8 @@ php_printf(\ refcount(%u)\n, Z_REFCOUNT_PP(struc)); break; case IS_UNICODE: - /* temporary, for debugging */ php_printf(%sunicode(%d) , COMMON, u_countChar32((*struc)-value.ustr.val, (*struc)-value.ustr.len)); - php_var_dump_unicode((*struc)-value.ustr.val, (*struc)-value.ustr.len, verbose TSRMLS_CC); + php_var_dump_unicode((*struc)-value.ustr.val, (*struc)-value.ustr.len, verbose, \ TSRMLS_CC); php_printf( refcount(%u)\n, Z_REFCOUNT_PP(struc)); break; case IS_ARRAY: @@ -462,7 +461,7 @@ } else { /* string key */ php_printf(%*c', level + 1, ' '); if (hash_key-type == IS_UNICODE) { - php_printf(%r, hash_key-u.unicode); + php_var_dump_unicode(hash_key-u.unicode, hash_key-nKeyLength-1, 0, TSRMLS_CC); } else { char *key; int key_len; @@ -539,9 +538,7 @@ /* TODO tmp_str = php_addcslashes(Z_STRVAL_PP(struc), Z_STRLEN_PP(struc), tmp_len, 0, '\\, 2 TSRMLS_CC); */ - PUTS ('); - php_printf(%r, Z_USTRVAL_PP(struc)); - PUTS ('); + php_var_dump_unicode(Z_USTRVAL_PP(struc), Z_USTRLEN_PP(struc), 0, ' TSRMLS_CC); break; case IS_ARRAY: myht = Z_ARRVAL_PP(struc); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/array bug25708.phpt bug26458.phpt
dmitry Tue Aug 16 05:25:05 2005 EDT Modified files: /php-src/ext/standard var.c /php-src/ext/standard/tests/array bug25708.phpt bug26458.phpt Log: Unicode support http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.208r2=1.209ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.208 php-src/ext/standard/var.c:1.209 --- php-src/ext/standard/var.c:1.208Sun Aug 14 17:26:01 2005 +++ php-src/ext/standard/var.c Tue Aug 16 05:25:03 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.208 2005/08/14 21:26:01 helly Exp $ */ +/* $Id: var.c,v 1.209 2005/08/16 09:25:03 dmitry Exp $ */ @@ -380,7 +380,7 @@ /* temporary, for debugging */ php_printf(%sunicode(%d) , COMMON, u_countChar32((*struc)-value.ustr.val, (*struc)-value.ustr.len)); php_var_dump_unicode((*struc)-value.ustr.val, (*struc)-value.ustr.len, verbose TSRMLS_CC); - php_printf(\ refcount(%u)\n, Z_REFCOUNT_PP(struc)); + php_printf( refcount(%u)\n, Z_REFCOUNT_PP(struc)); break; case IS_ARRAY: myht = Z_ARRVAL_PP(struc); http://cvs.php.net/diff.php/php-src/ext/standard/tests/array/bug25708.phpt?r1=1.2r2=1.3ty=u Index: php-src/ext/standard/tests/array/bug25708.phpt diff -u php-src/ext/standard/tests/array/bug25708.phpt:1.2 php-src/ext/standard/tests/array/bug25708.phpt:1.3 --- php-src/ext/standard/tests/array/bug25708.phpt:1.2 Mon Aug 15 10:37:55 2005 +++ php-src/ext/standard/tests/array/bug25708.phpt Tue Aug 16 05:25:04 2005 @@ -252,9 +252,9 @@ long(3) refcount(2) -- long(4) refcount(1) -unicode(1) x refcount(1) +unicode(1) x { 0078 } refcount(1) long(4) refcount(1) -unicode(1) x refcount(1) +unicode(1) x { 0078 } refcount(1) long(3) refcount(2) -- long(1) refcount(2) @@ -290,9 +290,9 @@ long(3) refcount(2) -- long(4) refcount(1) -unicode(1) x refcount(1) +unicode(1) x { 0078 } refcount(1) long(4) refcount(1) -unicode(1) x refcount(1) +unicode(1) x { 0078 } refcount(1) long(3) refcount(2) -- long(1) refcount(2) @@ -328,9 +328,9 @@ long(3) refcount(2) -- long(4) refcount(1) -unicode(1) x refcount(1) +unicode(1) x { 0078 } refcount(1) long(4) refcount(1) -unicode(1) x refcount(1) +unicode(1) x { 0078 } refcount(1) long(3) refcount(2) -- long(1) refcount(2) @@ -366,13 +366,13 @@ long(3) refcount(2) -- long(4) refcount(1) -unicode(1) x refcount(1) +unicode(1) x { 0078 } refcount(1) long(4) refcount(1) -unicode(1) x refcount(1) +unicode(1) x { 0078 } refcount(1) long(3) refcount(2) -- long(1) refcount(2) long(2) refcount(2) r -unicode(2) ok refcount(2) -unicode(2) ok refcount(2) +unicode(2) ok { 006f 006b } refcount(2) +unicode(2) ok { 006f 006b } refcount(2) http://cvs.php.net/diff.php/php-src/ext/standard/tests/array/bug26458.phpt?r1=1.1r2=1.2ty=u Index: php-src/ext/standard/tests/array/bug26458.phpt -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
helly Sun Aug 14 11:08:39 2005 EDT Modified files: /php-src/ext/standard var.c Log: - Show classname very needed - No 3rd which doesn't help parsing # Does the class name need to be printed as uname ? http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.205r2=1.206ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.205 php-src/ext/standard/var.c:1.206 --- php-src/ext/standard/var.c:1.205Fri Aug 12 14:54:18 2005 +++ php-src/ext/standard/var.c Sun Aug 14 11:08:38 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.205 2005/08/12 18:54:18 tony2001 Exp $ */ +/* $Id: var.c,v 1.206 2005/08/14 15:08:38 helly Exp $ */ @@ -163,7 +163,7 @@ if (class_name[0]=='*') { ZEND_PUTS(:protected); } else { - ZEND_PUTS(:private); + php_printf(:%s:private, class_name); } } else { if (hash_key-type == IS_STRING) { @@ -173,9 +173,8 @@ php_printf(u); php_var_dump_unicode(hash_key-u.unicode, hash_key-nKeyLength-1, verbose TSRMLS_CC); } - ZEND_PUTS(:public); } - ZEND_PUTS(\]=\n); + ZEND_PUTS(]=\n); } php_var_dump(zv, level + 2, verbose TSRMLS_CC); return 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
helly Sun Aug 14 11:18:46 2005 EDT Modified files: /php-src/ext/standard var.c Log: - If prop_name is printed as unicode then class_name needs to be treated in the exact same manner http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.206r2=1.207ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.206 php-src/ext/standard/var.c:1.207 --- php-src/ext/standard/var.c:1.206Sun Aug 14 11:08:38 2005 +++ php-src/ext/standard/var.c Sun Aug 14 11:18:46 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.206 2005/08/14 15:08:38 helly Exp $ */ +/* $Id: var.c,v 1.207 2005/08/14 15:18:46 helly Exp $ */ @@ -163,7 +163,9 @@ if (class_name[0]=='*') { ZEND_PUTS(:protected); } else { - php_printf(:%s:private, class_name); + php_printf(:u); + php_var_dump_unicode((UChar*)class_name, u_strlen((UChar*)class_name), verbose TSRMLS_CC); + ZEND_PUTS(:private); } } else { if (hash_key-type == IS_STRING) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard var.c
Hello Andrei, shouldn't we just drop that u... here and simply use %r internally? Sunday, August 14, 2005, 5:18:46 PM, you wrote: helly Sun Aug 14 11:18:46 2005 EDT Modified files: /php-src/ext/standard var.c Log: - If prop_name is printed as unicode then class_name needs to be treated in the exact same manner http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.206r2=1.207ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.206 php-src/ext/standard/var.c:1.207 --- php-src/ext/standard/var.c:1.206Sun Aug 14 11:08:38 2005 +++ php-src/ext/standard/var.c Sun Aug 14 11:18:46 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.206 2005/08/14 15:08:38 helly Exp $ */ +/* $Id: var.c,v 1.207 2005/08/14 15:18:46 helly Exp $ */ @@ -163,7 +163,9 @@ if (class_name[0]=='*') { ZEND_PUTS(:protected); } else { - php_printf(:%s:private, class_name); + php_printf(:u); + php_var_dump_unicode((UChar*)class_name, u_strlen((UChar*)class_name), verbose TSRMLS_CC); + ZEND_PUTS(:private); } } else { if (hash_key-type == IS_STRING) { Best regards, Marcus -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard var.c
This is what I get after your patch: object(test)#1 (3) { @[private_prop:u[EMAIL PROTECTED]@:private]= string(7) private @[public_prop]= string(6) public @[protected_prop:protected]= string(9) protected } The garbage instead of the classname is shown because we can't determine if the classname is in Unicode or not (though I still can see the same garbage even when the classname is in Unicode). Btw, I don't get the point in adding classname to private vars, while the class name is printed just before that: object(classname)? - No 3rd which doesn't help parsing What's the problem with the 3rd ? No we got no at the end. Marcus Boerger wrote: helly Sun Aug 14 11:18:46 2005 EDT Modified files: /php-src/ext/standard var.c Log: - If prop_name is printed as unicode then class_name needs to be treated in the exact same manner http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.206r2=1.207ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.206 php-src/ext/standard/var.c:1.207 --- php-src/ext/standard/var.c:1.206Sun Aug 14 11:08:38 2005 +++ php-src/ext/standard/var.c Sun Aug 14 11:18:46 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.206 2005/08/14 15:08:38 helly Exp $ */ +/* $Id: var.c,v 1.207 2005/08/14 15:18:46 helly Exp $ */ @@ -163,7 +163,9 @@ if (class_name[0]=='*') { ZEND_PUTS(:protected); } else { - php_printf(:%s:private, class_name); + php_printf(:u); + php_var_dump_unicode((UChar*)class_name, u_strlen((UChar*)class_name), verbose TSRMLS_CC); + ZEND_PUTS(:private); } } else { if (hash_key-type == IS_STRING) { -- Wbr, Antony Dovgal -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard var.c
On Aug 14, 2005, at 8:08 AM, Marcus Boerger wrote: hellySun Aug 14 11:08:39 2005 EDT Modified files: /php-src/ext/standardvar.c Log: - Show classname very needed - No 3rd which doesn't help parsing # Does the class name need to be printed as uname ? How would you suggest indicating that it is a Unicode string vs. normal one? Or does it matter, really? -Andrei -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard var.c
When unicode_semantics=on, all identifiers are Unicode. You can rely on that and test for it with UG(unicode) flag. -Andrei On Aug 14, 2005, at 12:00 PM, Antony Dovgal wrote: This is what I get after your patch: object(test)#1 (3) { @[private_prop:u[EMAIL PROTECTED]@:private]= string(7) private @[public_prop]= string(6) public @[protected_prop:protected]= string(9) protected } The garbage instead of the classname is shown because we can't determine if the classname is in Unicode or not (though I still can see the same garbage even when the classname is in Unicode). Btw, I don't get the point in adding classname to private vars, while the class name is printed just before that: object(classname)? - No 3rd which doesn't help parsing What's the problem with the 3rd ? No we got no at the end. Marcus Boerger wrote: hellySun Aug 14 11:18:46 2005 EDT Modified files: /php-src/ext/standard var.c Log: - If prop_name is printed as unicode then class_name needs to be treated in the exact same manner http://cvs.php.net/diff.php/php-src/ext/standard/var.c? r1=1.206r2=1.207ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.206 php-src/ext/standard/ var.c:1.207 --- php-src/ext/standard/var.c:1.206Sun Aug 14 11:08:38 2005 +++ php-src/ext/standard/var.cSun Aug 14 11:18:46 2005 @@ -18,7 +18,7 @@ + --+ */ -/* $Id: var.c,v 1.206 2005/08/14 15:08:38 helly Exp $ */ +/* $Id: var.c,v 1.207 2005/08/14 15:18:46 helly Exp $ */ @@ -163,7 +163,9 @@ if (class_name[0]=='*') { ZEND_PUTS(:protected); } else { -php_printf(:%s:private, class_name); +php_printf(:u); +php_var_dump_unicode((UChar*)class_name, u_strlen ((UChar*)class_name), verbose TSRMLS_CC); +ZEND_PUTS(:private); } } else { if (hash_key-type == IS_STRING) { -- Wbr, Antony Dovgal -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
dmitry Thu Jul 21 03:18:05 2005 EDT Modified files: /php-src/ext/standard var.c Log: Recursion protection http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.201r2=1.202ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.201 php-src/ext/standard/var.c:1.202 --- php-src/ext/standard/var.c:1.201Tue Jun 28 05:46:30 2005 +++ php-src/ext/standard/var.c Thu Jul 21 03:18:02 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.201 2005/06/28 09:46:30 stas Exp $ */ +/* $Id: var.c,v 1.202 2005/07/21 07:18:02 dmitry Exp $ */ @@ -252,10 +252,18 @@ break; case IS_ARRAY: myht = Z_ARRVAL_PP(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)); goto head_done; case IS_OBJECT: myht = Z_OBJPROP_PP(struc); + if (myht myht-nApplyCount 1) { + PUTS(*RECURSION*\n); + return; + } ce = Z_OBJCE(**struc); Z_OBJ_HANDLER(**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)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
dmitry Wed Jun 8 11:48:15 2005 EDT Modified files: /php-src/ext/standard var.c Log: Fixed incorrect usage of zend_mangle_property_name() (valgrind errors) http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.199r2=1.200ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.199 php-src/ext/standard/var.c:1.200 --- php-src/ext/standard/var.c:1.199Wed Jun 1 07:03:42 2005 +++ php-src/ext/standard/var.c Wed Jun 8 11:48:12 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.199 2005/06/01 11:03:42 dmitry Exp $ */ +/* $Id: var.c,v 1.200 2005/06/08 15:48:12 dmitry Exp $ */ /* {{{ includes @@ -584,18 +584,18 @@ do { zend_mangle_property_name(priv_name, prop_name_length, ce-name, ce-name_length, - Z_STRVAL_PP(name), Z_STRLEN_PP(name) + 1, ce-type ZEND_INTERNAL_CLASS); - if (zend_hash_find(Z_OBJPROP_PP(struc), priv_name, prop_name_length, (void *) d) == SUCCESS) { - php_var_serialize_string(buf, priv_name, prop_name_length-1); + Z_STRVAL_PP(name), Z_STRLEN_PP(name), ce-type ZEND_INTERNAL_CLASS); + if (zend_hash_find(Z_OBJPROP_PP(struc), priv_name, prop_name_length+1, (void *) d) == SUCCESS) { + php_var_serialize_string(buf, priv_name, prop_name_length); efree(priv_name); php_var_serialize_intern(buf, d, var_hash TSRMLS_CC); break; } efree(priv_name); zend_mangle_property_name(prot_name, prop_name_length, *, 1, - Z_STRVAL_PP(name), Z_STRLEN_PP(name) + 1, ce-type ZEND_INTERNAL_CLASS); - if (zend_hash_find(Z_OBJPROP_PP(struc), prot_name, prop_name_length, (void *) d) == SUCCESS) { - php_var_serialize_string(buf, prot_name, prop_name_length - 1); + Z_STRVAL_PP(name), Z_STRLEN_PP(name), ce-type ZEND_INTERNAL_CLASS); + if (zend_hash_find(Z_OBJPROP_PP(struc), prot_name, prop_name_length+1, (void *) d) == SUCCESS) { + php_var_serialize_string(buf, prot_name, prop_name_length); efree(prot_name); php_var_serialize_intern(buf, d, var_hash TSRMLS_CC); break; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c var_unserializer.c var_unserializer.re
dmitry Wed Jun 1 07:03:43 2005 EDT Modified files: /php-src/ext/standard var.c var_unserializer.c var_unserializer.re Log: Fixed bug #30791 (magic methods (__sleep/__wakeup/__toString) call __call if object is overloaded) http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.198r2=1.199ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.198 php-src/ext/standard/var.c:1.199 --- php-src/ext/standard/var.c:1.198Wed Feb 23 06:17:52 2005 +++ php-src/ext/standard/var.c Wed Jun 1 07:03:42 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.198 2005/02/23 11:17:52 stas Exp $ */ +/* $Id: var.c,v 1.199 2005/06/01 11:03:42 dmitry Exp $ */ /* {{{ includes @@ -696,7 +696,8 @@ return; } - if(Z_OBJCE_PP(struc) != PHP_IC_ENTRY) { + if (Z_OBJCE_PP(struc) != PHP_IC_ENTRY + zend_hash_exists(Z_OBJCE_PP(struc)-function_table, __sleep, sizeof(__sleep))) { INIT_PZVAL(fname); ZVAL_STRINGL(fname, __sleep, sizeof(__sleep) - 1, 0); res = call_user_function_ex(CG(function_table), struc, fname, http://cvs.php.net/diff.php/php-src/ext/standard/var_unserializer.c?r1=1.64r2=1.65ty=u Index: php-src/ext/standard/var_unserializer.c diff -u php-src/ext/standard/var_unserializer.c:1.64 php-src/ext/standard/var_unserializer.c:1.65 --- php-src/ext/standard/var_unserializer.c:1.64Tue May 31 05:41:46 2005 +++ php-src/ext/standard/var_unserializer.c Wed Jun 1 07:03:42 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var_unserializer.c,v 1.64 2005/05/31 09:41:46 sniper Exp $ */ +/* $Id: var_unserializer.c,v 1.65 2005/06/01 11:03:42 dmitry Exp $ */ #include php.h #include ext/standard/php_var.h @@ -325,7 +325,8 @@ return 0; } - if(Z_OBJCE_PP(rval) != PHP_IC_ENTRY) { + if (Z_OBJCE_PP(rval) != PHP_IC_ENTRY + zend_hash_exists(Z_OBJCE_PP(rval)-function_table, __wakeup, sizeof(__wakeup))) { INIT_PZVAL(fname); ZVAL_STRINGL(fname, __wakeup, sizeof(__wakeup) - 1, 0); call_user_function_ex(CG(function_table), rval, fname, retval_ptr, 0, 0, 1, NULL TSRMLS_CC); http://cvs.php.net/diff.php/php-src/ext/standard/var_unserializer.re?r1=1.50r2=1.51ty=u Index: php-src/ext/standard/var_unserializer.re diff -u php-src/ext/standard/var_unserializer.re:1.50 php-src/ext/standard/var_unserializer.re:1.51 --- php-src/ext/standard/var_unserializer.re:1.50 Tue May 31 05:41:36 2005 +++ php-src/ext/standard/var_unserializer.reWed Jun 1 07:03:42 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: var_unserializer.re,v 1.50 2005/05/31 09:41:36 sniper Exp $ */ +/* $Id: var_unserializer.re,v 1.51 2005/06/01 11:03:42 dmitry Exp $ */ #include php.h #include ext/standard/php_var.h @@ -329,7 +329,8 @@ return 0; } - if(Z_OBJCE_PP(rval) != PHP_IC_ENTRY) { + if (Z_OBJCE_PP(rval) != PHP_IC_ENTRY + zend_hash_exists(Z_OBJCE_PP(rval)-function_table, __wakeup, sizeof(__wakeup))) { INIT_PZVAL(fname); ZVAL_STRINGL(fname, __wakeup, sizeof(__wakeup) - 1, 0); call_user_function_ex(CG(function_table), rval, fname, retval_ptr, 0, 0, 1, NULL TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/array var_export2.phpt
On Sun, 19 Dec 2004, Andi Gutmans wrote: At 03:42 AM 12/18/2004 +0100, Derick Rethans wrote: On Fri, 17 Dec 2004, Andi Gutmans wrote: OK I think restoring BC for now is OK. I'm not sure var_dump() really has var_export() you mean? to support protected/private but the manual says so: The first one is that the returned representation is valid PHP code, the second that it will also return protected and private properties of an object with PHP 5.. So we might want to fix one or the other at some point :) I've no idea why that last line was added, it's simply incorrect. This was never my plan to add. Also, those are *object* properties, which have nothing to do with the code that I just changed ;-) I didn't realize that. I thought that code also ran for object properties. Yeah, I meant var_export() and it seems like the PHP manual might need fixing. Yup, and that's why I'm CC-ing them now. :) Derick -- Derick Rethans http://derickrethans.nl | http://ez.no | http://xdebug.org -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] Re: [PHP-DOC] Re: [PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/array var_export2.phpt
On Sun, 19 Dec 2004, Andi Gutmans wrote: At 03:42 AM 12/18/2004 +0100, Derick Rethans wrote: On Fri, 17 Dec 2004, Andi Gutmans wrote: OK I think restoring BC for now is OK. I'm not sure var_dump() really has var_export() you mean? to support protected/private but the manual says so: The first one is that the returned representation is valid PHP code, the second that it will also return protected and private properties of an object with PHP 5.. So we might want to fix one or the other at some point :) I've no idea why that last line was added, it's simply incorrect. This was never my plan to add. Also, those are *object* properties, which have nothing to do with the code that I just changed ;-) I didn't realize that. I thought that code also ran for object properties. Yeah, I meant var_export() and it seems like the PHP manual might need fixing. Yup, and that's why I'm CC-ing them now. :) Derick Maybe var_dump() doc page needs also a little fix?, because both functions output public/private/protected properties. ? class xpto { public $p = 'a'; private $pr ='b'; protected $prot=8; static $a='a'; const CONSTT='hhh'; function func() {} } $a = new xpto(); var_export($a); var_dump($a); ? outputs: class xpto { public $p = 'a'; private $pr = 'b'; protected $prot = 8; } object(xpto)#1 (3) { [p]= string(1) a [pr:private]= string(1) b [prot:protected]= int(8) Nuno -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/array var_export2.phpt
At 03:42 AM 12/18/2004 +0100, Derick Rethans wrote: On Fri, 17 Dec 2004, Andi Gutmans wrote: OK I think restoring BC for now is OK. I'm not sure var_dump() really has var_export() you mean? to support protected/private but the manual says so: The first one is that the returned representation is valid PHP code, the second that it will also return protected and private properties of an object with PHP 5.. So we might want to fix one or the other at some point :) I've no idea why that last line was added, it's simply incorrect. This was never my plan to add. Also, those are *object* properties, which have nothing to do with the code that I just changed ;-) I didn't realize that. I thought that code also ran for object properties. Yeah, I meant var_export() and it seems like the PHP manual might need fixing. Andi -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/array var_export2.phpt
derick Fri Dec 17 09:40:39 2004 EDT Modified files: /php-src/ext/standard var.c /php-src/ext/standard/tests/array var_export2.phpt Log: - MF43: Fixed bug #31072 (var_export() does not output an array element with an empty string key). (Derick) http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.196r2=1.197ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.196 php-src/ext/standard/var.c:1.197 --- php-src/ext/standard/var.c:1.196Fri Oct 8 15:02:00 2004 +++ php-src/ext/standard/var.c Fri Dec 17 09:40:39 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.196 2004/10/08 19:02:00 helly Exp $ */ +/* $Id: var.c,v 1.197 2004/12/17 14:40:39 derick Exp $ */ /* {{{ includes @@ -319,20 +319,13 @@ if (hash_key-nKeyLength==0) { /* numeric key */ php_printf(%*c%ld = , 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') { - return 0; - } else { - char *key; - int key_len; - key = php_addcslashes(hash_key-arKey, hash_key-nKeyLength - 1, key_len, 0, '\\, 2 TSRMLS_CC); - php_printf(%*c', level + 1, ' '); - PHPWRITE(key, key_len); - php_printf(' = ); - efree(key); - } + char *key; + int key_len; + key = php_addcslashes(hash_key-arKey, hash_key-nKeyLength - 1, key_len, 0, '\\, 2 TSRMLS_CC); + php_printf(%*c', level + 1, ' '); + PHPWRITE(key, key_len); + php_printf(' = ); + efree(key); } php_var_export(zv, level + 2 TSRMLS_CC); PUTS (,\n); http://cvs.php.net/diff.php/php-src/ext/standard/tests/array/var_export2.phpt?r1=1.1r2=1.2ty=u Index: php-src/ext/standard/tests/array/var_export2.phpt -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/array var_export2.phpt
This isn't the right fix. You should just fix the if() statement only return 0 if hash_key-arKey[0] == '\0' hash_key-nKeyLength 1. No? Andi At 02:40 PM 12/17/2004 +, Derick Rethans wrote: derick Fri Dec 17 09:40:39 2004 EDT Modified files: /php-src/ext/standard var.c /php-src/ext/standard/tests/array var_export2.phpt Log: - MF43: Fixed bug #31072 (var_export() does not output an array element with an empty string key). (Derick) http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.196r2=1.197ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.196 php-src/ext/standard/var.c:1.197 --- php-src/ext/standard/var.c:1.196Fri Oct 8 15:02:00 2004 +++ php-src/ext/standard/var.c Fri Dec 17 09:40:39 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.196 2004/10/08 19:02:00 helly Exp $ */ +/* $Id: var.c,v 1.197 2004/12/17 14:40:39 derick Exp $ */ /* {{{ includes @@ -319,20 +319,13 @@ if (hash_key-nKeyLength==0) { /* numeric key */ php_printf(%*c%ld = , 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') { - return 0; - } else { - char *key; - int key_len; - key = php_addcslashes(hash_key-arKey, hash_key-nKeyLength - 1, key_len, 0, '\\, 2 TSRMLS_CC); - php_printf(%*c', level + 1, ' '); - PHPWRITE(key, key_len); - php_printf(' = ); - efree(key); - } + char *key; + int key_len; + key = php_addcslashes(hash_key-arKey, hash_key-nKeyLength - 1, key_len, 0, '\\, 2 TSRMLS_CC); + php_printf(%*c', level + 1, ' '); + PHPWRITE(key, key_len); + php_printf(' = ); + efree(key); } php_var_export(zv, level + 2 TSRMLS_CC); PUTS (,\n); http://cvs.php.net/diff.php/php-src/ext/standard/tests/array/var_export2.phpt?r1=1.1r2=1.2ty=u Index: php-src/ext/standard/tests/array/var_export2.phpt -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/array var_export2.phpt
On Fri, 17 Dec 2004, Andi Gutmans wrote: This isn't the right fix. You should just fix the if() statement only return 0 if hash_key-arKey[0] == '\0' hash_key-nKeyLength 1. No? No :) This check was for (private and public) properties which should not be don ehere at all (as it's for array elements). Although using binary data as array key is not the wisest thing to do, it DID work always just fine until this unneccesary change. I'm just restoring BC here, as this broken some things for us. regards, Derick -- Derick Rethans http://derickrethans.nl | http://ez.no | http://xdebug.org -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/array var_export2.phpt
OK I think restoring BC for now is OK. I'm not sure var_dump() really has to support protected/private but the manual says so: The first one is that the returned representation is valid PHP code, the second that it will also return protected and private properties of an object with PHP 5.. So we might want to fix one or the other at some point :) Andi At 03:33 AM 12/18/2004 +0100, Derick Rethans wrote: On Fri, 17 Dec 2004, Andi Gutmans wrote: This isn't the right fix. You should just fix the if() statement only return 0 if hash_key-arKey[0] == '\0' hash_key-nKeyLength 1. No? No :) This check was for (private and public) properties which should not be don ehere at all (as it's for array elements). Although using binary data as array key is not the wisest thing to do, it DID work always just fine until this unneccesary change. I'm just restoring BC here, as this broken some things for us. regards, Derick -- Derick Rethans http://derickrethans.nl | http://ez.no | http://xdebug.org -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/array var_export2.phpt
On Fri, 17 Dec 2004, Andi Gutmans wrote: OK I think restoring BC for now is OK. I'm not sure var_dump() really has var_export() you mean? to support protected/private but the manual says so: The first one is that the returned representation is valid PHP code, the second that it will also return protected and private properties of an object with PHP 5.. So we might want to fix one or the other at some point :) I've no idea why that last line was added, it's simply incorrect. This was never my plan to add. Also, those are *object* properties, which have nothing to do with the code that I just changed ;-) Derick -- Derick Rethans http://derickrethans.nl | http://ez.no | http://xdebug.org -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
helly Thu Sep 2 14:28:47 2004 EDT Modified files: /php-src/ext/standard var.c Log: Fix memleak in serialize http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.193r2=1.194ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.193 php-src/ext/standard/var.c:1.194 --- php-src/ext/standard/var.c:1.193Sun Aug 29 13:16:20 2004 +++ php-src/ext/standard/var.c Thu Sep 2 14:28:47 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.193 2004/08/29 17:16:20 iliaa Exp $ */ +/* $Id: var.c,v 1.194 2004/09/02 18:28:47 helly Exp $ */ /* {{{ includes @@ -598,6 +598,7 @@ php_var_serialize_intern(buf, d, var_hash TSRMLS_CC); break; } + efree(priv_name); zend_mangle_property_name(prot_name, prop_name_length, *, 1, Z_STRVAL_PP(name), Z_STRLEN_PP(name) + 1, ce-type ZEND_INTERNAL_CLASS); if (zend_hash_find(Z_OBJPROP_PP(struc), prot_name, prop_name_length, (void *) d) == SUCCESS) { @@ -606,12 +607,10 @@ php_var_serialize_intern(buf, d, var_hash TSRMLS_CC); break; } + efree(prot_name); php_error_docref(NULL TSRMLS_CC, E_NOTICE, \%s\ returned as member variable from __sleep() but does not exist, Z_STRVAL_PP(name)); php_var_serialize_string(buf, Z_STRVAL_PP(name), Z_STRLEN_PP(name)); php_var_serialize_intern(buf, nvalp, var_hash TSRMLS_CC); - - efree(prot_name); - efree(priv_name); } while (0); } else { php_var_serialize_string(buf, Z_STRVAL_PP(name), Z_STRLEN_PP(name)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c /tests/classes bug26737.phpt
andrey Sat Aug 21 09:49:19 2004 EDT Modified files: /php-src/tests/classes bug26737.phpt /php-src/ext/standard var.c Log: fix for bug 26737 : private protected member variables not serialized when user defined __sleep() is declared. Additionally E_NOTICE is being thrown if __sleep() returns a non-existing member variable name http://cvs.php.net/diff.php/php-src/tests/classes/bug26737.phpt?r1=1.2r2=1.3ty=u Index: php-src/tests/classes/bug26737.phpt diff -u php-src/tests/classes/bug26737.phpt:1.2 php-src/tests/classes/bug26737.phpt:1.3 --- php-src/tests/classes/bug26737.phpt:1.2 Thu Jul 22 14:40:19 2004 +++ php-src/tests/classes/bug26737.phpt Sat Aug 21 09:49:19 2004 @@ -10,12 +10,13 @@ public function __sleep() { - return array('private', 'protected', 'public'); + return array('private', 'protected', 'public', 'no_such'); } } $foo = new foo(); $data = serialize($foo); var_dump(str_replace(\0, '\0', $data)); ? ---EXPECT-- -string(76) O:3:foo:3:{s:7:private;N;s:9:protected;R:2;s:6:public;s:6:public;} +--EXPECTF-- +Notice: serialize(): no_such returned as member variable from __sleep() but does not exist in %s on line %d +string(130) O:3:foo:4:{s:12:\0foo\0private;s:7:private;s:12:\0*\0protected;s:9:protected;s:6:public;s:6:public;s:7:no_such;N;} http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.191r2=1.192ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.191 php-src/ext/standard/var.c:1.192 --- php-src/ext/standard/var.c:1.191Sun Jul 4 07:14:17 2004 +++ php-src/ext/standard/var.c Sat Aug 21 09:49:19 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.191 2004/07/04 11:14:17 helly Exp $ */ +/* $Id: var.c,v 1.192 2004/08/21 13:49:19 andrey Exp $ */ /* {{{ includes @@ -578,14 +578,40 @@ smart_str_appendl(buf,N;, 2); continue; } - - php_var_serialize_string(buf, Z_STRVAL_PP(name), Z_STRLEN_PP(name)); - if (zend_hash_find(Z_OBJPROP_PP(struc), Z_STRVAL_PP(name), Z_STRLEN_PP(name) + 1, (void *) d) == SUCCESS) { - php_var_serialize_intern(buf, d, var_hash TSRMLS_CC); + php_var_serialize_string(buf, Z_STRVAL_PP(name), Z_STRLEN_PP(name)); + php_var_serialize_intern(buf, d, var_hash TSRMLS_CC); } else { - php_var_serialize_intern(buf, nvalp, var_hash TSRMLS_CC); + zend_class_entry *ce; + ce = zend_get_class_entry(*struc TSRMLS_CC); + if (ce) { + char *prot_name, *priv_name; + 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) + 1, ce-type ZEND_INTERNAL_CLASS); + if (zend_hash_find(Z_OBJPROP_PP(struc), priv_name, prop_name_length, (void *) d) == SUCCESS) { + php_var_serialize_string(buf, priv_name, prop_name_length-1); + php_var_serialize_intern(buf, d, var_hash TSRMLS_CC); + break; + } + zend_mangle_property_name(prot_name, prop_name_length, *, 1, + Z_STRVAL_PP(name), Z_STRLEN_PP(name) + 1, ce-type ZEND_INTERNAL_CLASS); + if (zend_hash_find(Z_OBJPROP_PP(struc), prot_name, prop_name_length, (void *) d) == SUCCESS) { + php_var_serialize_string(buf, prot_name, prop_name_length - 1); + php_var_serialize_intern(buf, d, var_hash TSRMLS_CC); + break; + } + php_error_docref(NULL TSRMLS_CC, E_NOTICE, \%s\ returned as member variable from __sleep() but does not exist, Z_STRVAL_PP(name)); + php_var_serialize_string(buf, Z_STRVAL_PP(name), Z_STRLEN_PP(name)); +
Re: [PHP-CVS] cvs: php-src /ext/standard var.c
On Sat, 3 Jul 2004, Moriyoshi Koizumi wrote: moriyoshi Sat Jul 3 12:10:29 2004 EDT Modified files: /php-src/ext/standard var.c Log: - Bugfix #28325 (circular reference serialisation). Can you please add a test case for this bug? The variable serializer is pretty volatile stuff and having a testcase for each bug that is fixed would be a very good idea. regards, Derick -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
helly Sun Jul 4 07:14:17 2004 EDT Modified files: /php-src/ext/standard var.c Log: Fix TSRM build http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.190r2=1.191ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.190 php-src/ext/standard/var.c:1.191 --- php-src/ext/standard/var.c:1.190Sat Jul 3 12:10:28 2004 +++ php-src/ext/standard/var.c Sun Jul 4 07:14:17 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.190 2004/07/03 16:10:28 moriyoshi Exp $ */ +/* $Id: var.c,v 1.191 2004/07/04 11:14:17 helly Exp $ */ /* {{{ includes @@ -461,7 +461,7 @@ 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) +static inline int php_add_var_hash(HashTable *var_hash, zval *var, void *var_old TSRMLS_DC) { ulong var_no; char id[32], *p; @@ -600,7 +600,7 @@ HashTable *myht; if (var_hash -php_add_var_hash(var_hash, *struc, (void *) var_already) == FAILURE) { +php_add_var_hash(var_hash, *struc, (void *) var_already TSRMLS_CC) == FAILURE) { if((*struc)-is_ref) { smart_str_appendl(buf, R:, 2); smart_str_append_long(buf, *var_already); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
moriyoshi Sat Jul 3 12:10:29 2004 EDT Modified files: /php-src/ext/standard var.c Log: - Bugfix #28325 (circular reference serialisation). http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.189r2=1.190ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.189 php-src/ext/standard/var.c:1.190 --- php-src/ext/standard/var.c:1.189Thu May 20 17:15:42 2004 +++ php-src/ext/standard/var.c Sat Jul 3 12:10:28 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.189 2004/05/20 21:15:42 andrey Exp $ */ +/* $Id: var.c,v 1.190 2004/07/03 16:10:28 moriyoshi Exp $ */ /* {{{ includes @@ -467,10 +467,21 @@ char id[32], *p; register int len; - /* relies on (long) being a perfect hash function for data pointers */ - p = smart_str_print_long(id + sizeof(id) - 1, (long) var); - len = id + sizeof(id) - 1 - p; - + /* relies on (long) being a perfect hash function for data pointers, + however the actual identity of an object has had to be determined + by its object handle and the class entry since 5.0. */ + if (Z_TYPE_P(var) == IS_OBJECT) { + p = smart_str_print_long(id + sizeof(id) - 1, + (((unsigned long)Z_OBJCE_P(var) 5) + | ((unsigned long)Z_OBJCE_P(var) (sizeof(long) * 8 - 5))) + + (long) Z_OBJ_HANDLE_P(var)); + *(--p) = 'O'; + len = id + sizeof(id) - 1 - p; + } else { + p = smart_str_print_long(id + sizeof(id) - 1, (long) var); + len = id + sizeof(id) - 1 - p; + } + if (var_old zend_hash_find(var_hash, p, len, var_old) == SUCCESS) { if (!var-is_ref) { /* we still need to bump up the counter, since non-refs will @@ -588,8 +599,8 @@ ulong *var_already; HashTable *myht; - if(var_hash - php_add_var_hash(var_hash, *struc, (void *) var_already) == FAILURE) { + if (var_hash +php_add_var_hash(var_hash, *struc, (void *) var_already) == FAILURE) { if((*struc)-is_ref) { smart_str_appendl(buf, R:, 2); smart_str_append_long(buf, *var_already); @@ -703,7 +714,7 @@ } switch (i) { - case HASH_KEY_IS_LONG: + case HASH_KEY_IS_LONG: php_var_serialize_long(buf, index); break; case HASH_KEY_IS_STRING: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
andrey Thu May 20 13:46:20 2004 EDT Modified files: /php-src/ext/standard var.c Log: var_dump() now shows private and protected member variables. Not BC is that since now the public variables are explicitly shown as public Example : class a{ protected $a=1; private $b=2;var $c=3;} $a=new a(); var_dump($a); object(a)#1 (3) { [a:protected]= int(1) [b:private]= int(2) [c:public]= int(3) } http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.187r2=1.188ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.187 php-src/ext/standard/var.c:1.188 --- php-src/ext/standard/var.c:1.187Thu Mar 18 11:54:36 2004 +++ php-src/ext/standard/var.c Thu May 20 13:46:20 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.187 2004/03/18 16:54:36 dmitry Exp $ */ +/* $Id: var.c,v 1.188 2004/05/20 17:46:20 andrey Exp $ */ /* {{{ includes @@ -64,11 +64,42 @@ return 0; } +static int php_object_property_dump(zval **zv, int num_args, va_list args, zend_hash_key *hash_key) +{ + int level; + char *prop_name, *class_name; + TSRMLS_FETCH(); + + level = va_arg(args, int); + + if (hash_key-nKeyLength ==0 ) { /* numeric key */ + php_printf(%*c[%ld]=\n, level + 1, ' ', hash_key-h); + } else { /* string key */ + zend_unmangle_property_name(hash_key-arKey, class_name, prop_name); + if (class_name) { + php_printf(%*c[\%s, level + 1, ' ', prop_name); + if (class_name[0]=='*') { + ZEND_PUTS(:protected); + } else { + ZEND_PUTS(:private); + } + } else { + php_printf(%*c[\%s, level + 1, ' ', hash_key-arKey); + ZEND_PUTS(:public); + } + ZEND_PUTS(\]=\n); + } + php_var_dump(zv, level + 2 TSRMLS_CC); + return 0; +} + + PHPAPI void php_var_dump(zval **struc, int level TSRMLS_DC) { HashTable *myht = NULL; char *class_name; zend_uint class_name_len; + int (*php_element_dump_func)(zval**, int, va_list, zend_hash_key*); if (level 1) { php_printf(%*c, level - 1, ' '); @@ -99,6 +130,7 @@ return; } php_printf(%sarray(%d) {\n, COMMON, zend_hash_num_elements(myht)); + php_element_dump_func = php_array_element_dump; goto head_done; case IS_OBJECT: myht = Z_OBJPROP_PP(struc); @@ -110,9 +142,10 @@ 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(class_name); + php_element_dump_func = php_object_property_dump; head_done: if (myht) { - zend_hash_apply_with_arguments(myht, (apply_func_args_t) php_array_element_dump, 1, level, (Z_TYPE_PP(struc) == IS_ARRAY ? 0 : 1)); + zend_hash_apply_with_arguments(myht, (apply_func_args_t) php_element_dump_func, 1, level, (Z_TYPE_PP(struc) == IS_ARRAY ? 0 : 1)); } if (level 1) { php_printf(%*c, level-1, ' '); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
andrey Thu May 20 17:15:43 2004 EDT Modified files: /php-src/ext/standard var.c Log: for now removing :public. Waiting for a decision? :public will require quite a lot of phpt files changes. http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.188r2=1.189ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.188 php-src/ext/standard/var.c:1.189 --- php-src/ext/standard/var.c:1.188Thu May 20 13:46:20 2004 +++ php-src/ext/standard/var.c Thu May 20 17:15:42 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.188 2004/05/20 17:46:20 andrey Exp $ */ +/* $Id: var.c,v 1.189 2004/05/20 21:15:42 andrey Exp $ */ /* {{{ includes @@ -85,7 +85,9 @@ } } else { php_printf(%*c[\%s, level + 1, ' ', hash_key-arKey); +#ifdef ANDREY_0 ZEND_PUTS(:public); +#endif } ZEND_PUTS(\]=\n); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
iliaa Sun Mar 7 22:06:57 2004 EDT Modified files: /php-src/ext/standard var.c Log: Fixed compiler warnings. http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.184r2=1.185ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.184 php-src/ext/standard/var.c:1.185 --- php-src/ext/standard/var.c:1.184Wed Feb 25 15:16:26 2004 +++ php-src/ext/standard/var.c Sun Mar 7 22:06:56 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.184 2004/02/25 20:16:26 abies Exp $ */ +/* $Id: var.c,v 1.185 2004/03/08 03:06:56 iliaa Exp $ */ /* {{{ includes @@ -69,7 +69,6 @@ HashTable *myht = NULL; char *class_name; zend_uint class_name_len; - zend_class_entry *ce; if (level 1) { php_printf(%*c, level - 1, ' '); @@ -741,7 +740,7 @@ if (!php_var_unserialize(return_value, p, p + Z_STRLEN_PP(buf), var_hash TSRMLS_CC)) { PHP_VAR_UNSERIALIZE_DESTROY(var_hash); zval_dtor(return_value); - php_error_docref(NULL TSRMLS_CC, E_NOTICE, Error at offset %ld of %ld bytes, p - Z_STRVAL_PP(buf), Z_STRLEN_PP(buf)); + php_error_docref(NULL TSRMLS_CC, E_NOTICE, Error at offset %d of %d bytes, p - Z_STRVAL_PP(buf), Z_STRLEN_PP(buf)); RETURN_FALSE; } PHP_VAR_UNSERIALIZE_DESTROY(var_hash); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
stasMon Feb 16 06:21:32 2004 EDT Modified files: /php-src/ext/standard var.c Log: ce is not used, don't get it http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.182r2=1.183ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.182 php-src/ext/standard/var.c:1.183 --- php-src/ext/standard/var.c:1.182Thu Feb 5 04:07:46 2004 +++ php-src/ext/standard/var.c Mon Feb 16 06:21:31 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.182 2004/02/05 09:07:46 stas Exp $ */ +/* $Id: var.c,v 1.183 2004/02/16 11:21:31 stas Exp $ */ /* {{{ includes @@ -108,8 +108,6 @@ return; } - ce = Z_OBJCE(**struc); - 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(class_name); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
stasThu Feb 5 04:07:46 2004 EDT Modified files: /php-src/ext/standard var.c Log: fix serialization http://cvs.php.net/diff.php/php-src/ext/standard/var.c?r1=1.181r2=1.182ty=u Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.181 php-src/ext/standard/var.c:1.182 --- php-src/ext/standard/var.c:1.181Tue Feb 3 09:12:58 2004 +++ php-src/ext/standard/var.c Thu Feb 5 04:07:46 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.181 2004/02/03 14:12:58 stas Exp $ */ +/* $Id: var.c,v 1.182 2004/02/05 09:07:46 stas Exp $ */ /* {{{ includes @@ -554,12 +554,13 @@ smart_str_appendl(buf, R:, 2); smart_str_append_long(buf, *var_already); smart_str_appendc(buf, ';'); + return; } else if(Z_TYPE_PP(struc) == IS_OBJECT) { smart_str_appendl(buf, r:, 2); smart_str_append_long(buf, *var_already); smart_str_appendc(buf, ';'); + return; } - return; } switch (Z_TYPE_PP(struc)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
derick Sun Dec 28 16:56:16 2003 EDT Modified files: /php-src/ext/standard var.c Log: - Fix typo Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.177 php-src/ext/standard/var.c:1.178 --- php-src/ext/standard/var.c:1.177Fri Nov 28 23:43:06 2003 +++ php-src/ext/standard/var.c Sun Dec 28 16:56:15 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.177 2003/11/29 04:43:06 iliaa Exp $ */ +/* $Id: var.c,v 1.178 2003/12/28 21:56:15 derick Exp $ */ /* {{{ includes @@ -51,7 +51,7 @@ php_printf(%*c[%ld]=\n, level + 1, ' ', hash_key-h); } else { /* string key */ if (va_arg(args, int) hash_key-arKey[0] == '\0') { - /* XXX: perphaps when we are inside the class we should permit access to + /* XXX: perhaps when we are inside the class we should permit access to * private protected values */ return 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
wez Fri Nov 28 10:42:59 2003 EDT Modified files: /php-src/ext/standard var.c Log: fix #26001; serialize crashes when accessing an overloaded object that has no properties (NULL hashtable). Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.175 php-src/ext/standard/var.c:1.176 --- php-src/ext/standard/var.c:1.175Tue Nov 4 11:08:10 2003 +++ php-src/ext/standard/var.c Fri Nov 28 10:42:58 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.175 2003/11/04 16:08:10 moriyoshi Exp $ */ +/* $Id: var.c,v 1.176 2003/11/28 15:42:58 wez Exp $ */ /* {{{ includes @@ -585,15 +585,16 @@ /* fall-through */ } case IS_ARRAY: - myht = HASH_OF(*struc); if (Z_TYPE_PP(struc) == IS_ARRAY) { smart_str_appendl(buf, a:, 2); + myht = HASH_OF(*struc); } else { php_var_serialize_class_name(buf, struc TSRMLS_CC); + myht = Z_OBJPROP_PP(struc); } /* count after serializing name, since php_var_serialize_class_name changes the count if the variable is incomplete class */ - i = zend_hash_num_elements(myht); + i = myht ? zend_hash_num_elements(myht) : 0; smart_str_append_long(buf, i); smart_str_appendl(buf, :{, 2); if (i 0) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/array 007.phpt array_intersect_1.phpt bug26458.phpt
iliaa Fri Nov 28 23:43:07 2003 EDT Added files: /php-src/ext/standard/tests/array bug26458.phpt Modified files: /php-src/ext/standard var.c /php-src/ext/standard/tests/array array_intersect_1.phpt 007.phpt Log: Fixed bug #26458 (var_dump(), var_export(), debug_zval_dump() not binary safe for array keys). Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.176 php-src/ext/standard/var.c:1.177 --- php-src/ext/standard/var.c:1.176Fri Nov 28 10:42:58 2003 +++ php-src/ext/standard/var.c Fri Nov 28 23:43:06 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.176 2003/11/28 15:42:58 wez Exp $ */ +/* $Id: var.c,v 1.177 2003/11/29 04:43:06 iliaa Exp $ */ /* {{{ includes @@ -50,7 +50,15 @@ if (hash_key-nKeyLength==0) { /* numeric key */ php_printf(%*c[%ld]=\n, level + 1, ' ', hash_key-h); } else { /* string key */ - php_printf(%*c[\%s\]=\n, level + 1, ' ', hash_key-arKey); + if (va_arg(args, int) hash_key-arKey[0] == '\0') { + /* XXX: perphaps when we are inside the class we should permit access to +* private protected values +*/ + return 0; + } + php_printf(%*c[\, level + 1, ' '); + PHPWRITE(hash_key-arKey, hash_key-nKeyLength - 1); + php_printf(\]=\n); } php_var_dump(zv, level + 2 TSRMLS_CC); return 0; @@ -107,7 +115,7 @@ efree(class_name); head_done: if (myht) { - zend_hash_apply_with_arguments(myht, (apply_func_args_t) php_array_element_dump, 1, level); + zend_hash_apply_with_arguments(myht, (apply_func_args_t) php_array_element_dump, 1, level, (Z_TYPE_PP(struc) == IS_ARRAY ? 0 : 1)); } if (level 1) { php_printf(%*c, level-1, ' '); @@ -166,7 +174,15 @@ if (hash_key-nKeyLength==0) { /* numeric key */ php_printf(%*c[%ld]=\n, level + 1, ' ', hash_key-h); } else { /* string key */ - php_printf(%*c[\%s\]=\n, level + 1, ' ', hash_key-arKey); + /* 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') { + return 0; + } + php_printf(%*c[\, level + 1, ' '); + PHPWRITE(hash_key-arKey, hash_key-nKeyLength - 1); + php_printf(\]=\n); } php_debug_zval_dump(zv, level + 2 TSRMLS_CC); return 0; @@ -213,7 +229,7 @@ efree(class_name); head_done: if (myht) { - zend_hash_apply_with_arguments(myht, (apply_func_args_t) zval_array_element_dump, 1, level); + zend_hash_apply_with_arguments(myht, (apply_func_args_t) zval_array_element_dump, 1, level, (Z_TYPE_PP(struc) == IS_ARRAY ? 0 : 1)); } if (level 1) { php_printf(%*c, level-1, ' '); @@ -271,11 +287,20 @@ if (hash_key-nKeyLength==0) { /* numeric key */ php_printf(%*c%ld = , level + 1, ' ', hash_key-h); } else { /* string key */ - char *key; - int key_len; - key = php_addcslashes(hash_key-arKey, hash_key-nKeyLength - 1, key_len, 0, '\\, 2 TSRMLS_CC); - php_printf(%*c'%s' = , level + 1, ' ', key); - efree(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') { + return 0; + } else { + char *key; + int key_len; + key = php_addcslashes(hash_key-arKey, hash_key-nKeyLength - 1, key_len, 0, '\\, 2 TSRMLS_CC); + php_printf(%*c', level + 1, ' '); + PHPWRITE(key, key_len); + php_printf(' = ); + efree(key); + } } php_var_export(zv, level + 2 TSRMLS_CC); PUTS (,\n); @@ -331,7 +356,7 @@ php_printf(\n%*c, level - 1, ' '); } PUTS (array (\n); - zend_hash_apply_with_arguments(myht, (apply_func_args_t) php_array_element_export, 1, level); + zend_hash_apply_with_arguments(myht, (apply_func_args_t) php_array_element_export, 1, level, (Z_TYPE_PP(struc) == IS_ARRAY ? 0 : 1)); if (level 1) {
[PHP-CVS] cvs: php-src /ext/standard var.c
moriyoshi Tue Nov 4 11:08:17 2003 EDT Modified files: /php-src/ext/standard var.c Log: Fixed bug #24394 (serializing cross-referenced objects causes segfault) Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.174 php-src/ext/standard/var.c:1.175 --- php-src/ext/standard/var.c:1.174Tue Oct 7 21:51:32 2003 +++ php-src/ext/standard/var.c Tue Nov 4 11:08:10 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.174 2003/10/08 01:51:32 moriyoshi Exp $ */ +/* $Id: var.c,v 1.175 2003/11/04 16:08:10 moriyoshi Exp $ */ /* {{{ includes @@ -513,7 +513,7 @@ if(var_hash php_add_var_hash(var_hash, *struc, (void *) var_already) == FAILURE -(*struc)-is_ref) { +((*struc)-is_ref || Z_TYPE_PP(struc) == IS_OBJECT)) { smart_str_appendl(buf, R:, 2); smart_str_append_long(buf, *var_already); smart_str_appendc(buf, ';'); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/array bug25758.phpt
iliaa Tue Oct 7 21:16:45 2003 EDT Added files: /php-src/ext/standard/tests/array bug25758.phpt Modified files: /php-src/ext/standard var.c Log: Fixed bug #25758 (var_export does not escape ' \ inside array keys) Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.171 php-src/ext/standard/var.c:1.172 --- php-src/ext/standard/var.c:1.171Thu Aug 28 12:28:33 2003 +++ php-src/ext/standard/var.c Tue Oct 7 21:16:44 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.171 2003/08/28 16:28:33 sas Exp $ */ +/* $Id: var.c,v 1.172 2003/10/08 01:16:44 iliaa Exp $ */ /* {{{ includes @@ -271,7 +271,11 @@ if (hash_key-nKeyLength==0) { /* numeric key */ php_printf(%*c%ld = , level + 1, ' ', hash_key-h); } else { /* string key */ - php_printf(%*c'%s' = , level + 1, ' ', hash_key-arKey); + char *key; + int key_len; + key = php_addcslashes(hash_key-arKey, strlen(hash_key-arKey), key_len, 0, '\\, 2 TSRMLS_CC); + php_printf(%*c'%s' = , level + 1, ' ', key); + efree(key); } php_var_export(zv, level + 2 TSRMLS_CC); PUTS (,\n); Index: php-src/ext/standard/tests/array/bug25758.phpt +++ php-src/ext/standard/tests/array/bug25758.phpt --TEST-- Bug #25758 (var_export does not escape ' \ inside array keys) --FILE-- ?php $a = array (quote' = array(quote')); echo var_export($a, true); ? --EXPECT-- array ( 'quote\'' = array ( 0 = 'quote\'', ), ) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
moriyoshi Tue Oct 7 21:49:32 2003 EDT Modified files: /php-src/ext/standard var.c Log: Better fix for bug #25758 Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.172 php-src/ext/standard/var.c:1.173 --- php-src/ext/standard/var.c:1.172Tue Oct 7 21:16:44 2003 +++ php-src/ext/standard/var.c Tue Oct 7 21:49:31 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.172 2003/10/08 01:16:44 iliaa Exp $ */ +/* $Id: var.c,v 1.173 2003/10/08 01:49:31 moriyoshi Exp $ */ /* {{{ includes @@ -273,7 +273,7 @@ } else { /* string key */ char *key; int key_len; - key = php_addcslashes(hash_key-arKey, strlen(hash_key-arKey), key_len, 0, '\\, 2 TSRMLS_CC); + key = php_addcslashes(hash_key-arKey, hash_key-nKeyLength, key_len, 0, '\\, 2 TSRMLS_CC); php_printf(%*c'%s' = , level + 1, ' ', key); efree(key); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c
moriyoshi Tue Oct 7 21:51:33 2003 EDT Modified files: /php-src/ext/standard var.c Log: Oops.. Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.173 php-src/ext/standard/var.c:1.174 --- php-src/ext/standard/var.c:1.173Tue Oct 7 21:49:31 2003 +++ php-src/ext/standard/var.c Tue Oct 7 21:51:32 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.173 2003/10/08 01:49:31 moriyoshi Exp $ */ +/* $Id: var.c,v 1.174 2003/10/08 01:51:32 moriyoshi Exp $ */ /* {{{ includes @@ -273,7 +273,7 @@ } else { /* string key */ char *key; int key_len; - key = php_addcslashes(hash_key-arKey, hash_key-nKeyLength, key_len, 0, '\\, 2 TSRMLS_CC); + key = php_addcslashes(hash_key-arKey, hash_key-nKeyLength - 1, key_len, 0, '\\, 2 TSRMLS_CC); php_printf(%*c'%s' = , level + 1, ' ', key); efree(key); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard var.c /ext/standard/tests/serialize bug21957.phpt
iliaa Sun Aug 10 23:22:24 2003 EDT Added files: /php-src/ext/standard/tests/serialize bug21957.phpt Modified files: /php-src/ext/standard var.c Log: Fixed bug #21957 (serialize() mangles objects with __sleep). Index: php-src/ext/standard/var.c diff -u php-src/ext/standard/var.c:1.168 php-src/ext/standard/var.c:1.169 --- php-src/ext/standard/var.c:1.168Tue Aug 5 05:19:38 2003 +++ php-src/ext/standard/var.c Sun Aug 10 23:22:24 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: var.c,v 1.168 2003/08/05 09:19:38 stas Exp $ */ +/* $Id: var.c,v 1.169 2003/08/11 03:22:24 iliaa Exp $ */ /* {{{ includes @@ -483,7 +483,7 @@ 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,s:0:\\;N;, 9); + smart_str_appendl(buf,N;, 2); continue; } @@ -565,6 +565,9 @@ 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); Index: php-src/ext/standard/tests/serialize/bug21957.phpt +++ php-src/ext/standard/tests/serialize/bug21957.phpt --TEST-- Bug #21957 (serialize() mangles objects with __sleep) --FILE-- ?php class test { var $a, $b; function test() { $this-a = 7; $this-b = 2; } function __sleep() { $this-b = 0; } } $t['one'] = 'ABC'; $t['two'] = new test(); var_dump($t); $s = @serialize($t); echo $s . \n; var_dump(unserialize($s)); ? --EXPECT-- array(2) { [one]= string(3) ABC [two]= object(test)#1 (2) { [a]= int(7) [b]= int(2) } } a:2:{s:3:one;s:3:ABC;s:3:two;N;} array(2) { [one]= string(3) ABC [two]= NULL } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php